Closed spencer-lunarg closed 7 months ago
attempt 2 of https://github.com/KhronosGroup/SPIRV-Reflect/pull/236 (closes https://github.com/KhronosGroup/SPIRV-Reflect/issues/234)
When ByteAddressBuffer are collapsed they start to look like
ByteAddressBuffer
OpDecorateString %var UserTypeGOOGLE "byteaddressbuffer" %var = OpVariable %22 StorageBuffer %a = OpLoad %type %input %b = OpIAdd %type %a %uint_16 %c = OpShiftRightLogical %type %b uint_2 %_ = OpAccessChain %e %var 0 %c
using the UserType we can detect which variable is used, from here we can build up an offset by working out the math
UserType
// offset + 16 %b = OpIAdd %type %a %uint_16 // offset >> 2 %c = OpShiftRightLogical %type %b uint_2 // offset == 4
I've tested the latest PR with our full shader corpus and can confirm it's working properly and producing proper ByteAddressBuffer offsets. Looks good to merge to me.
attempt 2 of https://github.com/KhronosGroup/SPIRV-Reflect/pull/236 (closes https://github.com/KhronosGroup/SPIRV-Reflect/issues/234)
When
ByteAddressBuffer
are collapsed they start to look likeusing the
UserType
we can detect which variable is used, from here we can build up an offset by working out the math