TsundereStation/tools/regen_vulkan_spirv.py

275 lines
9.9 KiB
Python
Raw Normal View History

common/vulkan, core: pre-bake screen-quad VS, no glslang at runtime 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).
2026-05-17 17:49:19 +00:00
#!/usr/bin/env python3
# Regenerate embedded Vulkan SPIR-V blobs from GLSL sources.
#
# This script is NOT invoked by the core build. It is run by contributors who
# edit shader sources under data/shaders/vulkan/. The build itself only sees
# the resulting .inc files (checked into src/common/vulkan/embedded_spirv/),
# so the libretro core has zero glslangValidator dependency.
#
# Usage:
# python3 tools/regen_vulkan_spirv.py [--glslang PATH]
#
# Requires glslangValidator from the Vulkan SDK or the `glslang-tools`
# package on Debian / Ubuntu.
import argparse
import os
import re
import struct
import subprocess
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
GLSL_DIR = REPO_ROOT / "data" / "shaders" / "vulkan"
INC_DIR = REPO_ROOT / "src" / "common" / "vulkan" / "embedded_spirv"
# Map glsl file suffix to glslangValidator stage flag. Anything not in this
# table is skipped with a warning.
STAGE_FROM_SUFFIX = {
".vert.glsl": ("vert", "vs"),
".frag.glsl": ("frag", "fs"),
".comp.glsl": ("comp", "cs"),
".geom.glsl": ("geom", "gs"),
}
common/vulkan, core: pre-bake batch VS (18-blob template, 2 spec consts) 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.
2026-05-17 22:55:46 +00:00
# Templates: shader sources that produce more than one .inc output, each
# with a different combination of -D preprocessor defines. Index ordering
# below MUST match the helper in src/common/vulkan/embedded_shaders.cpp
# that picks the right blob at runtime - if you add a variant here, add
# the matching entry there too.
#
# For each entry: filename -> [(variant_suffix, [-D defines]), ...]
def _batch_vs_variants():
out = []
# Attribute layout: untextured / textured / textured + UV limits.
attr_axes = [
("untextured", []),
("textured", ["TEXTURED"]),
("textured_uvlim", ["TEXTURED", "UV_LIMITS"]),
]
# Output interpolation: standard / centroid (MSAA) / sample (SSAA).
interp_axes = [
("none", []),
("centroid", ["INTERP_CENTROID"]),
("sample", ["INTERP_SAMPLE"]),
]
# Color perspective: standard / noperspective.
persp_axes = [
("persp", []),
("noperp", ["NOPERSP"]),
]
for a_name, a_defs in attr_axes:
for i_name, i_defs in interp_axes:
for p_name, p_defs in persp_axes:
suffix = f"{a_name}_{i_name}_{p_name}"
out.append((suffix, a_defs + i_defs + p_defs))
return out
common/vulkan, core: pre-bake batch FS untextured slice (24 blobs) 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.
2026-05-17 23:12:22 +00:00
def _batch_fs_untextured_variants():
out = []
# Output interpolation: standard / centroid (MSAA) / sample (SSAA).
# MUST match the batch VS chosen by the C++ side.
interp_axes = [
("none", []),
("centroid", ["INTERP_CENTROID"]),
("sample", ["INTERP_SAMPLE"]),
]
# Color perspective: standard / noperspective. MUST match batch VS.
persp_axes = [
("persp", []),
("noperp", ["NOPERSP"]),
]
# Dual-source colour output: 1 attachment vs 2 (location 0
# index 0/1). Pipeline blend state references SRC1_* or it does
# not - per-call decision driven by transparency_mode AND
# m_supports_dual_source_blend.
dual_axes = [
("nodual", []),
("dual", ["DUAL_SOURCE"]),
]
# PGXP depth axis: when set, the FS omits gl_FragDepth so the
# rasterizer-interpolated VS depth (a_pos.w under PGXP) is used
# directly and early-Z stays available. Per-session.
pgxp_axes = [
("pgxpoff", []),
("pgxpon", ["PGXP_DEPTH"]),
]
for i_name, i_defs in interp_axes:
for p_name, p_defs in persp_axes:
for d_name, d_defs in dual_axes:
for x_name, x_defs in pgxp_axes:
suffix = f"{i_name}_{p_name}_{d_name}_{x_name}"
out.append((suffix, i_defs + p_defs + d_defs + x_defs))
return out
common/vulkan, core: pre-bake batch FS textured Nearest slice (48 blobs) 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.
2026-05-17 23:36:53 +00:00
def _batch_fs_textured_nearest_variants():
out = []
interp_axes = [
("none", []),
("centroid", ["INTERP_CENTROID"]),
("sample", ["INTERP_SAMPLE"]),
]
persp_axes = [("persp", []), ("noperp", ["NOPERSP"])]
dual_axes = [("nodual", []), ("dual", ["DUAL_SOURCE"])]
pgxp_axes = [("pgxpoff", []), ("pgxpon", ["PGXP_DEPTH"])]
uv_axes = [("nouv", []), ("uv", ["UV_LIMITS"])]
for i_name, i_defs in interp_axes:
for p_name, p_defs in persp_axes:
for d_name, d_defs in dual_axes:
for x_name, x_defs in pgxp_axes:
for u_name, u_defs in uv_axes:
suffix = f"{i_name}_{p_name}_{d_name}_{x_name}_{u_name}"
out.append((suffix, i_defs + p_defs + d_defs + x_defs + u_defs))
return out
common/vulkan, core: pre-bake batch VS (18-blob template, 2 spec consts) 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.
2026-05-17 22:55:46 +00:00
TEMPLATE_VARIANTS = {
common/vulkan, core: pre-bake batch FS textured Nearest slice (48 blobs) 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.
2026-05-17 23:36:53 +00:00
"batch.vert.glsl": _batch_vs_variants(),
"batch_untextured.frag.glsl": _batch_fs_untextured_variants(),
"batch_textured_nearest.frag.glsl": _batch_fs_textured_nearest_variants(),
common/vulkan, core: pre-bake batch VS (18-blob template, 2 spec consts) 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.
2026-05-17 22:55:46 +00:00
}
common/vulkan, core: pre-bake screen-quad VS, no glslang at runtime 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).
2026-05-17 17:49:19 +00:00
def find_glslang(explicit):
if explicit:
return explicit
for name in ("glslangValidator", "glslangValidator.exe"):
from shutil import which
path = which(name)
if path:
return path
sys.stderr.write(
"error: glslangValidator not found on PATH. Install the Vulkan SDK\n"
" or the glslang-tools package, or pass --glslang PATH.\n")
sys.exit(1)
def sanitize_identifier(stem):
# Map "screen_quad.vert" -> "screen_quad_vs"; only [A-Za-z0-9_] survive.
name = re.sub(r"[^A-Za-z0-9_]", "_", stem)
return name
common/vulkan, core: pre-bake batch VS (18-blob template, 2 spec consts) 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.
2026-05-17 22:55:46 +00:00
def compile_one(glslang, glsl_path, stage_flag, defines=None):
common/vulkan, core: pre-bake screen-quad VS, no glslang at runtime 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).
2026-05-17 17:49:19 +00:00
# Write SPIR-V to a temp file under INC_DIR so we don't pollute /tmp on
# restricted-filesystem hosts.
spv_path = INC_DIR / (glsl_path.stem + ".spv.tmp")
cmd = [
glslang,
"--target-env", "vulkan1.0",
"-S", stage_flag,
"-V", str(glsl_path),
"-o", str(spv_path),
]
common/vulkan, core: pre-bake batch VS (18-blob template, 2 spec consts) 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.
2026-05-17 22:55:46 +00:00
for d in defines or ():
cmd.append(f"-D{d}")
common/vulkan, core: pre-bake screen-quad VS, no glslang at runtime 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).
2026-05-17 17:49:19 +00:00
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
sys.stderr.write(f"glslangValidator failed for {glsl_path.name}:\n")
sys.stderr.write(result.stdout)
sys.stderr.write(result.stderr)
if spv_path.exists():
spv_path.unlink()
sys.exit(1)
data = spv_path.read_bytes()
spv_path.unlink()
if len(data) % 4 != 0:
sys.stderr.write(
f"error: {glsl_path.name} produced {len(data)} bytes "
f"of SPIR-V (not a multiple of 4)\n")
sys.exit(1)
words = struct.unpack(f"<{len(data) // 4}I", data)
if not words or words[0] != 0x07230203:
sys.stderr.write(
f"error: {glsl_path.name} produced invalid SPIR-V (bad magic)\n")
sys.exit(1)
return words
def emit_inc(identifier, glsl_name, words, out_path):
# 8 words per line keeps the file diff-friendly without being too tall.
PER_LINE = 8
lines = []
lines.append(
f"// Autogenerated from data/shaders/vulkan/{glsl_name}.\n"
f"// DO NOT EDIT. Regenerate with tools/regen_vulkan_spirv.py.\n"
f"// glslangValidator --target-env vulkan1.0\n"
f"//\n"
f"// Included inside namespace Vulkan::EmbeddedShaders in\n"
f"// embedded_shaders.cpp. The matching extern declaration lives in\n"
f"// embedded_shaders.h.\n"
f"\n"
f"const uint32_t k_{identifier}[] = {{\n")
for i in range(0, len(words), PER_LINE):
chunk = ", ".join(f"0x{w:08x}u" for w in words[i:i + PER_LINE])
lines.append(f" {chunk},\n")
lines.append(f"}};\n"
f"const size_t k_{identifier}_size_bytes = "
f"sizeof(k_{identifier});\n")
out_path.write_text("".join(lines))
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--glslang", help="path to glslangValidator binary")
args = ap.parse_args()
glslang = find_glslang(args.glslang)
INC_DIR.mkdir(parents=True, exist_ok=True)
glsl_files = sorted(GLSL_DIR.glob("*.glsl"))
if not glsl_files:
sys.stderr.write(f"warning: no .glsl files under {GLSL_DIR}\n")
return
total = 0
for glsl_path in glsl_files:
# glsl_path.name looks like "screen_quad.vert.glsl".
suffix = None
for k in STAGE_FROM_SUFFIX:
if glsl_path.name.endswith(k):
suffix = k
break
if suffix is None:
sys.stderr.write(
f"warning: {glsl_path.name} has no recognised stage suffix; "
f"skipping\n")
continue
stage_flag, ident_suffix = STAGE_FROM_SUFFIX[suffix]
# "screen_quad.vert.glsl" -> stem "screen_quad.vert" -> "screen_quad"
base = glsl_path.name[:-len(suffix)]
common/vulkan, core: pre-bake batch VS (18-blob template, 2 spec consts) 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.
2026-05-17 22:55:46 +00:00
variants = TEMPLATE_VARIANTS.get(glsl_path.name)
if variants is None:
# Single-variant shader: one .inc, no -D flags.
identifier = sanitize_identifier(base) + "_" + ident_suffix
out_path = INC_DIR / (identifier + ".inc")
words = compile_one(glslang, glsl_path, stage_flag)
emit_inc(identifier, glsl_path.name, words, out_path)
size_kb = (len(words) * 4) / 1024.0
print(f" {glsl_path.name:<40} -> {out_path.name} "
f"({len(words)} words, {size_kb:.1f} KiB)")
total += 1
else:
# Template: emit one .inc per variant, named with a suffix
# appended after the stage identifier.
for variant_suffix, defines in variants:
identifier = (sanitize_identifier(base) + "_" + ident_suffix +
"_" + variant_suffix)
out_path = INC_DIR / (identifier + ".inc")
words = compile_one(glslang, glsl_path, stage_flag, defines)
emit_inc(identifier, glsl_path.name, words, out_path)
size_kb = (len(words) * 4) / 1024.0
print(f" {glsl_path.name:<40} -> {out_path.name} "
f"({len(words)} words, {size_kb:.1f} KiB)")
total += 1
common/vulkan, core: pre-bake screen-quad VS, no glslang at runtime 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).
2026-05-17 17:49:19 +00:00
print(f"regenerated {total} SPIR-V blob(s) in {INC_DIR}")
if __name__ == "__main__":
main()