TsundereStation/data
LibretroAdmin 74bebf8908 common/vulkan, core: pre-bake VRAM update-depth FS (MSAA blob pair, no spec consts)
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.
2026-05-18 00:38:31 +02:00
..
shaders/vulkan common/vulkan, core: pre-bake VRAM update-depth FS (MSAA blob pair, no spec consts) 2026-05-18 00:38:31 +02:00