shader: do not reuse texture size query (fixes AMD compiler crash) #133

Closed
GaiuLulius wants to merge 0 commits from upstream-pr/133 into main
GaiuLulius commented 2026-11-28 02:08:29 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by GaiuLulius on 2026-11-28T02:08:29Z.


Port of Belobug PR #324.

🇧🇷 Português

Impede que o otimizador de bitcode desduplique consultas de dimensão de texturas (dx.op.getDimensions). No driver Direct3D 12 da AMD (amdxc64.dll, arquitetura RDNA4/RDNA2), a reutilização de uma mesma consulta getDimensions entre múltiplos blocos provocava o crash do compilador em 29 pipelines de compute de raytracing (CS_RaytracingResolve). Com esta alteração, a consulta permanece no ponto emitido pelo lowering. Inclui teste de regressão a_size_query_is_not_reused.

🇺🇸 English

Prevents the bitcode optimizer from reusing texture size queries (dx.op.getDimensions). On AMD's D3D12 driver compiler (amdxc64.dll), deduplicating getDimensions calls across blocks caused the compiler to crash on 29 raytracing compute pipelines (CS_RaytracingResolve). With this change, size queries remain where lowering placed them. Includes regression test a_size_query_is_not_reused.

Co-authored-by: Belobug [email protected]

<!-- greyfinch-sync:uiliannn/VItoriaBr:issue:5535675283 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VitoriaBr2.0/pull/133). Originally posted by [GaiuLulius](https://github.com/GaiuLulius) on 2026-11-28T02:08:29Z. --- Port of Belobug PR #324. ## 🇧🇷 Português Impede que o otimizador de bitcode desduplique consultas de dimensão de texturas (dx.op.getDimensions). No driver Direct3D 12 da AMD (amdxc64.dll, arquitetura RDNA4/RDNA2), a reutilização de uma mesma consulta getDimensions entre múltiplos blocos provocava o crash do compilador em 29 pipelines de compute de raytracing (CS_RaytracingResolve). Com esta alteração, a consulta permanece no ponto emitido pelo lowering. Inclui teste de regressão a_size_query_is_not_reused. ## 🇺🇸 English Prevents the bitcode optimizer from reusing texture size queries (dx.op.getDimensions). On AMD's D3D12 driver compiler (amdxc64.dll), deduplicating getDimensions calls across blocks caused the compiler to crash on 29 raytracing compute pipelines (CS_RaytracingResolve). With this change, size queries remain where lowering placed them. Includes regression test a_size_query_is_not_reused. Co-authored-by: Belobug [169477042+[email protected]](mailto:169477042+[email protected])
upipibi commented 2026-11-28 02:18:37 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by upipibi on 2026-11-28T02:18:37Z.


One follow-up that may be needed on RDNA 4 (read from another tree's threads, not run):

ZigZagBoi1/ScarlettPort, also from the fxceless lineage with the same bitcode/opt.rs, already had this fix (Belobug's "size query not reused"). An RX 9070 XT (Adrenalin 26.11.2) still died in AMD's compiler at amdxc64.dll+0x861b9f (read 0x8) right after the pipeline backlog cleared (ScarlettPort#73). They called it "a different trigger in the same compiler".

What stopped it was avatarmanz/VIctory-7900XTX#357, ported as ScarlettPort#93 (both GPL-3). On RDNA 4 hosts (0x7550..=0x75ff), a raw view's getDimensions gets a handle of its own. Its heap index is computed again, marked NonUniformResourceIndex, and kept out of the clean-up passes (Module::mark / keep_since), so REUSE can't merge it back into the load's index. The reporter played 8.5 minutes in the world with it, without the crash.

So this PR covers the 29 CS_RaytracingResolve pipelines. The RDNA 4 fault may need ScarlettPort#93 on top. Upstream VIctory has the separate-handle form as Marvisak/VIctory#2122.

AI-assisted (Claude Code, Claude Opus 5.5 read ScarlettPort#73/#93 and this diff).

<!-- greyfinch-sync:uiliannn/VItoriaBr:comment:7232275595 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/133#issuecomment-7232275595). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T02:18:37Z. --- One follow-up that may be needed on RDNA 4 (read from another tree's threads, not run): ZigZagBoi1/ScarlettPort, also from the fxceless lineage with the same `bitcode/opt.rs`, already had this fix (Belobug's "size query not reused"). An RX 9070 XT (Adrenalin 26.11.2) still died in AMD's compiler at `amdxc64.dll+0x861b9f` (read `0x8`) right after the pipeline backlog cleared (ScarlettPort#73). They called it "a different trigger in the same compiler". What stopped it was avatarmanz/VIctory-7900XTX#357, ported as ScarlettPort#93 (both GPL-3). On RDNA 4 hosts (`0x7550..=0x75ff`), a raw view's `getDimensions` gets a handle of its own. Its heap index is computed again, marked `NonUniformResourceIndex`, and kept out of the clean-up passes (`Module::mark` / `keep_since`), so REUSE can't merge it back into the load's index. The reporter played 8.5 minutes in the world with it, without the crash. So this PR covers the 29 `CS_RaytracingResolve` pipelines. The RDNA 4 fault may need ScarlettPort#93 on top. Upstream VIctory has the separate-handle form as Marvisak/VIctory#2122. AI-assisted (Claude Code, Claude Opus 5.5 read ScarlettPort#73/#93 and this diff).
GaiuLulius commented 2026-11-28 02:26:26 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by GaiuLulius on 2026-11-28T02:26:26Z.


Thanks for the context and pointers to ScarlettPort#93 and Marvisak/VIctory#2122!

Indeed, keeping this PR strictly focused on the 29 CS_RaytracingResolve pipelines makes it clean and easy to review/merge. I can prepare the separate handle / NonUniformResourceIndex follow-up for RDNA 4 (0x7550..=0x75ff) in a subsequent PR on top of this.

AI-assisted (Hermes Agent, local analysis on VItoriaBr and Belobug diffs).

<!-- greyfinch-sync:uiliannn/VItoriaBr:comment:7232363145 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/133#issuecomment-7232363145). Originally posted by [GaiuLulius](https://github.com/GaiuLulius) on 2026-11-28T02:26:26Z. --- Thanks for the context and pointers to ScarlettPort#93 and Marvisak/VIctory#2122! Indeed, keeping this PR strictly focused on the 29 `CS_RaytracingResolve` pipelines makes it clean and easy to review/merge. I can prepare the separate handle / `NonUniformResourceIndex` follow-up for RDNA 4 (0x7550..=0x75ff) in a subsequent PR on top of this. AI-assisted (Hermes Agent, local analysis on VItoriaBr and Belobug diffs).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
uiliannn/VItoriaBr!133
No description provided.