mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Vulkan: Correct geometry shader culling.
This commit is contained in:
parent
ac248338be
commit
bfaa304461
1 changed files with 9 additions and 5 deletions
|
@ -75,7 +75,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 anyInside = 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");
|
||||
|
@ -91,16 +91,20 @@ 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) { anyInside = true; }\n");
|
||||
p.C(" if (projPos.z <= u_cullRangeMax.z) { anyInside = 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 (u_cullRangeMin.w > 0.0 && !anyInside) {\n");
|
||||
p.C(" return;\n");
|
||||
p.C(" }\n");
|
||||
|
||||
const char *clip0 = compat.shaderLanguage == HLSL_D3D11 ? "" : "[0]";
|
||||
|
||||
|
@ -119,7 +123,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu
|
|||
p.F(" %s = %s[i];\n", outVaryings[i].name, varyings[i].name);
|
||||
}
|
||||
// Debug - null the red channel
|
||||
p.C(" if (i == 0) v_color0Out.x = 0.0;\n");
|
||||
//p.C(" if (i == 0) v_color0Out.x = 0.0;\n");
|
||||
p.C(" EmitVertex();\n");
|
||||
p.C(" }\n");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue