diff --git a/reference/shaders-hlsl-no-opt/asm/vert/builtin-output-initializer.asm.vert b/reference/shaders-hlsl-no-opt/asm/vert/builtin-output-initializer.asm.vert index cf3e916f..ee30c178 100644 --- a/reference/shaders-hlsl-no-opt/asm/vert/builtin-output-initializer.asm.vert +++ b/reference/shaders-hlsl-no-opt/asm/vert/builtin-output-initializer.asm.vert @@ -2,9 +2,14 @@ static const float _23[1] = { 0.0f }; static const float _24[1] = { 0.0f }; static float4 gl_Position = 0.0f.xxxx; +static float gl_PointSize = 0.0f; +static float gl_ClipDistance[1] = _23; +static float gl_CullDistance[1] = _24; struct SPIRV_Cross_Output { float4 gl_Position : SV_Position; + float gl_ClipDistance0 : SV_ClipDistance0; + float gl_CullDistance0 : SV_CullDistance0; }; void vert_main() @@ -17,5 +22,7 @@ SPIRV_Cross_Output main() vert_main(); SPIRV_Cross_Output stage_output; stage_output.gl_Position = gl_Position; + stage_output.gl_ClipDistance0.x = gl_ClipDistance[0]; + stage_output.gl_CullDistance0.x = gl_CullDistance[0]; return stage_output; } diff --git a/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc b/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc index 83e2651c..13e1d329 100644 --- a/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc +++ b/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc @@ -1,6 +1,14 @@ #version 450 layout(vertices = 4) out; +out gl_PerVertex +{ + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[1]; + float gl_CullDistance[1]; +} gl_out[4]; + layout(location = 0) patch out vert { float v0; @@ -23,6 +31,8 @@ layout(location = 8) out vert2 const vec4 _3_0_init[4] = vec4[](vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); const float _3_1_init[4] = float[](0.0, 0.0, 0.0, 0.0); +const float _3_2_init[4][1] = float[][](float[](0.0), float[](0.0), float[](0.0), float[](0.0)); +const float _3_3_init[4][1] = float[][](float[](0.0), float[](0.0), float[](0.0), float[](0.0)); const float _6_0_init[2] = float[](0.0, 0.0); const float _6_1_init[2] = float[](0.0, 0.0); const float _7_init = 0.0; @@ -34,6 +44,8 @@ void main() { gl_out[gl_InvocationID].gl_Position = _3_0_init[gl_InvocationID]; gl_out[gl_InvocationID].gl_PointSize = _3_1_init[gl_InvocationID]; + gl_out[gl_InvocationID].gl_ClipDistance = _3_2_init[gl_InvocationID]; + gl_out[gl_InvocationID].gl_CullDistance = _3_3_init[gl_InvocationID]; if (gl_InvocationID == 0) { _5.v0 = 0.0; diff --git a/reference/shaders-no-opt/asm/vert/builtin-output-initializer.asm.vert b/reference/shaders-no-opt/asm/vert/builtin-output-initializer.asm.vert index 4b77870a..b449f080 100644 --- a/reference/shaders-no-opt/asm/vert/builtin-output-initializer.asm.vert +++ b/reference/shaders-no-opt/asm/vert/builtin-output-initializer.asm.vert @@ -1,9 +1,14 @@ #version 450 +out float gl_ClipDistance[1]; +out float gl_CullDistance[1]; + void main() { gl_Position = vec4(0.0); gl_PointSize = 0.0; + gl_ClipDistance = float[](0.0); + gl_CullDistance = float[](0.0); gl_Position = vec4(1.0); } diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 3b5bd8e3..ab479410 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -2801,6 +2801,13 @@ bool CompilerGLSL::should_force_emit_builtin_block(StorageClass storage) } }); + // If we're declaring clip/cull planes with control points we need to force block declaration. + if (get_execution_model() == ExecutionModelTessellationControl && + (clip_distance_count || cull_distance_count)) + { + should_force = true; + } + return should_force; }