Constant buffer views are encoded with stride 0, so idxen reads from a CBV ignore the index – measured on Linux, Windows measurement wanted #307
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#307
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ozimchuk on GitHub · 2026-11-23 23:02 UTC · original
CreateConstantBufferView(real.rs,dev_create_cbv_x) writes every CBV as a raw V#:buffer_words(va, 0, size, 22), i.e. stride 0, num_records in bytes. Console shaders also read constant buffers withbuffer_load_* … idxen, the element number as the index. With stride 0 the index is ignored (the hardware rule, which the recompiler follows:base + stride·index), so every such read returns element 0.Where it shows (Linux, NVIDIA, Wine + relaxed vkd3d-proton,
main9ab7d76): the black image with the 1-pixel diagonal in #175. A retail game's UI element VS (28d887aa04ffa15a) computes each vertex asx = X·A.x + Y·A.y + A.w,y = X·B.x + Y·B.y + B.w, with A and B read bybuffer_load_dwordx4 … idxenat elements4k+2and4k+3of a CBV. The V# it loads from its root table (XCL_TRACE_FRAME=1 XCL_TRACE_SHADERS=28d887aa04ffa15a, and the table read as raw memory at the draw and again at the next present) is[base, 0x4, 0x600, 0x31016fac]– stride 0 both times – so A = B and every vertex lands on x = y.Experiment: CBVs as float4 elements,
buffer_words(va, 16, size / 16, 77). Scalar loads are unaffected (s_buffer_loadlimits atnum_records × stride), offset-addressed loads read the same addresses. Frame dumps (XCL_FRAME_DUMP=1) go from black-with-the-diagonal to the menus; with #244 and #283 on top, the intro video and the first-run settings screens at 30 fps.What I can't explain, and why a Windows measurement would help: that code has no platform switch, yet the menus draw on Windows and in the stock-vkd3d-proton Linux setup in #175 (FilipeSilvens). Either the CBV reaches the table another way on those setups, or the diagonal has another cause there and the stride change only hides it. On a setup where the menu shows, could someone run
and post the
p0 table … [0] - T# […]part of the firstframe trace: UI drawline? The second word decides:0x4(stride 0) or e.g.0x100004(stride 16).Not known: the console driver's own CBV encoding (stride, out-of-range mode). A merge request waits for this answer.
AI-assisted (Claude Code, Claude Opus 5.5).
@ozimchuk on GitHub · 2026-11-23 23:47 UTC · original
Opened #335 with the change.
What settled it, from #175:
[base, 0x00100004, 0x00000060, 0x0002403c], stride 16 and num_records = size / 16. On the setups with the diagonal it callsCreateConstantBufferViewinstead, and XCL wrote stride 0. #335 makes XCL's CBV match the title's own encoding.Measured for #335 (Linux, NVIDIA, under Wine), main against the PR:
Still open: what makes the title take one path or the other. It is not
7a033c8, and not the relaxed vkd3d-proton build. With unmodified vkd3d-proton and a vtable hand-back like FilipeSilvens', the title still callsCreateConstantBufferViewhere. That hand-back also needs the consoleResetX(list_x::reset_x) covered, or the title stops after a list Reset returns E_INVALIDARG.AI-assisted (Claude Code, Claude Opus 5.5).
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@MonkeyPython on GitHub · 2026-11-24 00:06 UTC · original
Windows measurement, from a setup where the menus draw (RTX 3080 Ti, wave32-only).
Setup: Windows 11 Pro build 26300, Ryzen 7 7800X3D, 32 GB, NVIDIA RTX 3080 Ti 12 GB
(driver 621.24), Rust 1.100.0 stable MSVC, DXC 1.8.2502.11 (SDK 10.0.26100). Built from
mainat4017f8ff8faaae6007fd83910d230a027dd85a33, release. Run withXCL_NETWORK=0and the requested
XCL_TRACE_FRAME=1 XCL_TRACE_SHADERS=28d887aa04ffa15a XCL_TRACE_MANY=4,60 s (
XCL_RUN_SECONDS=60).The first
frame trace: UI drawline (vs28d887aa04ffa15a, psb40d9ca24fe3d23d,pipeline
0x1ed30daf790):The second word is
0x100004— stride 16, not0x4. The next three UI draws in thesame trace show the same
[base, 100004, 60, 2403c]shape at different table addresses.So on this Windows setup the CBV reaches the root table with stride 16, while the Linux
measurement in this issue saw stride 0 (
[base, 0x4, 0x600, 0x31016fac]) for the sameshader — consistent with the "the CBV reaches the table another way on those setups"
hypothesis. (Word 3 also differs:
0x60here vs0x600there.)One nuance from a later run without the shader filter: a different UI vertex shader
(
7fda1be8fbc78299) shows[0] - T# Some([4dbc93e0, 4, 80, 31016fac])— second word0x4, stride 0 — on the same Windows setup, while entry[2]of that same table is100004(stride 16). Both encodings coexist here; the stride-16 answer above is for theshader this issue asked about (
28d887aa04ffa15a).Run context: the title ran the full 60 s and exited
0x0: 641 frames shown, 641PresentX calls at 3840×2160, 13.4 fps over the last 300 (first run on this machine, so
#284's coherent-window learning may apply). No assert, no crash, no device removal —
on this same GPU model #301 reported an early
0x80000003with 0 presents at9ab7d76;at this commit it does not reproduce here.
Follow-up runs (same commit, after
uma_coherent.txtwas learned, 4095 MB coherentwindow): three clean 60 s runs, exit
0x0, 1499–1511 frames at 29.8–30.0 fps overthe last 300 — the #284 first-run penalty (13.4 → ~30 fps) reproduces and clears exactly
as described. One run with
XCL_FRAME_DUMP=1crashed at ~250 presents with0xc0000005innvwgf2umx.dll+0x8d713f(read at0x3c); the three runs without thedump were clean. The game's crash reporter attempted an upload during that crash and
failed (
WinHttpSendRequest error: 12007underXCL_NETWORK=0); the ~30 MB minidumpstayed local.
Not tested: other GPUs, the Linux path, a second run after
uma_coherent.txtislearned.
AI use: Gentle Shell (Pi coding agent), model qwen4-max: ran the title and wrote this
report from the trace output; a human reviewed it before posting. No code changes.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@MonkeyPython on GitHub · 2026-11-24 01:02 UTC · original
Thanks — the code reading matches what we measured, and the trace has one more data
point that fits your "different V# reaching that slot" branch.
The stride-16 word is real in the table: on Windows with the menus drawing, the first
frame trace: UI drawfor28d887aa04ffa15areads[0] - T# Some([4e36dc00, 100004, 60, 2403c])(and the next three UI draws the sameshape). Given
dev_create_cbv_xwrites stride 0 unconditionally, that entry cannot beruntime-encoded — and the base (
0x4e36dc00) is a title-memory console VA, so adescriptor written there by the game's own console code, read as-is by the root table,
is the source your analysis leaves open.
The coexistence shows up in a later run at
a6f5f7awithout the shader filter: adifferent UI vertex shader,
7fda1be8fbc78299, has[0] - T# Some([4dbc93e0, 4, 80, 31016fac])— stride 0 — while entry[2]of that sametable is
[4dbc9200, 100004, 1e, 2403c]— stride 16. Both encodings side by side in oneWindows run, which is what you would expect if some slots hold game-written V#s and
others hold runtime-written ones, rather than a platform switch in the encoder.
So the measurement side says: stride 16 for the asked shader on Windows, stride 0 for
another, same machine same run. Your 4070 Ti trace will show whether the same shader
gets the same word on a second Windows setup.
AI use: Gentle Shell (Pi coding agent), model qwen4-max: ran the traces and wrote
this reply from their output; a human reviewed it before posting. No code changes.