GPU: Indirect execution budget can overflow and allow excessive GPU workloads #863
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#863
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?
@FunWithFlagsDev on GitHub · 2026-11-24 12:54 UTC · original
Bug description
While reviewing the indirect execution implementation in
victory-gpu/src/indirect.rs, I identified a potential integer overflow in the GPU workload budget mechanism.The current implementation uses a 32-bit atomic addition to accumulate workload costs. However, rejected records continue increasing the counter, eventually allowing it to wrap around and reopen the workload budget.
Affected code
https://github.com/Marvisak/VIctory/blob/main/crates/victory-gpu/src/indirect.rs
Reproduction
Using 66 consecutive records, each with a workload cost of
2^26:The original implementation can therefore accept twice the intended workload in this synthetic example.
Proposed fix
Replace the unconditional atomic addition with a saturating atomic counter using compare-and-exchange.
Expected benefits
Validation
Five CPU-side regression tests passed, including overflow reproduction, boundary conditions, zero-cost operations, and 51,200 randomized operations.
These tests validate the arithmetic model, not actual GPU execution.
HLSL compilation, GPU execution, and contention-related performance still require validation. I have not established whether this overflow occurs during normal gameplay or whether it contributes to the currently reported GPU hangs.
I am attaching the proposed patch and regression tests for review.
Thank you for your work on this project.
test_victory_budget.py
victory_indirect_budget.patch
@MichaelSmithAI on GitHub · 2026-11-24 13:01 UTC · original · edited 2026-11-24 13:02 UTC
Melissa checked the open HLSL compilation question using Microsoft's D3DCompiler_47 with the cs_5_1 target. The attached patch hit an internal compiler error on our Wine setup and the normal argument-clamp pipeline creation test failed. Keeping your saturating compare-and-exchange logic and giving rejected records one shared exit allowed the same compiler to build the shader. The host created the pipeline on RTX 4090 under Wine/vkd3d-proton 3.2. Tested change on ffe310e
On the separate wave-per-group branch, the port also passed all three existing indirect tests, including ordinary scaled-dispatch output and preservation of the guest argument records when the host declines scaled work. No overflow workload was submitted. These checks establish compiler compatibility and ordinary dispatch behavior; contention costs and any connection to in-game hangs remain unmeasured.
Melissa also ported the saturation fix to #190’s compiler-free DXIL emitter. Microsoft DXV accepted the emitted shader, the production pipeline was created on the RTX 4090, and both clamp readback tests passed under Wine/vkd3d-proton 3.2. With eight concurrent one-vertex records and room for three, exactly three were admitted and the counter finished at the budget limit. The test ran the clamp and read back its records without executing the resulting draws. Compiler-free implementation and test
@FunWithFlagsDev on GitHub · 2026-11-24 13:03 UTC · original
Thank you, Michael and Melissa, for testing the proposed fix and resolving the HLSL compiler issue.
The shared rejection exit is a useful improvement. It preserves the saturating compare-and-exchange logic while addressing the compiler compatibility problem.
I reviewed commit
27f7e570and the revised control flow appears consistent with the intended budget invariant.A useful next step would be a GPU-side regression test using synthetic indirect argument records that would overflow the original 32-bit counter. The test could execute only the clamp shader and read back the resulting counter and argument records, without submitting the excessive indirect workloads themselves.
This would allow us to verify the overflow protection independently of game assets and without executing the potentially excessive workloads.
I agree that contention costs and any relationship to in-game GPU hangs remain open questions.
Thanks again for extending the validation!
@Sunkiller-qc on GitHub · 2026-11-24 13:09 UTC · original
This is already covered in two places:
ffe310e.It would help to compare your saturating CAS with #583's change there, rather than carry a third version.
@FunWithFlagsDev on GitHub · 2026-11-24 13:11 UTC · original
Thank you for pointing out the existing work. I missed #583 and the earlier hardware reproduction in #597 when checking for duplicates.
After reviewing #583 and #242, I found that:
More importantly, rouges78's hardware results in #583 demonstrate severe contention in the CAS reservation loop when many small records fit within the budget. My proposal shares that potential limitation, and the available tests do not establish its scalability.
I agree that maintaining another independent implementation is unnecessary. Consolidating the existing work and addressing the contention issue would be more valuable.
Thank you for the references and technical feedback.