From 3105e82b2e14832b5d4027467e5894e2d70cb0d1 Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Mon, 16 Aug 2021 11:23:15 -0400 Subject: MSL: Fix duplicate gl_Position outputs when gl_Position defined but unused. When gl_Position is defined by SPIR-V, but neither used nor initialized, it appeared twice in the MSL output, as gl_Position and glPosition_1. The existing tests for whether an output is active check only that it is used by an op, or initialized. Adding the implicit gl_Position also marked the existing gl_Position as active, duplicating the output variable. Fix is that when checking for the need to add an implicit gl_Position output, also check if the var is already defined in the shader, and just needs to be marked as active. Add test shader. --- reference/opt/shaders-msl/vert/unused-position.vert | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 reference/opt/shaders-msl/vert/unused-position.vert (limited to 'reference/opt/shaders-msl') diff --git a/reference/opt/shaders-msl/vert/unused-position.vert b/reference/opt/shaders-msl/vert/unused-position.vert new file mode 100644 index 00000000..7dc46721 --- /dev/null +++ b/reference/opt/shaders-msl/vert/unused-position.vert @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; + float gl_PointSize [[point_size]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + out.gl_PointSize = 1.0; + return out; +} + -- cgit v1.2.3