Follow-up to 078783e (Vulkan VS UV_LIMITS collapse) and the
earlier 8b43518 (C++ shadergen UV_LIMITS routing). Brings the
Vulkan Nearest FS into the same shape as the C++ shadergen
routing - UV_LIMITS is no longer a SPIR-V-structural axis on
the Vulkan side; the Nearest FS source has a single shape and
runtime-branches on u_uv_limits.
With this commit m_using_uv_limits is no longer a shader-
source-changed trigger for any backend, so it leaves the
rebuild-trigger predicates entirely. It remains as a member
field that drives the per-vertex ComputePolygonUVLimits CPU
optimisation (gpu_hw.cpp:740) - that's an orthogonal concern
from shader / pipeline routing.
What changes:
data/shaders/vulkan/batch_textured_nearest.frag.glsl
- Adds u_uv_limits to the BatchUBOData declaration with
an explicit layout(offset = 56) (skips past the spec-
const-handled fields between offset 32 and 55, which
Vulkan does not redeclare in its UBO because per-
session settings are spec consts on this path -
RESOLUTION_SCALE, TRUE_COLOR, SCALED_DITHERING,
DITHERING, INTERLACING, PGXP_DEPTH). Explicit offset
via GL_ARB_enhanced_layouts is core in GLSL 4.40+ and
supported by Vulkan GLSL.
- v_uv_limits input declaration drops its
#if defined(UV_LIMITS) guard - always declared,
matching the always-emitted output from the
post-collapse batch VS.
- Body sample/clamp block: the two-branch
#if UV_LIMITS / #else compile-time fork collapses to
a single shape with a runtime `if (u_uv_limits != 0u)`
branch. The "scale uv_limits up by RESOLUTION_SCALE
for non-palette modes" computation moves inside the
branch so it only runs when the values are actually
used.
- Header comment: 5 axes / 48 blobs -> 4 axes / 24 blobs.
tools/regen_vulkan_spirv.py
- _batch_fs_textured_nearest_variants() drops the
uv_axes dimension. The Nearest cube is now in parity
shape with the Bilinear / JINC2 / xBR templates
(UV_LIMITS implicit on those by ShouldUseUVLimits()
coupling - TEXTURE_FILTERING != Nearest forces
m_using_uv_limits true, so they never needed a UV
variant axis).
src/common/vulkan/embedded_spirv/
- 24 new batch_textured_nearest_fs_*.inc files (no
_nouv / _uv suffix) with the collapsed-shape SPIR-V.
- 48 deleted batch_textured_nearest_fs_*_nouv.inc and
_uv.inc files (the obsolete two-shape variants).
- 151 .inc files in the directory total (was 175;
the VS collapse already took it from 181).
src/common/vulkan/embedded_shaders.{h,cpp}
- k_batch_textured_nearest_fs_blobs[48] ->
k_batch_textured_nearest_fs_blobs[24]. The table loses
the alternating _nouv / _uv pairs; the surviving
entries match the new filename layout.
- GetBatchTexturedNearestFragmentShaderBlob drops the
bool uv_limits parameter. Index encoding becomes
index = interp*8 + persp*4 + dual*2 + pgxp (0..23)
(was: interp*16 + persp*8 + dual*4 + pgxp*2 + uv).
- 48 #include lines collapse to 24, matching the
regenerated filename set.
- Header docstring updated to match (5 axes -> 4, blob
array size, UV_LIMITS note added).
src/core/gpu_hw_vulkan.cpp
- The single GetBatchTexturedNearestFragmentShaderBlob
call site (the m_texture_filter == Nearest branch of
the per-pipeline FS lookup) drops its sixth argument
(m_using_uv_limits). Bilinear / JINC2 / xBR call sites
are unchanged - those helpers never had uv_limits as
an argument because their templates already had
UV_LIMITS implicit.
src/core/gpu_hw.cpp
- non_dim_diff in UpdateHWSettings drops the
m_using_uv_limits != use_uv_limits clause.
- shader_source_changed in UpdateHWSettings drops the
same clause.
- display_only_source_changed's other_source_diff
drops it too.
All three trigger predicates are now uv_limits-blind.
m_using_uv_limits flips no longer invalidate the shader
cache or PSO matrix on any backend.
m_using_uv_limits itself stays as a member field -
UpdateHWSettings still computes use_uv_limits via
ShouldUseUVLimits() and assigns it for the runtime
ComputePolygonUVLimits CPU-side decision and for the
u_uv_limits cbuffer push - but it no longer triggers
rebuilds.
What this completes:
The UV_LIMITS axis is now fully routed across all four
backends.
D3D11 / D3D12 / OpenGL (C++ shadergen path):
- Shader source invariant under m_uv_limits since
8b43518.
- Input layout binds ATTR4 unconditionally when
textured (D3D11 / D3D12 since 8b43518; OpenGL was
already unconditional).
Vulkan (pre-baked SPIR-V path):
- VS shape collapsed since 078783e (12 VS blobs).
- Nearest FS shape collapsed in this commit (24 FS
blobs).
- Bilinear / JINC2 / xBR templates unchanged - they
never had UV_LIMITS as an axis (settings-coupling
guarantee).
- Vulkan FS UBO grows by one field (u_uv_limits at
offset 56); other Vulkan FS templates that don't
read UV limits don't need to redeclare it - they
just ignore the extra bytes in the backing buffer.
All backends:
- m_using_uv_limits is no longer a rebuild trigger.
Cost matrix delta:
Per-session flip that touches m_using_uv_limits (e.g.
PGXP on / off under filter Nearest, or filter cross-
Nearest transition):
Pre-commit (Vulkan only): 24 Nearest FS pipelines per
cell rebuilt to swap from _nouv to _uv variants.
Tens of milliseconds cold, instant with disk
pipeline cache.
Post-commit: 0 FS rebuilds across all backends. The
u_uv_limits cbuffer write picks up at next
FlushRender.
Cold launch precompile pass on Vulkan: 24 fewer Nearest
FS pipelines to enumerate. Tens of ms on cold cache.
Steady-state runtime cost (Vulkan Nearest FS):
+ 4-byte UBO read on every fragment.
+ One branch on u_uv_limits (sub-coherent across the
warp because u_uv_limits is uniform).
+ The "scale uv_limits up by RESOLUTION_SCALE" math
moved inside the branch, so when u_uv_limits == 0
that work is also skipped - net cost reduction on
the non-UV path.
Disk footprint:
Before: 175 .inc files, ~12.9 MiB.
After: 151 .inc files, ~11.3 MiB. (-24 files, ~1.6
MiB. The 24 new files are larger than the 24
old _nouv files they implicitly replace because
they always emit the v_uv_limits flat input
declaration and the body branch.)
Test:
- Build: tools/regen_vulkan_spirv.py runs cleanly,
producing 151 blobs. Embedded_shaders.cpp compiles
against the smaller table. gpu_hw_vulkan.cpp link is
clean.
- Boot any PSX title with PGXP off + filter Nearest:
u_uv_limits = 0, the FS branch takes the no-clamp
path. Output identical to pre-commit.
- Toggle PGXP on with filter Nearest: u_uv_limits flips
to 1 via the existing UpdateHWSettings cbuffer push;
the FS picks the clamp path on next FlushRender. No
pipeline rebuild fired.
- Toggle filter to Bilinear: m_texture_filtering changes,
which still fires shader_source_changed (filter is a
distinct rebuild trigger). The Bilinear FS picks up
its template normally, which always uses UV limits
(settings coupling guarantee).
- Cross-test on non-Vulkan backends: D3D11 / D3D12 /
OpenGL also no longer rebuild on UV_LIMITS flip alone
(the trigger drop in gpu_hw.cpp affects them too).
Their shader sources were already invariant since
8b43518, so the only behaviour change is the
rebuild-trigger removal.
Next:
- PGXP_DEPTH for the FS (always-emit SV_Depth / FragDepth
perf measurement first - the FS keeps captured
m_pgxp_depth because the !m_pgxp_depth value gates
DeclareFragmentEntryPoint's depth_output parameter,
which controls whether SV_Depth is declared in the FS
entry signature; routing that requires either always-
emitting SV_Depth or hoisting that decision through
the DeclareFragmentEntryPoint surface).
- per_sample / dcp collapse decisions (forced-always
via settings or keep as variant axes).
- Pre-bake the resulting reduced D3D12 FS matrix.