mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
feat(core)!: add Limits::max_inter_stage_shader_variables
This commit is contained in:
1 parent
344eeb4bc8
commit
0fbfbf8aa4
10 files changed
+40
-4
No files matched your search
@@ -273,8 +273,7 @@ ObjectDefineProperty(GPUSupportedLimitsPrototype, privateCustomInspect, {
|
||||
"maxBufferSize",
|
||||
"maxVertexAttributes",
|
||||
"maxVertexBufferArrayStride",
|
||||
// TODO(@crowlKats): support max_inter_stage_shader_variables
|
||||
// "maxInterStageShaderVariables",
|
||||
"maxInterStageShaderVariables",
|
||||
"maxColorAttachments",
|
||||
"maxColorAttachmentBytesPerSample",
|
||||
"maxComputeWorkgroupStorageSize",
|
||||
|
||||
@@ -339,7 +339,10 @@ impl GPUSupportedLimits {
|
||||
self.0.max_vertex_buffer_array_stride
|
||||
}
|
||||
|
||||
// TODO(@crowlKats): support max_inter_stage_shader_variables
|
||||
#[getter]
|
||||
fn maxInterStageShaderVariables(&self) -> u32 {
|
||||
self.0.max_inter_stage_shader_variables
|
||||
}
|
||||
|
||||
#[getter]
|
||||
fn maxColorAttachments(&self) -> u32 {
|
||||
|
||||
@@ -810,6 +810,7 @@ impl super::Adapter {
|
||||
Direct3D12::D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT,
|
||||
min_storage_buffer_offset_alignment: 4,
|
||||
max_inter_stage_shader_components: base.max_inter_stage_shader_components,
|
||||
max_inter_stage_shader_variables: base.max_inter_stage_shader_variables,
|
||||
max_color_attachments,
|
||||
max_color_attachment_bytes_per_sample,
|
||||
// From: https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#18.6.6%20Inter-Thread%20Data%20Sharing
|
||||
|
||||
@@ -768,6 +768,19 @@ impl super::Adapter {
|
||||
max_varying_components
|
||||
}
|
||||
},
|
||||
max_inter_stage_shader_variables: {
|
||||
// MAX_VARYING_COMPONENTS may return 0, because it is deprecated since OpenGL 3.2 core,
|
||||
// and an OpenGL Context with the core profile and with forward-compatibility=true,
|
||||
// will make deprecated constants unavailable.
|
||||
let max_varying_components =
|
||||
unsafe { gl.get_parameter_i32(glow::MAX_VARYING_COMPONENTS) } as u32;
|
||||
if max_varying_components == 0 {
|
||||
// default value for max_inter_stage_shader_variables
|
||||
15
|
||||
} else {
|
||||
max_varying_components / 4
|
||||
}
|
||||
},
|
||||
max_color_attachments,
|
||||
max_color_attachment_bytes_per_sample,
|
||||
max_compute_workgroup_storage_size: if supports_work_group_params {
|
||||
|
||||
@@ -1191,6 +1191,7 @@ impl super::PrivateCapabilities {
|
||||
max_vertex_attributes: 31,
|
||||
max_vertex_buffer_array_stride: base.max_vertex_buffer_array_stride,
|
||||
max_immediate_size: 0x1000,
|
||||
max_inter_stage_shader_variables: self.max_varying_components / 4,
|
||||
min_uniform_buffer_offset_alignment: self.buffer_alignment as u32,
|
||||
min_storage_buffer_offset_alignment: self.buffer_alignment as u32,
|
||||
max_inter_stage_shader_components: self.max_varying_components,
|
||||
|
||||
@@ -182,6 +182,7 @@ pub const CAPABILITIES: crate::Capabilities = {
|
||||
max_buffer_size: ALLOC_MAX_U32 as u64,
|
||||
max_vertex_attributes: ALLOC_MAX_U32,
|
||||
max_vertex_buffer_array_stride: ALLOC_MAX_U32,
|
||||
max_inter_stage_shader_variables: ALLOC_MAX_U32,
|
||||
min_uniform_buffer_offset_alignment: 1,
|
||||
min_storage_buffer_offset_alignment: 1,
|
||||
max_inter_stage_shader_components: ALLOC_MAX_U32,
|
||||
|
||||
@@ -1431,6 +1431,10 @@ impl PhysicalDeviceProperties {
|
||||
max_vertex_attributes: limits.max_vertex_input_attributes,
|
||||
max_vertex_buffer_array_stride: limits.max_vertex_input_binding_stride,
|
||||
max_immediate_size: limits.max_push_constants_size,
|
||||
max_inter_stage_shader_variables: limits
|
||||
.max_vertex_output_components
|
||||
.min(limits.max_fragment_input_components)
|
||||
/ 4,
|
||||
min_uniform_buffer_offset_alignment: limits.min_uniform_buffer_offset_alignment as u32,
|
||||
min_storage_buffer_offset_alignment: limits.min_storage_buffer_offset_alignment as u32,
|
||||
max_inter_stage_shader_components: limits
|
||||
|
||||
@@ -164,6 +164,7 @@ fn print_adapter(output: &mut impl io::Write, report: &AdapterReport, idx: usize
|
||||
max_buffer_size,
|
||||
max_vertex_attributes,
|
||||
max_vertex_buffer_array_stride,
|
||||
max_inter_stage_shader_variables,
|
||||
min_uniform_buffer_offset_alignment,
|
||||
min_storage_buffer_offset_alignment,
|
||||
max_inter_stage_shader_components,
|
||||
@@ -219,6 +220,7 @@ fn print_adapter(output: &mut impl io::Write, report: &AdapterReport, idx: usize
|
||||
writeln!(output, "\t\t Max Vertex Attributes: {max_vertex_attributes}")?;
|
||||
writeln!(output, "\t\t Max Vertex Buffer Array Stride: {max_vertex_buffer_array_stride}")?;
|
||||
writeln!(output, "\t\t Max Immediate data Size: {max_immediate_size}")?;
|
||||
writeln!(output, "\t\t Max Inter-stage Shader Variables: {max_inter_stage_shader_variables}")?;
|
||||
writeln!(output, "\t\t Min Uniform Buffer Offset Alignment: {min_uniform_buffer_offset_alignment}")?;
|
||||
writeln!(output, "\t\t Min Storage Buffer Offset Alignment: {min_storage_buffer_offset_alignment}")?;
|
||||
writeln!(output, "\t\t Max Inter-Stage Shader Component: {max_inter_stage_shader_components}")?;
|
||||
|
||||
@@ -180,6 +180,11 @@ pub struct Limits {
|
||||
/// Maximum value for `VertexBufferLayout::array_stride` when creating a `RenderPipeline`.
|
||||
/// Defaults to 2048. Higher is "better".
|
||||
pub max_vertex_buffer_array_stride: u32,
|
||||
/// Maximum value for the number of input or output variables for inter-stage communication
|
||||
/// (like vertex outputs or fragment inputs) `@location(…)`s (in WGSL parlance)
|
||||
/// when creating a `RenderPipeline`.
|
||||
/// Defaults to 16. Higher is "better".
|
||||
pub max_inter_stage_shader_variables: u32,
|
||||
/// Required `BufferBindingType::Uniform` alignment for `BufferBinding::offset`
|
||||
/// when creating a `BindGroup`, or for `set_bind_group` `dynamicOffsets`.
|
||||
/// Defaults to 256. Lower is "better".
|
||||
@@ -325,6 +330,7 @@ impl Limits {
|
||||
/// max_buffer_size: 256 << 20, // (256 MiB)
|
||||
/// max_vertex_attributes: 16,
|
||||
/// max_vertex_buffer_array_stride: 2048,
|
||||
/// max_inter_stage_shader_variables: 16,
|
||||
/// min_uniform_buffer_offset_alignment: 256,
|
||||
/// min_storage_buffer_offset_alignment: 256,
|
||||
/// max_inter_stage_shader_components: 60,
|
||||
@@ -383,6 +389,7 @@ impl Limits {
|
||||
max_buffer_size: 256 << 20, // (256 MiB)
|
||||
max_vertex_attributes: 16,
|
||||
max_vertex_buffer_array_stride: 2048,
|
||||
max_inter_stage_shader_variables: 16,
|
||||
min_uniform_buffer_offset_alignment: 256,
|
||||
min_storage_buffer_offset_alignment: 256,
|
||||
max_inter_stage_shader_components: 60,
|
||||
@@ -447,6 +454,7 @@ impl Limits {
|
||||
/// max_immediate_size: 0,
|
||||
/// min_uniform_buffer_offset_alignment: 256,
|
||||
/// min_storage_buffer_offset_alignment: 256,
|
||||
/// max_inter_stage_shader_variables: 15,
|
||||
/// max_inter_stage_shader_components: 60,
|
||||
/// max_color_attachments: 4,
|
||||
/// max_color_attachment_bytes_per_sample: 32,
|
||||
@@ -487,6 +495,7 @@ impl Limits {
|
||||
max_texture_dimension_3d: 256,
|
||||
max_storage_buffers_per_shader_stage: 4,
|
||||
max_uniform_buffer_binding_size: 16 << 10, // (16 KiB)
|
||||
max_inter_stage_shader_variables: 15,
|
||||
max_color_attachments: 4,
|
||||
// see: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=7
|
||||
max_compute_workgroup_storage_size: 16352,
|
||||
@@ -524,6 +533,7 @@ impl Limits {
|
||||
/// max_immediate_size: 0,
|
||||
/// min_uniform_buffer_offset_alignment: 256,
|
||||
/// min_storage_buffer_offset_alignment: 256,
|
||||
/// max_inter_stage_shader_variables: 15,
|
||||
/// max_inter_stage_shader_components: 31,
|
||||
/// max_color_attachments: 4,
|
||||
/// max_color_attachment_bytes_per_sample: 32,
|
||||
@@ -573,6 +583,7 @@ impl Limits {
|
||||
max_compute_workgroups_per_dimension: 0,
|
||||
|
||||
// Value supported by Intel Celeron B830 on Windows (OpenGL 3.1)
|
||||
max_inter_stage_shader_variables: 15,
|
||||
max_inter_stage_shader_components: 31,
|
||||
|
||||
// Most of the values should be the same as the downlevel defaults
|
||||
|
||||
@@ -808,6 +808,7 @@ fn map_wgt_limits(limits: webgpu_sys::GpuSupportedLimits) -> wgt::Limits {
|
||||
max_buffer_size: limits.max_buffer_size() as u64,
|
||||
max_vertex_attributes: limits.max_vertex_attributes(),
|
||||
max_vertex_buffer_array_stride: limits.max_vertex_buffer_array_stride(),
|
||||
max_inter_stage_shader_variables: limits.max_inter_stage_shader_variables(),
|
||||
min_uniform_buffer_offset_alignment: limits.min_uniform_buffer_offset_alignment(),
|
||||
min_storage_buffer_offset_alignment: limits.min_storage_buffer_offset_alignment(),
|
||||
max_color_attachments: limits.max_color_attachments(),
|
||||
@@ -895,7 +896,7 @@ fn map_js_sys_limits(limits: &wgt::Limits) -> js_sys::Object {
|
||||
(maxBufferSize, max_buffer_size),
|
||||
(maxVertexAttributes, max_vertex_attributes),
|
||||
(maxVertexBufferArrayStride, max_vertex_buffer_array_stride),
|
||||
// TODO: (maxInterStageShaderVariables, max_inter_stage_shader_variables),
|
||||
(maxInterStageShaderVariables, max_inter_stage_shader_variables),
|
||||
(maxColorAttachments, max_color_attachments),
|
||||
(maxColorAttachmentBytesPerSample, max_color_attachment_bytes_per_sample),
|
||||
(maxComputeWorkgroupStorageSize, max_compute_workgroup_storage_size),
|
||||
|
||||
Reference in new issue
Block a user