AGC: agc_driver_tessellation's merged hull program draws a different wrong patch on each run on AMD's Windows driver #8861

Closed
opened 2026-10-21 03:36:30 +00:00 by thuanquang · 1 comment
thuanquang commented 2026-10-21 03:36:30 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T03:36:30Z.


The merged hull path from #6679 (8b8219dce) makes agc_driver_tessellation fail on AMD's proprietary Windows driver. CI (lavapipe) and NVIDIA pass. @wachi35676 saw this on an RDNA 2 iGPU with 32.0.21042.62, in #8134. It also happens on a discrete card.

Setup:

  • RX 6700 XT (gfx1031), AMD driver 32.0.21045.5002, Windows 11 26200.
  • MinGW GCC 15.2.0 Release, main d0852defa.
  • ANYPS5_NO_SHADER_CACHE=1, with every run from a renamed copy of the exe, so the driver's pipeline cache starts empty.

The first RequirePatches(..., MergedHullCode, "merged hull program", MergedTriangles, MergedHullCode) call fails on every run. Which check fails changes from run to run:

Runs Failure
default, run 1 and 3 merged hull program, unculled: the level-5 patch has no interior domain points at its centre, centre (16, 24, 40, 255) (background)
default, run 2 the level-1 patch was not drawn as one flat triangle, centre background
APS5_NO_GPL=1, run 1 the level-1 patch was not drawn as one flat triangle
APS5_NO_GPL=1, run 2 and 3 the level-5 patch has no interior domain points, centre (255, 0, 0, 255) (drawn flat)
Khronos validation layer, ctest -V the level-5 patch has no interior domain points, (255, 0, 0, 255); 0 VUID- lines, and the layer loaded

Every earlier RequirePatches case in the test, with separate local and hull programs, passes on this card.

I dumped the merged program's SPIR-V. Its tessellation control shader:

  • uses the GLSL450 memory model, OutputVertices 3, and no subgroup operations;
  • has the local part read control point min(gl_InvocationID, 2) from the input array, then write the per-vertex ControlShared output (location 2) at index gl_InvocationID;
  • runs OpControlBarrier Workgroup Invocation None in a merge block that every invocation reaches;
  • writes the control point output at gl_InvocationID, and the reads I checked after the barrier use the invocation's own record;
  • writes the tessellation levels and the patch output only from invocation 0, after clamping them with push-constant words 30 and 31.

I found nothing there that the spec leaves undefined. But results that change from run to run look like a value is read before anything writes it, somewhere in the merged path or in the driver's handling of it. I have not narrowed it down further.

The SPIR-V (base64 and disassembly), the local stage, and the run logs are here: https://gist.github.com/thuanquang/acb22ee3eb1076854624d8764289bfca

Not tested: RADV, and any title that uses type-3 programs.

cc @SleglJan

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5953856244 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8861). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T03:36:30Z. --- The merged hull path from #6679 (8b8219dce) makes `agc_driver_tessellation` fail on AMD's proprietary Windows driver. CI (lavapipe) and NVIDIA pass. @wachi35676 saw this on an RDNA 2 iGPU with 32.0.21042.62, in #8134. It also happens on a discrete card. **Setup:** - RX 6700 XT (gfx1031), AMD driver 32.0.21045.5002, Windows 11 26200. - MinGW GCC 15.2.0 Release, `main` `d0852defa`. - `ANYPS5_NO_SHADER_CACHE=1`, with every run from a renamed copy of the exe, so the driver's pipeline cache starts empty. The first `RequirePatches(..., MergedHullCode, "merged hull program", MergedTriangles, MergedHullCode)` call fails on every run. Which check fails changes from run to run: | Runs | Failure | |---|---| | default, run 1 and 3 | `merged hull program, unculled: the level-5 patch has no interior domain points at its centre`, centre (16, 24, 40, 255) (background) | | default, run 2 | `the level-1 patch was not drawn as one flat triangle`, centre background | | `APS5_NO_GPL=1`, run 1 | `the level-1 patch was not drawn as one flat triangle` | | `APS5_NO_GPL=1`, run 2 and 3 | `the level-5 patch has no interior domain points`, centre (255, 0, 0, 255) (drawn flat) | | Khronos validation layer, `ctest -V` | `the level-5 patch has no interior domain points`, (255, 0, 0, 255); 0 `VUID-` lines, and the layer loaded | Every earlier `RequirePatches` case in the test, with separate local and hull programs, passes on this card. I dumped the merged program's SPIR-V. Its tessellation control shader: - uses the GLSL450 memory model, `OutputVertices 3`, and no subgroup operations; - has the local part read control point `min(gl_InvocationID, 2)` from the input array, then write the per-vertex `ControlShared` output (location 2) at index `gl_InvocationID`; - runs `OpControlBarrier Workgroup Invocation None` in a merge block that every invocation reaches; - writes the control point output at `gl_InvocationID`, and the reads I checked after the barrier use the invocation's own record; - writes the tessellation levels and the patch output only from invocation 0, after clamping them with push-constant words 30 and 31. I found nothing there that the spec leaves undefined. But results that change from run to run look like a value is read before anything writes it, somewhere in the merged path or in the driver's handling of it. I have not narrowed it down further. The SPIR-V (base64 and disassembly), the local stage, and the run logs are here: https://gist.github.com/thuanquang/acb22ee3eb1076854624d8764289bfca Not tested: RADV, and any title that uses type-3 programs. cc @SleglJan
thuanquang commented 2026-10-21 04:28:34 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T04:28:34Z.


Found it; the fix is in #8884.

TessellationPointer built a tessellation attribute's vertex, location and component indices with OpUDiv, OpUMod and shifts even for an immediate address. Without SPIRV-Tools those stay arithmetic on constants in the access chain. AMD's Windows driver reads a per-vertex hull output indexed that way wrongly.

Two local experiments isolate it:

  • A read of the invocation's own record through such a constant index fails like the original.
  • With the program's one cross-record read replaced by a register copy, the case passes.

So it is not barrier visibility, and a stronger barrier didn't help either. With the indices emitted as OpConstants, agc_driver_tessellation passes 3 of 3 on the RX 6700 XT, along with the related tests and the validation layer.

@wachi35676, if you get a chance, a run of #8884 on your 32.0.21042.62 iGPU would cover the second driver.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308054840 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8861#issuecomment-6308054840). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T04:28:34Z. --- Found it; the fix is in #8884. `TessellationPointer` built a tessellation attribute's vertex, location and component indices with `OpUDiv`, `OpUMod` and shifts even for an immediate address. Without SPIRV-Tools those stay arithmetic on constants in the access chain. AMD's Windows driver reads a per-vertex hull output indexed that way wrongly. Two local experiments isolate it: - A read of the invocation's own record through such a constant index fails like the original. - With the program's one cross-record read replaced by a register copy, the case passes. So it is not barrier visibility, and a stronger barrier didn't help either. With the indices emitted as `OpConstant`s, `agc_driver_tessellation` passes 3 of 3 on the RX 6700 XT, along with the related tests and the validation layer. @wachi35676, if you get a chance, a run of #8884 on your 32.0.21042.62 iGPU would cover the second driver.
Sign in to join this conversation.
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
boykopovar/AnyPS5#8861
No description provided.