Repository navigation
Shader: honor BGRA views for normalized formatted buffer stores - #1341
Conversation
The runtime describes two encodable packed UNORM formats in BGRA order through V# selectors. A store must place red in the third memory field even when only the red input is present.
|
Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51, llvm-mc 23.1.6): pass. |
|
Tested I assembled eight synthetic wave32 compute shaders covering the two supported BGRA/RGBA UNORM encodings (8:8:8:8 and 10:10:10:2), both selector orders and ordinary and D16 stores. Each shader exercised x, xy, xyz and xyzw. All 32 packed words and 32 guards matched the CPU reference. The 8-bit BGRA x store wrote A temporary control translator forced identity channel order for these two encodings. All 16 BGRA words then differed from the reference, while the 16 RGBA words and 32 guards still matched. All 16 modules passed SPIR-V validation. Linux 7.0.0-43-generic, llvm-mc 21.1.8, SPIRV-Tools 2026.1. The GPU run covered wave32 for these two encodings. AI-assisted verification. |
|
Tested dac5489 on NVIDIA GeForce RTX 3090 (Ampere, subgroup 32..32), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 26300: pass, no regression. The PR's diff applied cleanly to
|
|
Tested dac5489 on AMD Radeon RX 7900 XTX (RDNA3, Navi 31), AMD driver 26.11.2, Vulkan 1.4.359, Windows 11: no regression.
Tools: llvm-mc 21.1.8 (WSL), Vulkan SDK 1.4.363.0, MSVC 14.44. Base |
|
@Rainmaker33 I added ordinary 8/8/8/8 and packed single-component 10/10/10/2 BGRA stores to the existing cs_store fixture in #1394 at 554b1d1. This PR merged dac5489 before the additional test commit arrived. You can run them without pytest: The last two words were 0x400080ff and 0x000003ff on the base translator, so the new checker failed. On RTX 5080 and Radeon the same shader now gives 0x40ff8000 and 0x3ff00000, respectively, with all six preceding words still matching. If you rerun on Ampere, those last two words directly check the change. AI-assisted. |
Claimed in the coordination issue as BGRA formatted buffer stores.
What and why
The runtime represents B8G8R8A8_UNORM and A2R10G10B10_UNORM with the same format codes as their RGBA counterparts and the V# selectors Z,Y,X,W. Formatted stores previously placed the red value in the low memory field for either selector order. The encoder now fills absent source components with zero and exchanges the red and blue fields for the BGRA view on these two formats. This includes one-component instructions.
This change covers the two existing UNORM encodings. A separate native sample with format 54 (2_10_10_10_UINT) confirmed that BGRA swaps those fields too. The translator's format table currently omits 54. Across all 24 permutations of the four RGBA selectors on gfx1036, some stores followed neither a direct nor an inverse permutation. This patch implements only the measured BGRA case.
Tested
Checklist
AI-assisted.