1#[cfg(dx12)]
2pub(super) mod dxgi;
3
4#[cfg(all(native, feature = "renderdoc"))]
5pub(super) mod renderdoc;
6
7pub mod db {
8 pub mod amd {
9 pub const VENDOR: u32 = 0x1002;
11 }
12 pub mod apple {
13 pub const VENDOR: u32 = 0x106B;
15 }
16 pub mod arm {
17 pub const VENDOR: u32 = 0x13B5;
19 }
20 pub mod broadcom {
21 pub const VENDOR: u32 = 0x14E4;
23 }
24 pub mod imgtec {
25 pub const VENDOR: u32 = 0x1010;
27 }
28 pub mod intel {
29 pub const VENDOR: u32 = 0x8086;
31 pub const DEVICE_KABY_LAKE_MASK: u32 = 0x5900;
32 pub const DEVICE_SKY_LAKE_MASK: u32 = 0x1900;
33 }
34 pub mod mesa {
35 pub const VENDOR: u32 = 0x10005;
41 }
42 pub mod nvidia {
43 pub const VENDOR: u32 = 0x10DE;
45 }
46 pub mod qualcomm {
47 pub const VENDOR: u32 = 0x5143;
49 }
50}
51
52pub const MAX_I32_BINDING_SIZE: u32 = (1 << 31) - 1;
57
58pub fn map_naga_stage(stage: naga::ShaderStage) -> wgt::ShaderStages {
59 match stage {
60 naga::ShaderStage::Vertex => wgt::ShaderStages::VERTEX,
61 naga::ShaderStage::Fragment => wgt::ShaderStages::FRAGMENT,
62 naga::ShaderStage::Compute => wgt::ShaderStages::COMPUTE,
63 naga::ShaderStage::Task => wgt::ShaderStages::TASK,
64 naga::ShaderStage::Mesh => wgt::ShaderStages::MESH,
65 }
66}
67
68impl crate::CopyExtent {
69 pub fn map_extent_to_copy_size(extent: &wgt::Extent3d, dim: wgt::TextureDimension) -> Self {
70 Self {
71 width: extent.width,
72 height: extent.height,
73 depth: match dim {
74 wgt::TextureDimension::D1 | wgt::TextureDimension::D2 => 1,
75 wgt::TextureDimension::D3 => extent.depth_or_array_layers,
76 },
77 }
78 }
79
80 pub fn min(&self, other: &Self) -> Self {
81 Self {
82 width: self.width.min(other.width),
83 height: self.height.min(other.height),
84 depth: self.depth.min(other.depth),
85 }
86 }
87
88 pub fn at_mip_level(&self, level: u32) -> Self {
92 Self {
93 width: (self.width >> level).max(1),
94 height: (self.height >> level).max(1),
95 depth: (self.depth >> level).max(1),
96 }
97 }
98}
99
100impl crate::TextureCopyBase {
101 pub fn max_copy_size(&self, full_size: &crate::CopyExtent) -> crate::CopyExtent {
102 let mip = full_size.at_mip_level(self.mip_level);
103 crate::CopyExtent {
104 width: mip.width - self.origin.x,
105 height: mip.height - self.origin.y,
106 depth: mip.depth - self.origin.z,
107 }
108 }
109}
110
111impl crate::BufferTextureCopy {
112 pub fn clamp_size_to_virtual(&mut self, full_size: &crate::CopyExtent) {
113 let max_size = self.texture_base.max_copy_size(full_size);
114 self.size = self.size.min(&max_size);
115 }
116}
117
118impl crate::TextureCopy {
119 pub fn clamp_size_to_virtual(
120 &mut self,
121 full_src_size: &crate::CopyExtent,
122 full_dst_size: &crate::CopyExtent,
123 ) {
124 let max_src_size = self.src_base.max_copy_size(full_src_size);
125 let max_dst_size = self.dst_base.max_copy_size(full_dst_size);
126 self.size = self.size.min(&max_src_size).min(&max_dst_size);
127 }
128}