Repository navigation
feat(agc): remap a viewport depth range the device cannot express into the vertex shader - #4650
Conversation
|
Needs a rebase: it conflicts with main in |
d17e97e to
13b626a
Compare
13b626a to
60b467c
Compare
|
Windows run, since the description says Windows is untested. Setup: Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release,
Not tested: a title. AI-assisted: yes (Claude Code) |
…ing it ApplyDepthRemap gives the Vulkan viewport the console's clamp bounds clipped to [0, 1]. A zero-to-one viewport maps the shader's z/w linearly onto [minDepth, maxDepth], so with bounds narrower than [0, 1] the remap rescaled the depth into them instead of clamping it there; only bounds of [0, 1] or wider (Minecraft's [-1, 1]) came out right. Scale and offset are now divided by the clamp range and the offset moved by its minimum, so the viewport and the depth clamp together give scale * z/w + offset clamped to the bounds. agc_driver_depth_range_remap_draw draws through the remap path and, when the device has VK_EXT_depth_range_unrestricted, through the unrestricted path, then checks the stored depth with probe draws and that the two clip distances cut at the near and far planes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The depth remap mode, scale and offset change the pipeline a draw creates, so the pipeline journal's recipe carries them. The file format is bumped and the State layout guard follows the new size.
The depth remap fields moved to request format 33 when this branch was rebased onto main's format 32. The replay tests that rebuild older streams now drop and append the remap tail on top of the linked call fallbacks and the spanned waves flag, and the depth remap test downgrades to format 32.
…t run time The remap mode stays a specialization constant and cache key input. Scale and offset are two push words at byte 104, patched per draw, so draws that differ only in depth range share one pipeline. The recipe, journal and serializer carry the mode only.
…in a direct build
…e as a specialization constant
…he artifact's SPIR-V
A remapped vertex shader reads the scale and offset from the push block, but the pipeline's push constant stages only counted programs with push data of their own, so a shader with none got no stage in a non-GPL layout and its scale and offset never arrived. The result now says it reads them, and the push stages include the vertex stage for it. The draw test gains a fetchless remapped vertex shader with no push data.
…words The flag that adds the vertex stage to the push constant stages was not part of the encoded result, so a journalled remapped vertex shader replayed without it. Encode and decode it with the invocation and cover it in the result round trip and the push stage test.
…heck The SPIR-V interface check only allowed a push constant block for a program with push data of its own, so a remapped vertex shader without any was rejected as having an invalid push constant interface.
On a device without VK_EXT_depth_range_unrestricted the target remaps every vertex shader, so an in-range draw carries the remap's push block too. Draw it from a direct and from a prepared build; both must validate and store the right depth.
|
@nikowolf123 sorry, I missed this request on 10-14. I'll run your AI-assisted: yes (Claude Code) |
|
@nikowolf123 results for your
AI-assisted: yes (Claude Code) |
|
New issue #4762 adds a direct Windows Intel Iris Xe reproduction of the same |
60b467c to
5392c27
Compare
# Conflicts: # core/shader/recompiler/ShaderDiskCache.cpp
# Conflicts: # core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp # core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp # core/shader/recompiler/tests/RequestSerializerTests.cpp
# Conflicts: # core/shader/recompiler/ShaderDiskCache.cpp
What
Intel's ANV has no
VK_EXT_depth_range_unrestricted, so a viewport depth range outside [0, 1] threw "viewport depth [-1, 1] out of range". Minecraft (PPSA17221) draws its whole world that way:PA_CL_VPORT_ZSCALE1 andZOFFSET0 in negative-one-to-one clip space, so the console's depth is the raw z/w in [-1, 1], clamped byPA_SC_VPORT_ZMIN/ZMAXto [0, 1] on write. Clamping the viewport to [0, 1] instead maps the range linearly and writes every depth value wrong.The remap folds the transform into the vertex shader on such a device, generic for any scale and offset:
Graphics::ApplyDepthRemap(afterDecodeState, with the device context) leaves a range inside [0, 1] or an unrestricted device alone. Otherwise it records the viewport's scale, offset and clip-space mode inState::depthRemap, gives the Vulkan viewport the console's clamp bounds, turns depth clamping on (the console'sZMIN/ZMAXclamp) and clip control off. It requires the vertex path and a device with depth clamping; mesh and tessellation draws with such a range still throw.RemapPositionDepth, emitted whenSpirvTarget::depthRangeRemap) computes z' = scale·z + offset·w, so z'/w is the console's depth before its clamp, and writes two extragl_ClipDistanceelements, w + z (or z in zero-to-one clip space) and w − z, restoring the near and far planes depth clamping removes. Mode, scale and offset are specialization constants (PipelineSpecialization::DepthRemapBase), filled from the draw'sShaderVertexStageInfoin both the per-draw and the registration-module path; mode 0 folds to the untouched position, so shaders of in-range draws are unchanged.VulkanDevicesets the target flag from the missing extension.agc_depth_range_remap(new) checks the emitted module declares the three specialization constants with the draw's values, two clip distances and the scale, and that an unrestricted target declares none;agc_driver_graphicsgainsDepthRemapTestsforApplyDepthRemap: the [-1, 1] case, an unrestricted device, a device without depth clamping, an in-range transform and a zero-to-one transform with narrower clamp bounds.Tested
Fedora 44 (kernel 7.2.8, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, Intel Arc Meteor Lake, Mesa 26.2.3, noVK_EXT_depth_range_unrestricted), worktree onmainffa1984:agc_depth_range_remap,agc_driver_graphics,agc_position_invariance,agc_shader_disk_cachepass;tools/check_conventions.py --base origin/mainandgit diff --checkpass. Minecraft (PPSA17221): the title's world draws havePA_SC_VPORT_ZMIN/ZMAXat [-1, 1] on a float depth target, so the remap clips the clamp to [0, 1] and reports it once; worlds render with the remap, with water and fog at their expected depths. Without the remap the same draws threw. Not tested on Windows or on a device with the extension (where the remap stays off).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code