Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeomeryShaderGen: Set gl_ClipDistance on Vulkan as well as OpenGL #10286

Merged
merged 1 commit into from Dec 27, 2021

Conversation

Pokechu22
Copy link
Contributor

Fixes https://bugs.dolphin-emu.org/issues/12548.

Both Vulkan and OpenGL use gl_ClipDistance when backend depth clamping is enabled. However, the geometry shader was only copying it for OpenGL, not for Vulkan. Since stereoscopic 3D uses a geometry shader, this was most visible there, but I suspect it could also affect line/point effects (I was unable to confirm this though).

Here's the relevant vertex shader code (skipping the non-geomerty-shader path):

if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
if (host_config.backend_geometry_shaders)
{
AssignVSOutputMembers(out, "vs", "o", uid_data->numTexGens, host_config);
}
else
{

}
if (host_config.backend_depth_clamp)
{
out.Write("gl_ClipDistance[0] = clipDist0;\n"
"gl_ClipDistance[1] = clipDist1;\n");
}
// Vulkan NDC space has Y pointing down (right-handed NDC space).
if (api_type == APIType::Vulkan)
out.Write("gl_Position = float4(o.pos.x, -o.pos.y, o.pos.z, o.pos.w);\n");
else
out.Write("gl_Position = o.pos;\n");
}
else // D3D
{
out.Write("return o;\n");
}

Copy link
Contributor

@iwubcode iwubcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Tested and confirmed that the bug was fixed, didn't notice any regressions

@JMC47 JMC47 merged commit 4dcf232 into dolphin-emu:master Dec 27, 2021
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants