Repository navigation
[SPIR-V] Fix vk::BufferPointer bitfield stores - #8713
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Gregory Roth (@pow2clk) I can't add reviewers yet. Could you please review? |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Gregory Roth (pow2clk)
left a comment
There was a problem hiding this comment.
I tried to convince myself that there was some way to reorganize things so the alignment value could be calculated sooner and the bitfieldLoad wouldn't have to be outside the conditional so the bitfield handling code could be consolidated, but I don't think that's reasonable if it is possible.
There was a problem hiding this comment.
Pull request overview
Fixes a SPIR-V codegen crash when storing into a bitfield through vk::BufferPointer by ensuring the replacement value keeps AST type information so alignment can be computed and applied to the generated memory ops.
Changes:
- Preserve AST result type on the bitfield-inserted store value to avoid a null/invalid type flowing into alignment calculation.
- Apply the computed PhysicalStorageBuffer alignment to both the generated load (for read-modify-write) and the final store.
- Add a regression test covering
pc.ptr.Get().a = 123for a bitfield member.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/clang/lib/SPIRV/SpirvBuilder.cpp | Keeps AST typing/alignment intact for bitfield RMW stores via vk::BufferPointer, preventing the alignment calculator crash. |
| tools/clang/test/CodeGenSPIRV/vk.buffer-pointer.bitfield.hlsl | Adds a regression test asserting the expected OpLoad/OpBitFieldInsert/OpStore sequence with Aligned 4. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Preserve the bitfield AST type and align the generated load and store.
5c68c19 to
971d659
Compare
Added an entry in |
|
Gregory Roth (@pow2clk). I've addressed all the outstanding comments. If this is now OK, would you mind submitting it for me? Thanks. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
…8715) Since I was doing bitfield fixes in #8713, I took this one too. This PR fixes #8526. Copying a `ConstantBuffer` value with merged bitfields into a local struct overwrites the members after the bitfields. For `struct MyData { uint a : 16; uint b : 16; uint c; }`, reading `c` returns the word holding `a` and `b`. This change makes `processFlatConversion` pick the decomposition mode from the source and destination AST types. A same-type conversion emits one scalar per SPIR-V field. But a cast that changes the shape, keeps one scalar per AST field. I added the test from the original issue. --------- Co-authored-by: Gregory Roth <[email protected]>
This fixes #8402.
Storing to a bitfield through
vk::BufferPointercrashes inAlignmentSizeCalculator::getAlignmentAndSize. The bitfield update was losing the AST Type and alignment information.This change preserves the original AST type while producing the replacement value. It calculates the physical-memory alignment from that type and applies it to both the generated load and store.
I added the original reproducer as a new test.