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.
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.
The prize set. display_ps is the per-frame hot shader - every
frame goes through this on its way to the host display, so cold-
flip cost matters here more than anywhere else in the GPU
pipeline. This commit pre-bakes 54 variants covering the full
runtime configuration matrix and replaces the shadergen +
m_shader_cache.GetPixelShader path in GetDisplayPipeline with
indexed-lookup into two static arrays of D3D12_SHADER_BYTECODE.
Variant axes (4 axes, 54 unique blobs):
* DEPTH_24BIT (2 values): 16-bit framebuffer (the common case;
every game's standard scanout) vs 24-bit (FMV cutscenes,
games that opt into true-colour framebuffers).
* interlace_mode (3 values): InterlacedRenderMode enum from
gpu_hw.h. Mapped to a (INTERLACED, INTERLEAVED) bool pair
in the variant /D defines:
i=0 (None): (INTERLACED=0, INTERLEAVED=0)
i=1 (InterleavedFields): (INTERLACED=1, INTERLEAVED=1)
i=2 (SeparateFields): (INTERLACED=1, INTERLEAVED=0)
* SMOOTH_CHROMA (2 values): chroma-plane smoothing in the
24-bit path. Heavy when active - SampleVRAM24Smoothed runs
9 SampleVRAM24 calls per output pixel (1 centre + 4 x 2x2
averages), each of which is 2 LoadVRAM calls. Dead code
when DEPTH_24BIT=0; the variant table omits the c=1 entry
for d=0 (54 = 18 + 36, not 72 = 2 x 3 x 2 x 6).
* MULTISAMPLES (6 values: 1, 2, 4, 8, 16, 32): MSAA sample
count. Same cardinality axis as vram_read_ps (21f4623).
Composed multiplicatively with SMOOTH_CHROMA: at
/DSMOOTH_CHROMA=1 /DMULTISAMPLES=32 the inner loop unrolls
to 9 * 2 * 32 = 576 texture loads per pixel - the d1i?c1m32
blobs are correspondingly the largest in the set (99 kB
each).
Variant suffix convention: d{0,1}i{0,1,2}c{0,1}m{01,02,04,08,16,
32}. MULTISAMPLES padded to 2 digits so alphabetical .inc
filename ordering matches the natural nested-loop iteration
order. The d=0 set has 18 entries (one chroma value); d=1 has
36 (both chroma values).
Blob size distribution:
smallest: 1276 B d0i0c0m01 (16-bit, no interlace, no MSAA)
median: ~3500 B
largest: 99152 B d1i2c1m32 (24-bit, SeparateFields, smooth
chroma, 32x MSAA - 576 loads/px)
total: 942 kB of DXBC across 54 .inc files
on-disk: ~5.6 MB of .inc text (the hex-encoding overhead is
~6x vs the binary - "0xXX, " per byte - same shape
as the vram_read note in 21f4623)
Runtime selection in GetDisplayPipeline:
if (depth_24) -> k_display_d1[interlace_mode][chroma][ms_idx]
else -> k_display_d0[interlace_mode][ms_idx]
Two arrays rather than one ragged 4D, because the smooth_chroma
dimension is structurally absent on the d=0 path (SMOOTH_CHROMA
is dead code there; fxc /O3 would have produced identical DXBC
for c=0 and c=1 anyway, so we save 18 blobs / ~30 kB DXBC by
not baking them). ms_idx is log2(m_multisamples) computed by a
function-scope kMultisamplesIndex lambda - same predicate /
fallback shape as the vram_read pre-bake. The arrays are
function-scope static const so they initialise on first call
and the cost is amortised across the per-frame display PSO
stream for the rest of the session.
Files added:
* data/shaders/d3d12/display.ps.hlsl: standalone HLSL matching
GenerateDisplayFragmentShader's D3D12 output post-e64fc28
cbuffer routing. 24-byte cbuffer (u_vram_offset.xy,
u_crop_left, u_field_offset, u_resolution_scale, u_pad0)
layout-identical to the GPU_HW_D3D12::UpdateDisplay
SetGraphicsRoot32BitConstants push. RGBA8ToRGBA5551,
RGBToYUV, YUVToRGB, fixYCoord helpers all inlined.
SampleVRAM24, SampleVRAMAverage2x2, SampleVRAM24Smoothed
match the shadergen body byte-for-byte.
* src/common/d3d12/embedded_dxbc/display_ps_d{0,1}i{0,1,2}c{0,1}
m{01,02,04,08,16,32}.inc: 54 DXBC blobs (with the
smooth-chroma collapse on the d=0 path). All built with
Microsoft fxc; full RDEF/ISGN/OSGN/SHEX/STAT chunk set; all
54 stamped "Microsoft (R) HLSL Shader Compiler 10.1". Validator
(check_microsoft_creator in tools/regen_d3d12_dxbc.py)
passes all 54.
Files modified:
* tools/regen_d3d12_dxbc.py: TEMPLATE_VARIANTS gains the
display.ps.hlsl entry with 54 rows. Comment explains the
interlace_mode -> (INTERLACED, INTERLEAVED) mapping and the
d=0 chroma collapse.
* src/common/d3d12/embedded_shaders.h: 108 extern declarations
(54 array + 54 size_bytes). Header docblock explains the
variant axis breakdown, the suffix convention, and the
two-array runtime selection.
* src/common/d3d12/embedded_shaders.cpp: 54 #include lines for
the new .inc files, inside namespace D3D12::EmbeddedShaders.
* src/core/gpu_hw_d3d12.cpp GetDisplayPipeline: shadergen call
+ m_shader_cache.GetPixelShader path replaced with the
kMultisamplesIndex lambda + two static arrays + ternary
indexed-lookup. The m_shadergen-not-yet-built check is
dropped for this path since the embedded blobs are
statically linked. Pipeline build downstream is unchanged
(same root signature, RT format, blend/depth state).
Cost matrix delta (D3D12) for display_ps:
Cold-flip multisamples toggle: ~50 ms x 6 D3DCompile +
~10 ms x 6 PSO
-> ~10 ms x 6 PSO only.
(Multisamples rebuild touches the full 2x3 display PSO
matrix at the new sample count.)
Cold-flip smooth_chroma toggle: ~50 ms x 2 D3DCompile +
~10 ms x 2 PSO
-> ~10 ms x 2 PSO only.
(Only the 2 d=1 PSOs are affected; d=0 PSOs are
chroma-independent.)
Disk-cache-warm: ~1 ms each -> 0 ms.
Resolution scale toggle: 0 ms (cbuffer-routed via e64fc28).
Per-frame PSO selection: previously a shader_cache hash
lookup; now an array index. ~ns vs ~us delta - negligible.
The shadergen GenerateDisplayFragmentShader function is left
intact in gpu_hw_shadergen.cpp - the other three backends still
call it through their runtime shader-cache paths. Only D3D12
bypasses it now. This is the final shader on the non-batch
pre-bake roadmap.
Test:
- Build: D3D12 backend links without unresolved symbols
across all 54 new externs. Specific risk: a typo in any of
the 108 extern names or 54 includes would surface here.
- Runtime, default config (MSAA off, no chroma smoothing):
every game must continue to scanout correctly. Failure
modes if the d=0 path is wrong:
* Garbled framebuffer / wrong colours on the per-frame
display.
* Interlace fields rendered wrong - test signal: any PSX
game in interlaced output mode (most TV-target games).
Wrong interlace mapping would manifest as field
comb-tearing or half-height output.
- Runtime, 24-bit colour: trigger any FMV. Standard test
cases:
* Sony intro bookend FMV - leaves no doubt the 24-bit
path is hit.
* In-game cutscene FMVs (FF7, MGS, Resident Evil).
Failure mode if d=1 c=0 path wrong: FMV plays but colours
are wrong (off hue, mismatched chroma).
- Runtime, 24-bit + chroma smoothing: enable the "24-bit
Chroma Smoothing" core option, then play FMV. Failure mode
if d=1 c=1 path wrong: FMV plays with sharp chroma edges
(the smoothing isn't happening) or with garbled output
(variant table miswired).
- MSAA at each level (2x/4x/8x/16x/32x): same screenshot
tests at each. Failure mode for any individual blob:
visible MSAA averaging artefacts in the displayed image.
32x specifically validates that kMultisamplesIndex picks
ms_idx=5 - wrong-side switch would index m16 (4) instead
of m32 (5).
- All combinations: display_ps is selected freshly each
UpdateDisplay call, so the array indexing is exercised
every frame. Any mis-indexed combo would be visually
obvious.
- Chroma toggle: flip "24-bit Chroma Smoothing" mid-FMV. The
next display PSO selection picks blobs from k_display_d1
[interlace_mode][1] instead of [0]. Failure mode: chroma
smoothing doesn't toggle, or wrong PSO selected leading to
garbled output.
If everything works, the only remaining pre-bake target is the
batch matrix - the ~1 min cold-flip prize, hundreds of variants.
That's the final arc of this whole sequence.
First MSAA-count cardinality variant. Where vram_update_depth_ps
(91f8c32) split on a binary MULTISAMPLING flag (Texture2D vs
Texture2DMS<float4>), vram_read_ps splits on the MULTISAMPLES
*count* itself - the [unroll] sample-resolve loop in the shader's
LoadVRAM helper unrolls a different number of times per variant.
Each power-of-2 sample count produces a distinct DXBC; the m1
blob takes the Texture2D path with a single Load, while m2..m32
all use Texture2DMS<float4> with different unroll counts in the
sample-averaging loop.
vram_read_ps is the upscaled-VRAM-to-native-16bpp encode pass
that backs screenshot capture, libretro readback, and save-state
staging. It's not in the per-frame hot path - it only runs when
the frontend explicitly requests VRAM contents - but every
MULTISAMPLES variant must be statically available because
m_multisamples can change between runs and pre-bake decisions
are made at link time.
Variant axis: MULTISAMPLES = 1, 2, 4, 8, 16, or 32 (6 blobs).
MULTISAMPLING is derived in-shader (#if MULTISAMPLES > 1) rather
than passed as a separate /D, since the binding type and the
unroll count are both functions of the same value.
Cbuffer is post-2980961 (24 bytes: u_base_coords, u_size,
u_resolution_scale, u_pad0), so RESOLUTION_SCALE is a runtime
cbuffer value and the box-filter loops in SampleVRAM remain
runtime loops (not [unroll]'d). Resolution scale therefore
doesn't multiply the variant count.
Blob sizes scale linearly with MULTISAMPLES because of the
[unroll] of the sample-resolve loop:
vram_read_ps_m1.inc 3636 B (Texture2D path, no loop)
vram_read_ps_m2.inc 3996 B (2 sample loads + averaging)
vram_read_ps_m4.inc 4572 B (4 sample loads)
vram_read_ps_m8.inc 5724 B (8 sample loads)
vram_read_ps_m16.inc 8028 B (16 sample loads)
vram_read_ps_m32.inc 12636 B (32 sample loads)
Total embedded bytecode footprint ~ 38 KB across the 6 blobs.
The .inc text-file sizes (22 KB - 77 KB) are larger than the
binary sizes by ~6x due to the hex-formatting overhead of the
.inc representation ("0xXX, " per byte) - this is invariant
across all pre-bakes and is reflected in the on-disk repo
footprint, not the runtime memory footprint.
Files added:
* data/shaders/d3d12/vram_read.ps.hlsl: standalone HLSL source
matching GenerateVRAMReadFragmentShader's D3D12 output
post-2980961. 24-byte cbuffer (u_base_coords.xy, u_size.xy,
u_resolution_scale, u_pad0) layout-identical to the
GPU_HW_D3D12::ReadVRAM SetGraphicsRoot32BitConstants push.
RGBA8ToRGBA5551 helper inlined. LoadVRAM helper's MS-path
loop is [unroll]'d (MULTISAMPLES is a compile-time /D);
SampleVRAM's box-filter loops are runtime loops over
u_resolution_scale.
* src/common/d3d12/embedded_dxbc/vram_read_ps_{m1,m2,m4,m8,m16,
m32}.inc: 6 DXBC blobs, one per MULTISAMPLES value. All built
with Microsoft fxc; full RDEF/ISGN/OSGN/SHEX/STAT chunk set;
creator stamped "Microsoft (R) HLSL Shader Compiler 10.1".
Validator (check_microsoft_creator in
tools/regen_d3d12_dxbc.py) passes all 6.
Files modified:
* tools/regen_d3d12_dxbc.py: TEMPLATE_VARIANTS gains the
vram_read.ps.hlsl entry with 6 rows (m1, m2, m4, m8, m16, m32).
* src/common/d3d12/embedded_shaders.h: 6 extern declarations
added with their _size_bytes companions. Header docblock
explains the cardinality-axis distinction vs the binary-axis
variants above.
* src/common/d3d12/embedded_shaders.cpp: 6 #include lines.
* src/core/gpu_hw_d3d12.cpp GetVRAMReadbackPipeline: shadergen
call + m_shader_cache.GetPixelShader path replaced with a
switch on m_multisamples picking between the 6 blobs. Default
case is a safety net that falls back to the m1 blob with a
warn log - in practice every supported config falls into a
named case because the libretro UI dropdown is restricted to
the same 6 values the switch handles, and the GPU driver-
capability detection in CreateResources only reports
power-of-2 counts as supported. The
m_shadergen-not-yet-built check is dropped for this path since
the embedded blobs are statically linked.
Cost matrix delta (D3D12) for vram_read_ps:
Cold-flip multisamples toggle: ~50 ms x N D3DCompile + ~10 ms
x N PSO -> ~10 ms x N PSO only.
(N = number of distinct MULTISAMPLES values cycled through in
one session; typically 1-2 if the user picks one MSAA setting
and keeps it.)
Disk-cache-warm: ~1 ms each -> 0 ms.
Resolution scale toggle: 0 ms (cbuffer-routed, no PSO change).
The shadergen GenerateVRAMReadFragmentShader function is left
intact in gpu_hw_shadergen.cpp - the other three backends still
call it through their runtime shader-cache paths. Only D3D12
bypasses it now.
Test:
- Build: D3D12 backend links without unresolved symbols across
all 6 new externs.
- Runtime, MSAA disabled: trigger any readback path. Concrete
cases:
* RetroArch "Take Screenshot" hotkey - reads VRAM and
encodes to PNG. Failure mode if m1 blob is wrong:
garbled screenshot or wrong colours.
* Save state - dumps VRAM into the savestate blob.
Failure mode: load-state restores garbled VRAM.
- Runtime, MSAA enabled at each level (2x/4x/8x/16x/32x):
same screenshot / savestate tests. Failure mode: VRAM
averaging incorrect; per-sample data not properly
collapsed. Specifically:
* Slightly off colours on edges of polygons (the MS
averaging path is what makes upscaled VRAM look
coherent vs the native 1024x512 readback).
* 32x specifically tested for unroll-count correctness -
if the runtime selects m16 by mistake when m_multisamples
is 32, the readback would load 16 samples instead of 32
and divide by 16 instead of 32, producing visibly darker
readback output.
- Resolution-scale toggle 1x <-> 8x: no PSO recompile (blob
is scale-independent post-2980961); next readback uses the
same PSO but different u_resolution_scale value through
the cbuffer. SampleVRAM's box-filter loops scale at runtime.
Next per the same template now that cardinality-axis is
validated: display_ps (12 x M variants on depth_24 x
interlace_mode x smooth_chroma x MSAA). Largest blob set per
shader. After that the only remaining pre-bake target is the
batch matrix - the ~1 min cold-flip prize, hundreds of variants.
First MSAA texture-binding variant pre-bake. Where vram_copy /
vram_write / vram_fill split on PGXP_DEPTH / WRAPPED / INTERLACED
which are body-branch flags only, vram_update_depth_ps splits on
MULTISAMPLING which changes the *binding type* of samp0
(Texture2D vs Texture2DMS<float4>) plus adds a conditional
SV_SampleIndex input to the entry-point signature. This exercises
the indexed-lookup runtime selection in territory that vram_read_ps
and display_ps will need too.
vram_update_depth runs the depth-only pass that propagates colour-
texture alpha (the PSX mask bit) into the depth buffer after every
CPU->VRAM upload. It's hit on every UpdateVRAM completion path in
games that toggle the mask bit, which means most native rendering
plus any title's transparency layer.
Variant axis: MULTISAMPLING on/off only (2 blobs). msaa0 is the
Texture2D path with .Load(int3(coords, mip)) form; msaa1 is the
Texture2DMS<float4> path with .Load(coords, sample) form and
SV_SampleIndex as an additional entry-point input. HLSL forces
per-sample shading on the msaa1 variant because SV_SampleIndex is
declared, so the PSO MSAA configuration (gpbuilder.SetMultisamples)
must match the shader's per-sample expectation - runtime selection
uses m_multisamples > 1 (same predicate as the shadergen
UsingMSAA() helper).
Files added:
* data/shaders/d3d12/vram_update_depth.ps.hlsl: standalone HLSL
matching GenerateVRAMUpdateDepthFragmentShader's D3D12 output.
No cbuffer - the shadergen function never calls
DeclareUniformBuffer. v_tex0 declared but unused (matches the
shadergen entry-point template which emits texcoord inputs
unconditionally; the optimiser drops the dead read). #if
MULTISAMPLING block switches both the binding and the body Load
form; the SamplerState is declared for both variants to match
shadergen byte-for-byte (Texture2DMS doesn't need a sampler for
Load, but the dead binding is free at runtime).
* src/common/d3d12/embedded_dxbc/vram_update_depth_ps_msaa0.inc:
DXBC for /DMULTISAMPLING=0 (Texture2D path). 672 bytes.
* src/common/d3d12/embedded_dxbc/vram_update_depth_ps_msaa1.inc:
DXBC for /DMULTISAMPLING=1 (Texture2DMS<float4> path). 732
bytes (60B larger for the per-sample shading flag in STAT plus
the SV_SampleIndex input in ISGN).
Both built with Microsoft fxc; full RDEF/ISGN/OSGN/SHEX/STAT
chunk set; creator stamped "Microsoft (R) HLSL Shader Compiler
10.1". Validator (check_microsoft_creator in
tools/regen_d3d12_dxbc.py) passes both.
Files modified:
* tools/regen_d3d12_dxbc.py: TEMPLATE_VARIANTS gains the
vram_update_depth.ps.hlsl entry with two rows (msaa0, msaa1).
* src/common/d3d12/embedded_shaders.h: 2 extern declarations
added. Header docblock explains the MSAA binding-type difference
vs the body-branch variants above.
* src/common/d3d12/embedded_shaders.cpp: 2 #include lines for
the new .inc files.
* src/core/gpu_hw_d3d12.cpp GetVRAMUpdateDepthPipeline:
shadergen call + m_shader_cache.GetPixelShader path replaced
with a ternary on m_multisamples > 1 picking between the two
D3D12_SHADER_BYTECODE structs. gpbuilder.SetMultisamples is
unchanged - it drives the PSO MSAA state from m_multisamples
directly. The m_shadergen-not-yet-built check is dropped for
this path since the embedded blobs are statically linked.
The "match the PSO MSAA configuration to the shader expectation"
discipline is the load-bearing piece here. SV_SampleIndex in the
shader forces per-sample shading; the PSO must be configured with
matching MSAA sample count or the runtime will reject PSO creation
(D3D12 PSO validation does cross-check the rasterizer sample count
against the PS expectation). The pattern below scales naturally
to vram_read_ps and display_ps where M (the sample count itself)
also varies.
Cost matrix delta (D3D12) for vram_update_depth_ps:
Cold-flip multisamples toggle: ~50 ms D3DCompile + ~10 ms PSO
-> ~10 ms PSO only.
Disk-cache-warm: ~1 ms -> 0 ms.
Resolution scale toggle: 0 ms (no scale dependency).
Note: the multisamples toggle itself triggers a much larger
rebuild cascade (every MSAA-sensitive PSO across the GPU
matrix), so vram_update_depth_ps's share is small in absolute
terms - but it's the first proof point for the technique.
The shadergen GenerateVRAMUpdateDepthFragmentShader function is
left intact in gpu_hw_shadergen.cpp - OpenGL / Vulkan / D3D11
still call it through their runtime shader-cache paths. Only
D3D12 bypasses it now.
Test:
- Build: D3D12 backend links without unresolved symbols.
Specific risk: a typo in the MSAA-path entry signature would
surface here (SV_SampleIndex semantic name, ordering vs
SV_Position).
- Runtime, MSAA disabled (default): every CPU->VRAM upload
must continue to propagate mask bits correctly. Test signal:
any game with mask-bit-using transparent sprites (FF7 spell
effects, Tekken 3 ring-out smoke, MGS guard-search beams).
Failure mode: transparency rendering wrong (sprites drawn at
wrong depth, mask-bit-disabled pixels showing through layers
that should occlude them).
- Runtime, MSAA enabled (Multi-Sample Antialiasing core option
set to 2x / 4x / 8x): same transparency tests, but per-sample
depth propagation. The msaa1 blob is selected and the PS runs
once per sample. Failure mode would be MSAA edges around
transparent sprite boundaries flashing or disappearing because
per-sample depth wasn't propagated.
- MSAA toggle (1x -> 4x): triggers full PSO rebuild cascade as
today. The vram_update_depth_ps portion now picks msaa1
blob[1] instead of falling through D3DCompile. Cold-flip
time drops by the D3DCompile share (~50 ms for this one
shader).
- Resolution scale toggle: no PSO recompile (blob is scale-
independent); next UpdateVRAM completion uses the same PSO.
Next per the same template now that MSAA-binding is validated:
vram_read_ps (M MSAA variants on top of the 2980961 cbuffer
routing - first multi-axis MSAA-binding variant), then display_ps
(12xM variants - the prize set).
First multi-axis pre-bake. Where vram_copy (cb4b443) and vram_write
(ba013aa) each had a single PGXP_DEPTH dimension and 2 blobs,
vram_fill is 3 axes (PGXP_DEPTH x WRAPPED x INTERLACED) for 8 blobs
total. Exercises the TEMPLATE_VARIANTS table for the first time
with a nested variant space and validates the indexed-lookup
runtime selection pattern that vram_update_depth / vram_read /
display will need for their MSAA splits.
vram_fill is hit on every screen-clear that the game submits, plus
FillVRAM operations from CPU DMA writes - common games that clear
every frame (most 3D titles) hit this constantly, but even
non-clearing-every-frame titles (2D scrollers, JRPG menus) hit it
on scene transitions. Pre-baking removes another D3DCompile from
cold-flips and another path exposed to shader-cache invalidation.
Variant axis breakdown:
* PGXP_DEPTH: m_pgxp_depth_buffer runtime toggle. Controls how
o_depth is written - u_fill_color.a (legacy alpha-as-depth) or
constant 1.0 (PGXP-depth mode where depth is per-vertex from
CPU projection).
* WRAPPED: fill rect wraps past the VRAM edge. The runtime
decides this per-call from the destination rect geometry via
IsVRAMFillOversized at the call site (line 2194). When set,
the shader does the same wrap-around discard logic as
vram_copy / vram_write.
* INTERLACED: skip every-other-row to preserve the field not
currently being displayed. Set when the destination overlaps
the active scanout region during interlaced output. The shader
discards based on (dst_coords.y & 1) == u_interlaced_displayed_field.
No u_resolution_scale dependency in the shader body for D3D12
mode (fixYCoord is identity on HLSL; only the OpenGL backend's
GLSL body references VRAM_SIZE for the y-flip). No scale-refactor
was needed before pre-baking - the shadergen path's CONSTANT
RESOLUTION_SCALE emission would have been dead code.
Files added:
* data/shaders/d3d12/vram_fill.ps.hlsl: standalone HLSL source
matching GenerateVRAMFillFragmentShader's D3D12 output.
36-byte cbuffer member-for-member identical to VRAMFillUBOData
(u_dst_coords, u_end_coords, u_fill_color, u_interlaced_-
displayed_field). float4 u_fill_color forces 16-byte alignment
so it lands at offset 16; the trailing uint sits at offset 32.
Three #define switches at the top control body branches; v_pos
is only read when INTERLACED || WRAPPED (the discard paths).
* src/common/d3d12/embedded_dxbc/vram_fill_ps_{p0w0i0,p0w0i1,
p0w1i0,p0w1i1,p1w0i0,p1w0i1,p1w1i0,p1w1i1}.inc: 8 DXBC blobs,
one per variant combo. Sizes scale predictably with feature
complexity - 1016B for the minimal p1w0i0 (no wrap, no
interlace, constant depth), 1380B for the maximal p0w1i1 (both
discards plus the alpha-as-depth branch). All built with
Microsoft fxc via Wine + d3dcompiler_47.dll; full
RDEF/ISGN/OSGN/SHEX/STAT chunk set; creator string
"Microsoft (R) HLSL Shader Compiler 10.1". Validator
(check_microsoft_creator in tools/regen_d3d12_dxbc.py) passes
all 8.
Files modified:
* tools/regen_d3d12_dxbc.py: TEMPLATE_VARIANTS gains the
vram_fill.ps.hlsl entry with 8 rows. Variant suffix encodes
the three flags as p{0,1}w{0,1}i{0,1} so the alphabetical
ordering of the .inc files matches the natural nested-loop
iteration order (pgxp outer, wrapped middle, interlaced
inner). embedded_shaders.h externs and the GetVRAMFillPipeline
call site mirror this naming convention exactly so a reader
can grep p?w?i? across all three files and find consistent
hits.
* src/common/d3d12/embedded_shaders.h: 8 extern declarations
(one per variant) plus size constants. Header docblock
explains the variant-axis breakdown and the indexed-lookup
selection pattern.
* src/common/d3d12/embedded_shaders.cpp: 8 #include lines for
the new .inc files, inside namespace D3D12::EmbeddedShaders.
* src/core/gpu_hw_d3d12.cpp GetVRAMFillPipeline: shadergen
call + m_shader_cache.GetPixelShader path replaced with a
function-scope static const D3D12_SHADER_BYTECODE
[2][2][2] array indexed by [m_pgxp_depth_buffer ? 1 : 0]
[wrapped & 1][interlaced & 1]. The static-const initializer
runs once on first call (k_xxx externs and _size_bytes
constants are linker-visible by then); subsequent calls are
3 byte indexes. PSO build downstream is unchanged. The
m_shadergen-not-yet-built check is dropped for this path
since the embedded blobs are statically linked.
Cost matrix delta (D3D12) for vram_fill_ps:
Cold-flip PGXP toggle: ~50ms x 4 D3DCompile + ~10ms x 4 PSO
-> ~10ms x 4 PSO only.
(PGXP rebuilds the full wrapped x interlaced submatrix.)
Disk-cache-warm: ~1 ms each -> 0 ms.
Resolution scale toggle: 0 ms (no dependency in body).
The shadergen GenerateVRAMFillFragmentShader function is left
intact in gpu_hw_shadergen.cpp - the OpenGL / Vulkan / D3D11
backends still call it through their runtime shader-cache
paths. Only D3D12 bypasses it now.
Test:
- Build: D3D12 backend links without unresolved symbols across
all 8 new externs.
- Runtime: every screen clear in every game must continue to
render correctly. Concrete signals:
* Most 3D titles clear every frame (test signal: any 3D
title's gameplay, the screen-clear path is hit before
every frame's draw queue). Failure mode: previous
frame's content stays visible / smears between frames.
* Tekken 3 round-start fades through a black clear before
the round draw - if the wrong variant were selected,
the fade would either not happen or leave stale pixels.
* FF7 scene transitions (entering/leaving battle, world
map -> field) clear the framebuffer; the transition
flash would corrupt if the variant were wrong.
- PGXP toggle: flip the "PGXP CPU mode" core option. First
flip rebuilds all 4 (wrapped x interlaced) PSOs picking
the p1??? variants instead of the p0??? variants. Subsequent
same-direction flips hit the PSO cache.
- Resolution scale toggle 1x <-> 8x: no PSO recompile (blobs
are scale-independent); CPU side just updates the viewport
and the next FillVRAM hits the same PSO.
- Interlaced mode test: enable "Force Progressive Scan" off,
play any title that runs in interlaced output (most PSX
games do). The INTERLACED=1 path is hit when FillVRAM
overlaps the active scanout - test signal: no flicker
between fields during a fill operation.
- Wrapped fill test: trigger any oversized FillVRAM (CPU
writes a fill that crosses the right or bottom VRAM edge).
Some games do this for the standby blackout overlay or for
fullscreen depth-buffer clears that span multiple 256-tall
VRAM strips. The WRAPPED=1 path is hit; failure mode would
be the spillover region staying uncleared.
Next per the same template now that multi-axis is validated:
vram_update_depth_ps (2 MSAA variants - first MSAA texture-
binding variant exercise, Texture2D vs Texture2DMS<float4>),
then vram_read_ps (M MSAA variants on top of 2980961), then
display_ps (12xM variants - largest blob set per shader).
Same template as cb4b443 (vram_copy pre-bake), applied to vram_write_ps.
vram_write_ps is the CPU->VRAM upload path - hit on every game's
framebuffer streaming and FMV staging path, so it runs many times
per frame in practice. Pre-baking it removes another D3DCompile
from cold-flips and another path that's exposed to shader-cache
invalidation.
Variant axis: PGXP_DEPTH on/off only (2 blobs). The shadergen's
`use_ssbo` parameter is GLSL/Vulkan-only - the D3D12 caller at
GPU_HW_D3D12::GetVRAMWritePipeline always passes `false`, so the
use_ssbo dimension collapses to a single value for D3D12 and only
the texture-buffer source path (Buffer<uint4> samp0) gets pre-baked.
Files added:
* data/shaders/d3d12/vram_write.ps.hlsl: standalone HLSL source
matching GenerateVRAMWriteFragmentShader(false)'s D3D12 output
post-9d2b49d. 44-byte cbuffer member-for-member identical to
VRAMWriteUBOData (u_base_coords, u_end_coords, u_size,
u_buffer_base_offset, u_mask_or_bits, u_depth_value,
u_resolution_scale, u_pad0). VRAM_SIZE / RESOLUTION_SCALE aliases
inlined. RGBA5551ToRGBA8 helper inlined (no shadergen prelude
available to standalone HLSL). PGXP_DEPTH branch in body controls
the o_depth assignment.
* src/common/d3d12/embedded_dxbc/vram_write_ps_pgxp0.inc: DXBC for
/DPGXP_DEPTH=0 (PGXP off, conditional o_depth). 2048 bytes.
* src/common/d3d12/embedded_dxbc/vram_write_ps_pgxp1.inc: DXBC for
/DPGXP_DEPTH=1 (PGXP on, o_depth = 1.0). 2028 bytes.
Both built with Microsoft fxc via Wine + d3dcompiler_47.dll - full
RDEF/ISGN/OSGN/SHEX/STAT chunk set, creator stamped "Microsoft (R)
HLSL Shader Compiler 10.1". Validator (check_microsoft_creator in
tools/regen_d3d12_dxbc.py) passes both.
Files modified:
* tools/regen_d3d12_dxbc.py: TEMPLATE_VARIANTS gains the
vram_write.ps.hlsl entry with two rows (pgxp0, pgxp1). Same
shape as the vram_copy entry.
* src/common/d3d12/embedded_shaders.h: extern declarations added
for the two new blobs and their size constants. Header docblock
explains the use_ssbo collapse.
* src/common/d3d12/embedded_shaders.cpp: two #include lines for
the new .inc files, inside namespace D3D12::EmbeddedShaders.
* src/core/gpu_hw_d3d12.cpp GetVRAMWritePipeline: shadergen call +
m_shader_cache.GetPixelShader path replaced with an inline
D3D12_SHADER_BYTECODE picked via m_pgxp_depth_buffer. PSO build
downstream is unchanged (same root signature, MSAA, depth state,
shader-cache PSO disk-cache via gpbuilder.Create). The
m_shadergen-not-yet-built check is dropped for this path since
the embedded blob is statically linked.
Cost matrix delta (D3D12) for vram_write_ps:
Cold-flip PGXP toggle: ~50 ms x 2 D3DCompile + ~10 ms x 2 PSO
-> ~10 ms x 2 PSO only.
Disk-cache-warm: ~1 ms each -> 0 ms.
Resolution scale: 0 ms (already cbuffer-routed since 9d2b49d).
The shadergen GenerateVRAMWriteFragmentShader function is left
intact in gpu_hw_shadergen.cpp - the other three backends still
call it through their runtime shader-cache paths. Only D3D12
bypasses it now.
Test:
- Build: D3D12 backend links without unresolved symbols.
- Runtime: every VRAM upload that previously worked must still
work. Concrete test: any game's pre-rendered backdrop streaming
(FF7 entering new screens, MGS pre-rendered cutscene backdrops),
any FMV playback (Sony intro bookend, in-game cutscenes), and
any sprite-page reload (fighting-game character select). If
the embedded blob were wrong, framebuffer uploads would land
at wrong VRAM offsets and produce visible texture garble
within seconds of any of those activities.
- PGXP toggle: flip the "PGXP CPU mode" core option in RetroArch.
First flip rebuilds PSOs picking blob[1] vs blob[0]; subsequent
same-direction flips hit the PSO cache.
- Resolution scale toggle 1x <-> 4x: no PSO recompile (blob is
scale-independent post-9d2b49d); next CPU->VRAM upload pushes
a different u_resolution_scale through the cbuffer.
Next per the same template now that the toolchain is trusted and
the pattern is established: vram_fill_ps (8 variants on PGXP x
WRAPPED x INTERLACED, no scale-refactor needed - body doesn't
reference RESOLUTION_SCALE for D3D12 mode), vram_update_depth_ps
(2 MSAA variants - first MSAA texture-binding variant exercise),
vram_read_ps (M MSAA variants - on top of the e64fc28-line
cbuffer routing already done).
Second attempt at the cd971cd / da20f5b pre-bake, now with the
Microsoft fxc toolchain in place (09ca0dc). Same shadergen +
runtime changes as the reverted cd971cd; the only material
difference is that the .inc files are produced by Microsoft's
D3DCompile API instead of Wine's vkd3d-shader reimplementation,
which means the DXBC has the SHEX + STAT chunks that
CreateGraphicsPipelineState validation needs.
Output deltas vs the failed cd971cd attempt:
vram_copy_ps_pgxp0.inc 3108B (vkd3d) -> 1908B (Microsoft)
vram_copy_ps_pgxp1.inc 2984B (vkd3d) -> 1828B (Microsoft)
Microsoft's compiler produces smaller bytecode (better optimization
at /O3) and emits the full chunk set RDEF/ISGN/OSGN/SHEX/STAT,
where vkd3d-shader was emitting only ISGN/OSGN/RDEF/SHDR. The
SHEX chunk in particular is what changes here - it's the Shader
Model 5.0+ extended bytecode format that D3D12 PSO validation
expects for SM 5.0 shaders. SHDR is the older SM 4.0 format;
Microsoft D3D12 accepts SHDR for simple shaders by coincidence
of how the validator is structured, but rejects it for anything
with SV_Depth + discard + non-trivial cbuffer (the threshold
case cd971cd hit). SHEX-format output passes uniformly.
Validator confirmation:
Both .inc files stamp creator string
"Microsoft (R) HLSL Shader Compiler 10.1"; the
check_microsoft_creator hook in tools/regen_d3d12_dxbc.py
(ebd2300) passes them.
This restores the full set of changes that cd971cd shipped:
* data/shaders/d3d12/vram_copy.ps.hlsl - standalone HLSL source
matching GenerateVRAMCopyFragmentShader's D3D12 output. Cbuffer
layout member-for-member identical to VRAMCopyUBOData (48 bytes
- u_src_coords, u_dst_coords, u_end_coords, u_size,
u_set_mask_bit, u_depth_value, u_resolution_scale, u_pad0).
VRAM_SIZE alias inlined. PGXP_DEPTH branch in body controls
the o_depth assignment.
* tools/regen_d3d12_dxbc.py TEMPLATE_VARIANTS dict gains the
vram_copy.ps.hlsl entry with two rows (pgxp0, pgxp1).
* src/common/d3d12/embedded_shaders.h gains extern declarations
for k_vram_copy_ps_pgxp0[], _pgxp1[], and the matching
_size_bytes constants.
* src/common/d3d12/embedded_shaders.cpp gains two #include
lines inside namespace D3D12::EmbeddedShaders for the new
.inc files.
* src/core/gpu_hw_d3d12.cpp GetVRAMCopyPipeline: shadergen call
+ m_shader_cache.GetPixelShader path replaced with an inline
D3D12_SHADER_BYTECODE picked via m_pgxp_depth_buffer. PSO
build downstream is unchanged. The m_shadergen-not-yet-built
check is dropped for this path since the embedded blob is
statically linked.
Variant axis: PGXP_DEPTH only (2 blobs, ~3.7 KB total). Resolution
scale is cbuffer-routed since e56d4d4 so it's not a variant; MSAA
isn't a variant since vram_copy never runs in MSAA mode (texture
binding conflict on the source view).
Cost matrix delta (D3D12 specifically) for vram_copy_ps:
Cold-flip PGXP toggle: ~50 ms x 2 D3DCompile + ~10 ms x 2 PSO
-> ~10 ms x 2 PSO only.
Disk-cache-warm: ~1 ms each -> 0 ms.
Resolution scale: 0 ms (already cbuffer-routed).
Test:
- Build: D3D12 backend links without unresolved symbols.
- Runtime: FF7 menu navigation (heavy VRAM-copy traffic for
menu sprite composition) and Tekken 3 round transitions
(every-frame VRAM-copy splat for round number / TOTAL DMG
text) render correctly. Failure mode if the .inc were wrong:
visible sprite / text garble within a second of entering
a menu or starting a round. Since cd971cd's failure mode
was "D3D12 backend never inits", the success signal is
simply that the backend comes up at all - the cd971cd
log line "CreateGraphicsPipelineState failed: 80004005"
no longer fires.
- PGXP toggle: flip the "PGXP CPU mode" core option; the
first flip rebuilds PSOs picking blob[1] vs blob[0] and
renders correctly. Subsequent same-direction flips hit the
PSO cache.
- Resolution scale toggle 1x <-> 4x: no PSO recompile (the
blob is scale-independent post-e56d4d4); CopyVRAM next
frame pushes a different u_resolution_scale value through
the cbuffer.
If this attempt also fails, the diff to look at is the .inc bytes
themselves (Microsoft-compiled, full chunk set) vs cd971cd's
.inc (vkd3d-shader-compiled, missing SHEX/STAT). Anything else
in the source is identical.
Next on the pre-bake side per the same template now that
the toolchain is trusted: vram_write_ps (4 variants: PGXP x
use_ssbo), vram_fill_ps (8 variants, no scale-refactor needed),
vram_update_depth_ps (2 MSAA variants - first MSAA texture-binding
variant exercise).
Post-mortem follow-up to cd971cd / da20f5b. The pre-bake attempt
failed because Wine's bundled d3dcompiler_47.dll (which is the
vkd3d-shader reimplementation, currently at version 1.10) produces
DXBC that's syntactically valid as a container but trips Microsoft
D3D12's CreateGraphicsPipelineState with E_FAIL for non-trivial
shaders. The vram_copy.ps.hlsl case crossed that threshold; the
simpler fullscreen_quad.vs.hlsl + copy.ps.hlsl cases happen to
work and are still in the repo, but they were also vkd3d-shader-
compiled and should be regenerated with Microsoft fxc when the
opportunity arises.
The fix is twofold: improve the SDK auto-detection so contributors
who have Microsoft fxc installed don't have to fight the script,
and add an output validator that refuses to write .inc files
produced by any compiler that isn't Microsoft fxc.
Auto-detection improvements (find_fxc):
* Wine prefix discovery widened. Previously the script only
checked $WINEPREFIX/drive_c if WINEPREFIX was set. Now it also
checks ~/.wine (the Wine default when WINEPREFIX is unset),
and any prefix directory under ~/.local/share/wineprefixes/
that has a drive_c subtree (PlayOnLinux / lutris-style layouts).
Both /Program Files/ and /Program Files (x86)/ are searched in
each prefix.
* Error message now points at the README's installation steps
rather than telling the user to just install the SDK.
* Error message explicitly calls out that Wine's bundled
d3dcompiler_47.dll is NOT a substitute and references
da20f5b for context.
Output validator (extract_rdef_creator + check_microsoft_creator):
* extract_rdef_creator walks the DXBC container chunk index, finds
the RDEF chunk, follows the creator_offset field at chunk body
offset 24, and reads back the null-terminated ASCII creator
string. The DXBC container layout (16-byte hash + version +
total size + chunk count + chunk offsets) and the RDEF body
layout (constant_buffer_count, constant_buffer_offset,
resource_binding_count, resource_binding_offset, shader_version,
compiler_flags, creator_offset) are documented in MSDN's old
D3D11 reflection notes and in the wikitalk pages around DXBC;
the implementation here uses fixed offsets that match what
fxc.exe and vkd3d-shader both produce.
* check_microsoft_creator hooks into compile_one after the magic
check. It refuses with a clear error message if the creator
string doesn't contain "Microsoft". Microsoft fxc stamps
something like "Microsoft (R) HLSL Shader Compiler 10.1";
vkd3d-shader stamps "vkd3d-shader 1.10 (Wine bundled)". One
substring check disambiguates.
What the validator does NOT do:
* It does not retroactively reject existing .inc files in the
repo. The validator only fires on freshly-produced DXBC during
a regen run. The vkd3d-shader-built fullscreen_quad_vs.inc and
copy_ps.inc are unchanged by this commit; they'll get refreshed
the next time a contributor with Microsoft fxc runs the regen
script. Until then, they keep working because they're already
in the repo and the build just compiles them as plain C++
byte arrays - they never go through PSO validation (they're
already valid DXBC).
* It does not lock the script to a specific fxc version. Any
Microsoft fxc.exe (10.1, 10.5, the version that ships with the
Windows 11 SDK, etc.) is accepted - they all stamp "Microsoft"
in the creator string.
* It does not validate the binding layout vs the runtime root
signature. That's a future enhancement - the runtime side
expects specific (b0, t0, s0) layouts and the regen script
could cross-check, but that's a much bigger feature.
README changes:
* New "Microsoft fxc.exe is required" section spells out why and
cites the cd971cd / da20f5b failure as the worked example.
* "Installing Microsoft fxc.exe" subsection with separate
Windows / Linux instructions. Linux gets two paths: install
the SDK under a Wine prefix (auto-detected), or extract
fxc.exe + d3dcompiler_47.dll directly from the MSI with
msitools and pass --fxc. Both must live in the same dir so
Wine's loader prefers Microsoft's d3dcompiler_47.dll over its
bundled vkd3d-shader version.
* The auto-detection scope (WINEPREFIX, ~/.wine, ~/.local/share/
wineprefixes/*) is now documented so contributors know where
the script is looking.
This commit does NOT re-add the vram_copy.ps.hlsl source removed
by da20f5b. That comes back in a follow-up patch once a Microsoft
fxc-built .inc is available - same patch lands the .hlsl, the
.inc, and the call-site flip together (the dd54a73 lesson).
Test:
- python3 -c 'import ast; ast.parse(open("tools/regen_d3d12_dxbc.py").read())'
passes.
- Loading the script as a module and feeding the EXISTING
vkd3d-built copy_ps.inc into extract_rdef_creator returns
'vkd3d-shader 1.10 (Wine bundled)'; the Microsoft substring
check returns False. Confirms the validator would catch the
cd971cd mistake if anyone tries to reproduce it.
- find_fxc's broader Wine prefix scan is exercised by the
standard test of running the script in an environment without
Microsoft fxc; it now fails with the new pointed-at-README
message instead of the old generic SDK message.
This reverts commit cd971cd. The pre-baked DXBC blob causes
CreateGraphicsPipelineState to fail with E_FAIL (0x80004005)
during D3D12 backend Initialize, falling back to software
renderer. Confirmed by Lib's screenshot + log output:
[libretro INFO] [GPU_HW_D3D12] Max texture size: 16384x16384
[libretro INFO] [GPU_HW_D3D12] Dual-source blend: supported
[libretro INFO] [GPU_HW_D3D12] Per-sample shading: supported
[libretro INFO] [GPU_HW_D3D12] Max multisamples: 8
[libretro ERROR] [GetPipelineState] CreateGraphicsPipelineState failed: 80004005
[libretro ERROR] [Initialize] Failed to compile pipelines
Root cause is in the wine + vkd3d-shader compilation path used to
produce vram_copy_ps_pgxp{0,1}.inc. Inspecting the DXBC reveals
vkd3d-shader (vkd3d-shader 1.10 Wine bundled) strips the
SamplerState samp0_ss declaration from the RDEF chunk because the
shader uses .Load() not .Sample() so samp0_ss is unused:
copy_ps.inc RDEF: 3 bindings (samp0_ss, samp0, UBOBlock) - works
vram_copy_ps_pgxp0.inc RDEF: 2 bindings (samp0, UBOBlock) - fails
This SHOULD be fine since D3D12 allows the shader to use a subset
of the root signature's resource bindings. But the Microsoft D3D12
runtime rejects this particular blob at PSO creation - likely
some other metadata mismatch (SHEX vs SHDR chunk format, missing
STAT chunk, or vkd3d-shader emitting SV_Depth / discard in a form
Microsoft's runtime won't accept). Without D3D12 debug-layer
messages it's hard to localize further.
copy_ps and fullscreen_quad_vs (both Wine-compiled) work in
production, so vkd3d-shader output is not universally
incompatible - it's specific to this shader's combination of
features (SV_Depth output + discard + larger cbuffer + bool
member + uint arithmetic).
For future pre-bakes of more complex shaders, the .inc files
should be regenerated using the Microsoft fxc.exe from a Windows
10/11 SDK (running natively on Windows or under Wine - Microsoft's
fxc.exe is an x86 PE binary that runs fine under Wine, no
vkd3d-shader reimplementation in the path). The current
fullscreen_quad_vs + copy_ps blobs landed with vkd3d-shader
because they're simple enough that the resulting bytecode passes
PSO validation; vram_copy_ps is the threshold case where it
doesn't.
Next pre-bake attempt should:
1. Switch tools/regen_d3d12_dxbc.py to prefer Microsoft fxc.exe
by default (Wine prefix lookup + WINEPREFIX environment),
fall back to fxc_lite only when explicitly asked.
2. Regenerate fullscreen_quad_vs + copy_ps with Microsoft fxc
(to confirm byte-different output - and to lock in a known-
working reference for diff comparison when adding new
pre-baked shaders).
3. Then redo vram_copy_ps with Microsoft fxc; expect to land
it with no other changes needed.
The non-batch RESOLUTION_SCALE cbuffer refactor arc (e56d4d4,
9d2b49d, 2980961, e64fc28) is unaffected by this revert - those
commits don't touch any pre-baked blobs, just route u_resolution_scale
through cbuffers. The pre-bake follow-ups can resume once the
fxc.exe toolchain is in place.
First multi-variant pre-bake, exercising the TEMPLATE_VARIANTS
infrastructure in tools/regen_d3d12_dxbc.py for the first time.
vram_copy_ps is the smallest cleanly-pre-bakeable non-batch shader
after the e56d4d4 RESOLUTION_SCALE refactor took it from
PGXP x N variants down to just PGXP (2 blobs). Pure body-branch
variant axis - no texture binding changes, no MSAA split, no
input-layout differences. Body is small (~30 lines) and the
runtime call site is one function (GetVRAMCopyPipeline) in one
backend.
Why pre-bake vram_copy_ps:
* It's hit constantly during gameplay. Every PSX game uses
VRAM-to-VRAM copies for sprite caching (Final Fantasy 7's
pre-rendered backgrounds streaming sprites in, Tekken 3's
text rendering between rounds, every fighting game's HUD
composite, every JRPG's menu system).
* After e56d4d4 the only variant axis is PGXP_DEPTH on/off, so
2 blobs cover every (m_pgxp_depth_buffer, m_resolution_scale)
combination - cleanest possible variant count.
* It's the natural exercise for TEMPLATE_VARIANTS (which has
sat empty since the regen tool was first scaffolded at
ca8c9b0). Subsequent multi-variant pre-bakes (vram_write 4
variants, vram_read M MSAA variants, display 12 x MSAA
variants) reuse the same pattern.
Files added:
* data/shaders/d3d12/vram_copy.ps.hlsl: standalone HLSL source
matching the GenerateVRAMCopyFragmentShader output for D3D12
post-e56d4d4. The cbuffer layout matches VRAMCopyUBOData
member-for-member (u_src_coords, u_dst_coords, u_end_coords,
u_size, u_set_mask_bit, u_depth_value, u_resolution_scale,
u_pad0 = 48 bytes). VRAM_SIZE alias inlined since the helper
emission isn't accessible to standalone HLSL.
PGXP_DEPTH variant is a single #if in the body controlling
the o_depth assignment. MSAA path omitted entirely - vram_copy
never runs in MSAA mode because the source texture is bound
as both shader-resource AND framebuffer-output, which D3D12
doesn't permit with an MSAA resource; the runtime uses the
non-MSAA m_vram_read_texture shadow.
* src/common/d3d12/embedded_dxbc/vram_copy_ps_pgxp0.inc: DXBC
blob for /DPGXP_DEPTH=0 (PGXP off, conditional o_depth).
~3.1 KB of bytecode.
* src/common/d3d12/embedded_dxbc/vram_copy_ps_pgxp1.inc: DXBC
blob for /DPGXP_DEPTH=1 (PGXP on, o_depth = 1.0). ~3.0 KB.
Files modified:
* tools/regen_d3d12_dxbc.py: TEMPLATE_VARIANTS dict populated
with the vram_copy.ps.hlsl entry. Two variant rows:
("pgxp0", ["PGXP_DEPTH=0"])
("pgxp1", ["PGXP_DEPTH=1"])
The dispatch loop at line 232-238 (untouched, pre-existed
from ca8c9b0) does the right thing: emit one .inc per row,
identifier suffix from the variant_suffix string.
* src/common/d3d12/embedded_shaders.h: extern declarations
added for the two new blobs (k_vram_copy_ps_pgxp0,
k_vram_copy_ps_pgxp0_size_bytes, and pgxp1 pair). Each pair
matches the regen tool's naming convention.
* src/common/d3d12/embedded_shaders.cpp: two #include lines
added inside namespace D3D12::EmbeddedShaders, mirroring
what was done for fullscreen_quad_vs + copy_ps. The .inc
files define the storage; the prior extern declarations in
the header give them external linkage.
* src/core/gpu_hw_d3d12.cpp GetVRAMCopyPipeline: dropped the
shadergen-call + m_shader_cache.GetPixelShader path; replaced
with an inline D3D12_SHADER_BYTECODE constructed from the
embedded blob selected via m_pgxp_depth_buffer. Same PSO-
creation flow downstream (gpbuilder, MSAA state, depth state,
shader-cache PSO disk-cache via gpbuilder.Create). The
m_shadergen-not-yet-constructed check is dropped for this
path since the embedded blobs are statically linked - no
ordering dependency on shadergen lifetime.
Toolchain confirmation:
Built with Wine's d3dcompiler_47.dll via /tmp/fxc_lite/fxc_lite.exe
on the contributor side (same tooling as 77b255f / 443a2a1).
DXBC magic verified at regen time (the 'DXBC' signature in the
first 4 bytes; the regen tool aborts the build if that doesn't
match).
Cost matrix delta (D3D12 specifically):
vram_copy_ps D3DCompile cost on cold-cache flip: ~50 ms each
for the two PGXP variants -> 0 ms after this commit. The PSO
compile itself still runs through gpbuilder.Create (~10 ms),
so total cold-flip-of-PGXP cost drops by ~50 ms per variant.
Disk-cache-warm cost was already in the noise (~1 ms cache
lookup); now it's literally zero.
Progress tracker: non_batch_progress_units stays at 17 - we
still tick once per (depth_test) GetVRAMCopyPipeline call
inside the precompile_sync loop. PSO compile is still the
unit; we just stopped doing the D3DCompile half of that
work.
Variant count after this commit, for the cold-flip cost matrix
columns we care about, for vram_copy specifically:
* resolution_scale : 0 ms (cbuffer-routed since e56d4d4)
* pgxp_depth : 0 ms D3DCompile + ~10 ms PSO compile
* multisamples : 0 (not a vram_copy variant axis)
* filter / chroma : 0 (no relationship to vram_copy)
The shadergen GenerateVRAMCopyFragmentShader function is left
intact in gpu_hw_shadergen.cpp - the other three backends
(D3D11, OpenGL, Vulkan) still call it through their runtime
shader-cache paths. Only the D3D12 backend bypasses it now.
Future per-backend pre-bake work could extend the pattern
to those backends too (Vulkan via SPIR-V pre-bake, OpenGL via
something else - GLSL doesn't have a comparable offline-
compiled bytecode format; SPIR-V cross would be the route).
Test:
- Build: D3D12 backend should link without unresolved symbols.
The shadergen->GenerateVRAMCopyFragmentShader path is no
longer reachable through GetVRAMCopyPipeline on D3D12 but
the function is still defined and used by other backends.
- Runtime: every VRAM copy that previously worked must still
work. Concrete test - FF7 menu navigation (uses VRAM copy
for menu sprite composition heavily), Tekken 3 round-
transition text rendering (VRAM copy each frame to splat
the round number / TOTAL DMG sprites). If the embedded
blob were wrong, sprites and menu text would garble within
a second of entering a menu or starting a round.
- PGXP toggle: flip the "PGXP CPU mode" option on and off
in RetroArch's core options. The first flip recompiles
PSOs; the embedded blob path picks blob[1] vs blob[0] and
builds fresh PSOs. Subsequent same-direction flips hit the
PSO cache.
- Resolution scale toggle: 1x <-> 4x. No PSO recompile (since
the blob is scale-independent now); CopyVRAM next frame
just pushes a different u_resolution_scale value through
the cbuffer.
This is the first non-batch FRAGMENT pre-bake on top of the
RESOLUTION_SCALE refactor. Following the same template:
vram_write_ps (4 variants: PGXP x use_ssbo), vram_fill_ps (8
variants: PGXP x wrapped x interlaced, no refactor needed
since the body doesn't reference RESOLUTION_SCALE), and
vram_update_depth_ps (2 MSAA variants, exercises MSAA
texture-binding variant for the first time).
First step of the D3D12 pre-baked DXBC arc that was originally
flagged in 7b575a3's commit message as the natural follow-up to
the cbuffer / dim cache / chroma-split / non-batch-skip
optimisation series. Sets up the directory layout, regen tool,
and namespace scaffolding that subsequent patches will populate
with individual shader migrations.
Mirror of the Vulkan-side infrastructure that lives at
data/shaders/vulkan/ + src/common/vulkan/embedded_shaders.{h,cpp}
+ tools/regen_vulkan_spirv.py + src/common/vulkan/embedded_spirv/
(181 .inc files). The Vulkan side replaces glslang -> SPIR-V at
runtime with pre-compiled SPIR-V blobs; the D3D12 side will
replace D3DCompile -> DXBC at runtime with pre-compiled DXBC
blobs from fxc.exe.
Motivation: after the dim cache (10c53b8) and the chroma-split
(57ac62e), the D3D12 backend's UpdateSettings cost matrix has
one remaining 'still pays the full rebuild cost' class of
toggles - multisamples / per_sample_shading / uv_limits /
pgxp_depth / colour perspective - that genuinely invalidate
every HLSL variant in the 1164-cell batch pipeline matrix. On
a cold shader cache, walking that matrix synchronously costs on
the order of one minute under shader_precompile_mode = Enabled,
because every cell pays a fresh D3DCompile. Pre-baking the DXBC
eliminates the D3DCompile pass on those cells, dropping the
cold-flip cost to whatever the PSO-creation pass alone takes
(ID3D12Device::CreateGraphicsPipelineState, much faster than
D3DCompile + CreateGraphicsPipelineState).
The pre-bake also forecloses a class of 'd3dcompiler_47.dll
version drift invalidates the cached DXBC' failures the
runtime shader cache sometimes hits on driver updates.
Files in this scaffold patch:
* tools/regen_d3d12_dxbc.py - mirror of regen_vulkan_spirv.py
for the fxc.exe / DXBC path. Walks data/shaders/d3d12/*.hlsl,
determines stage from filename suffix (.vs.hlsl / .ps.hlsl /
.cs.hlsl / .gs.hlsl), compiles each via fxc /O3 /T <stage>_5_0
/E main, validates the output DXBC magic, and emits a .inc
with const uint8_t array + size_t size_bytes. Honours a
TEMPLATE_VARIANTS dict (initially empty) for shaders that need
multiple pre-baked variants via /D defines. Auto-detects
fxc.exe in the Windows 10 SDK install path; supports Wine on
Linux via --wine and explicit --fxc PATH.
In its empty-input case (the state immediately after this
patch lands) the script exits zero with a 'nothing to do'
message - no fxc lookup needed when there are no shaders to
compile, so the script is runnable on systems without the
Windows SDK / Wine until the first shader source actually
shows up under data/shaders/d3d12/.
* data/shaders/d3d12/README.md - workflow documentation mirror
of data/shaders/vulkan/README.md. Documents the
edit-.hlsl -> rerun-script -> commit-both convention, the
filename suffix -> shader stage mapping, the
TEMPLATE_VARIANTS partition for multi-variant blobs, and the
build-time constraint that the core build must never invoke
fxc.exe.
* src/common/d3d12/embedded_shaders.h - namespace
D3D12::EmbeddedShaders header. No extern declarations yet -
this patch lays down the namespace scaffold. Subsequent
patches add pairs of:
extern const uint8_t k_<stem>_<stage>[];
extern const size_t k_<stem>_<stage>_size_bytes;
per migrated shader. Comment block documents the (data, size)
-> D3D12_SHADER_BYTECODE aggregate-initialiser convention -
no wrapper helper needed (unlike Vulkan's CreateShaderModule
helper, because D3D12_SHADER_BYTECODE is a plain struct, not
an API call).
* src/common/d3d12/embedded_shaders.cpp - storage TU. Currently
empty inside the namespace block. As .inc files get added
under src/common/d3d12/embedded_dxbc/, each is #included
here from inside the namespace block so the arrays resolve
against the header's extern declarations.
* Makefile.libretro and src/common/CMakeLists.txt - register
embedded_shaders.cpp as a TU under the existing USE_D3D12
gate. Compiles as part of the libretro build whenever D3D12
support is enabled.
Subsequent patches in this arc will each:
1. Add data/shaders/d3d12/<name>.<stage>.hlsl from the runtime
ShaderGen output (cleaned up - no preprocessor noise that
fxc handles at compile time anyway).
2. Run tools/regen_d3d12_dxbc.py to produce the .inc(s).
3. Add the matching extern declarations to embedded_shaders.h
and the #include line to embedded_shaders.cpp.
4. Switch the D3D12 backend call site (typically in
gpu_hw_d3d12.cpp's GetXxxPipeline or CompilePipelines) to
bind the embedded blob via D3D12_SHADER_BYTECODE instead
of calling D3DCompile through the shared D3D11::ShaderCompiler
path.
Ordering preference: start with non-batch, single-variant
shaders (vram_read / vram_write / vram_update_depth /
vram_copy / vram_fill / display) to validate the pipeline
end-to-end with minimal blast radius. Then the multi-variant
display / chroma family. Then the batch matrix - which is the
bulk of the work and where the cold-flip cost actually lives.
Note: the .inc files don't exist yet because fxc.exe isn't
runnable in this submission environment (Linux without Wine /
Windows SDK). The script is functional and will produce
.inc files as soon as it gets run on a host with fxc.exe.
This patch is intentionally a foundation: build succeeds with
no behaviour change, runtime is untouched, and the next patch
in the arc adds the first shader source + its .inc + the
matching call-site flip.
Test:
- python3 tools/regen_d3d12_dxbc.py with no shader sources
exits 0 with 'nothing to do' message. No fxc.exe required.
- Build under USE_D3D12=1: embedded_shaders.cpp compiles
cleanly as an empty namespace TU. No new symbols emitted.
- Build under USE_D3D12=0: embedded_shaders.cpp is excluded
from the build per the existing if(USE_D3D12) gate in
src/common/CMakeLists.txt and the ifeq guard in
Makefile.libretro.
- Runtime: no behavior change. D3D12 backend continues to
compile every shader through the existing D3DCompile path.
Patch 15 in the glslang-elimination series. Final batch FS conversion
covering all three remaining texture filter families:
- Bilinear / BilinearBinAlpha (24 blobs)
- JINC2 / JINC2BinAlpha (24 blobs)
- xBR / xBRBinAlpha (24 blobs)
After this lands, every batch FS slot in m_batch_fragment_shaders is
filled from a pre-baked SPIR-V blob; the runtime shadergen path for
batch shaders is gone. The m_shadergen unique_ptr and its
construction in CompilePipelines are removed since they have no
consumers left.
Each filter family shares the same 4-axis structural cube as the
patch-15-Bilinear-prep work that immediately preceded this commit:
- Input interpolation qualifier (none / centroid / sample). 3.
- Color input perspective (standard / noperspective). 2.
- Dual-source output (1 vs 2 outputs). 2.
- PGXP depth output (writes gl_FragDepth or omits it). 2.
3 x 2 x 2 x 2 = 24 blobs per filter family. UV_LIMITS is implicit
for all non-Nearest filter families because ShouldUseUVLimits() in
gpu_hw.cpp forces m_using_uv_limits = true whenever
m_texture_filtering != Nearest. The *BinAlpha variant of each
family collapses into the BINALPHA per-call specialisation constant
(id=110) rather than a structural axis - the only SPIR-V difference
is a single ialpha-quantisation step at the end of
FilteredSampleFromVRAM.
Filter bodies are lifted from gpu_hw_shadergen.cpp WriteBatchTexture-
Filter:
- Bilinear lines ~188-224 (4-tap weighted average)
- JINC2 lines ~229-374 (4x4-tap sinc-windowed with anti-ring)
- xBR lines ~381-661 (5x5 neighbourhood, YCbCr edge
detection with BLEND_NONE / NORMAL /
DOMINANT directions per quadrant)
The xBR template is the largest of the three (~17 KiB per blob in
binary, the body is ~280 lines of GLSL). The translation from the
shadergen DSL is mechanical: float4 -> vec4, lerp -> mix, frac ->
fract, sign -> sign, VECTOR_EQ -> all(equal(...)), VECTOR_NEQ ->
any(notEqual(...)). The P() helper macro on xBR closes over coords
and uv_limits the same way the shadergen original does.
One xBR quirk is preserved verbatim: the Iw flag computation in
shadergen uses VECTOR_NEQ(H, ...) instead of VECTOR_NEQ(I, ...)
which is almost certainly a bug, but the alternative output would
differ visually from the released shadergen path. Preserving it
keeps the embedded-vs-shadergen output byte-identical for compat;
fixing it can be a follow-up patch with its own visual-test cycle.
GetBatchFragmentShader is now a switch on m_texture_filtering with
no fallback: every filter resolves to one of the embedded helpers.
The 'dual_source = ... || filter != Nearest' branch is preserved
verbatim from the shadergen-side derivation.
GenerateBatchFragmentShader and the m_shadergen unique_ptr are no
longer referenced. The construction at CompilePipelines is removed
along with the reset in DestroyPipelines and the declaration in
the header. The 'gpu_hw_shadergen.h' include is dropped from both
gpu_hw_vulkan.cpp and gpu_hw_vulkan.h. shader_compiler.{h,cpp},
dep/glslang/, and the Makefile / CMake glslang references are NOT
removed in this patch - that final cleanup will land separately
once this patch has been confirmed working in the wild, on the
theory that backing it out is easier with the runtime path's
support files still present.
Smoke tests:
- g++ -fsyntax-only on the touched common TU.
- spirv-val --target-env vulkan1.0 on all 72 new blobs: 72/72 valid.
- Total .inc text size for the three filter families: ~9.2 MiB
(Bilinear ~1.4 MiB, JINC2 ~2.6 MiB, xBR ~4.7 MiB). Binary
contribution is ~25% of those numbers, so adding ~2.3 MiB to
the .so. xBR alone is ~1.2 MiB binary contribution; this is the
largest single chunk of pre-baked SPIR-V in the project.
Test priority - this patch covers the actively-rendered path for
users who enable any non-Nearest filter, so:
- **Bilinear / BilinearBinAlpha**: smooth edges on textured
surfaces, slight softening of palette textures. Test by setting
the texture filter core option to Bilinear / Bilinear (BinAlpha).
- **JINC2 / JINC2BinAlpha**: sharper sampling than Bilinear with
visible anti-ringing on textured polygons. Heavier per-pixel
cost; testing on FF8/9 backgrounds, MGS textured screens, etc.
- **xBR / xBRBinAlpha**: pixel-art upscaler, very visible smooth
edges on 2D sprites. Best exercise targets are 2D-heavy games -
Castlevania SOTN, Symphony of the Night, Mega Man X4-6, the
Suikoden series. xBR is the most complex shader in the project
and produces visually-distinctive output that immediately
reveals miscompilation.
- All three families x every precompile mode (Disabled / Lazy /
Enabled) x antialiasing toggle round-trips.
- Cross-check: switch m_texture_filtering at runtime between all
six filter values plus Nearest. Each transition should produce
visibly-correct rendering without intermediate corruption.
After this lands and is confirmed working, the final patch in the
series will remove dep/glslang/, src/common/vulkan/shader_compiler
.{h,cpp}, and the Makefile.libretro / CMakeLists.txt entries that
pull glslang into the link.
Patch 14 in the glslang-elimination series. Second slice of the
batch FS conversion: the textured + Nearest-filter path
(texture_mode != Disabled AND m_texture_filter == Nearest). The
runtime decision in GetBatchFragmentShader now routes both the
untextured slice (patch 13) and this slice through the embedded
blob set; only textured non-Nearest still goes through
shadergen + glslang.
Five SPIR-V-structural axes (48 blobs total = 3 x 2 x 2 x 2 x 2):
- Input interpolation qualifier (none / centroid / sample). 3.
- Color input perspective (standard / noperspective). 2.
- Dual-source output (1 vs 2 outputs). 2.
- PGXP depth output (writes gl_FragDepth or omits it). 2.
- UV limits (without / with v_uv_limits flat input). 2.
The UV_LIMITS axis is new vs the untextured slice - it controls
whether v_uv_limits is declared as a per-vertex flat input on the
FS, matching the per-session m_using_uv_limits choice that already
drives the matching batch VS structural pick. Without UV limits the
FS skips the per-sample clamp.
Three new per-call specialisation constants relative to the
untextured slice cover the textured texture_mode encoding:
id = 107 PALETTE_4_BIT (bool, actual_texture_mode == 0)
id = 108 PALETTE_8_BIT (bool, actual_texture_mode == 1)
id = 109 RAW_TEXTURE (bool, RawTextureBit set in texture_mode)
PALETTE = PALETTE_4_BIT || PALETTE_8_BIT is derived inside the
shader. The texture_mode bit layout is described in
src/core/gpu_types.h; the C++ side derives the three boolean spec
const values from the per-call texture_mode in GetBatchPipeline.
Untextured blobs do not declare 107-109; passing them is harmless
per the Vulkan spec (unrecognised spec const IDs in the supplied
VkSpecializationInfo are silently dropped).
The shader body covers the helpers the shadergen path inlines:
ApplyTextureWindow, ApplyUpscaledTextureWindow, FloatToIntegerCoords,
RGBA8ToRGBA5551, and SampleFromVRAM. SampleFromVRAM splits on the
derived PALETTE flag and, within the palette branch, on
PALETTE_4_BIT vs PALETTE_8_BIT to do the correct sub-texel address
arithmetic. fixYCoord on Vulkan is the identity function so we use
the coord directly. The Vulkan-only API_VULKAN-y-flip in the VS
already accounts for sample-space orientation.
Output and discard logic mirrors the shadergen TEXTURED branches:
the no-TRANSPARENCY case writes o_col0 (and o_col1 when DUAL_SOURCE)
unconditionally; the TRANSPARENCY case branches on the texel's
semitransparency bit and applies the TRANSPARENCY_ONLY_OPAQUE /
TRANSPARENCY_ONLY_TRANSPARENT per-texel discard the way the
shadergen does.
Helper-side index encoding for the 48-blob array, matching
GetBatchTexturedNearestFragmentShaderBlob in embedded_shaders.cpp:
interp = per_sample_shading ? 2 : (msaa ? 1 : 0) (0..2)
persp = noperspective_color ? 1 : 0 (0..1)
dual = dual_source ? 1 : 0 (0..1)
pgxp = pgxp_depth ? 1 : 0 (0..1)
uv = uv_limits ? 1 : 0 (0..1)
index = interp*16 + persp*8 + dual*4 + pgxp*2 + uv (0..47)
The use_dual_source derivation in GetBatchFragmentShader matches
the shadergen-side check exactly: supports_dual_source_blend &&
((render_mode is transparent) || filter != Nearest). For the two
embedded branches (untextured and textured Nearest) the filter-half
of the OR evaluates false, so both branches fall through to the
render_mode test.
Smoke tests:
- g++ -fsyntax-only on the touched common TU.
- spirv-val --target-env vulkan1.0 on all 48 blobs - 48/48 valid.
- Total .inc size: ~2.2 MiB across all 48 blobs (~46 KiB each in
text form, which is the 0xNNNNNNNNu, packed layout from the regen
tool; binary contribution to the linked output is roughly 1/4 of
that, so ~550 KiB. Acceptable for a renderer that previously
pulled in glslang at runtime).
- --target-env vulkan1.0 vs un-flagged glslangValidator: byte-
identical for every variant.
Test priority:
- Routine smoke under Enabled / Lazy / Disabled with Nearest
filter (the default). Any textured polygon in any game now
exercises the embedded path: dialogue portraits, sprite layers,
background textures - the vast majority of pixels in most
games.
- Toggle PGXP UV correction (drives m_using_uv_limits) to flip
the UV_LIMITS structural axis. Games that benefit most from
PGXP corrections - Final Fantasy series, Tekken 3, Soul Blade -
are good exercise targets.
- Antialiasing toggle round-trip under Disabled mode per the
patch-5-fix protocol (flips interpolation axis).
- Each texture mode is exercised by different draws: palette
textures dominate (most game art is 4-bit indexed), with
direct-16bpp showing up for render-to-texture effects. Raw
textures appear in framebuffer effects and some UI passes.
- Cross-check with shadergen path by switching texture filter to
Bilinear (still on the shadergen path) and back to Nearest -
rendering should remain consistent across the switch.
After this lands, the only remaining glslang consumers in the
Vulkan backend are the texture-filter slices (Bilinear /
BilinearBinAlpha, JINC2 / JINC2BinAlpha, xBR / xBRBinAlpha). Each
of those filter families has its own FilteredSampleFromVRAM body
and will get its own template in subsequent patches.
Patch 13 in the glslang-elimination series. First slice of the batch
FS conversion (Bucket B's bigger half) - the untextured path
(texture_mode == GPUTextureMode::Disabled). Solid-shaded polygons
with no VRAM sampling, no palette logic, no texture filter
machinery, no UV limit logic; the shader is comparatively simple
and a good first cut into the FS state space.
Four SPIR-V-structural axes (24 blobs total = 3 x 2 x 2 x 2):
- Input interpolation qualifier on v_col0, matching the batch VS
this FS is bound with. None / centroid / sample. (3)
- Color input perspective. Standard / noperspective. (2)
- Dual-source colour output. With dual-source-blend hardware the
TransparentAndOpaque and OnlyTransparent render modes write a
second colour at (location 0 index 1) that drives SRC1_COLOR /
SRC1_ALPHA. The pipeline blend state references SRC1_* or it
does not - the output declaration count must match. (2)
- PGXP depth output. With PGXP Depth Buffer enabled the FS omits
gl_FragDepth so the rasterizer-interpolated VS depth (a_pos.w
under PGXP) is used directly and early-Z stays available.
Splitting this structurally preserves the early-Z optimisation
that the original shadergen also relies on. (2)
Per-call knobs (TRANSPARENCY tri-state from BatchRenderMode,
DITHERING, INTERLACING) and the remaining per-session knobs
(TRUE_COLOR, DITHERING_SCALED, RESOLUTION_SCALE) collapse into
specialisation constants applied at pipeline-create time:
id = 0 RESOLUTION_SCALE (uint, per-session)
id = 100 TRANSPARENCY (bool, per-call)
id = 101 TRANSPARENCY_ONLY_OPAQUE (bool, per-call)
id = 102 TRANSPARENCY_ONLY_TRANSPARENT (bool, per-call)
id = 103 DITHERING (bool, per-call)
id = 104 INTERLACING (bool, per-call)
id = 105 DITHERING_SCALED (bool, per-session)
id = 106 TRUE_COLOR (bool, per-session)
The TRANSPARENCY trio encodes the BatchRenderMode enum:
TransparencyDisabled -> (false, *, *)
TransparentAndOpaque -> (true, false, false)
OnlyOpaque -> (true, true, false)
OnlyTransparent -> (true, false, true)
These are spec consts applied to the FS in GetBatchPipeline.
The same constant_id values are passed to the runtime shadergen-
compiled textured FS as well, where they are silently dropped per
the Vulkan spec (unrecognised spec const IDs in the supplied
VkSpecializationInfo are ignored).
GetBatchFragmentShader now branches on lookup_mode at the slot-
miss path: GPUTextureMode::Disabled goes to the embedded blob set,
everything else continues through GenerateBatchFragmentShader +
g_vulkan_shader_cache->GetFragmentShader. The textured slices land
in subsequent patches, one or two texture filter values at a time
(Nearest first, then Bilinear / BilinearBinAlpha / JINC2 / xBRZ).
The regen tool's TEMPLATE_VARIANTS manifest grows a second entry
covering the 24 untextured FS variants alongside the 18 batch VS
variants that were already there. Same -D-flag-driven template
mechanism as patch 12. The unused 'fs' local at the bottom of
GetBatchPipeline before the SetFragmentShader call now collects
the FS spec constant info; both batch VS and FS spec constants
are independent VkSpecializationInfo blobs per Vulkan rules.
Smoke tests:
- g++ -fsyntax-only on the touched common TU.
- spirv-val --target-env vulkan1.0 on all 24 blobs - 24/24 valid.
- Total .inc size: ~127 KiB across all 24 blobs (~5 KiB each).
- --target-env vulkan1.0 vs un-flagged glslangValidator: byte-
identical for every variant.
Untextured batch draws are extremely common - solid-shaded
polygons in 2D HUDs, fills, debug overlays, the framebuffer clear
quads at the top of every frame on many games. If the embedded
untextured FS is wrong it will be IMMEDIATELY obvious on the first
frame of any game (HUD bars / lifebars / dialogue boxes will be
visibly broken).
Test priority:
- Routine smoke under Enabled / Lazy / Disabled. Boot any game
and watch the HUD: solid-shaded health/mana bars (most JRPGs),
fade-in/fade-out solid alpha overlays (cutscenes), and 2D menu
backgrounds are direct exercises of this path.
- Antialiasing toggle round-trip under Disabled mode per the
patch-5-fix protocol, confirming the structural blob-pick
flips cleanly across interpolation axes as m_multisamples /
m_per_sample_shading change.
- Toggle PGXP Depth Buffer at runtime to flip the PGXP_DEPTH
structural axis. Behaviour should be unchanged from the
shadergen baseline.
- Toggle 'disable color perspective' (under Texture Correction)
to flip the perspective axis.
Patch 12 in the glslang-elimination series, and the first step into
Bucket B (batch shaders). The batch VS state space has three SPIR-V-
structurally-distinct axes that specialisation constants cannot fold:
1. Vertex attribute layout. 2 inputs (untextured), 4 (textured
without UV limits) or 5 (textured with UV limits). The 'in <type>
<name>' declarations are part of the SPIR-V module interface.
2. Output interpolation qualifier on the v_col0 / v_tex0 outputs.
None / centroid / sample, selected per session by UsingMSAA() /
UsingPerSampleShading(). These compile to OpMemberDecorate
Centroid / Sample on the VertexData output block, which is not
a spec-constant-controllable property of the SPIR-V module.
3. Color output perspective. m_disable_color_perspective toggles a
'noperspective' qualifier on v_col0, compiling to
OpMemberDecorate NoPerspective.
3 x 3 x 2 = 18 structurally distinct blobs. Body-level knobs
(RESOLUTION_SCALE, PGXP_DEPTH) are common-knob specialisation
constants on every blob (constant_id = 0 and 3 per the project
convention).
To avoid maintaining 18 hand-edited .glsl files, the source is a
single template (data/shaders/vulkan/batch.vert.glsl) with #if
guards on TEXTURED, UV_LIMITS, INTERP_CENTROID / INTERP_SAMPLE, and
NOPERSP. The regen tool (tools/regen_vulkan_spirv.py) is extended
with a TEMPLATE_VARIANTS manifest that compiles the template once
per variant with the corresponding -D flags. Build-time impact is
zero - the script is still developer-only and the .inc files are
checked in.
The matching index encoding lives in src/common/vulkan/embedded_-
shaders.cpp next to the lookup helper:
attr = !textured ? 0 : (uv_limits ? 2 : 1) (0..2)
interp = per_sample_shading ? 2 : (msaa ? 1 : 0) (0..2)
persp = noperspective_color ? 1 : 0 (0..1)
index = attr * 6 + interp * 2 + persp (0..17)
The C++ side calls GetBatchVertexShaderBlob with the per-session
state (m_using_uv_limits, m_multisamples > 1, m_per_sample_shading,
m_disable_color_perspective) and the per-call 'textured' loop
variable to pick the right blob in CompilePipelines. The existing
m_batch_vertex_shaders[2] cache shape is preserved - the helper just
selects which two of the 18 blobs to instantiate this session.
Spec constants are applied at PIPELINE-create time inside
GetBatchPipeline rather than at module-create time, matching the
SpecConstants infrastructure laid down in patch 3. The values are
session-constant, so they are the same for every batch pipeline in
a session and the driver caches them keyed by (module + spec values)
in the pipeline cache.
Header-side ergonomics: instead of declaring 36 individual extern
arrays (18 SPIR-V + 18 size), the .h declares a small
EmbeddedShaderBlob struct and a single
k_batch_vs_blobs[18] array, plus the GetBatchVertexShaderBlob
helper. The same struct is intended to be reused for the eventual
batch FS conversion (likely many more blobs given the texture filter
state space).
Smoke tests:
- g++ -fsyntax-only on the touched common TU.
- spirv-val --target-env vulkan1.0 on all 18 blobs - 18/18 valid.
- Total .inc size: ~53 KiB across all 18 blobs.
- --target-env vulkan1.0 vs un-flagged glslangValidator: byte-
identical for every variant.
The batch VS is filled in CompilePipelines for all three precompile
modes (Enabled, Lazy, Disabled), so this conversion does not change
the hot-path-pre-build pattern from the patch 10-fix. The two VS
modules are present before any batch draw on every code path.
Test priority:
- Routine smoke under Enabled / Lazy / Disabled. Any rendering at
all exercises both VS modules immediately, so visual regressions
show up on the first frame of the first game booted.
- SSAA / MSAA round-trip in Disabled mode (per the patch-5-fix
protocol), specifically to confirm the structural-blob-pick
flips through 'none' -> 'centroid' -> 'sample' interp variants
cleanly as m_multisamples changes.
- Toggle 'disable color perspective' core option (under Texture
Correction) to flip the perspective axis; visual difference is
subtle but the blob-pick change is real.
- Toggle PGXP Geometry Correction (drives UV_LIMITS via
m_using_uv_limits) and PGXP Depth Buffer (drives PGXP_DEPTH
spec const) to flip the body and attribute-layout axes.
After this lands, the only remaining runtime glslang consumer in
the Vulkan backend is the batch FS (GenerateBatchFragmentShader at
gpu_hw_shadergen.cpp line ~667). That is a far larger state space
- six texture filters x ~14 boolean macros plus the structural
USE_DUAL_SOURCE / PALETTE_* axes - and will need to land in
several patches, one or two texture filters at a time.
This is the probe patch in a series that eliminates dep/glslang from the
libretro core build. It establishes the infrastructure - the GLSL source
tree, the embedded-SPIR-V loader, the regeneration tool, and the build
wiring - by converting exactly one call site so the pattern can be
smoke-tested in isolation before the rest of Bucket A and then Bucket B
follow in subsequent patches. glslang stays in the tree until the final
patch in the series, which removes dep/glslang and the surrounding
shader_compiler.cpp.
What this patch does:
- Adds data/shaders/vulkan/screen_quad.vert.glsl - the GLSL source for
the screen-quad VS, kept in the tree for human readability. The build
does NOT see this file; it is consumed only by the offline regen tool.
- Adds src/common/vulkan/embedded_spirv/screen_quad_vs.inc - the
pre-compiled SPIR-V blob as a 'const uint32_t[]' (367 words, 1.4 KiB),
generated offline from the .glsl by glslangValidator targeting
vulkan1.0. The .inc is checked in and #include'd by embedded_shaders.cpp
inside namespace Vulkan::EmbeddedShaders. spirv-val confirms the blob
is valid Vulkan 1.0 SPIR-V (magic 0x07230203, version 1.0).
- Adds src/common/vulkan/embedded_shaders.{h,cpp}. The header exposes a
pair of extern declarations per blob and a single
CreateShaderModule(const uint32_t*, size_t) loader. The loader
intentionally bypasses Vulkan::ShaderCache - pre-baked SPIR-V is
already final, so there is nothing to compile and nothing worth
caching on disk. Just a sized-and-checked vkCreateShaderModule call.
- Adds tools/regen_vulkan_spirv.py - the offline workflow for
contributors who edit shader .glsl sources. It invokes
glslangValidator on each .glsl under data/shaders/vulkan/ and rewrites
the matching .inc. CRITICAL: this tool is NEVER invoked by Make or
CMake. The build sees only .h/.cpp/.inc files and has no shader-
compiler dependency. Contributors run the script manually after
editing .glsl, commit both files together.
- Adds data/shaders/vulkan/README.md documenting the workflow and the
invariant that the build must never invoke an external shader
compiler.
- Switches GPU_HW_Vulkan::GetFullscreenQuadVertexShader() (in
src/core/gpu_hw_vulkan.cpp) from
g_vulkan_shader_cache->GetVertexShader(m_shadergen->Generate...)
to
Vulkan::EmbeddedShaders::CreateShaderModule(k_screen_quad_vs, ...).
The m_shadergen null-check is removed since the embedded path has no
such ordering dependency. The function's contract (lazy creation,
stored in m_fullscreen_quad_vertex_shader, returned to multiple
pipeline builders) is unchanged.
- Registers src/common/vulkan/embedded_shaders.cpp in both
Makefile.libretro (alphabetical order in the vulkan/ SOURCES_CXX
block) and src/common/CMakeLists.txt (alphabetical order in the
common target's source list). Neither change adds any build-tool
dependency; the new .cpp compiles like any other.
What this patch does NOT do:
- It does not remove dep/glslang or the SOURCES_CXX entries that pull
in its 99 translation units. glslang is still needed for every shader
generator that has not yet been converted - in particular all of
GPU_HW_ShaderGen, plus the remaining utility shaders (UV quad VS,
VRAM read/copy/write/fill/update-depth FS, display FS, adaptive
downsample mip/blur/composite FS, box-sample downsample FS).
Subsequent patches in this series convert those one bucket at a time.
The final patch removes dep/glslang, src/common/vulkan/shader_compiler.{h,cpp},
the glslang link line in CMake, and the Makefile entries.
- It does not touch the disk-backed Vulkan::ShaderCache. That cache
still serves the runtime-glslang path for remaining shaders.
Smoke tests performed in isolation:
- glslangValidator --target-env vulkan1.0 succeeds on the .glsl source,
producing 367 32-bit words of SPIR-V.
- spirv-val --target-env vulkan1.0 reports VALID on the blob.
- spirv-dis confirms the entry point, VertexData block, and Position/
VertexIndex built-ins are correctly emitted.
- A standalone harness including the .inc inside the
Vulkan::EmbeddedShaders namespace and calling CreateShaderModule
through a stubbed vkCreateShaderModule reads back the correct magic
word and size.
- g++ -fsyntax-only on embedded_shaders.cpp against the real headers
in the tree (excluding only the platform-specific X11 surface define
not used by this TU) is clean.
Smoke tests that require the user's setup:
- Real build on Windows (RTX 5090) and macOS.
- Vulkan core boots, RetroArch's pipeline cache populates, and at
least one game renders past the first frame using the screen-quad
pipeline (VRAM ops, display, downsample - all of which call
GetFullscreenQuadVertexShader internally).