TsundereStation/data/shaders/vulkan/present_cursor.frag.glsl

18 lines
555 B
Text
Raw Normal View History

common/vulkan, core: pre-bake UV-quad VS and three presentation-stage shaders Patch 2 in the glslang-elimination series (probe was 2cbcefc). Converts four more shaders to the pre-baked SPIR-V path established in the probe. No new infrastructure - each blob just adds an extern pair to embedded_shaders.h, a #include inside the namespace block in embedded_shaders.cpp, and a call-site swap. The probe pattern handles N=5 blobs as cleanly as it handled N=1. Shaders converted by this patch: 1. UV-quad vertex shader (GPU_HW_Vulkan::GetUVQuadVertexShader, the variant of the screen-quad that maps the swept triangle into a [u_uv_min..u_uv_max] UV rect from a push constant). The runtime equivalent is ShaderGen::GenerateUVQuadVertexShader(). 2. Presentation-stage fullscreen-quad VS - the one with the u_src_rect push constant, distinct from the GPU_HW screen quad. Used only by LibretroVulkanHostDisplay to blit the rendered frame and the software cursor into the libretro framebuffer. 3. Presentation-stage display FS - writes the source texture opaque. 4. Presentation-stage cursor FS - preserves source alpha for blending. Shaders 2-4 previously lived as inline R"()" string literals at the top of LibretroVulkanHostDisplay::CreateResources() in src/core/gpu_hw_vulkan.cpp. They are now in data/shaders/vulkan/ with matching pre-compiled SPIR-V under src/common/vulkan/embedded_spirv/. The C++-side pipeline layout (16-byte u_src_rect push constant, single combined image sampler at set 0 / binding 0) is unchanged, so no descriptor or push-constant byte-layout coordination is needed. Cumulative state after this patch: - 5 of ~25-30 utility-shader variants in Bucket A converted. - glslang is still in dep/ and still in the build - it is needed by every shader generator not yet converted, in particular all of GPU_HW_ShaderGen plus the remaining utility shaders that bake RESOLUTION_SCALE / MULTISAMPLES / PGXP_DEPTH into source via WriteCommonFunctions. The next patch in the series introduces specialization-constant infrastructure in GraphicsPipelineBuilder so those constants can be moved out of GLSL into SPIR-V OpSpecConstant, enabling the rest of Bucket A. Smoke tests in the sandbox: - All 5 .inc files reconstruct to SPIR-V that passes 'spirv-val --target-env vulkan1.0'. - spirv-dis confirms each blob's entry point, descriptor bindings, and push-constant block match the call-site expectations. - g++ -fsyntax-only on embedded_shaders.cpp against the real tree headers is clean. Smoke tests at user's end: - Cold-boot the Vulkan backend with the disk shader cache nuked. The three presentation-stage pipelines build during LibretroVulkanHostDisplay::CreateResources(); the UV-quad VS is faulted in lazily by any of the three adaptive-downsample pipeline paths (line ~2284 in gpu_hw_vulkan.cpp post-patch). All four must succeed for the emulator to reach a first frame. - A second cold boot (same nuke) verifies the embedded path is reproducibly correct, not relying on any leftover state.
2026-05-17 18:20:32 +00:00
// Pre-baked Vulkan source for the presentation-stage cursor FS.
//
// Previously lived as an inline R"()" string literal in
// LibretroVulkanHostDisplay::CreateResources() in src/core/gpu_hw_vulkan.cpp.
// Differs from present_display.frag.glsl in that it preserves the source
// alpha so the software cursor can be alpha-blended over the framebuffer.
#version 450 core
layout(set = 0, binding = 0) uniform sampler2D samp0;
layout(location = 0) in vec2 v_tex0;
layout(location = 0) out vec4 o_col0;
void main()
{
o_col0 = texture(samp0, v_tex0);
}