From 8663541403cb89ca113e744d2d359eb5573d4994 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 5 Oct 2022 20:11:10 -0700 Subject: [PATCH] Vulkan: Avoid max_vertices=12 if unnecessary. --- GPU/Common/GeometryShaderGenerator.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 525dc1f0f5..d9e8c8c22a 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -45,10 +45,16 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu gl_exts.push_back("#extension GL_EXT_gpu_shader4 : enable"); } } + bool vertexRangeCulling = !id.Bit(GS_BIT_CURVE); + bool clipClampedDepth = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && !gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts.data(), gl_exts.size()); p.C("layout(triangles) in;\n"); - p.C("layout(triangle_strip, max_vertices = 12) out;\n"); + if (clipClampedDepth && vertexRangeCulling) { + p.C("layout(triangle_strip, max_vertices = 12) out;\n"); + } else { + p.C("layout(triangle_strip, max_vertices = 6) out;\n"); + } if (compat.shaderLanguage == GLSL_VULKAN) { WRITE(p, "\n"); @@ -58,8 +64,6 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu } std::vector varyings, outVaryings; - bool vertexRangeCulling = !id.Bit(GS_BIT_CURVE); - bool clipClampedDepth = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && !gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); if (id.Bit(GS_BIT_DO_TEXTURE)) { varyings.push_back(VaryingDef{ "vec3", "v_texcoord", Draw::SEM_TEXCOORD0, 0, "highp" });