From 307ad8df8d433788f6e8c2b104e643cfe6b36b04 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 27 Oct 2021 21:00:37 -0700 Subject: [PATCH 1/2] Draw: Remove unused method with hack. --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 508f36ea8380..b2a634264583 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -267,7 +267,6 @@ class VKPipeline : public Pipeline { return buf->PushAligned(ubo_, uboSize_, vulkan->GetPhysicalDeviceProperties().properties.limits.minUniformBufferOffsetAlignment, vkbuf); } - int GetUniformLoc(const char *name); int GetUBOSize() const { return uboSize_; } @@ -1324,17 +1323,6 @@ ShaderModule *VKContext::CreateShaderModule(ShaderStage stage, ShaderLanguage la } } -int VKPipeline::GetUniformLoc(const char *name) { - int loc = -1; - - // HACK! As we only use one uniform we hardcode it. - if (!strcmp(name, "WorldViewProj")) { - return 0; - } - - return loc; -} - void VKContext::UpdateDynamicUniformBuffer(const void *ub, size_t size) { curPipeline_->SetDynamicUniformData(ub, size); } From cce03b69bd6b447787aed748dee541ce03814967 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 27 Oct 2021 21:22:45 -0700 Subject: [PATCH 2/2] GPU: Correct geometry shader culling. --- GPU/Common/GeometryShaderGenerator.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 74a71651ea81..f4ae8065060f 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -78,7 +78,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.BeginGSMain(varyings, outVaryings); // Apply culling - p.C(" bool anyInside = false;\n"); // TODO: 3 or gl_in.length()? which will be faster? + p.C(" bool insidePositiveZ = false, insideNegativeZ = false;\n"); p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); @@ -94,16 +94,18 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" }\n"); p.C(" if (u_cullRangeMin.w <= 0.0) {\n"); p.C(" if (projPos.z < u_cullRangeMin.z || projPos.z > u_cullRangeMax.z) {\n"); - p.C(" return;\n"); // Cull! + // When not clamping depth, cull the triangle of Z is outside the valid range (not based on clip Z.) + p.C(" return;\n"); p.C(" }\n"); p.C(" } else {\n"); - p.C(" if (projPos.z >= u_cullRangeMin.z && projPos.z <= u_cullRangeMax.z) { anyInside = true; }\n"); + p.C(" if (projPos.z >= u_cullRangeMin.z) { insideNegativeZ = true; }\n"); + p.C(" if (projPos.z <= u_cullRangeMax.z) { insidePositiveZ = true; }\n"); p.C(" }\n"); p.C(" } // for\n"); // Cull any triangle fully outside in the same direction when depth clamp enabled. // Basically simulate cull distances. - p.C(" if (!anyInside) { return; }\n"); + p.C(" if (!insideNegativeZ || !insidePositiveZ) { return; }\n"); const char *clip0 = compat.shaderLanguage == HLSL_D3D11 ? "" : "[0]";