@@ -4,7 +4,8 @@ use crate::maybe_pqp_cg_ssa as rustc_codegen_ssa;
4
4
use super :: Builder ;
5
5
use crate :: builder_spirv:: { SpirvValue , SpirvValueExt , SpirvValueKind } ;
6
6
use crate :: spirv_type:: SpirvType ;
7
- use rspirv:: spirv:: Word ;
7
+ use rspirv:: spirv:: { Decoration , Word } ;
8
+ use rustc_codegen_spirv_types:: Capability ;
8
9
use rustc_codegen_ssa:: traits:: BuilderMethods ;
9
10
use rustc_errors:: ErrorGuaranteed ;
10
11
use rustc_span:: DUMMY_SP ;
@@ -41,11 +42,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
41
42
} ;
42
43
let u32_ty = SpirvType :: Integer ( 32 , false ) . def ( DUMMY_SP , self ) ;
43
44
let u32_ptr = self . type_ptr_to ( u32_ty) ;
45
+ let array = array. def ( self ) ;
46
+ let actual_index = actual_index. def ( self ) ;
44
47
let ptr = self
45
48
. emit ( )
46
- . in_bounds_access_chain ( u32_ptr, None , array. def ( self ) , [ actual_index. def ( self ) ] )
49
+ . in_bounds_access_chain ( u32_ptr, None , array, [ actual_index] )
47
50
. unwrap ( )
48
51
. with_type ( u32_ptr) ;
52
+ if self . builder . has_capability ( Capability :: ShaderNonUniform ) {
53
+ // apply NonUniform to the operation and the index
54
+ self . emit ( )
55
+ . decorate ( ptr. def ( self ) , Decoration :: NonUniform , [ ] ) ;
56
+ self . emit ( )
57
+ . decorate ( actual_index, Decoration :: NonUniform , [ ] ) ;
58
+ }
49
59
self . load ( u32_ty, ptr, Align :: ONE )
50
60
}
51
61
@@ -233,11 +243,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
233
243
} ;
234
244
let u32_ty = SpirvType :: Integer ( 32 , false ) . def ( DUMMY_SP , self ) ;
235
245
let u32_ptr = self . type_ptr_to ( u32_ty) ;
246
+ let array = array. def ( self ) ;
247
+ let actual_index = actual_index. def ( self ) ;
236
248
let ptr = self
237
249
. emit ( )
238
- . in_bounds_access_chain ( u32_ptr, None , array. def ( self ) , [ actual_index. def ( self ) ] )
250
+ . in_bounds_access_chain ( u32_ptr, None , array, [ actual_index] )
239
251
. unwrap ( )
240
252
. with_type ( u32_ptr) ;
253
+ if self . builder . has_capability ( Capability :: ShaderNonUniform ) {
254
+ // apply NonUniform to the operation and the index
255
+ self . emit ( )
256
+ . decorate ( ptr. def ( self ) , Decoration :: NonUniform , [ ] ) ;
257
+ self . emit ( )
258
+ . decorate ( actual_index, Decoration :: NonUniform , [ ] ) ;
259
+ }
241
260
self . store ( value, ptr, Align :: ONE ) ;
242
261
Ok ( ( ) )
243
262
}
0 commit comments