Patch 11 in the glslang-elimination series, and the last non-batch
shader on the runtime shadergen path. This was the original patch 5
culprit - lazy-building this pipeline inside UpdateSettings tripped an
NVIDIA driver quirk that produced corrupted rendering on the next
frame. The preceding fix patch (pre-build hot-path utility pipelines
in shader_precompile=Disabled) sidestepped the failure mode by
ensuring m_vram_update_depth_pipeline is always built before any
cmdbuf that could need it, regardless of precompile mode, so this
conversion is now safe to land.
Shader converted:
VRAMUpdateDepthFragmentShader. Rebuilds the depth attachment of the
upscaled VRAM render pass from the colour attachment's alpha after a
framebuffer recreation (resolution scale change, antialiasing toggle,
true colour toggle). Trivial body - one texelFetch, one assignment
to gl_FragDepth.
Blobs:
vram_update_depth_fs - sampler2D, texelFetch(samp0, coord, 0).
vram_update_depth_msaa_fs - sampler2DMS, texelFetch(samp0, coord,
gl_SampleID). The gl_SampleID reference
forces per-sample shading per the
Vulkan spec, regardless of the
SetMultisamples per_sample_shading
flag the C++ side leaves at false (the
original shadergen relies on the same
implicit-per-sample behaviour).
No spec constants on either blob - there is nothing to specialise.
The pipeline-state knobs the C++ side cares about (sample count,
depth state, blend state) are pipeline-creation-time choices, not
shader-source knobs.
Bindings unchanged: set=0 binding=1 sampler from
m_single_sampler_descriptor_set_layout, no UBO at binding 0 (the
descriptor set layout only declares binding 1; the pipeline layout's
push constants are declared for ABI symmetry with other consumers but
are not read by this shader, and the C++ caller does not push any).
Smoke tests:
- g++ -fsyntax-only on the touched common TU.
- spirv-val --target-env vulkan1.0 on both blobs (219 / 242 words,
0.9 KiB each - the smallest blobs in the project).
- --target-env vulkan1.0 vs un-flagged glslangValidator: byte-
identical SPIR-V for both.
m_vram_update_depth_pipeline is on the antialiasing-toggle hot path
(UpdateSettings -> UpdateDepthBufferFromMaskBit at gpu_hw_vulkan.cpp
line ~817). With the preceding fix patch in place, the Disabled-mode
pre-build in CompilePipelines ensures the pipeline is always ready
before UpdateSettings' second cmdbuf starts recording, so the bug
that broke the original patch 5 (lazy build of MSAA depth blob in
the second SSAA toggle cycle, NVIDIA driver producing corrupt next
frame) is structurally impossible here.
Test priority:
- shader_precompile=Disabled: same SSAA / MSAA round-trip protocol
Lib used to surface the original patch 5 bug. Toggle SSAA None
-> 8x -> None -> 8x, MSAA 1 -> 4 -> 1 -> 4, resolution scale
1 -> 2 -> 1 -> 2, true colour off -> on -> off. Each toggle
should produce a clean frame.
- shader_precompile=Enabled / Lazy: routine smoke (any game).
After this lands, every non-batch shader in the Vulkan backend is
pre-baked SPIR-V; the only remaining runtime glslang consumers are
the two batch shaders (GenerateBatchVertexShader and
GenerateBatchFragmentShader at gpu_hw_vulkan.cpp lines ~1462 and
~1799). Those are Bucket B and a separate refactoring effort -
their state space is wide enough to warrant a different conversion
strategy from the per-shader spec-const collapses used here.
|
||
|---|---|---|
| .. | ||
| adaptive_downsample_blur.frag.glsl | ||
| adaptive_downsample_composite.frag.glsl | ||
| adaptive_downsample_mip.frag.glsl | ||
| box_sample_downsample.frag.glsl | ||
| display.frag.glsl | ||
| display_msaa.frag.glsl | ||
| present_cursor.frag.glsl | ||
| present_display.frag.glsl | ||
| present_fullscreen.vert.glsl | ||
| README.md | ||
| screen_quad.vert.glsl | ||
| uv_quad.vert.glsl | ||
| vram_copy.frag.glsl | ||
| vram_fill.frag.glsl | ||
| vram_readback.frag.glsl | ||
| vram_readback_msaa.frag.glsl | ||
| vram_update_depth.frag.glsl | ||
| vram_update_depth_msaa.frag.glsl | ||
| vram_write_ssbo.frag.glsl | ||
| vram_write_texbuf.frag.glsl | ||
Vulkan shader sources (pre-baked SPIR-V)
This directory holds the GLSL sources for shaders used by the Vulkan backend
that have been moved off the runtime ShaderGen path. Each .glsl file here
has a matching pre-compiled SPIR-V blob checked in to
src/common/vulkan/embedded_spirv/.
Why this exists
Historically the Vulkan backend generated GLSL at runtime via
src/core/shadergen.cpp and src/core/gpu_hw_shadergen.cpp, then handed the
text to glslang inside src/common/vulkan/shader_compiler.cpp to produce
SPIR-V. Both dep/glslang/ (4.4 MB of vendored source, 99 translation units)
and the disk-backed runtime shader cache exist solely to support that path.
Pre-baking the SPIR-V removes:
- the glslang dependency from the libretro core build,
- the per-launch shader compilation stall, and
- a class of "stale cache after glslang version bump" runtime failures.
The OpenGL / OpenGL ES / D3D11 / D3D12 backends still use the runtime
ShaderGen path; only the Vulkan backend reads from the embedded SPIR-V.
Build-time constraint
The core build (Makefile.libretro and src/common/CMakeLists.txt) must
never invoke an external shader compiler. The .inc files under
src/common/vulkan/embedded_spirv/ are checked into the repository and
compiled like any other C++ source. The tools/regen_vulkan_spirv.py helper
exists for contributors who edit the .glsl sources in this directory; it is
not part of the build.
Regenerating the SPIR-V blobs
After editing a .glsl file here, run:
python3 tools/regen_vulkan_spirv.py
This invokes glslangValidator --target-env vulkan1.0 on each .glsl file
and rewrites the matching .inc under src/common/vulkan/embedded_spirv/.
Both the .glsl and the regenerated .inc must be committed together so the
two stay in sync.
glslangValidator is part of the Vulkan SDK (or the glslang-tools package
on Debian / Ubuntu). It is not invoked by the core build.