Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add New Binding Array Specific Limits #6952

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions deno_webgpu/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,8 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
) {
return_features.push("sampled-texture-and-storage-buffer-array-non-uniform-indexing");
}
if features.contains(
wgpu_types::Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
) {
return_features.push("uniform-buffer-and-storage-texture-array-non-uniform-indexing");
if features.contains(wgpu_types::Features::STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING) {
return_features.push("storage-texture-array-non-uniform-indexing");
}
if features.contains(wgpu_types::Features::PARTIALLY_BOUND_BINDING_ARRAY) {
return_features.push("partially-bound-binding-array");
Expand Down Expand Up @@ -553,10 +551,10 @@ impl From<GpuRequiredFeatures> for wgpu_types::Features {
.contains("sampled-texture-and-storage-buffer-array-non-uniform-indexing"),
);
features.set(
wgpu_types::Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
wgpu_types::Features::STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
required_features
.0
.contains("uniform-buffer-and-storage-texture-array-non-uniform-indexing"),
.contains("storage-texture-array-non-uniform-indexing"),
);
features.set(
wgpu_types::Features::PARTIALLY_BOUND_BINDING_ARRAY,
Expand Down
6 changes: 5 additions & 1 deletion examples/features/src/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,11 @@ impl<E: Example + wgpu::WasmNotSendSync> From<ExampleTestParams<E>>

let features = E::required_features() | params.optional_features;

params.base_test_parameters.clone().features(features)
params
.base_test_parameters
.clone()
.features(features)
.limits(E::required_limits())
})
.run_async(move |ctx| async move {
let format = if E::SRGB {
Expand Down
7 changes: 7 additions & 0 deletions examples/features/src/texture_arrays/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ impl crate::framework::Example for Example {
fn required_features() -> wgpu::Features {
wgpu::Features::TEXTURE_BINDING_ARRAY
}
fn required_limits() -> wgpu::Limits {
wgpu::Limits {
max_binding_array_elements_per_shader_stage: 6,
max_binding_array_sampler_elements_per_shader_stage: 2,
..wgpu::Limits::downlevel_defaults()
}
}
fn init(
config: &wgpu::SurfaceConfiguration,
_adapter: &wgpu::Adapter,
Expand Down
7 changes: 4 additions & 3 deletions naga/src/valid/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ impl FunctionInfo {
..
} => {
// these are nasty aliases, but these idents are too long and break rustfmt
let ub_st = super::Capabilities::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING;
let sto = super::Capabilities::STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING;
let uni = super::Capabilities::UNIFORM_BUFFER_ARRAY_NON_UNIFORM_INDEXING;
let st_sb = super::Capabilities::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING;
let sampler = super::Capabilities::SAMPLER_NON_UNIFORM_INDEXING;

Expand All @@ -542,7 +543,7 @@ impl FunctionInfo {
needed_caps |= match *array_element_ty {
// If we're an image, use the appropriate limit.
crate::TypeInner::Image { class, .. } => match class {
crate::ImageClass::Storage { .. } => ub_st,
crate::ImageClass::Storage { .. } => sto,
_ => st_sb,
},
crate::TypeInner::Sampler { .. } => sampler,
Expand All @@ -551,7 +552,7 @@ impl FunctionInfo {
if let E::GlobalVariable(global_handle) = expression_arena[base] {
let global = &resolve_context.global_vars[global_handle];
match global.space {
crate::AddressSpace::Uniform => ub_st,
crate::AddressSpace::Uniform => uni,
crate::AddressSpace::Storage { .. } => st_sb,
_ => unreachable!(),
}
Expand Down
44 changes: 23 additions & 21 deletions naga/src/valid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,47 +90,49 @@ bitflags::bitflags! {
const PRIMITIVE_INDEX = 1 << 2;
/// Support for non-uniform indexing of sampled textures and storage buffer arrays.
const SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING = 1 << 3;
/// Support for non-uniform indexing of uniform buffers and storage texture arrays.
const UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING = 1 << 4;
/// Support for non-uniform indexing of storage texture arrays.
const STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING = 1 << 4;
/// Support for non-uniform indexing of uniform buffer arrays.
const UNIFORM_BUFFER_ARRAY_NON_UNIFORM_INDEXING = 1 << 5;
/// Support for non-uniform indexing of samplers.
const SAMPLER_NON_UNIFORM_INDEXING = 1 << 5;
const SAMPLER_NON_UNIFORM_INDEXING = 1 << 6;
/// Support for [`BuiltIn::ClipDistance`].
///
/// [`BuiltIn::ClipDistance`]: crate::BuiltIn::ClipDistance
const CLIP_DISTANCE = 1 << 6;
const CLIP_DISTANCE = 1 << 7;
/// Support for [`BuiltIn::CullDistance`].
///
/// [`BuiltIn::CullDistance`]: crate::BuiltIn::CullDistance
const CULL_DISTANCE = 1 << 7;
const CULL_DISTANCE = 1 << 8;
/// Support for 16-bit normalized storage texture formats.
const STORAGE_TEXTURE_16BIT_NORM_FORMATS = 1 << 8;
const STORAGE_TEXTURE_16BIT_NORM_FORMATS = 1 << 9;
/// Support for [`BuiltIn::ViewIndex`].
///
/// [`BuiltIn::ViewIndex`]: crate::BuiltIn::ViewIndex
const MULTIVIEW = 1 << 9;
const MULTIVIEW = 1 << 10;
/// Support for `early_depth_test`.
const EARLY_DEPTH_TEST = 1 << 10;
const EARLY_DEPTH_TEST = 1 << 11;
/// Support for [`BuiltIn::SampleIndex`] and [`Sampling::Sample`].
///
/// [`BuiltIn::SampleIndex`]: crate::BuiltIn::SampleIndex
/// [`Sampling::Sample`]: crate::Sampling::Sample
const MULTISAMPLED_SHADING = 1 << 11;
const MULTISAMPLED_SHADING = 1 << 12;
/// Support for ray queries and acceleration structures.
const RAY_QUERY = 1 << 12;
const RAY_QUERY = 1 << 13;
/// Support for generating two sources for blending from fragment shaders.
const DUAL_SOURCE_BLENDING = 1 << 13;
const DUAL_SOURCE_BLENDING = 1 << 14;
/// Support for arrayed cube textures.
const CUBE_ARRAY_TEXTURES = 1 << 14;
const CUBE_ARRAY_TEXTURES = 1 << 15;
/// Support for 64-bit signed and unsigned integers.
const SHADER_INT64 = 1 << 15;
const SHADER_INT64 = 1 << 16;
/// Support for subgroup operations.
/// Implies support for subgroup operations in both fragment and compute stages,
/// but not necessarily in the vertex stage, which requires [`Capabilities::SUBGROUP_VERTEX_STAGE`].
const SUBGROUP = 1 << 16;
const SUBGROUP = 1 << 17;
/// Support for subgroup barriers.
const SUBGROUP_BARRIER = 1 << 17;
const SUBGROUP_BARRIER = 1 << 18;
/// Support for subgroup operations in the vertex stage.
const SUBGROUP_VERTEX_STAGE = 1 << 18;
const SUBGROUP_VERTEX_STAGE = 1 << 19;
/// Support for [`AtomicFunction::Min`] and [`AtomicFunction::Max`] on
/// 64-bit integers in the [`Storage`] address space, when the return
/// value is not used.
Expand All @@ -140,9 +142,9 @@ bitflags::bitflags! {
/// [`AtomicFunction::Min`]: crate::AtomicFunction::Min
/// [`AtomicFunction::Max`]: crate::AtomicFunction::Max
/// [`Storage`]: crate::AddressSpace::Storage
const SHADER_INT64_ATOMIC_MIN_MAX = 1 << 19;
const SHADER_INT64_ATOMIC_MIN_MAX = 1 << 20;
/// Support for all atomic operations on 64-bit integers.
const SHADER_INT64_ATOMIC_ALL_OPS = 1 << 20;
const SHADER_INT64_ATOMIC_ALL_OPS = 1 << 21;
/// Support for [`AtomicFunction::Add`], [`AtomicFunction::Sub`],
/// and [`AtomicFunction::Exchange { compare: None }`] on 32-bit floating-point numbers
/// in the [`Storage`] address space.
Expand All @@ -151,11 +153,11 @@ bitflags::bitflags! {
/// [`AtomicFunction::Sub`]: crate::AtomicFunction::Sub
/// [`AtomicFunction::Exchange { compare: None }`]: crate::AtomicFunction::Exchange
/// [`Storage`]: crate::AddressSpace::Storage
const SHADER_FLOAT32_ATOMIC = 1 << 21;
const SHADER_FLOAT32_ATOMIC = 1 << 22;
/// Support for atomic operations on images.
const TEXTURE_ATOMIC = 1 << 22;
const TEXTURE_ATOMIC = 1 << 23;
/// Support for atomic operations on 64-bit images.
const TEXTURE_INT64_ATOMIC = 1 << 23;
const TEXTURE_INT64_ATOMIC = 1 << 24;
}
}

Expand Down
15 changes: 6 additions & 9 deletions tests/tests/binding_array/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ use wgpu_test::{gpu_test, FailureCase, GpuTestConfiguration, TestParameters, Tes
static BINDING_ARRAY_UNIFORM_BUFFERS: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
TestParameters::default()
.features(
Features::BUFFER_BINDING_ARRAY
| Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
)
.features(Features::BUFFER_BINDING_ARRAY | Features::UNIFORM_BUFFER_INDEXING)
.limits(Limits {
max_uniform_buffers_per_shader_stage: 16,
max_binding_array_elements_per_shader_stage: 16,
..Limits::default()
})
// Naga bug on vulkan: https://github.com/gfx-rs/wgpu/issues/6733
Expand All @@ -31,10 +28,10 @@ static PARTIAL_BINDING_ARRAY_UNIFORM_BUFFERS: GpuTestConfiguration = GpuTestConf
.features(
Features::BUFFER_BINDING_ARRAY
| Features::PARTIALLY_BOUND_BINDING_ARRAY
| Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
| Features::UNIFORM_BUFFER_INDEXING,
)
.limits(Limits {
max_uniform_buffers_per_shader_stage: 32,
max_binding_array_elements_per_shader_stage: 32,
..Limits::default()
})
// Naga bug on vulkan: https://github.com/gfx-rs/wgpu/issues/6733
Expand All @@ -56,7 +53,7 @@ static BINDING_ARRAY_STORAGE_BUFFERS: GpuTestConfiguration = GpuTestConfiguratio
| Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
)
.limits(Limits {
max_storage_buffers_per_shader_stage: 17,
max_binding_array_elements_per_shader_stage: 17,
..Limits::default()
})
// See https://github.com/gfx-rs/wgpu/issues/6745.
Expand All @@ -75,7 +72,7 @@ static PARTIAL_BINDING_ARRAY_STORAGE_BUFFERS: GpuTestConfiguration = GpuTestConf
| Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
)
.limits(Limits {
max_storage_buffers_per_shader_stage: 33,
max_binding_array_elements_per_shader_stage: 33,
..Limits::default()
})
// See https://github.com/gfx-rs/wgpu/issues/6745.
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/binding_array/sampled_textures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static BINDING_ARRAY_SAMPLED_TEXTURES: GpuTestConfiguration = GpuTestConfigurati
| Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
)
.limits(Limits {
max_sampled_textures_per_shader_stage: 16,
max_binding_array_elements_per_shader_stage: 16,
..Limits::default()
}),
)
Expand All @@ -30,7 +30,7 @@ static PARTIAL_BINDING_ARRAY_SAMPLED_TEXTURES: GpuTestConfiguration = GpuTestCon
| Features::PARTIALLY_BOUND_BINDING_ARRAY,
)
.limits(Limits {
max_sampled_textures_per_shader_stage: 32,
max_binding_array_elements_per_shader_stage: 32,
..Limits::default()
}),
)
Expand Down
6 changes: 4 additions & 2 deletions tests/tests/binding_array/samplers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ static BINDING_ARRAY_SAMPLERS: GpuTestConfiguration = GpuTestConfiguration::new(
| Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
)
.limits(Limits {
max_samplers_per_shader_stage: 2,
max_binding_array_elements_per_shader_stage: 2,
max_binding_array_sampler_elements_per_shader_stage: 2,
..Limits::default()
}),
)
Expand All @@ -28,7 +29,8 @@ static PARTIAL_BINDING_ARRAY_SAMPLERS: GpuTestConfiguration = GpuTestConfigurati
| Features::PARTIALLY_BOUND_BINDING_ARRAY,
)
.limits(Limits {
max_samplers_per_shader_stage: 4,
max_binding_array_elements_per_shader_stage: 4,
max_binding_array_sampler_elements_per_shader_stage: 4,
..Limits::default()
}),
)
Expand Down
8 changes: 4 additions & 4 deletions tests/tests/binding_array/storage_textures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ static BINDING_ARRAY_STORAGE_TEXTURES: GpuTestConfiguration = GpuTestConfigurati
.features(
Features::TEXTURE_BINDING_ARRAY
| Features::STORAGE_RESOURCE_BINDING_ARRAY
| Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING
| Features::STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING
| Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
)
.limits(Limits {
max_storage_textures_per_shader_stage: 17,
max_binding_array_elements_per_shader_stage: 17,
..Limits::default()
})
.expect_fail(FailureCase::backend(Backends::METAL)),
Expand All @@ -32,11 +32,11 @@ static PARTIAL_BINDING_ARRAY_STORAGE_TEXTURES: GpuTestConfiguration = GpuTestCon
Features::TEXTURE_BINDING_ARRAY
| Features::PARTIALLY_BOUND_BINDING_ARRAY
| Features::STORAGE_RESOURCE_BINDING_ARRAY
| Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING
| Features::STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING
| Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
)
.limits(Limits {
max_storage_textures_per_shader_stage: 33,
max_binding_array_elements_per_shader_stage: 33,
..Limits::default()
})
.expect_fail(FailureCase::backend(Backends::METAL)),
Expand Down
11 changes: 3 additions & 8 deletions tests/tests/binding_array/validation.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::num::NonZeroU32;

use wgpu::*;
use wgpu_test::{
fail, gpu_test, FailureCase, GpuTestConfiguration, TestParameters, TestingContext,
};
use wgpu_test::{fail, gpu_test, GpuTestConfiguration, TestParameters, TestingContext};

#[gpu_test]
static VALIDATION: GpuTestConfiguration = GpuTestConfiguration::new()
Expand All @@ -12,12 +10,9 @@ static VALIDATION: GpuTestConfiguration = GpuTestConfiguration::new()
.features(Features::TEXTURE_BINDING_ARRAY)
.limits(Limits {
max_dynamic_storage_buffers_per_pipeline_layout: 1,
max_binding_array_elements_per_shader_stage: 4,
..Limits::downlevel_defaults()
})
.expect_fail(
// https://github.com/gfx-rs/wgpu/issues/6950
FailureCase::backend(Backends::VULKAN).validation_error("has not been destroyed"),
),
}),
)
.run_async(validation);

Expand Down
Loading
Loading