Repository navigation
d3d12: a constant-buffer view's V# steps 16 bytes a row (RT-CBV-VSHARP-STRIDE) - #513
Closed
oscarlosu-lab wants to merge 1 commit into
Closed
oscarlosu-lab wants to merge 1 commit into
oscarlosu-lab wants to merge 1 commit into
Conversation
…P-STRIDE) CreateConstantBufferView wrote the CBV's raw V# with STRIDE 0. A buffer access with idxen adds index x STRIDE to the address, so a program that indexes its constant buffer by row read row 0 for every index. ThatRecompDev/five-star-recomp (GPL-3.0, commit 4c6bce59b) measured this on the retail title: the UI's batch programs read each vertex's matrix rows from their CBV by index, and with stride 0 every UI shape fell on the line x = y. STRIDE is now 16, a constant buffer's row. NUM_RECORDS stays the view's size in bytes with OOB_SELECT RAW, which bounds a MUBUF access by its offset rather than index x STRIDE, so that bound is unchanged; an s_buffer_load bound becomes NUM_RECORDS x STRIDE. d3d12_compute_test checks the new words; the descriptor notes in docs/d3d12_vulkan.md describe the CBV V# (they still listed CBVs and buffer SRVs as unwritten). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Independent GPU verification on Windows 11 26100.7623, RTX 5070 Ti (610.74), MSVC 19.44.35220 Release, with the Khronos Vulkan validation layer enabled. I reused the two 256-byte CBVs from d3d12_compute_test. A temporary GLSL stand-in used the V# stride for row indexing and read 16 valid rows from each view. Counts below are matching dwords read back from the GPU.
Main reused row zero. With the PR, the normal d3d12_compute_test also passes with validation enabled. Separately, the translator's semantic harness matched all 32 valid row/word cases for RAW idxen loads at strides 0 and 16. Synthetic fixtures only. AI-assisted verification. |
demoz53
added a commit
to demoz53/leonida
that referenced
this pull request
Nov 24, 2026
… 16 bytes a row (RT-CBV-VSHARP-STRIDE)
This was referenced Nov 24, 2026
4 tasks done
3 of 4 tasks
4 tasks done
2 of 4 tasks
whoalin1
added a commit
to whoalin1/leonida-continued
that referenced
this pull request
Nov 25, 2026
Measured on the RDNA2 iGPU (gfx1036, tools/f16_interp_probe.py, 98,304 samples over 12 native draws): the SPI writes P10/P20 for a 16-bit channel as per-half f16 differences (round to nearest even), the weighted sum stays f32, and v_interp_p2_f16 narrows toward zero -- the driver's ISA runs the pair inside s_round_mode 0x000c, so the narrow is toward zero whatever the shader's own MODE writes are. The rdna2 model explains 98,274 of 98,304 samples; the previous translation (f32 deltas, nearest-even narrow) explains 62,226. - Gen.f16_round: f32 -> nearest-f16 value via f16_bits + UnpackHalf2x16 (integer-built bits, so no driver folds the round trip away, ProjectLeonida#512/ProjectLeonida#513); applied to the P1-P0 / P2-P0 deltas of 16-bit-channel reads in attribute(). - v_interp_p2_f16 narrows with f16_bits(rtz=True) and keeps the SHADER-430 partial-write high half via write_lo16. - vk_harness: scan both stages for Float16 / StorageInputOutput16 / Float64 capabilities (77 when the device lacks them), enable the matching Vulkan 1.1/1.2 features, VKH_PC_BYTES to shrink the push-constant range for hand-written fixtures, and VKH_SHADER_INFO to dump the driver's fragment disassembly. - tests/semantic/test_interp_f16_round.py: the two telling cases (f16 delta overflow to inf; toward-zero vs nearest-even tie). - tests/semantic/test_interp_p1lv_f16.py: reference oracle updated to the measured model (f16 deltas, f32 sum, toward-zero narrow). - docs/design.md: 16-bit interpolation row records the SHADER-468 measurements and remaining unverified items. Co-Authored-By: Devin <noreply@cognition.ai>
aslan2142
pushed a commit
that referenced
this pull request
Nov 25, 2026
…first-run UI Build on the public frame-loop integration in #321. Carry the texture-view and depth work from #213 and #261, the layout provider from #461, the responsive window from #526, and the rectangle generator from #682. Integrate the Xbox constant-buffer row addressing measured in #513 and the draw-time rectangle selection in #722. Keep all fixtures synthetic. The Windows GPU path resolves title-owned shader objects, retires geometry uploads per submission, materializes texture views on use, maps linear surfaces, and delivers completed GPU label writes. A first-run UI launch selects the tested settings for these paths.
Contributor
Author
whoalin1
added a commit
to whoalin1/leonida-continued
that referenced
this pull request
Nov 25, 2026
Measured on the RDNA2 iGPU (gfx1036, tools/f16_interp_probe.py, 98,304 samples over 12 native draws): the SPI writes P10/P20 for a 16-bit channel as per-half f16 differences (round to nearest even), the weighted sum stays f32, and v_interp_p2_f16 narrows toward zero -- the driver's ISA runs the pair inside s_round_mode 0x000c, so the narrow is toward zero whatever the shader's own MODE writes are. The rdna2 model explains 98,274 of 98,304 samples; the previous translation (f32 deltas, nearest-even narrow) explains 62,226. - Gen.f16_round: f32 -> nearest-f16 value via f16_bits + UnpackHalf2x16 (integer-built bits, so no driver folds the round trip away, ProjectLeonida#512/ProjectLeonida#513); applied to the P1-P0 / P2-P0 deltas of 16-bit-channel reads in attribute(). - v_interp_p2_f16 narrows with f16_bits(rtz=True) and keeps the SHADER-430 partial-write high half via write_lo16. - vk_harness: scan both stages for Float16 / StorageInputOutput16 / Float64 capabilities (77 when the device lacks them), enable the matching Vulkan 1.1/1.2 features, VKH_PC_BYTES to shrink the push-constant range for hand-written fixtures, and VKH_SHADER_INFO to dump the driver's fragment disassembly. - tests/semantic/test_interp_f16_round.py: the two telling cases (f16 delta overflow to inf; toward-zero vs nearest-even tie). - tests/semantic/test_interp_p1lv_f16.py: reference oracle updated to the measured model (f16 deltas, f32 sum, toward-zero narrow). - docs/design.md: 16-bit interpolation row records the SHADER-468 measurements and remaining unverified items. Co-Authored-By: Devin <noreply@cognition.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: RT-CBV-VSHARP-STRIDE
What and why
CreateConstantBufferViewwrote the CBV's raw GFX10 V# with STRIDE 0. A translated buffer access withidxenadds index × V# STRIDE to the address (tools/rdna2spirv.py, buffer addressing), so a program that indexes its constant buffer by 16-byte row read row 0 for every index.ThatRecompDev/five-star-recomp (GPL-3.0), commit
4c6bce59b, measured this on the retail title: the UI's batch programs read each vertex's matrix rows from their CBV by index (row batch × 4 + k); with stride 0 both screen coordinates came out equal and every vector shape of the UI fell on the line x = y (the diagonal across the first-run screens, letters drawn as shapes). Their fix gives a buffer view's record the element stride: 16 for a CBV, the structure for a structured view, the element for a typed one, 0 for raw. In Leonida the structured and typed buffer SRV/UAV paths already write their stride and raw views keep 0, so the CBV is the only gap.Change
runtime/shims/d3d12_vulkan_device.cpp: the CBV V#'s STRIDE is 16 (kConstantBufferRow). NUM_RECORDS stays the view's size in bytes with OOB_SELECT RAW: RAW bounds a MUBUF access by its offset, not index × STRIDE (docs/design.md, Buffer bounds checking), so that bound is unchanged. Ans_buffer_loadbound becomes NUM_RECORDS × STRIDE, past the end of any constant a program declares.runtime/test/d3d12_compute_test.cpp: the decoded CBV words expect STRIDE 16.docs/d3d12_vulkan.md: describes the CBV V#; the known-gaps list still said CBVs and buffer SRVs were not written.Tested
Windows 11, MSVC 19.52 x64, NVIDIA GeForce RTX 3060 (driver 621.35): runtime builds with no warnings in the touched files;
d3d12_compute_test,d3d12_descriptor_testandd3d12_vulkan_device_testpass.scripts/check_no_game_data.pyandtests/test_docs_links.pypass. Not yet measured on a retail boot here; I will add the result when we have it.AI-assisted (Claude Code). No game files.