@@ -1029,7 +1029,10 @@ macro_rules! check_one_validation {
10291029/// NOTE: The only reason we don't use a function for this is because we need to syntactically
10301030/// re-use `$val_err_pat`.
10311031macro_rules! check_extension_validation {
1032- ( $caps: expr, $source: expr, $parse_err: expr, $val_err_pat: pat ) => {
1032+ ( $caps: expr, $source: expr, $parse_err: expr, $val_err_pat: pat $( , $other_caps: expr) ? ) => {
1033+ #[ allow( unused_mut, unused_assignments) ]
1034+ let mut other_caps = naga:: valid:: Capabilities :: empty( ) ;
1035+ $( other_caps = $other_caps; ) ?
10331036 let caps = $caps;
10341037 let source = $source;
10351038 let mut ext = None ;
@@ -1081,7 +1084,9 @@ macro_rules! check_extension_validation {
10811084 } ;
10821085
10831086 // Second check, for the expected validation error when the capability is not present
1084- let error = naga:: valid:: Validator :: new( naga:: valid:: ValidationFlags :: all( ) , !caps)
1087+ // Don't check with explicitly allowed caps, as certain things (currently just
1088+ // `acceleration_structure`s) can be enabled by multiple extensions
1089+ let error = naga:: valid:: Validator :: new( naga:: valid:: ValidationFlags :: all( ) , !( caps | other_caps) )
10851090 . validate( & module)
10861091 . map_err( |e| e. into_inner( ) ) ; // TODO(https://github.com/gfx-rs/wgpu/issues/8153): Add tests for spans
10871092 #[ allow( clippy:: redundant_pattern_matching) ]
@@ -4285,7 +4290,7 @@ fn source_with_control_char() {
42854290}
42864291
42874292#[ test]
4288- fn ray_query_enable_extension ( ) {
4293+ fn ray_types_enable_extension ( ) {
42894294 check_extension_validation ! (
42904295 Capabilities :: RAY_QUERY ,
42914296 r#"fn foo() {
@@ -4307,6 +4312,8 @@ fn ray_query_enable_extension() {
43074312 } )
43084313 ) ;
43094314
4315+
4316+ // can be enabled by either of these extensions
43104317 check_extension_validation ! (
43114318 Capabilities :: RAY_QUERY ,
43124319 r#"@group(0) @binding(0)
@@ -4324,7 +4331,28 @@ fn ray_query_enable_extension() {
43244331 Err ( naga:: valid:: ValidationError :: Type {
43254332 source: naga:: valid:: TypeError :: MissingCapability ( Capabilities :: RAY_QUERY ) ,
43264333 ..
4327- } )
4334+ } ) ,
4335+ Capabilities :: RAY_TRACING_PIPELINE
4336+ ) ;
4337+ check_extension_validation ! (
4338+ Capabilities :: RAY_TRACING_PIPELINE ,
4339+ r#"@group(0) @binding(0)
4340+ var acc_struct: acceleration_structure;
4341+ "# ,
4342+ r#"error: the `wgpu_ray_query` enable extension is not enabled
4343+ ┌─ wgsl:2:25
4344+ │
4345+ 2 │ var acc_struct: acceleration_structure;
4346+ │ ^^^^^^^^^^^^^^^^^^^^^^ the `wgpu_ray_query` "Enable Extension" is needed for this functionality, but it is not currently enabled.
4347+ │
4348+ = note: You can enable this extension by adding `enable wgpu_ray_query;` at the top of the shader, before any other items.
4349+
4350+ "# ,
4351+ Err ( naga:: valid:: ValidationError :: Type {
4352+ source: naga:: valid:: TypeError :: MissingCapability ( Capabilities :: RAY_QUERY ) ,
4353+ ..
4354+ } ) ,
4355+ Capabilities :: RAY_QUERY
43284356 ) ;
43294357}
43304358
0 commit comments