Repository navigation
D3D12.X: constant buffer views are float4 rows (stride 16), not raw buffers - #335
Conversation
…uffers CreateConstantBufferView wrote every CBV as a raw V# (stride 0, num_records in bytes). Console shaders index constant-buffer arrays with buffer_load_* idxen and the row as the index; with stride 0 the index is ignored, so every row read returns row 0. A retail game's UI element shader reads its transform as two such rows: with both equal, every vertex lands on x = y and the UI collapses onto the screen's diagonal (ivall#175, ivall#307). Where the title writes this descriptor itself, it writes stride 16 and num_records = size / 16. desc::cbv_words: stride 16, num_records = ceil(size / 16). Loads by byte offset read the same addresses as before; scalar loads keep their byte limit (num_records x stride). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Test report for Tested
Reviewed (read the whole diff)
Not tested
AI use
|
|
Merged (a6f5f7a). Checked on an RX 9070 (RDNA4) on main a6f5f7a, together with #335, #322, #331, #330, #338, #318 and #332: |
|
Test report on our machine with this PR's head (01a7446) stacked on main db1ddb2 + #300 + #294 + #273 + #236 + #304: Ryzen 7 9800X3D, RTX 3060 Ti 8 GB (wave32), driver 32.0.16.1742, Windows 11.
For comparison, our previous stack without this PR (main 4017f8f + #300 + #294 + #273/+#208 + #283/+#252) crashed at t=395 s in a 600 s run with 0xc0000005 (write at 0xc43440110, game+0x35a47bc) at ~26.6 GB commit. Different stack, so this is not a controlled A/B of this PR alone - but no regression on our hardware and the run went further. The artwork-intro slow stretch (4.4-8.6 fps, t~45-165 s) is unchanged with this PR; we measured it identical with and without the audio PRs, so it is not this CBV path either. Not tested: unit tests for this report (run-only data point); the diagonal-collapse case from #175 (we never saw it on NVIDIA). AI use: GPT-6.2 Astra (API model selector) ran the build and run and wrote this report; the human contributor reviewed it. |
Fixes #307. The black image with a 1-pixel diagonal reported in #175.
CreateConstantBufferView(real.rs,dev_create_cbv_x) wrote every CBV as a raw V#: stride 0, num_records in bytes. Console shaders also read constant-buffer arrays withbuffer_load_* … idxenand the row number as the index. With stride 0 the index is ignored (the recompiler follows the hardware rulebase + stride·index), so every such read returns row 0. A retail game's UI element VS (28d887aa04ffa15a) reads its transform as two rows,4k+2and4k+3. With both equal, every vertex lands on x = y and the whole UI collapses onto the screen's diagonal.Where the title writes this descriptor itself, it writes
[base, 0x00100004, 0x00000060, 0x0002403c]for the same 1536-byte buffer (@FilipeSilvens' trace in #175): stride 16, num_records = size / 16. XCL's CBV now matches that. @notdxbi found the same cause independently in #175; @wiktorekdev carries the same change locally.Discussion
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175: the black image with the diagonal on Linux.idxenreads from a CBV ignore the index – measured on Linux, Windows measurement wanted #307: the report of this cause and the question it asked: why the menus draw on some setups without the change.ignore_shared_fence, an audio device).What is in it
desc::cbv_words(address, size): stride 16, num_records = ceil(size / 16), format 32_32_32_32_FLOAT.dev_create_cbv_xuses it instead ofbuffer_words(va, 0, size, 22).s_buffer_loadbounds atnum_records × stride. One difference: a vector load by byte offset is now bounded by the row index (always 0 there), not by the byte size. Reads inside the buffer are unchanged.gpu::desc::tests::cbv_is_float4_rows.Tested
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175 withVKD3D_CONFIG=ignore_shared_fence, DXVK dxgi; Rust 1.100.0,x86_64-pc-windows-gnu, release.cargo test -p xcl --libunder Wine, without a GPU, main and this branch: 613 passed / 12 failed / 21 ignored on main, 614 / 12 / 21 here. The extra pass is the new test, and the 12 failures are the same on both: tests that need a D3D12 device or the LLVM corpus.XCL_FRAME_DUMP=1):Regression run
Made under Wine on Linux with the equivalent of
scripts/smoke.ps1:XCL_NETWORK=0 XCL_RUN_SECONDS=120 XCL_ACTIVITY=1 xcl.exe run <title>, the same block read from the log. Both builds come from clean checkouts of the two commits. Peak commit reads 0 under Wine.main:
PR:
Not tested
scripts/smoke.ps1itself (no Windows machine here).CreateConstantBufferViewon others (Constant buffer views are encoded with stride 0, soidxenreads from a CBV ignore the index – measured on Linux, Windows measurement wanted #307). Either way, the CBV path now writes what the title would.AI use
🤖 Generated with Claude Code
AI-assisted.