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;
10 }
11 pub mod apple {
12 pub const VENDOR: u32 = 0x106B;
13 }
14 pub mod arm {
15 pub const VENDOR: u32 = 0x13B5;
16 }
17 pub mod broadcom {
18 pub const VENDOR: u32 = 0x14E4;
19 }
20 pub mod imgtec {
21 pub const VENDOR: u32 = 0x1010;
22 }
23 pub mod intel {
24 pub const VENDOR: u32 = 0x8086;
25 pub const DEVICE_KABY_LAKE_MASK: u32 = 0x5900;
26 pub const DEVICE_SKY_LAKE_MASK: u32 = 0x1900;
27 }
28 pub mod mesa {
29 pub const VENDOR: u32 = 0x10005;
34 }
35 pub mod nvidia {
36 pub const VENDOR: u32 = 0x10DE;
37 }
38 pub mod qualcomm {
39 pub const VENDOR: u32 = 0x5143;
40 }
41}
42
43pub const MAX_I32_BINDING_SIZE: u32 = (1 << 31) - 1;
48
49pub fn map_naga_stage(stage: naga::ShaderStage) -> wgt::ShaderStages {
50 match stage {
51 naga::ShaderStage::Vertex => wgt::ShaderStages::VERTEX,
52 naga::ShaderStage::Fragment => wgt::ShaderStages::FRAGMENT,
53 naga::ShaderStage::Compute => wgt::ShaderStages::COMPUTE,
54 }
55}
56
57impl crate::CopyExtent {
58 pub fn map_extent_to_copy_size(extent: &wgt::Extent3d, dim: wgt::TextureDimension) -> Self {
59 Self {
60 width: extent.width,
61 height: extent.height,
62 depth: match dim {
63 wgt::TextureDimension::D1 | wgt::TextureDimension::D2 => 1,
64 wgt::TextureDimension::D3 => extent.depth_or_array_layers,
65 },
66 }
67 }
68
69 pub fn min(&self, other: &Self) -> Self {
70 Self {
71 width: self.width.min(other.width),
72 height: self.height.min(other.height),
73 depth: self.depth.min(other.depth),
74 }
75 }
76
77 pub fn at_mip_level(&self, level: u32) -> Self {
81 Self {
82 width: (self.width >> level).max(1),
83 height: (self.height >> level).max(1),
84 depth: (self.depth >> level).max(1),
85 }
86 }
87}
88
89impl crate::TextureCopyBase {
90 pub fn max_copy_size(&self, full_size: &crate::CopyExtent) -> crate::CopyExtent {
91 let mip = full_size.at_mip_level(self.mip_level);
92 crate::CopyExtent {
93 width: mip.width - self.origin.x,
94 height: mip.height - self.origin.y,
95 depth: mip.depth - self.origin.z,
96 }
97 }
98}
99
100impl crate::BufferTextureCopy {
101 pub fn clamp_size_to_virtual(&mut self, full_size: &crate::CopyExtent) {
102 let max_size = self.texture_base.max_copy_size(full_size);
103 self.size = self.size.min(&max_size);
104 }
105}
106
107impl crate::TextureCopy {
108 pub fn clamp_size_to_virtual(
109 &mut self,
110 full_src_size: &crate::CopyExtent,
111 full_dst_size: &crate::CopyExtent,
112 ) {
113 let max_src_size = self.src_base.max_copy_size(full_src_size);
114 let max_dst_size = self.dst_base.max_copy_size(full_dst_size);
115 self.size = self.size.min(&max_src_size).min(&max_dst_size);
116 }
117}