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.
36 lines
1.3 KiB
GLSL
36 lines
1.3 KiB
GLSL
// Pre-baked Vulkan source for
|
|
// GPU_HW_ShaderGen::GenerateVRAMUpdateDepthFragmentShader() when the
|
|
// source m_vram_texture is single-sample (sampler2D).
|
|
//
|
|
// The "update depth" pipeline rebuilds the depth attachment of the
|
|
// upscaled VRAM render pass from the colour attachment's alpha channel
|
|
// after a framebuffer recreation (resolution scale change,
|
|
// antialiasing toggle, true colour toggle). Single sampler bound at
|
|
// set=0 binding=1, no UBO, no push constants - the shader is literally
|
|
// "copy alpha to depth".
|
|
//
|
|
// Two blobs handle the structural MSAA split (sampler2D vs sampler2DMS,
|
|
// matching the display / VRAM readback pattern). No spec constants
|
|
// needed on the non-MSAA blob - there is nothing to specialise.
|
|
//
|
|
// Bindings (match m_single_sampler_pipeline_layout):
|
|
// set=0 binding=1 - uniform sampler2D samp0 (m_vram_texture view)
|
|
//
|
|
// The pipeline layout declares push constants for ABI symmetry with
|
|
// other m_single_sampler_pipeline_layout consumers; the shader does
|
|
// not read any, and the C++ caller (UpdateDepthBufferFromMaskBit)
|
|
// does not push any either.
|
|
|
|
#version 450 core
|
|
|
|
layout(set = 0, binding = 1) uniform sampler2D samp0;
|
|
|
|
// Unused; kept for interface-match with the screen-quad VS.
|
|
layout(location = 0) in VertexData {
|
|
vec2 v_tex0;
|
|
};
|
|
|
|
void main()
|
|
{
|
|
gl_FragDepth = texelFetch(samp0, ivec2(gl_FragCoord.xy), 0).a;
|
|
}
|