Merge pull request #867 from cdavis5e/tese-shader-origin-2

MSL: Don't bother fixing up triangle tess coords.
This commit is contained in:
Hans-Kristian Arntzen 2019-02-20 22:36:21 +01:00 committed by GitHub
commit ed7292fec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 90 deletions

View File

@ -1,28 +0,0 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 gl_Position [[position]];
};
struct main0_in
{
float4 gl_Position [[attribute(0)]];
};
struct main0_patchIn
{
patch_control_point<main0_in> gl_in;
};
[[ patch(triangle, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], float3 gl_TessCoord [[position_in_patch]])
{
main0_out out = {};
gl_TessCoord.yz = float2(gl_TessCoord.y - gl_TessCoord.x, 1.0 - gl_TessCoord.y);
out.gl_Position = ((patchIn.gl_in[0].gl_Position * gl_TessCoord.x) + (patchIn.gl_in[1].gl_Position * gl_TessCoord.y)) + (patchIn.gl_in[2].gl_Position * gl_TessCoord.z);
return out;
}

View File

@ -1,28 +0,0 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 gl_Position [[position]];
};
struct main0_in
{
float4 gl_Position [[attribute(0)]];
};
struct main0_patchIn
{
patch_control_point<main0_in> gl_in;
};
[[ patch(triangle, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], float3 gl_TessCoord [[position_in_patch]])
{
main0_out out = {};
gl_TessCoord.yz = float2(gl_TessCoord.y - gl_TessCoord.x, 1.0 - gl_TessCoord.y);
out.gl_Position = ((patchIn.gl_in[0].gl_Position * gl_TessCoord.x) + (patchIn.gl_in[1].gl_Position * gl_TessCoord.y)) + (patchIn.gl_in[2].gl_Position * gl_TessCoord.z);
return out;
}

View File

@ -1,22 +0,0 @@
#version 450
layout(cw, triangles, fractional_even_spacing) in;
in gl_PerVertex
{
vec4 gl_Position;
} gl_in[gl_MaxPatchVertices];
out gl_PerVertex
{
vec4 gl_Position;
};
void main()
{
gl_Position =
gl_in[0].gl_Position * gl_TessCoord.x +
gl_in[1].gl_Position * gl_TessCoord.y +
gl_in[2].gl_Position * gl_TessCoord.z;
}

View File

@ -5587,20 +5587,12 @@ void CompilerMSL::fix_up_shader_inputs_outputs()
});
break;
case BuiltInTessCoord:
// Emit a fixup to account for the shifted domain. The fixup for triangles can be derived
// thus:
// u' = u
// w' = 1 - v
// v' = 1 - u' - w' = 1 - u - (1 - v) = v - u
// v and w are swapped because the winding must be reversed in lower-left mode.
if (msl_options.tess_domain_origin_lower_left)
// Emit a fixup to account for the shifted domain. Don't do this for triangles;
// MoltenVK will just reverse the winding order instead.
if (msl_options.tess_domain_origin_lower_left && !get_entry_point().flags.get(ExecutionModeTriangles))
{
string tc = to_expression(var_id);
if (get_entry_point().flags.get(ExecutionModeTriangles))
entry_func.fixup_hooks_in.push_back(
[=]() { statement(tc, ".yz = float2(", tc, ".y - ", tc, ".x, 1.0 - ", tc, ".y);"); });
else
entry_func.fixup_hooks_in.push_back([=]() { statement(tc, ".y = 1.0 - ", tc, ".y;"); });
entry_func.fixup_hooks_in.push_back([=]() { statement(tc, ".y = 1.0 - ", tc, ".y;"); });
}
break;
default: