Skip to content
Permalink
Browse files
Merge pull request #10286 from Pokechu22/geometry-shader-depth-clamp
GeomeryShaderGen: Set gl_ClipDistance on Vulkan as well as OpenGL
  • Loading branch information
JMC47 committed Dec 27, 2021
2 parents 1f1e78e + 1cd148d commit 4dcf232
Showing 1 changed file with 7 additions and 9 deletions.
@@ -331,23 +331,21 @@ static void EmitVertex(ShaderCode& out, const ShaderHostConfig& host_config,
if (wireframe && first_vertex)
out.Write("\tif (i == 0) first = {};\n", vertex);

if (api_type == APIType::OpenGL)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
out.Write("\tgl_Position = {}.pos;\n", vertex);
// Vulkan NDC space has Y pointing down (right-handed NDC space).
if (api_type == APIType::Vulkan)
out.Write("\tgl_Position = float4({0}.pos.x, -{0}.pos.y, {0}.pos.z, {0}.pos.w);\n", vertex);
else
out.Write("\tgl_Position = {}.pos;\n", vertex);

if (host_config.backend_depth_clamp)
{
out.Write("\tgl_ClipDistance[0] = {}.clipDist0;\n", vertex);
out.Write("\tgl_ClipDistance[1] = {}.clipDist1;\n", vertex);
}
AssignVSOutputMembers(out, "ps", vertex, uid_data->numTexGens, host_config);
}
else if (api_type == APIType::Vulkan)
{
// Vulkan NDC space has Y pointing down (right-handed NDC space).
out.Write("\tgl_Position = {}.pos;\n", vertex);
out.Write("\tgl_Position.y = -gl_Position.y;\n");
AssignVSOutputMembers(out, "ps", vertex, uid_data->numTexGens, host_config);
}
else
{
out.Write("\tps.o = {};\n", vertex);

0 comments on commit 4dcf232

Please sign in to comment.