Commit 492b5f51 by Jiawei Shao Committed by Commit Bot

ES31: Support struct arrays as Geometry Shader inputs

This patch adds the support of struct arrays as valid geometry shader user-defined inputs. Struct arrays are accepted as geometry shader inputs to match the vertex shader outputs that are also declared as structs. BUG=angleproject:1941 TEST=angle_unittests Change-Id: I0b5d545b10e9dda576a1c96d7c93ec2450611e9e Reviewed-on: https://chromium-review.googlesource.com/823622 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 8c3988c5
......@@ -1054,8 +1054,13 @@ bool TParseContext::checkIsValidTypeAndQualifierForArray(const TSourceLoc &index
// In ESSL1.00 shaders, structs cannot be varying (section 4.3.5). This is checked elsewhere.
// In ESSL3.00 shaders, struct inputs/outputs are allowed but not arrays of structs (section
// 4.3.4).
// Geometry shader requires each user-defined input be declared as arrays or inside input
// blocks declared as arrays (GL_EXT_geometry_shader section 11.1gs.4.3). For the purposes of
// interface matching, such variables and blocks are treated as though they were not declared
// as arrays (GL_EXT_geometry_shader section 7.4.1).
if (mShaderVersion >= 300 && elementType.getBasicType() == EbtStruct &&
sh::IsVarying(elementType.qualifier))
sh::IsVarying(elementType.qualifier) &&
!IsGeometryShaderInput(mShaderType, elementType.qualifier))
{
error(indexLocation, "cannot declare arrays of structs of this qualifier",
TType(elementType).getCompleteString().c_str());
......
......@@ -1571,3 +1571,55 @@ TEST_F(GeometryShaderOutputCodeTest, ValidateGLInMembersInOutputShaderString)
compile(shaderString2);
EXPECT_TRUE(foundInESSLCode("].gl_Position"));
}
// Verify that geometry shader inputs can be declared as struct arrays.
TEST_F(GeometryShaderTest, StructArrayInput)
{
const std::string &shaderString =
R"(#version 310 es
#extension GL_EXT_geometry_shader : require
layout (points) in;
layout (points, max_vertices = 2) out;
struct S
{
float value1;
vec4 value2;
};
in S gs_input[];
out S gs_output;
void main()
{
gs_output = gs_input[0];
})";
if (!compile(shaderString))
{
FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog;
}
}
// Verify that geometry shader outputs cannot be declared as struct arrays.
TEST_F(GeometryShaderTest, StructArrayOutput)
{
const std::string &shaderString =
R"(#version 310 es
#extension GL_EXT_geometry_shader : require
layout (points) in;
layout (points, max_vertices = 2) out;
struct S
{
float value1;
vec4 value2;
};
out S gs_output[1];
void main()
{
gs_output[0].value1 = 1.0;
gs_output[0].value2 = vec4(1.0, 0.0, 0.0, 1.0);
})";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment