Fix layoutDescriptorStride bitfield truncation for large stride values#4184
Fix layoutDescriptorStride bitfield truncation for large stride values#4184jeremy-lunarg merged 3 commits intoKhronosGroup:mainfrom
Conversation
|
Hello @Tobski and @spencer-lunarg , Here is the fix for #4178, please help me review. |
|
SPIR-V generated with this fix: |
|
@Guang-035 can we add this as a test (or preferably a test of various structs using |
Hello @spencer-lunarg , I've added a test with descriptor_stride=512 using a buffer block with mat4 members. Could you clarify what you mean by "various structs"? A GLSL example would be helpful. |
Basically test that setting |
|
Yea I don't think we need to test different structs; the struct definition for the UBO has no interaction with the stride. What might be worth adding a test for is the same but for the stride of an image descriptor. E.g. layout(descriptor_heap, descriptor_stride = 1024) image2D image; |
|
(This is more for regression testing - I don't think there's any reason it's necessary to test it for this particular change) |
|
@Guang-035 we can't merge this until you sign the CLA |
|
@Guang-035 You will need to sign the CLA, then I will be able to merge this. |
Add an image2D declaration with descriptor_stride=1024 alongside the existing buffer test with descriptor_stride=512, covering both buffer and image descriptor types as suggested in code review.
|
Add an image2D declaration with descriptor_stride=1024 alongside the buffer test with descriptor_stride=512, covering both buffer image descriptor types as suggested by @Tobski . |
|
Can you provide a pre-compiled binary so I can test if this fixes the issues I've been having? |
Issue: #4178
RootCause:
layoutDescriptorStride was declared as a 4-bit bitfield, which can only values 0-15. Since descriptor_stride must be a power of two, any >= 16 (e.g. 512) was silently truncated to 0 — the "not set" sentinel — causing the SPIR-V backend to fall back to instead of emitting the user-specified stride.
Fix:
Widen the field to a full unsigned int to support the complete range allowed by the GL_EXT_descriptor_heap and SPV_EXT_descriptor_heap specs.