GPU: the depth twin's converter builds its root signature when the compiler drops it (Wine) #1872
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1872
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1872/head"
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?
@BastienRodz on GitHub · 2026-11-24 23:56 UTC · original
BastienRodz:gpu/twin-converter-root-signature→main· +170 −3 · 1 files · 2 commits · closed without mergingWhat's wrong
In #1860, 16-bit depth written through unordered access views never
reaches the host 24-bit depth texture under Wine's builtin
d3dcompiler_47:crates/victory-gpu/src/twin.rscompiles the compute converter(
SOURCE,cs_5_1, with#define RS "RootConstants(num32BitConstants=8, b0), UAV(u0)"and[RootSignature(RS)]) and then callsdevice.CreateRootSignature(0, bytes)on the shader blob itself.d3dcompiler_47(vkd3d-shader, as measured in #1860on Wine 11.22) ignores the
[RootSignature]attribute with warningW5302, producing a shader blob without an embedded root signature.CreateRootSignature(0, bytes)then fails with0x80004005(
E_FAIL), soconverter()returnsNoneandTwin::copyskipsconversion, leaving the depth texture clear.
What the fix does
crates/victory-gpu/src/twin.rs,compile()(factored throughcompile_source(source: &str)) still triesdevice.CreateRootSignature(0, bytes)first, leaving the Microsoftd3dcompiler_47path unchanged.CreateRootSignature(0, bytes)fails, it falls back tofallback_root_signature(device), which serializes the matchingD3D12_ROOT_SIGNATURE_DESC(version 1.0,D3D12_ROOT_SIGNATURE_FLAG_NONE,D3D12_SHADER_VISIBILITY_ALL):b0, space 0(
SetComputeRoot32BitConstants(0, 8, ...)),u0, space 0(
SetComputeRootUnorderedAccessView(1, ...)),via
D3D12SerializeRootSignature, creates theID3D12RootSignature,and logs once at
debuglevel (converter()isOnceLock-cached).tracing::warn!message in
converter()is unchanged.twin::tests::converter_falls_back_when_shader_blob_has_no_root_signature,which strips
[RootSignature(RS)]fromSOURCE, compiles it throughcompile_source, and dispatches the fallback converter in bothdirections (16-bit
0x1234→ 24-bit0x123412, and 24-bit0x800000→ 16-bit32768).Tests
twin::tests::converter_falls_back_when_shader_blob_has_no_root_signature(new). It compilesSOURCEwith[RootSignature(RS)]stripped, which gives the same blob Wine's compiler produces afterW5302. On that blob,CreateRootSignaturefails, so the fallback builds the signature, the pipeline is created, and the GPU converts all 16 texels both ways: 16-bit0x1234becomes 24-bit0x123412, and 24-bit0x800000becomes 16-bit32768.windows-latest.draw::tests::a_depth_texture_written_through_unordered_views_reads_as_depthpasses as before with Microsoft's compiler (natived3dcompiler_47under Wine + vkd3d-proton, andwindows-latest).windows-latestwith the upstream CI's commands,victory-gpuhas 79 passed, 0 failed, both tests included: https://github.com/BastienRodz/VIctory/actions/runs/45513753703victory-shader'sgathers_at_a_level_match_the_hardwareandpermutes_read_the_lane_named_and_zero_from_lanes_left_out. They fail the same way onmain70564ae(software adapter on the runner), and #1752 fixes them.-D warningspasses with and without--all-features, and so doescargo xtask policy.Not reproduced exactly: this host's Wine 10.0 has an older vkd3d-shader than #1860's Wine 11.22. It rejects
SOURCEeven earlier (E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'), so the issue's exact path (compile succeeds, signature dropped) could only be reproduced by stripping the attribute, as above. A run on Wine 11.22 + RADV, as in the report, would confirm it end to end.Not tested: an AMD or NVIDIA Windows driver. The Microsoft compiler path is unchanged there.
Fixes #1860.
No game data used. AI-assisted: implemented with Gemini 4 Neon, reviewed and verified with Claude Code.
🤖 Generated with Claude Code
98c654b1945ebd6d3@CaravelaLabs on GitHub · 2026-11-25 00:08 UTC · original
@BastienRodz thanks for taking this. Ran
654301ahere: Wine 11.22, vkd3d-proton 3.1, Radeon 8060S (RADV GFX1151, Mesa 25.2.8). The device was reached. Not native Windows. No title run.With Microsoft's
d3dcompiler_47, both tests pass, including your new one (16-bit0x1234to 24-bit and back). The signature built beside the shader does convert on this GPU when the shader itself compiles. A blob that already has a signature still takes the old path.With Wine's own compiler, neither test gets there.
a_depth_texture_written_through_unordered_views_reads_as_depthstill stops in the test's own setup:CreateRootSignaturereturns0x80004005atdraw.rs:1872, before the converter. Same as on main. It cannot show the fallback.converter_falls_back_when_shader_blob_has_no_root_signaturefails incompile_source.D3DCompileof the converter source returns0x80004005:E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'(buf.Load). Same text with[RootSignature]left in and with it stripped, so the fallback is not reached. Same error you saw on Wine 10. Wine 11.22's builtin compiler does not get past it either.I had said on #1860 that this compiler only drops the attribute (
W5302). That warning was from a shorter shader that only carried the attribute, not from this source. I've corrected that note. Sorry for the bad lead.AI-assisted; tests run on this machine.
@BastienRodz on GitHub · 2026-11-25 00:09 UTC · original
@CaravelaLabs Thanks, that's the decisive run: the fallback is needed but not enough, because vkd3d-shader stops at
RWByteAddressBuffer.Loadfirst. Next commit: the converter reads and writes through aRWStructuredBuffer<uint>indexed by dword, which vkd3d-shader accepts, with the same results and the fallback kept. This host's Wine compiler fails the same way, so I can check the whole Wine path here (compile, attribute dropped, fallback, conversion) before pushing.@BastienRodz on GitHub · 2026-11-25 00:28 UTC · original
Moving this to draft: on its own it doesn't fix #1860 for Wine users. Here is what I found with Wine's builtin
d3dcompiler_47(vkd3d-shader; Wine 10 here, and @CaravelaLabs saw the same on 11.22):RWByteAddressBuffer, every read is rejected withE5005 ... is not defined:Load,InterlockedOr,InterlockedAddandInterlockedCompareExchangeall fail.RWStructuredBuffer<uint>reads compile, but stores fail withE5017: Structured buffers store is not implemented.ByteAddressBufferSRV for the reads compiles, but one buffer can't be SRV and UAV in the same dispatch. vkd3d-proton also refuses the PSO (dxil-spirv: Failed to remap SRV).RWBuffer<uint>through a descriptor table does work end to end under the builtin compiler: the attribute is dropped (W5302), the fallback signature is used, and all 16 texels convert both ways. It needsTwin::copyto set its own descriptor heap, though, and thenState::prepare_for/State::bindhave to transition targets and make tables before binding the title's heaps (bde1967on my fork,draw.rs+40/-45). That is a lot of churn in the draw path for this.So the root-signature fallback here is needed but not sufficient. There seem to be two real options: that heap rework, or building the converter with the shader crate's own DXIL writer so no run-time HLSL compiler is involved (Exorion1er did that for the rectangle expander in #346). I'll leave it in draft until it's clear which one the maintainer prefers.
@Marvisak on GitHub · 2026-11-25 17:17 UTC · original
Automated triage for the maintainers.
Needs rebase. This branch conflicts with
mainincrates/victory-gpu/src/twin.rs. It will be reviewed once it is rebased and marked ready.Generated by Claude Code
@arogan178 on GitHub · 2026-11-25 23:58 UTC · original
On Proton-CachyOS 11.0 (RX 9070 XT, RADV), this PR's fallback isn't reached. Wine's built-in compiler fails on the shader's
buf.Load(E_FAIL) before any root signature is involved.converter_falls_back_when_shader_blob_has_no_root_signaturefails there withfallback converter: ... 0x80004005.#2919 adds the other half: structured buffers indexed in words, plus a root signature that is always built in code. It also carries your round-trip test, which passes there with Wine's compiler. You're credited as co-author.
@BastienRodz on GitHub · 2026-11-26 00:00 UTC · original
Closing in favour of #2919, which does both halves under Wine: the structured buffer the built-in compiler accepts, plus the root signature built in code. It carries this PR's round-trip test, adapted. That is what this draft was missing: the root signature alone never helped, because Wine's compiler fails on
buf.Loadfirst.Thanks @arogan178 for taking it the rest of the way and for the co-author credit.
Pull request closed