Follow-up to 8b43518 (UV_LIMITS routing for the C++ shadergen,
D3D11 / D3D12 / OpenGL only). Vulkan has its own pre-baked
SPIR-V pipeline rooted in data/shaders/vulkan/*.glsl, compiled
via tools/regen_vulkan_spirv.py, and indexed by per-axis blob
tables in src/common/vulkan/embedded_shaders.cpp. This commit
parallels the C++ shadergen routing on the VS side: collapses
the UV_LIMITS attribute-layout variant from the batch VS so
that "textured" always means "textured with v_uv_limits", and
the C++ Vulkan input layout binds ATTR4 unconditionally when
textured.
The FS-side UV_LIMITS axis (the Nearest filter's two-variant
nouv / uv expansion) is NOT in this commit. Routing it
through a UBO field requires extending the Vulkan batch FS
UBO declaration with u_uv_limits, body-level runtime
branches, and regenerating the 48 Nearest FS .inc blobs. That
is the natural next commit; this one limits the blast radius
to the VS side, which is a simpler structural change with
fewer downstream touch points.
What changes:
data/shaders/vulkan/batch.vert.glsl
- Drops the #if defined(UV_LIMITS) guards in three sites
(a_uv_limits input declaration, v_uv_limits varying
output declaration, v_uv_limits assignment in main()).
When TEXTURED, a_uv_limits / v_uv_limits are always
declared and v_uv_limits is always written.
- Header comment updated from "3 attribute layouts" to
"2 attribute layouts" and the total variant count from
18 to 12.
tools/regen_vulkan_spirv.py
- _batch_vs_variants(): drops the third attr_axes entry
("textured_uvlim", ["TEXTURED", "UV_LIMITS"]). The
remaining "textured" entry's GLSL output now always
includes the a_uv_limits / v_uv_limits declarations
because the source-side #if guards are gone, so the
single "textured" variant produces the same SPIR-V that
"textured_uvlim" used to. Variant count drops from 18
to 12.
- The Nearest FS variants table is unchanged (still has
the UV_LIMITS axis); collapsing that side is the
follow-up.
src/common/vulkan/embedded_spirv/
- Six batch_vs_textured_uvlim_*.inc files DELETED (no
longer in the regen output set).
- Six batch_vs_textured_*.inc files REGENERATED with the
new GLSL that always emits a_uv_limits / v_uv_limits.
Content shape: same length / structure as the old
"textured_uvlim" .inc files (since both correspond to
the "textured + UV_LIMITS" build); the OLD plain
"textured" .inc files (the smaller no-UV variant) are
effectively replaced.
- Other 169 blobs untouched. Total goes 181 -> 175.
src/common/vulkan/embedded_shaders.{h,cpp}
- k_batch_vs_blobs[18] -> k_batch_vs_blobs[12]. The
table loses the "attr = 1 (textured, no UV limits)"
block; the surviving "attr = 1" block is what used to
be "attr = 2 (textured + UV limits)", just renamed for
cleaner end state.
- GetBatchVertexShaderBlob() drops the bool uv_limits
parameter. Index encoding becomes
attr = textured ? 1 : 0 (was: !textured ? 0 :
(uv_limits ? 2 : 1))
Same interp / persp arithmetic.
- Header docstring and #include block updated to match
(six fewer #includes; the six uvlim ones).
src/core/gpu_hw_vulkan.cpp
- The single GetBatchVertexShaderBlob() call site at the
CompilePipelines VS-fill loop drops its second
argument (m_using_uv_limits) so the new four-arg
signature is satisfied.
- The input-layout builder at the per-pipeline
gpbuilder.AddVertexAttribute(4, ...) site drops its
`if (m_using_uv_limits)` guard. ATTR4 / a_uv_limits is
now bound unconditionally when textured, matching the
always-emitted shader input. BatchVertex carries the
uv_limits field unconditionally (gpu_hw.h:47), so the
binding always points at valid memory; the FS-side
u_uv_limits scalar still decides whether the value is
meaningful.
What does NOT change in this commit:
- The Vulkan batch FS Nearest variants still have
UV_LIMITS as a build axis. m_using_uv_limits is still
threaded to the FS blob lookup at
gpu_hw_vulkan.cpp:2139 (now line ~2140 after the diff).
The Nearest FS GLSL still has #if defined(UV_LIMITS)
guards. The 48 nearest_uv / nearest_nouv blobs remain.
Routing that side is the natural next commit; the
delta there is much larger (48 blobs, FS UBO grows,
runtime branch in the Nearest body).
- m_using_uv_limits STAYS in shader_source_changed across
backends. Vulkan still needs it to pick the right
Nearest FS blob, so the rebuild trigger has to stay
until the Nearest FS routing also lands.
- m_using_uv_limits STAYS as a member field. Still
drives the per-vertex ComputePolygonUVLimits decision
(gpu_hw.cpp:740) and still passed into the FS variant
lookup. The VS lookup no longer takes it.
- Bilinear / JINC2 / xBR FS templates: untouched. They
already assumed UV_LIMITS via the settings-layer
ShouldUseUVLimits() coupling (TEXTURE_FILTERING !=
Nearest implies m_using_uv_limits = true), so they
never had a UV_LIMITS variant axis to collapse.
Variant-count delta:
Batch VS: 18 -> 12 SPIR-V blobs. Pipeline cache footprint
drops by 6 VS pipelines per (filter, render, texture)
cell pair (filter side is per-FS so doesn't multiply VS
directly, but the VkPipeline cache key combines them and
6 fewer VS blobs mean 6 fewer paths through the
pipeline-create call).
Disk SPIR-V footprint:
Before: 181 .inc files, 13 MiB total.
After: 175 .inc files, 13 MiB - ~120 KiB = ~12.9 MiB.
(Six VS blobs at ~120 KiB each, ~2-2.5 KiB SPIR-V plus
the C-array boilerplate.)
Cost matrix delta (Vulkan):
UV_LIMITS flip mid-session (in practice triggered by PGXP
toggle or filter cross-Nearest transition, both of which
separately trigger m_using_uv_limits flips):
Pre-commit: VS pipeline-cache lookup picks a different
blob from the 18-entry table on flip.
Pipeline creation cost on cold cache:
~2 vkCreateGraphicsPipelines for the two
new (textured, textured_uvlim) VS variants
if both end up needed.
Post-commit: VS pipeline-cache lookup is invariant
under m_using_uv_limits at the VS axis;
the FS axis still flips. Saves ~2 cold VS
pipeline creates on the toggle. Symbolic
(small absolute cost) but it unlocks the
next Nearest-FS routing commit, which is
the actual large win on the Vulkan side.
Cold launch (precompile pass): 6 fewer VS pipelines to
enumerate / create. Probably tens of ms on cold cache.
Steady-state runtime cost: unchanged. The VS uniform
always-emits-v_uv_limits adds one MUL per vertex and one
vec4 of interpolant bandwidth, both sub-noise.
Test:
- Build: tools/regen_vulkan_spirv.py runs cleanly with
glslangValidator from the Vulkan SDK / glslang-tools
package, producing 175 blobs. The Vulkan backend builds
and links against the smaller blob table.
- Boot any PSX title with PGXP off + filter Nearest:
untextured / textured paths render identically. The
"textured" VS variant is now the always-UV blob;
BatchVertex.uv_limits is zero on these vertices (no
ComputePolygonUVLimits ran), v_uv_limits is propagated
as zero, and the Nearest FS (still UV_LIMITS-keyed in
this commit) picks its "nouv" variant.
- Toggle PGXP on or filter to Bilinear:
m_using_uv_limits flips to true, the Nearest FS picks
its "uv" variant, the VS variant is still the same
(post-commit there's only one textured VS variant).
Output identical to pre-commit equivalent state.
- Spec const flips (PGXP_DEPTH, RESOLUTION_SCALE) at
pipeline-create time: still produce the right pipeline
via the smaller blob table.
Next:
- Vulkan Nearest FS UV_LIMITS routing: extend Vulkan FS
UBO with u_uv_limits, drop the #if defined(UV_LIMITS)
guards from batch_textured_nearest.frag.glsl, runtime
branch in the body, regen 48 -> 24 Nearest FS blobs,
drop m_using_uv_limits from the FS lookup +
shader_source_changed. After that, all backends have
UV_LIMITS fully routed.
- PGXP_DEPTH for the FS (always-emit SV_Depth / FragDepth
perf measurement first).
- Pre-bake commits once remaining axes are decided.