GLSL: Force block declaration if clip/cull is used in tesc.

This commit is contained in:
Hans-Kristian Arntzen 2021-01-07 12:14:49 +01:00
parent 014b3bc5ea
commit 3776d8978c
4 changed files with 31 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}