#[cfg(all(native, feature = "renderdoc"))] pub(super) mod renderdoc;
pubmod db { pubmod amd { /// cbindgen:ignore pubconst VENDOR: u32 = 0x1002;
} pubmod apple { /// cbindgen:ignore pubconst VENDOR: u32 = 0x106B;
} pubmod arm { /// cbindgen:ignore pubconst VENDOR: u32 = 0x13B5;
} pubmod broadcom { /// cbindgen:ignore pubconst VENDOR: u32 = 0x14E4;
} pubmod imgtec { /// cbindgen:ignore pubconst VENDOR: u32 = 0x1010;
} pubmod intel { /// cbindgen:ignore pubconst VENDOR: u32 = 0x8086; pubconst DEVICE_KABY_LAKE_MASK: u32 = 0x5900; pubconst DEVICE_SKY_LAKE_MASK: u32 = 0x1900;
} pubmod mesa { // Mesa does not actually have a PCI vendor id. // // To match Vulkan, we use the VkVendorId for Mesa in the gles backend so that lavapipe (Vulkan) and // llvmpipe (OpenGL) have the same vendor id. /// cbindgen:ignore pubconst VENDOR: u32 = 0x10005;
} pubmod nvidia { /// cbindgen:ignore pubconst VENDOR: u32 = 0x10DE;
} pubmod qualcomm { /// cbindgen:ignore pubconst VENDOR: u32 = 0x5143;
}
}
/// Maximum binding size for the shaders that only support `i32` indexing. /// Interestingly, the index itself can't reach that high, because the minimum /// element size is 4 bytes, but the compiler toolchain still computes the /// offset at some intermediate point, internally, as i32. pubconst MAX_I32_BINDING_SIZE: u32 = (1 << 31) - 1;
// Get the copy size at a specific mipmap level. This doesn't make most sense, // since the copy extents are provided *for* a mipmap level to start with. // But backends use `CopyExtent` more sparingly, and this piece is shared. pubfn at_mip_level(&self, level: u32) -> Self { Self {
width: (self.width >> level).max(1),
height: (self.height >> level).max(1),
depth: (self.depth >> level).max(1),
}
}
}
/// Adjust `limits` to honor HAL-imposed maximums and comply with WebGPU's /// adapter capability guarantees. #[cfg_attr(not(any_backend), allow(dead_code))] pub(crate) fn adjust_raw_limits(mut limits: wgt::Limits) -> wgt::Limits { // Apply hal limits.
limits.max_bind_groups = limits.max_bind_groups.min(crate::MAX_BIND_GROUPS as u32);
limits.max_vertex_buffers = limits
.max_vertex_buffers
.min(crate::MAX_VERTEX_BUFFERS as u32); // Once we allow the 2 limits above to be higher than 24 we should use // `cap_limits_to_be_under_the_sum_limit` to cap them under // `max_bind_groups_plus_vertex_buffers`. const { assert!(crate::MAX_BIND_GROUPS + crate::MAX_VERTEX_BUFFERS == 24) };
limits.max_bind_groups_plus_vertex_buffers = limits.max_bind_groups_plus_vertex_buffers.min(24);
limits.max_color_attachments = limits
.max_color_attachments
.min(crate::MAX_COLOR_ATTACHMENTS as u32);
// WebGPU requires maxBindingsPerBindGroup to be at least the sum of all // per-stage limits multiplied with the maximum shader stages per pipeline. // // Since backends already report their maximum maxBindingsPerBindGroup, // we need to lower all per-stage limits to satisfy this guarantee. const MAX_SHADER_STAGES_PER_PIPELINE: u32 = 2; let max_per_stage_resources =
limits.max_bindings_per_bind_group / MAX_SHADER_STAGES_PER_PIPELINE;
// Not required by the spec but dynamic buffers count // towards non-dynamic buffer limits as well.
limits.max_dynamic_uniform_buffers_per_pipeline_layout = limits
.max_dynamic_uniform_buffers_per_pipeline_layout
.min(limits.max_uniform_buffers_per_shader_stage);
limits.max_dynamic_storage_buffers_per_pipeline_layout = limits
.max_dynamic_storage_buffers_per_pipeline_layout
.min(limits.max_storage_buffers_per_shader_stage);
let x = limits.max_compute_workgroup_size_x; let y = limits.max_compute_workgroup_size_y; let z = limits.max_compute_workgroup_size_z; let m = limits.max_compute_invocations_per_workgroup;
limits.max_compute_workgroup_size_x = x.min(m);
limits.max_compute_workgroup_size_y = y.min(m);
limits.max_compute_workgroup_size_z = z.min(m);
limits.max_compute_invocations_per_workgroup = m.min(x.saturating_mul(y).saturating_mul(z));
/// Evenly allocates space to each limit, /// capping them only if strictly necessary. pubfn cap_limits_to_be_under_the_sum_limit<const N: usize>( mut limits: [&mut u32; N],
sum_limit: u32,
) {
limits.sort();
letmut rem_limit = sum_limit; letmut divisor = limits.len() as u32; for limit_to_adjust in limits { let limit = rem_limit / divisor;
*limit_to_adjust = (*limit_to_adjust).min(limit);
rem_limit -= *limit_to_adjust;
divisor -= 1;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.