From 542209c99320371c41941025c2d482c1d3c35cb3 Mon Sep 17 00:00:00 2001 From: GPUCode <47210458+GPUCode@users.noreply.github.com> Date: Sun, 17 Sep 2023 00:46:44 +0300 Subject: [PATCH] video_core: Initialize unrefered attributes to 1.f (#6966) --- src/video_core/renderer_opengl/gl_shader_gen.cpp | 2 +- src/video_core/renderer_vulkan/vk_shader_gen.cpp | 4 ++-- src/video_core/shader/shader.cpp | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index c4dad2c32..90553cc7f 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -1841,7 +1841,7 @@ struct Vertex { if (attrib < config.gs_output_attributes) { return fmt::format("vtx.attributes[{}].{}", attrib, "xyzw"[comp]); } - return "0.0"; + return "1.0"; }; out += "const float EPSILON_Z = 0.00000001f;\n\n"; diff --git a/src/video_core/renderer_vulkan/vk_shader_gen.cpp b/src/video_core/renderer_vulkan/vk_shader_gen.cpp index 37aac4dd9..59fd56a8c 100644 --- a/src/video_core/renderer_vulkan/vk_shader_gen.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_gen.cpp @@ -1810,7 +1810,7 @@ layout (set = 0, binding = 0, std140) uniform vs_config { if (attrib < config.gs_output_attributes) { return fmt::format("vs_out_attr{}.{}", attrib, "xyzw"[comp]); } - return "0.0"; + return "1.0"; }; out += "const float EPSILON_Z = 0.00000001f;\n\n"; @@ -1900,7 +1900,7 @@ struct Vertex { if (attrib < config.gs_output_attributes) { return fmt::format("vtx.attributes[{}].{}", attrib, "xyzw"[comp]); } - return "0.0"; + return "1.0"; }; out += "const float EPSILON_Z = 0.00000001f;\n\n"; diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 126efd834..b8393c379 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -44,6 +44,10 @@ OutputVertex OutputVertex::FromAttributeBuffer(const RasterizerRegs& regs, std::array vertex_slots_overflow; }; + // Some games use attributes without setting them in GPUREG_SH_OUTMAP_Oi + // Hardware tests have shown that they are initialized to 1.f in this case. + vertex_slots_overflow.fill(f24::One()); + // Assert that OutputVertex has enough space for 24 semantic registers static_assert(sizeof(std::array) == sizeof(ret), "Struct and array have different sizes.");