Merge pull request #2237 from cdavis5e/raw-tese-input-patch-vertices

MSL: Fix patch vertex count with raw buffer tese input.
This commit is contained in:
Hans-Kristian Arntzen 2023-12-05 14:03:29 +01:00 committed by GitHub
commit 7c335edc66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 112 additions and 4 deletions

View File

@ -0,0 +1,18 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 gl_Position [[position]];
};
[[ patch(quad, 0) ]] vertex main0_out main0(uint gl_PrimitiveID [[patch_id]])
{
main0_out out = {};
uint gl_PatchVerticesIn = 0;
out.gl_Position = float4(float(gl_PatchVerticesIn), 0.0, 0.0, 1.0);
return out;
}

View File

@ -0,0 +1,8 @@
#version 450
layout(quads, ccw, equal_spacing) in;
void main()
{
gl_Position = vec4(float(gl_PatchVerticesIn), 0.0, 0.0, 1.0);
}

View File

@ -0,0 +1,26 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 gl_Position [[position]];
};
static inline __attribute__((always_inline))
float4 read_patch_vertices(thread uint& gl_PatchVerticesIn)
{
return float4(float(gl_PatchVerticesIn), 0.0, 0.0, 1.0);
}
[[ patch(quad, 0) ]] vertex main0_out main0(uint gl_PrimitiveID [[patch_id]])
{
main0_out out = {};
uint gl_PatchVerticesIn = 0;
out.gl_Position = read_patch_vertices(gl_PatchVerticesIn);
return out;
}

View File

@ -0,0 +1,13 @@
#version 450
layout(quads, ccw, equal_spacing) in;
vec4 read_patch_vertices()
{
return vec4(float(gl_PatchVerticesIn), 0.0, 0.0, 1.0);
}
void main()
{
gl_Position = read_patch_vertices();
}

View File

@ -0,0 +1,12 @@
#version 450
layout(quads) in;
vec4 read_patch_vertices()
{
return vec4(gl_PatchVerticesIn, 0, 0, 1);
}
void main()
{
gl_Position = read_patch_vertices();
}

View File

@ -0,0 +1,12 @@
#version 450
layout(quads) in;
vec4 read_patch_vertices()
{
return vec4(gl_PatchVerticesIn, 0, 0, 1);
}
void main()
{
gl_Position = read_patch_vertices();
}

View File

@ -9610,6 +9610,8 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage)
return "gl_TessLevelInner";
case BuiltInTessCoord:
return "gl_TessCoord";
case BuiltInPatchVertices:
return "gl_PatchVerticesIn";
case BuiltInFragCoord:
return "gl_FragCoord";
case BuiltInPointCoord:

View File

@ -13679,14 +13679,31 @@ void CompilerMSL::fix_up_shader_inputs_outputs()
break;
case BuiltInPatchVertices:
if (is_tese_shader())
entry_func.fixup_hooks_in.push_back([=]() {
{
if (msl_options.raw_buffer_tese_input)
{
entry_func.fixup_hooks_in.push_back(
[=]() {
statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ",
get_entry_point().output_vertices, ";");
});
}
else
{
entry_func.fixup_hooks_in.push_back(
[=]()
{
statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ",
to_expression(patch_stage_in_var_id), ".gl_in.size();");
});
}
}
else
{
entry_func.fixup_hooks_in.push_back([=]() {
statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = spvIndirectParams[0];");
});
}
break;
case BuiltInTessCoord:
if (get_entry_point().flags.get(ExecutionModeQuads))