agc_driver_prepared_shaders fails on GPUs without VK_EXT_depth_range_unrestricted (Intel on Windows); fix branch ready #3207

Closed
opened 2026-10-11 01:12:24 +00:00 by Silverash-i8 · 3 comments
Silverash-i8 commented 2026-10-11 01:12:24 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T01:12:24Z.


agc_driver_prepared_shaders and its _indirect, _uncached and _debug runs fail on a GPU without VK_EXT_depth_range_unrestricted. Intel GPUs on Windows don't have it, so all four fail here on main 06da1176 with:

AGC graphics: viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted

Why. SharedCodeHeaders (added in fb45627b, "retain registered headers sharing shader code") draws on the initial context. InitialContextRegisters sets the viewport Z scale to 1.0 and offset to 0, and PA_CL_CLIP_CNTL (0x204) has DX_CLIP_SPACE_DEF clear, so State.cpp takes the [-1, 1] clip space and asks for a viewport depth of zo - zs to zo + zs, which is [-1, 1]. I checked the values with a temporary print in ValidateViewport: min=-1.000000 max=1.000000. NVIDIA has the extension, so it passes there.

The draw isn't about depth at all, and the other draw tests already set the D3D clip space (for example DrawCacheReuse.cpp writes {0x204, 0x80000}), so the fix is one register write in the test:

fix/prepared-shaders-test-depth-range, commit 3c3bcf8f: the SharedCodeHeaders command stream also writes 0x204 = 0x80000, which gives the draw a [0, 1] depth range.

Tested on Windows 11, WinLibs GCC 15.2.0 r7, Release, on main 06da1176: all seven agc_driver_prepared_shaders* tests pass on the Arrow Lake iGPU (ANYPS5_GPU=Intel, 4 of them failed before) and on an RTX 5060 Laptop. tools/check_conventions.py --base upstream/main passes. The driver's check itself is unchanged; a title that really asks for depth outside [0, 1] still gets the error on such a device.

AI-assisted (Claude Code); I ran everything above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5796861932 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3207). Originally posted by [Silverash-i8](https://github.com/Silverash-i8) on 2026-10-11T01:12:24Z. --- `agc_driver_prepared_shaders` and its `_indirect`, `_uncached` and `_debug` runs fail on a GPU without `VK_EXT_depth_range_unrestricted`. Intel GPUs on Windows don't have it, so all four fail here on `main` 06da1176 with: ``` AGC graphics: viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted ``` **Why.** `SharedCodeHeaders` (added in fb45627b, "retain registered headers sharing shader code") draws on the initial context. `InitialContextRegisters` sets the viewport Z scale to 1.0 and offset to 0, and `PA_CL_CLIP_CNTL` (0x204) has `DX_CLIP_SPACE_DEF` clear, so `State.cpp` takes the [-1, 1] clip space and asks for a viewport depth of `zo - zs` to `zo + zs`, which is [-1, 1]. I checked the values with a temporary print in `ValidateViewport`: `min=-1.000000 max=1.000000`. NVIDIA has the extension, so it passes there. The draw isn't about depth at all, and the other draw tests already set the D3D clip space (for example `DrawCacheReuse.cpp` writes `{0x204, 0x80000}`), so the fix is one register write in the test: [`fix/prepared-shaders-test-depth-range`](https://github.com/Silverash-i8/AnyPS5-fork/tree/fix/prepared-shaders-test-depth-range), commit `3c3bcf8f`: the `SharedCodeHeaders` command stream also writes `0x204 = 0x80000`, which gives the draw a [0, 1] depth range. **Tested** on Windows 11, WinLibs GCC 15.2.0 r7, Release, on `main` 06da1176: all seven `agc_driver_prepared_shaders*` tests pass on the Arrow Lake iGPU (`ANYPS5_GPU=Intel`, 4 of them failed before) and on an RTX 5060 Laptop. `tools/check_conventions.py --base upstream/main` passes. The driver's check itself is unchanged; a title that really asks for depth outside [0, 1] still gets the error on such a device. AI-assisted (Claude Code); I ran everything above on my machine.
Dextroid17 commented 2026-10-11 01:59:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-11T01:59:09Z.


The one-register fix looks right, and the mechanism checks out against the driver's own decode.

I can confirm the chain statically — the limits of that are at the end.

  • The throw is ValidateViewport, Pipeline.cpp:111 — Require(context.depthRangeUnrestricted || (minDepth/maxDepth within [0, 1]), "viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted").
  • The register you write is the one that decides it: State.cpp:612 — result.negativeOneToOne = (read(cx, 0x204) & 0x80000u) == 0;
  • And that flag is what moves the range: State.cpp:688 — const auto minDepth = result.negativeOneToOne ? zo - zs : zo;. Bit clear gives minDepth = zo - zs, i.e. [-1, 1]; writing 0x80000 gives minDepth = zo, inside [0, 1]. So the assertion passes because the depth range genuinely changed, not because a check was skipped.

It is also the smallest fix that could work, and it is test-only — one line in tests/execution/PreparedShaders.cpp, no driver change, so no emulated behaviour moves.

The convention is already in the tree. Apart from the initial context's default ({0x204, 0} in InitialContextRegisters) and State.cpp's decode, no driver code writes 0x204 — the register keeps its zero reset for tests that never set it, so such a context decodes negativeOneToOne = true; and the base registers in tests/Graphics.cpp:57 ({0x206, 0x43f}, {0x204, 0x80000}, {0x205, 0x240}) are the established way a test opts into the D3D clip space. (I could not check the DrawCacheReuse.cpp example from here — that file contains no 0x204 in the tree I have, which is a frontier branch rather than 06da1176.)

One thing worth deciding before this is carried, because it changes where the line belongs: is the initial context faithful to the console? Since the initial context sets PA_CL_CLIP_CNTL to zero ({0x204, 0}, QueueState.hpp:145), every test that draws on the initial context starts in [-1, 1] and needs either the extension or a clip-control write, and Pipeline.cpp:190 asks for VK_EXT_depth_clip_control on the same flag, so such a draw needs two extensions it may not have. If the console's reset value really has that bit clear, this fix is exactly right and the test was simply missing a register write. If the console resets with the bit set, one line in InitialContextRegisters would be the faithful fix and would cover every test that draws on the initial context at once.

What I could not verify here, so the runtime evidence stays yours: lavapipe on this machine exposes VK_EXT_depth_range_unrestricted, so the failure cannot be provoked on it, and this tree predates fb45627b — its PreparedShaders.cpp has no SharedCodeHeaders at all — so I cannot run the test either way. Seven green on the Arrow Lake iGPU is the part only your machine shows.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104412991 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3207#issuecomment-6104412991). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-11T01:59:09Z. --- **The one-register fix looks right, and the mechanism checks out against the driver's own decode.** I can confirm the chain statically — the limits of that are at the end. - The throw is `ValidateViewport`, `Pipeline.cpp:111` — `Require(context.depthRangeUnrestricted || (minDepth/maxDepth within [0, 1]), "viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted")`. - The register you write is the one that decides it: `State.cpp:612` — `result.negativeOneToOne = (read(cx, 0x204) & 0x80000u) == 0;` - And that flag is what moves the range: `State.cpp:688` — `const auto minDepth = result.negativeOneToOne ? zo - zs : zo;`. Bit clear gives `minDepth = zo - zs`, i.e. [-1, 1]; writing `0x80000` gives `minDepth = zo`, inside [0, 1]. So the assertion passes because the depth range genuinely changed, not because a check was skipped. **It is also the smallest fix that could work, and it is test-only** — one line in `tests/execution/PreparedShaders.cpp`, no driver change, so no emulated behaviour moves. **The convention is already in the tree.** Apart from the initial context's default (`{0x204, 0}` in `InitialContextRegisters`) and `State.cpp`'s decode, no driver code writes `0x204` — the register keeps its zero reset for tests that never set it, so such a context decodes `negativeOneToOne = true`; and the base registers in `tests/Graphics.cpp:57` (`{0x206, 0x43f}, {0x204, 0x80000}, {0x205, 0x240}`) are the established way a test opts into the D3D clip space. (I could not check the `DrawCacheReuse.cpp` example from here — that file contains no `0x204` in the tree I have, which is a frontier branch rather than `06da1176`.) **One thing worth deciding before this is carried**, because it changes *where* the line belongs: is the initial context faithful to the console? Since the initial context sets `PA_CL_CLIP_CNTL` to zero (`{0x204, 0}`, `QueueState.hpp:145`), every test that draws on the initial context starts in [-1, 1] and needs either the extension or a clip-control write, and `Pipeline.cpp:190` asks for `VK_EXT_depth_clip_control` on the same flag, so such a draw needs two extensions it may not have. If the console's reset value really has that bit clear, this fix is exactly right and the test was simply missing a register write. If the console resets with the bit set, one line in `InitialContextRegisters` would be the faithful fix and would cover every test that draws on the initial context at once. **What I could not verify here, so the runtime evidence stays yours:** lavapipe on this machine exposes `VK_EXT_depth_range_unrestricted`, so the failure cannot be provoked on it, and this tree predates `fb45627b` — its `PreparedShaders.cpp` has no `SharedCodeHeaders` at all — so I cannot run the test either way. Seven green on the Arrow Lake iGPU is the part only your machine shows. Written with AI assistance.
Silverash-i8 commented 2026-10-11 02:18:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T02:18:09Z.


@Dextroid17 thanks for checking the chain against the decode.

On DrawCacheReuse.cpp: it's on main now. tests/execution/DrawCacheReuse.cpp:61 has {0x206, 0x43f}, {0x204, 0x80000}, {0x205, 0x240} on current main (it came in with bddcc71e, #2980), so your tree just predates it. tests/Graphics.cpp has the same convention, as you found (line 56 on current main).

On the reset value, I looked for anything that says the console resets PA_CL_CLIP_CNTL with DX_CLIP_SPACE_DEF set, and found nothing:

  • AnyPS5's InitialContextRegisters has {0x204, 0}.
  • KytyPS5 starts its hardware context with ClipControl::dx_clip_space = false (hardwareContext.h), and only a PA_CL_CLIP_CNTL write changes it.
  • Nothing in libSceAgc here writes 0x204 as a default.

So both emulators assume the bit is clear at reset, but neither is a hardware measurement, and I don't have one. Given that, I'd keep the fix in the test: it doesn't depend on the answer, and changing InitialContextRegisters would move every draw that never sets the register from [-1, 1] to [0, 1] on a guess. If someone measures the console's reset value and it turns out to be set, that one line would be the better fix and this test line becomes redundant.

AI-assisted (Claude Code); I checked the files above on current main and in KytyPS5.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104547902 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3207#issuecomment-6104547902). Originally posted by [Silverash-i8](https://github.com/Silverash-i8) on 2026-10-11T02:18:09Z. --- @Dextroid17 thanks for checking the chain against the decode. On `DrawCacheReuse.cpp`: it's on `main` now. `tests/execution/DrawCacheReuse.cpp:61` has `{0x206, 0x43f}, {0x204, 0x80000}, {0x205, 0x240}` on current `main` (it came in with bddcc71e, #2980), so your tree just predates it. `tests/Graphics.cpp` has the same convention, as you found (line 56 on current `main`). On the reset value, I looked for anything that says the console resets `PA_CL_CLIP_CNTL` with `DX_CLIP_SPACE_DEF` set, and found nothing: - AnyPS5's `InitialContextRegisters` has `{0x204, 0}`. - KytyPS5 starts its hardware context with `ClipControl::dx_clip_space = false` (`hardwareContext.h`), and only a `PA_CL_CLIP_CNTL` write changes it. - Nothing in `libSceAgc` here writes 0x204 as a default. So both emulators assume the bit is clear at reset, but neither is a hardware measurement, and I don't have one. Given that, I'd keep the fix in the test: it doesn't depend on the answer, and changing `InitialContextRegisters` would move every draw that never sets the register from [-1, 1] to [0, 1] on a guess. If someone measures the console's reset value and it turns out to be set, that one line would be the better fix and this test line becomes redundant. AI-assisted (Claude Code); I checked the files above on current `main` and in KytyPS5.
MarcZX10 commented 2026-10-11 04:34:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T04:34:15Z.


Opened PR #3269, carrying Abdulrahman Elkordy's one-line test setup correction with the original commit author preserved. It sets PA_CL_CLIP_CNTL.DX_CLIP_SPACE_DEF for the SharedCodeHeaders draw, so the test uses the supported [0, 1] depth range without changing driver behavior.

On current main, Linux GCC 12.2 Release builds agc_driver_prepared_shaders_tests, and all seven prepared-shader CTests pass on llvmpipe. The original author also reports all seven cases passing on Windows 11 with an Arrow Lake iGPU and RTX 5060; that run used the offered branch based on 06da1176, and this test file has no intervening changes through current main. The PR states that the local llvmpipe device has depthRangeUnrestricted=1, so it does not reproduce the unsupported-extension failure.

All applicable automatic PR checks pass, including conventions, intake, register-context, write-watch and Linux/Windows/macOS relinker checks. The full Linux and Windows build jobs are skipped under the repository's manual-run policy.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6105474124 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3207#issuecomment-6105474124). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T04:34:15Z. --- Opened [PR #3269](https://github.com/boykopovar/AnyPS5/pull/3269), carrying Abdulrahman Elkordy's one-line test setup correction with the original commit author preserved. It sets `PA_CL_CLIP_CNTL.DX_CLIP_SPACE_DEF` for the `SharedCodeHeaders` draw, so the test uses the supported [0, 1] depth range without changing driver behavior. On current `main`, Linux GCC 12.2 Release builds `agc_driver_prepared_shaders_tests`, and all seven prepared-shader CTests pass on llvmpipe. The original author also reports all seven cases passing on Windows 11 with an Arrow Lake iGPU and RTX 5060; that run used the offered branch based on `06da1176`, and this test file has no intervening changes through current `main`. The PR states that the local llvmpipe device has `depthRangeUnrestricted=1`, so it does not reproduce the unsupported-extension failure. All applicable automatic PR checks pass, including conventions, intake, register-context, write-watch and Linux/Windows/macOS relinker checks. The full Linux and Windows build jobs are skipped under the repository's manual-run policy. AI-assisted: yes.
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#3207
No description provided.