Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[spirv] Check parent class when setting contains-alias-component of "…
…this" (microsoft#4425) When we handle `Load/Store` method of ByteAddressBuffer, we first load the ByteAddressBuffer object if it is a reference of an alias variable. `this` object is a reference of an alias variable if a ByteAddressBuffer is a member of the class. The existing code checks members of the class to determine if it has ByteAddressBuffer or not, but it does not check its parent. Since we add all members of a parent to its child class, we have to check members of the parent as well. This commit fixes the issue and now `loadIfAliasVarRef(..)` properly loads the access chain to ByteAddressBuffer. For example, ``` // HLSL: struct Base { ByteAddressBuffer buffer; }; struct Child : Base { float load(in uint offset) { return asfloat(buffer.Load(offset)); } }; // Before: %param_this = OpFunctionParameter %_ptr_Function_Child %base = OpAccessChain %_ptr_Function_Base %param_this %uint_0 %ptr = OpAccessChain %_ptr_Function__ptr_Uniform_type_ByteAddressBuffer %base %int_0 OpAccessChain %_ptr_Uniform_uint %ptr %uint_0 ; <-- Error!! // After: %param_this = OpFunctionParameter %_ptr_Function_Child %base = OpAccessChain %_ptr_Function_Base %param_this %uint_0 %ptr = OpAccessChain %_ptr_Function__ptr_Uniform_type_ByteAddressBuffer %base %int_0 %buffer = OpLoad %_ptr_Uniform_type_ByteAddressBuffer %ptr OpAccessChain %_ptr_Uniform_uint %buffer %uint_0 ```
- Loading branch information