@@ -4,7 +4,8 @@ use crate::maybe_pqp_cg_ssa as rustc_codegen_ssa;
44use super :: Builder ;
55use crate :: builder_spirv:: { SpirvValue , SpirvValueExt , SpirvValueKind } ;
66use crate :: spirv_type:: SpirvType ;
7- use rspirv:: spirv:: Word ;
7+ use rspirv:: spirv:: { Decoration , Word } ;
8+ use rustc_codegen_spirv_types:: Capability ;
89use rustc_codegen_ssa:: traits:: BuilderMethods ;
910use rustc_errors:: ErrorGuaranteed ;
1011use rustc_span:: DUMMY_SP ;
@@ -41,11 +42,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4142 } ;
4243 let u32_ty = SpirvType :: Integer ( 32 , false ) . def ( DUMMY_SP , self ) ;
4344 let u32_ptr = self . type_ptr_to ( u32_ty) ;
45+ let array = array. def ( self ) ;
46+ let actual_index = actual_index. def ( self ) ;
4447 let ptr = self
4548 . 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] )
4750 . unwrap ( )
4851 . 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+ }
4959 self . load ( u32_ty, ptr, Align :: ONE )
5060 }
5161
@@ -233,11 +243,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
233243 } ;
234244 let u32_ty = SpirvType :: Integer ( 32 , false ) . def ( DUMMY_SP , self ) ;
235245 let u32_ptr = self . type_ptr_to ( u32_ty) ;
246+ let array = array. def ( self ) ;
247+ let actual_index = actual_index. def ( self ) ;
236248 let ptr = self
237249 . 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] )
239251 . unwrap ( )
240252 . 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+ }
241260 self . store ( value, ptr, Align :: ONE ) ;
242261 Ok ( ( ) )
243262 }
0 commit comments