Commit 7caa80e7 by Olli Etuaho Committed by Commit Bot

Edit tests to reference temporary variables

The shader translator is intended to prune unreferenced variables in the future. To maintain test coverage when this is done, most tests that used to have unreferenced GLSL locals and globals are edited to use built-ins or reference the necessary variables instead. BUG=angleproject:2166 TEST=angle_unittests, angle_end2end_tests Change-Id: I3964e7a80d52fc04a95f57e73da6095e433095e8 Reviewed-on: https://chromium-review.googlesource.com/768740Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 5ad52994
...@@ -252,7 +252,7 @@ TEST_F(BufferVariablesTest, AccessReadonlyBufferVariableByInstanceName) ...@@ -252,7 +252,7 @@ TEST_F(BufferVariablesTest, AccessReadonlyBufferVariableByInstanceName)
"} instanceBuffer;\n" "} instanceBuffer;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" float test = instanceBuffer.f;\n" " gl_Position.x = instanceBuffer.f;\n"
"}\n"; "}\n";
if (!compile(source)) if (!compile(source))
{ {
......
...@@ -940,19 +940,23 @@ TEST_F(CollectVertexVariablesTest, ViewID_OVR) ...@@ -940,19 +940,23 @@ TEST_F(CollectVertexVariablesTest, ViewID_OVR)
TEST_F(CollectGeometryVariablesTest, CollectGLInFields) TEST_F(CollectGeometryVariablesTest, CollectGLInFields)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"layout (points) in;\n"
"layout (points, max_vertices = 2) out;\n" layout (points) in;
"void main()\n" layout (points, max_vertices = 2) out;
"{\n"
" vec4 value = gl_in[0].gl_Position;\n" void main()
" vec4 value2 = gl_in[0].gl_Position;\n" {
"}\n"; vec4 value = gl_in[0].gl_Position;
vec4 value2 = gl_in[0].gl_Position;
gl_Position = value + value2;
EmitVertex();
})";
compile(shaderString); compile(shaderString);
EXPECT_TRUE(mTranslator->getOutputVaryings().empty()); EXPECT_EQ(1u, mTranslator->getOutputVaryings().size());
EXPECT_TRUE(mTranslator->getInputVaryings().empty()); EXPECT_TRUE(mTranslator->getInputVaryings().empty());
const auto &inBlocks = mTranslator->getInBlocks(); const auto &inBlocks = mTranslator->getInBlocks();
...@@ -985,10 +989,10 @@ TEST_F(CollectGeometryVariablesTest, GLInArraySize) ...@@ -985,10 +989,10 @@ TEST_F(CollectGeometryVariablesTest, GLInArraySize)
const GLuint kArraySizeForInputPrimitives[] = {1u, 2u, 4u, 3u, 6u}; const GLuint kArraySizeForInputPrimitives[] = {1u, 2u, 4u, 3u, 6u};
const std::string &functionBody = const std::string &functionBody =
"void main()\n" R"(void main()
"{\n" {
" vec4 value = gl_in[0].gl_Position;\n" gl_Position = gl_in[0].gl_Position;
"}\n"; })";
for (size_t i = 0; i < kInputPrimitives.size(); ++i) for (size_t i = 0; i < kInputPrimitives.size(); ++i)
{ {
...@@ -1007,18 +1011,19 @@ TEST_F(CollectGeometryVariablesTest, GLInArraySize) ...@@ -1007,18 +1011,19 @@ TEST_F(CollectGeometryVariablesTest, GLInArraySize)
TEST_F(CollectGeometryVariablesTest, CollectPrimitiveIDIn) TEST_F(CollectGeometryVariablesTest, CollectPrimitiveIDIn)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"layout (points) in;\n" layout (points) in;
"layout (points, max_vertices = 2) out;\n" layout (points, max_vertices = 2) out;
"void main()\n" void main()
"{\n" {
" int value = gl_PrimitiveIDIn;\n" gl_Position = vec4(gl_PrimitiveIDIn);
"}\n"; EmitVertex();
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(mTranslator->getOutputVaryings().empty()); EXPECT_EQ(1u, mTranslator->getOutputVaryings().size());
ASSERT_TRUE(mTranslator->getInBlocks().empty()); ASSERT_TRUE(mTranslator->getInBlocks().empty());
const auto &inputVaryings = mTranslator->getInputVaryings(); const auto &inputVaryings = mTranslator->getInputVaryings();
...@@ -1038,18 +1043,19 @@ TEST_F(CollectGeometryVariablesTest, CollectPrimitiveIDIn) ...@@ -1038,18 +1043,19 @@ TEST_F(CollectGeometryVariablesTest, CollectPrimitiveIDIn)
TEST_F(CollectGeometryVariablesTest, CollectInvocationID) TEST_F(CollectGeometryVariablesTest, CollectInvocationID)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"layout (points, invocations = 2) in;\n" layout (points, invocations = 2) in;
"layout (points, max_vertices = 2) out;\n" layout (points, max_vertices = 2) out;
"void main()\n" void main()
"{\n" {
" int value = gl_InvocationID;\n" gl_Position = vec4(gl_InvocationID);
"}\n"; EmitVertex();
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(mTranslator->getOutputVaryings().empty()); EXPECT_EQ(1u, mTranslator->getOutputVaryings().size());
ASSERT_TRUE(mTranslator->getInBlocks().empty()); ASSERT_TRUE(mTranslator->getInBlocks().empty());
const auto &inputVaryings = mTranslator->getInputVaryings(); const auto &inputVaryings = mTranslator->getInputVaryings();
...@@ -1069,18 +1075,19 @@ TEST_F(CollectGeometryVariablesTest, CollectInvocationID) ...@@ -1069,18 +1075,19 @@ TEST_F(CollectGeometryVariablesTest, CollectInvocationID)
TEST_F(CollectGeometryVariablesTest, CollectGLInIndexedByExpression) TEST_F(CollectGeometryVariablesTest, CollectGLInIndexedByExpression)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"layout (triangles, invocations = 2) in;\n" layout (triangles, invocations = 2) in;
"layout (points, max_vertices = 2) out;\n" layout (points, max_vertices = 2) out;
"void main()\n" void main()
"{\n" {
" vec4 value = gl_in[gl_InvocationID + 1].gl_Position;\n" gl_Position = gl_in[gl_InvocationID + 1].gl_Position;
"}\n"; EmitVertex();
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(mTranslator->getOutputVaryings().empty()); EXPECT_EQ(1u, mTranslator->getOutputVaryings().size());
const auto &inBlocks = mTranslator->getInBlocks(); const auto &inBlocks = mTranslator->getInBlocks();
ASSERT_EQ(1u, inBlocks.size()); ASSERT_EQ(1u, inBlocks.size());
...@@ -1191,12 +1198,15 @@ TEST_F(CollectGeometryVariablesTest, CollectLayer) ...@@ -1191,12 +1198,15 @@ TEST_F(CollectGeometryVariablesTest, CollectLayer)
TEST_F(CollectFragmentVariablesOESGeometryShaderTest, CollectPrimitiveID) TEST_F(CollectFragmentVariablesOESGeometryShaderTest, CollectPrimitiveID)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"void main()\n"
"{\n" out int my_out;
" int value = gl_PrimitiveID;\n"
"}\n"; void main()
{
my_out = gl_PrimitiveID;
})";
compile(shaderString); compile(shaderString);
...@@ -1219,12 +1229,15 @@ TEST_F(CollectFragmentVariablesOESGeometryShaderTest, CollectPrimitiveID) ...@@ -1219,12 +1229,15 @@ TEST_F(CollectFragmentVariablesOESGeometryShaderTest, CollectPrimitiveID)
TEST_F(CollectFragmentVariablesOESGeometryShaderTest, CollectLayer) TEST_F(CollectFragmentVariablesOESGeometryShaderTest, CollectLayer)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"void main()\n"
"{\n" out int my_out;
" int value = gl_Layer;\n"
"}\n"; void main()
{
my_out = gl_Layer;
})";
compile(shaderString); compile(shaderString);
...@@ -1300,21 +1313,22 @@ TEST_F(CollectFragmentVariablesES31Test, CollectInputWithLocation) ...@@ -1300,21 +1313,22 @@ TEST_F(CollectFragmentVariablesES31Test, CollectInputWithLocation)
TEST_F(CollectGeometryVariablesTest, CollectInputs) TEST_F(CollectGeometryVariablesTest, CollectInputs)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"layout (points) in;\n" layout (points) in;
"layout (points, max_vertices = 2) out;\n" layout (points, max_vertices = 2) out;
"in vec4 texcoord1[];\n" in vec4 texcoord1[];
"in vec4 texcoord2[1];\n" in vec4 texcoord2[1];
"void main()\n" void main()
"{\n" {
" vec4 coord1 = texcoord1[0];\n" gl_Position = texcoord1[0];
" vec4 coord2 = texcoord2[0];\n" gl_Position += texcoord2[0];
"}\n"; EmitVertex();
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(mTranslator->getOutputVaryings().empty()); EXPECT_EQ(1u, mTranslator->getOutputVaryings().size());
const auto &inputVaryings = mTranslator->getInputVaryings(); const auto &inputVaryings = mTranslator->getInputVaryings();
ASSERT_EQ(2u, inputVaryings.size()); ASSERT_EQ(2u, inputVaryings.size());
...@@ -1347,10 +1361,10 @@ TEST_F(CollectGeometryVariablesTest, CollectInputArraySizeForUnsizedInput) ...@@ -1347,10 +1361,10 @@ TEST_F(CollectGeometryVariablesTest, CollectInputArraySizeForUnsizedInput)
const std::string &kVariableDeclaration = "in vec4 texcoord[];\n"; const std::string &kVariableDeclaration = "in vec4 texcoord[];\n";
const std::string &kFunctionBody = const std::string &kFunctionBody =
"void main()\n" R"(void main()
"{\n" {
" vec4 value = texcoord[0];\n" gl_Position = texcoord[0];
"}\n"; })";
for (size_t i = 0; i < kInputPrimitives.size(); ++i) for (size_t i = 0; i < kInputPrimitives.size(); ++i)
{ {
...@@ -1382,10 +1396,11 @@ TEST_F(CollectGeometryVariablesTest, CollectInputsWithInterpolationQualifiers) ...@@ -1382,10 +1396,11 @@ TEST_F(CollectGeometryVariablesTest, CollectInputsWithInterpolationQualifiers)
{INTERPOLATION_FLAT, INTERPOLATION_SMOOTH, INTERPOLATION_CENTROID}}; {INTERPOLATION_FLAT, INTERPOLATION_SMOOTH, INTERPOLATION_CENTROID}};
const std::string &kFunctionBody = const std::string &kFunctionBody =
"void main()\n" R"(void main()
"{\n" {
" vec4 value = texcoord[0];\n" gl_Position = texcoord[0];
"}\n"; EmitVertex();
})";
for (size_t i = 0; i < kInterpolationQualifiers.size(); ++i) for (size_t i = 0; i < kInterpolationQualifiers.size(); ++i)
{ {
......
...@@ -99,28 +99,49 @@ const char ESSL300_MultipleYUVOutputsFailureShader[] = ...@@ -99,28 +99,49 @@ const char ESSL300_MultipleYUVOutputsFailureShader[] =
// Shader that specifies yuvCscStandartEXT type and associated values. // Shader that specifies yuvCscStandartEXT type and associated values.
const char ESSL300_YuvCscStandardEXTShader[] = const char ESSL300_YuvCscStandardEXTShader[] =
"precision mediump float;\n" R"(precision mediump float;
"yuvCscStandardEXT;\n" yuvCscStandardEXT;
"yuvCscStandardEXT conv;\n" yuvCscStandardEXT conv;
"yuvCscStandardEXT conv1 = itu_601;\n" yuvCscStandardEXT conv1 = itu_601;
"yuvCscStandardEXT conv2 = itu_601_full_range;\n" yuvCscStandardEXT conv2 = itu_601_full_range;
"yuvCscStandardEXT conv3 = itu_709;\n" yuvCscStandardEXT conv3 = itu_709;
"const yuvCscStandardEXT conv4 = itu_709;\n" const yuvCscStandardEXT conv4 = itu_709;
"yuvCscStandardEXT conv_standard() {\n"
" return itu_601;\n" uniform int u;
"}\n" out vec4 my_color;
"bool is_itu_601(inout yuvCscStandardEXT csc) {\n"
" csc = itu_601;\n" yuvCscStandardEXT conv_standard()
" return csc == itu_601;\n" {
"}\n" switch(u)
"bool is_itu_709(yuvCscStandardEXT csc) {\n" {
" return csc == itu_709;\n" case 1:
"}\n" return conv1;
"void main() { \n" case 2:
" yuvCscStandardEXT conv = conv_standard();\n" return conv2;
" bool csc_check1 = is_itu_601(conv);\n" case 3:
" bool csc_check2 = is_itu_709(itu_709);\n" return conv3;
"}\n"; default:
return conv;
}
}
bool is_itu_601(inout yuvCscStandardEXT csc)
{
csc = itu_601;
return csc == itu_601;
}
bool is_itu_709(yuvCscStandardEXT csc)
{
return csc == itu_709;
}
void main()
{
yuvCscStandardEXT conv = conv_standard();
bool csc_check1 = is_itu_601(conv);
bool csc_check2 = is_itu_709(itu_709);
if (csc_check1 && csc_check2) {
my_color = vec4(0, 1, 0, 1);
}
})";
// Shader that specifies yuvCscStandartEXT type constructor fails to compile. // Shader that specifies yuvCscStandartEXT type constructor fails to compile.
const char ESSL300_YuvCscStandartdEXTConstructFailureShader1[] = const char ESSL300_YuvCscStandartdEXTConstructFailureShader1[] =
...@@ -187,12 +208,17 @@ const char ESSL300_YuvCscStandartdEXTQualifiersFailureShader3[] = ...@@ -187,12 +208,17 @@ const char ESSL300_YuvCscStandartdEXTQualifiersFailureShader3[] =
// Shader that specifies yuv_to_rgb() and rgb_to_yuv() built-in functions. // Shader that specifies yuv_to_rgb() and rgb_to_yuv() built-in functions.
const char ESSL300_BuiltInFunctionsShader[] = const char ESSL300_BuiltInFunctionsShader[] =
"precision mediump float;\n" R"(precision mediump float;
"yuvCscStandardEXT conv = itu_601;\n" yuvCscStandardEXT conv = itu_601;
"void main() { \n"
" vec3 yuv = rgb_2_yuv(vec3(0.0f), conv);\n" out vec4 my_color;
" vec3 rgb = yuv_2_rgb(yuv, itu_601);\n"
"}\n"; void main()
{
vec3 yuv = rgb_2_yuv(vec3(0.0f), conv);
vec3 rgb = yuv_2_rgb(yuv, itu_601);
my_color = vec4(rgb, 1.0);
})";
class EXTYUVTargetTest : public testing::TestWithParam<testing::tuple<const char *, const char *>> class EXTYUVTargetTest : public testing::TestWithParam<testing::tuple<const char *, const char *>>
{ {
......
...@@ -119,7 +119,6 @@ class GeometryShaderTest : public ShaderCompileTreeTest ...@@ -119,7 +119,6 @@ class GeometryShaderTest : public ShaderCompileTreeTest
out vec4 o_color; out vec4 o_color;
void main() void main()
{ {
int maxValue = gl_MaxGeometryInputComponents;
for (int i = 0; i < i_color.length(); i++) for (int i = 0; i < i_color.length(); i++)
{ {
gl_Position = gl_in[i].gl_Position; gl_Position = gl_in[i].gl_Position;
...@@ -995,14 +994,15 @@ TEST_F(GeometryShaderTest, UseGLInLengthWithoutInputPrimitive) ...@@ -995,14 +994,15 @@ TEST_F(GeometryShaderTest, UseGLInLengthWithoutInputPrimitive)
TEST_F(GeometryShaderTest, UseGLInLengthWithInputPrimitive) TEST_F(GeometryShaderTest, UseGLInLengthWithInputPrimitive)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"layout (points) in;\n" layout (points) in;
"layout (points, max_vertices = 2) out;\n" layout (points, max_vertices = 2) out;
"void main()\n" void main()
"{\n" {
" int length = gl_in.length();\n" gl_Position = vec4(gl_in.length());
"}\n"; EmitVertex();
})";
if (!compile(shaderString)) if (!compile(shaderString))
{ {
...@@ -1135,13 +1135,13 @@ TEST_F(GeometryShaderTest, GeometryShaderBuiltInFunctionsWithoutExtension) ...@@ -1135,13 +1135,13 @@ TEST_F(GeometryShaderTest, GeometryShaderBuiltInFunctionsWithoutExtension)
TEST_F(GeometryShaderTest, GeometryShaderBuiltInConstants) TEST_F(GeometryShaderTest, GeometryShaderBuiltInConstants)
{ {
const std::string &kShaderHeader = const std::string &kShaderHeader =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"layout (points) in;\n" layout (points) in;
"layout (points, max_vertices = 2) out;\n" layout (points, max_vertices = 2) out;
"void main()\n" void main()
"{\n" {
" int val = "; gl_Position.x = float()";
const std::array<std::string, 9> kGeometryShaderBuiltinConstants = {{ const std::array<std::string, 9> kGeometryShaderBuiltinConstants = {{
"gl_MaxGeometryInputComponents", "gl_MaxGeometryOutputComponents", "gl_MaxGeometryInputComponents", "gl_MaxGeometryOutputComponents",
...@@ -1152,8 +1152,9 @@ TEST_F(GeometryShaderTest, GeometryShaderBuiltInConstants) ...@@ -1152,8 +1152,9 @@ TEST_F(GeometryShaderTest, GeometryShaderBuiltInConstants)
}}; }};
const std::string &kShaderTail = const std::string &kShaderTail =
";\n" R"();
"}\n"; EmitVertex();
})";
for (const std::string &kGSBuiltinConstant : kGeometryShaderBuiltinConstants) for (const std::string &kGSBuiltinConstant : kGeometryShaderBuiltinConstants)
{ {
...@@ -1295,7 +1296,8 @@ TEST_F(GeometryShaderTest, IndexingUnsizedInputDeclaredAfterInputPrimitive) ...@@ -1295,7 +1296,8 @@ TEST_F(GeometryShaderTest, IndexingUnsizedInputDeclaredAfterInputPrimitive)
in vec4[] texcoord3, texcoord4; in vec4[] texcoord3, texcoord4;
void main() void main()
{ {
vec4 coord = texcoord[0] + texcoord2[0] + texcoord3[0] + texcoord4[0]; gl_Position = texcoord[0] + texcoord2[0] + texcoord3[0] + texcoord4[0];
EmitVertex();
})"; })";
if (!compile(shaderString)) if (!compile(shaderString))
...@@ -1309,15 +1311,16 @@ TEST_F(GeometryShaderTest, IndexingUnsizedInputDeclaredAfterInputPrimitive) ...@@ -1309,15 +1311,16 @@ TEST_F(GeometryShaderTest, IndexingUnsizedInputDeclaredAfterInputPrimitive)
TEST_F(GeometryShaderTest, CallingLengthOnUnsizedInputDeclaredAfterInputPrimitive) TEST_F(GeometryShaderTest, CallingLengthOnUnsizedInputDeclaredAfterInputPrimitive)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"layout (points) in;\n" layout (points) in;
"layout (points, max_vertices = 1) out;\n" layout (points, max_vertices = 1) out;
"in vec4 texcoord[];\n" in vec4 texcoord[];
"void main()\n" void main()
"{\n" {
" int length = texcoord.length();\n" gl_Position = vec4(texcoord.length());
"}\n"; EmitVertex();
})";
if (!compile(shaderString)) if (!compile(shaderString))
{ {
...@@ -1349,18 +1352,19 @@ TEST_F(GeometryShaderTest, AssignValueToInput) ...@@ -1349,18 +1352,19 @@ TEST_F(GeometryShaderTest, AssignValueToInput)
TEST_F(GeometryShaderTest, InputWithLocations) TEST_F(GeometryShaderTest, InputWithLocations)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"layout (triangles) in;\n" layout (triangles) in;
"layout (points, max_vertices = 1) out;\n" layout (points, max_vertices = 1) out;
"layout (location = 0) in vec4 texcoord1[];\n" layout (location = 0) in vec4 texcoord1[];
"layout (location = 1) in vec4 texcoord2[];\n" layout (location = 1) in vec4 texcoord2[];
"void main()\n" void main()
"{\n" {
" int index = 0;\n" int index = 0;
" vec4 coord1 = texcoord1[0];\n" vec4 coord1 = texcoord1[0];
" vec4 coord2 = texcoord2[index];\n" vec4 coord2 = texcoord2[index];
"}\n"; gl_Position = coord1 + coord2;
})";
if (!compile(shaderString)) if (!compile(shaderString))
{ {
......
...@@ -27,14 +27,15 @@ class PackUnpackTest : public MatchOutputCodeTest ...@@ -27,14 +27,15 @@ class PackUnpackTest : public MatchOutputCodeTest
TEST_F(PackUnpackTest, PackSnorm2x16Emulation) TEST_F(PackUnpackTest, PackSnorm2x16Emulation)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" R"(#version 300 es
"precision mediump float;\n" precision mediump float;
"layout(location = 0) out mediump vec4 fragColor;" layout(location = 0) out mediump vec4 fragColor;
"void main() {\n" void main()
" vec2 v;\n" {
" uint u = packSnorm2x16(v);\n" vec2 v;
" fragColor = vec4(0.0);\n" uint u = packSnorm2x16(v);
"}\n"; fragColor = vec4(u);
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("uint packSnorm2x16_emu(vec2 v)")); ASSERT_TRUE(foundInCode("uint packSnorm2x16_emu(vec2 v)"));
} }
...@@ -43,14 +44,15 @@ TEST_F(PackUnpackTest, PackSnorm2x16Emulation) ...@@ -43,14 +44,15 @@ TEST_F(PackUnpackTest, PackSnorm2x16Emulation)
TEST_F(PackUnpackTest, UnpackSnorm2x16Emulation) TEST_F(PackUnpackTest, UnpackSnorm2x16Emulation)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" R"(#version 300 es
"precision mediump float;\n" precision mediump float;
"layout(location = 0) out mediump vec4 fragColor;" layout(location = 0) out mediump vec4 fragColor;
"void main() {\n" void main()
" uint u;\n" {
" vec2 v=unpackSnorm2x16(u);\n" uint u;
" fragColor = vec4(0.0);\n" vec2 v = unpackSnorm2x16(u);
"}\n"; fragColor = vec4(v, 0.0, 0.0);
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("vec2 unpackSnorm2x16_emu(uint u)")); ASSERT_TRUE(foundInCode("vec2 unpackSnorm2x16_emu(uint u)"));
} }
...@@ -59,14 +61,15 @@ TEST_F(PackUnpackTest, UnpackSnorm2x16Emulation) ...@@ -59,14 +61,15 @@ TEST_F(PackUnpackTest, UnpackSnorm2x16Emulation)
TEST_F(PackUnpackTest, PackUnorm2x16Emulation) TEST_F(PackUnpackTest, PackUnorm2x16Emulation)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" R"(#version 300 es
"precision mediump float;\n" precision mediump float;
"layout(location = 0) out mediump vec4 fragColor;" layout(location = 0) out mediump vec4 fragColor;
"void main() {\n" void main()
" vec2 v;\n" {
" uint u = packUnorm2x16(v);\n" vec2 v;
" fragColor = vec4(0.0);\n" uint u = packUnorm2x16(v);
"}\n"; fragColor = vec4(u);
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("uint packUnorm2x16_emu(vec2 v)")); ASSERT_TRUE(foundInCode("uint packUnorm2x16_emu(vec2 v)"));
} }
...@@ -75,14 +78,15 @@ TEST_F(PackUnpackTest, PackUnorm2x16Emulation) ...@@ -75,14 +78,15 @@ TEST_F(PackUnpackTest, PackUnorm2x16Emulation)
TEST_F(PackUnpackTest, UnpackUnorm2x16Emulation) TEST_F(PackUnpackTest, UnpackUnorm2x16Emulation)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" R"(#version 300 es
"precision mediump float;\n" precision mediump float;
"layout(location = 0) out mediump vec4 fragColor;" layout(location = 0) out mediump vec4 fragColor;
"void main() {\n" void main()
" uint u;\n" {
" vec2 v=unpackUnorm2x16(u);\n" uint u;
" fragColor = vec4(0.0);\n" vec2 v = unpackUnorm2x16(u);
"}\n"; fragColor = vec4(v, 0.0, 0.0);
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("vec2 unpackUnorm2x16_emu(uint u)")); ASSERT_TRUE(foundInCode("vec2 unpackUnorm2x16_emu(uint u)"));
} }
...@@ -91,14 +95,15 @@ TEST_F(PackUnpackTest, UnpackUnorm2x16Emulation) ...@@ -91,14 +95,15 @@ TEST_F(PackUnpackTest, UnpackUnorm2x16Emulation)
TEST_F(PackUnpackTest, PackHalf2x16Emulation) TEST_F(PackUnpackTest, PackHalf2x16Emulation)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" R"(#version 300 es
"precision mediump float;\n" precision mediump float;
"layout(location = 0) out mediump vec4 fragColor;" layout(location = 0) out mediump vec4 fragColor;
"void main() {\n" void main()
" vec2 v;\n" {
" uint u=packHalf2x16(v);\n" vec2 v;
" fragColor = vec4(0.0);\n" uint u = packHalf2x16(v);
"}\n"; fragColor = vec4(u);
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("uint packHalf2x16_emu(vec2 v)")); ASSERT_TRUE(foundInCode("uint packHalf2x16_emu(vec2 v)"));
} }
...@@ -107,14 +112,15 @@ TEST_F(PackUnpackTest, PackHalf2x16Emulation) ...@@ -107,14 +112,15 @@ TEST_F(PackUnpackTest, PackHalf2x16Emulation)
TEST_F(PackUnpackTest, UnpackHalf2x16Emulation) TEST_F(PackUnpackTest, UnpackHalf2x16Emulation)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" R"(#version 300 es
"precision mediump float;\n" precision mediump float;
"layout(location = 0) out mediump vec4 fragColor;" layout(location = 0) out mediump vec4 fragColor;
"void main() {\n" void main()
" uint u;\n" {
" vec2 v=unpackHalf2x16(u);\n" uint u;
" fragColor = vec4(0.0);\n" vec2 v = unpackHalf2x16(u);
"}\n"; fragColor = vec4(v, 0.0, 0.0);
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("vec2 unpackHalf2x16_emu(uint u)")); ASSERT_TRUE(foundInCode("vec2 unpackHalf2x16_emu(uint u)"));
} }
......
...@@ -27,12 +27,13 @@ class PrunePureLiteralStatementsTest : public MatchOutputCodeTest ...@@ -27,12 +27,13 @@ class PrunePureLiteralStatementsTest : public MatchOutputCodeTest
TEST_F(PrunePureLiteralStatementsTest, FloatLiteralStatement) TEST_F(PrunePureLiteralStatementsTest, FloatLiteralStatement)
{ {
const std::string shaderString = const std::string shaderString =
"precision mediump float;\n" R"(precision mediump float;
"void main()\n" void main()
"{\n" {
" float f = 41.0;\n" float f = 41.0;
" 42.0;\n" 42.0;
"}\n"; gl_FragColor = vec4(f);
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("41")); ASSERT_TRUE(foundInCode("41"));
ASSERT_TRUE(notFoundInCode("42")); ASSERT_TRUE(notFoundInCode("42"));
...@@ -42,12 +43,13 @@ TEST_F(PrunePureLiteralStatementsTest, FloatLiteralStatement) ...@@ -42,12 +43,13 @@ TEST_F(PrunePureLiteralStatementsTest, FloatLiteralStatement)
TEST_F(PrunePureLiteralStatementsTest, ConstructorLiteralStatement) TEST_F(PrunePureLiteralStatementsTest, ConstructorLiteralStatement)
{ {
const std::string shaderString = const std::string shaderString =
"precision mediump float;\n" R"(precision mediump float;
"void main()\n" void main()
"{\n" {
" vec2 f = vec2(41.0, 41.0);\n" vec2 f = vec2(41.0, 41.0);
" vec2(42.0, 42.0);\n" vec2(42.0, 42.0);
"}\n"; gl_FragColor = vec4(f, 0.0, 0.0);
})";
compile(shaderString); compile(shaderString);
ASSERT_TRUE(foundInCode("41")); ASSERT_TRUE(foundInCode("41"));
ASSERT_TRUE(notFoundInCode("42")); ASSERT_TRUE(notFoundInCode("42"));
......
...@@ -2339,17 +2339,19 @@ TEST_F(ComputeShaderValidationTest, InvalidUsageOfWorkGroupSize) ...@@ -2339,17 +2339,19 @@ TEST_F(ComputeShaderValidationTest, InvalidUsageOfWorkGroupSize)
TEST_F(ComputeShaderValidationTest, CorrectUsageOfComputeBuiltins) TEST_F(ComputeShaderValidationTest, CorrectUsageOfComputeBuiltins)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 310 es\n" R"(#version 310 es
"layout(local_size_x = 12) in;\n" layout(local_size_x=4, local_size_y=3, local_size_z=2) in;
"void main()\n" layout(rgba32ui) uniform highp writeonly uimage2D imageOut;
"{\n" void main()
" uvec3 NumWorkGroups = gl_NumWorkGroups;\n" {
" uvec3 WorkGroupSize = gl_WorkGroupSize;\n" uvec3 temp1 = gl_NumWorkGroups;
" uvec3 WorkGroupID = gl_WorkGroupID;\n" uvec3 temp2 = gl_WorkGroupSize;
" uvec3 GlobalInvocationID = gl_GlobalInvocationID;\n" uvec3 temp3 = gl_WorkGroupID;
" uvec3 LocalInvocationID = gl_LocalInvocationID;\n" uvec3 temp4 = gl_LocalInvocationID;
" uint LocalInvocationIndex = gl_LocalInvocationIndex;\n" uvec3 temp5 = gl_GlobalInvocationID;
"}\n"; uint temp6 = gl_LocalInvocationIndex;
imageStore(imageOut, ivec2(0), uvec4(temp1 + temp2 + temp3 + temp4 + temp5, temp6));
})";
if (!compile(shaderString)) if (!compile(shaderString))
{ {
FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog; FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog;
...@@ -2589,11 +2591,12 @@ TEST_F(FragmentShaderValidationTest, VariableDeclarationWithInvariantAndLayoutQu ...@@ -2589,11 +2591,12 @@ TEST_F(FragmentShaderValidationTest, VariableDeclarationWithInvariantAndLayoutQu
TEST_F(FragmentShaderValidationTest, ShiftBy32) TEST_F(FragmentShaderValidationTest, ShiftBy32)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" R"(#version 300 es
"precision mediump float;\n" precision mediump float;
"void main() {\n" out uint my_out;
" uint u = 1u << 32u;\n" void main() {
"}\n"; my_out = 1u << 32u;
})";
if (compile(shaderString)) if (compile(shaderString))
{ {
if (!hasWarning()) if (!hasWarning())
...@@ -2614,11 +2617,12 @@ TEST_F(FragmentShaderValidationTest, ShiftBy32) ...@@ -2614,11 +2617,12 @@ TEST_F(FragmentShaderValidationTest, ShiftBy32)
TEST_F(FragmentShaderValidationTest, ShiftByNegative) TEST_F(FragmentShaderValidationTest, ShiftByNegative)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" R"(#version 300 es
"precision mediump float;\n" precision mediump float;
"void main() {\n" out uint my_out;
" uint u = 1u << (-1);\n" void main() {
"}\n"; my_out = 1u << (-1);
})";
if (compile(shaderString)) if (compile(shaderString))
{ {
if (!hasWarning()) if (!hasWarning())
...@@ -4017,12 +4021,15 @@ TEST_F(FragmentShaderValidationTest, InvalidInterfaceBlockTernaryExpression) ...@@ -4017,12 +4021,15 @@ TEST_F(FragmentShaderValidationTest, InvalidInterfaceBlockTernaryExpression)
TEST_F(FragmentShaderValidationTest, BufferAndSharedAsIdentifierOnES3) TEST_F(FragmentShaderValidationTest, BufferAndSharedAsIdentifierOnES3)
{ {
const std::string &shaderString = const std::string &shaderString =
"#version 300 es\n" R"(#version 300 es
"void main()\n" precision highp float;
"{\n" out vec4 my_out;
" int buffer;\n" void main()
" int shared;\n" {
"}\n"; int buffer = 1;
int shared = 2;
my_out = vec4(buffer + shared);
})";
if (!compile(shaderString)) if (!compile(shaderString))
{ {
...@@ -4558,13 +4565,13 @@ TEST_F(FragmentShaderOESGeometryShaderValidationTest, AssignValueToLayer) ...@@ -4558,13 +4565,13 @@ TEST_F(FragmentShaderOESGeometryShaderValidationTest, AssignValueToLayer)
TEST_F(FragmentShaderOESGeometryShaderValidationTest, GeometryShaderBuiltInConstants) TEST_F(FragmentShaderOESGeometryShaderValidationTest, GeometryShaderBuiltInConstants)
{ {
const std::string &kShaderHeader = const std::string &kShaderHeader =
"#version 310 es\n" R"(#version 310 es
"#extension GL_OES_geometry_shader : require\n" #extension GL_OES_geometry_shader : require
"precision mediump float;\n" precision mediump float;
"layout(location = 0) out mediump vec4 fragColor;\n" layout(location = 0) out mediump vec4 fragColor;
"void main(void)\n" void main(void)
"{\n" {
" int val = "; int val = )";
const std::array<std::string, 9> kGeometryShaderBuiltinConstants = {{ const std::array<std::string, 9> kGeometryShaderBuiltinConstants = {{
"gl_MaxGeometryInputComponents", "gl_MaxGeometryOutputComponents", "gl_MaxGeometryInputComponents", "gl_MaxGeometryOutputComponents",
...@@ -4575,9 +4582,9 @@ TEST_F(FragmentShaderOESGeometryShaderValidationTest, GeometryShaderBuiltInConst ...@@ -4575,9 +4582,9 @@ TEST_F(FragmentShaderOESGeometryShaderValidationTest, GeometryShaderBuiltInConst
}}; }};
const std::string &kShaderTail = const std::string &kShaderTail =
";\n" R"(;
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n" fragColor = vec4(val, 0, 0, 1);
"}\n"; })";
for (const std::string &kGSBuiltinConstant : kGeometryShaderBuiltinConstants) for (const std::string &kGSBuiltinConstant : kGeometryShaderBuiltinConstants)
{ {
......
...@@ -254,18 +254,17 @@ TEST(ShaderVariableTest, IllegalInvariantVarying) ...@@ -254,18 +254,17 @@ TEST(ShaderVariableTest, IllegalInvariantVarying)
SH_GLSL_COMPATIBILITY_OUTPUT, &resources); SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
EXPECT_NE(static_cast<ShHandle>(0), compiler); EXPECT_NE(static_cast<ShHandle>(0), compiler);
const char *program1[] = const char *program1[] = {
{ R"(void foo()
"void foo() {\n" {
" vec4 v;\n" }
"}\n" varying vec4 v_varying;
"varying vec4 v_varying;\n" invariant v_varying;
"invariant v_varying;\n" void main()
"void main() {\n" {
" foo();\n" foo();
" gl_Position = v_varying;\n" gl_Position = v_varying;
"}" })"};
};
const char *program2[] = const char *program2[] =
{ {
"varying vec4 v_varying;\n" "varying vec4 v_varying;\n"
......
...@@ -387,7 +387,7 @@ TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionFloatResultTypeAndPrecision) ...@@ -387,7 +387,7 @@ TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionFloatResultTypeAndPrecision)
"void main() {\n" "void main() {\n"
" float fval2 = abs(fval1);\n" " float fval2 = abs(fval1);\n"
" float fval3 = sign(fval1);\n" " float fval3 = sign(fval1);\n"
" gl_FragColor = vec4(fval1, 0.0, 0.0, 1.0); \n" " gl_FragColor = vec4(fval1, fval2, fval3, 1.0); \n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree()); ASSERT_FALSE(foundErrorInIntermediateTree());
...@@ -406,7 +406,7 @@ TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionIntResultTypeAndPrecision) ...@@ -406,7 +406,7 @@ TEST_F(TypeTrackingTest, BuiltInAbsSignFunctionIntResultTypeAndPrecision)
"void main() {\n" "void main() {\n"
" int ival2 = abs(ival1);\n" " int ival2 = abs(ival1);\n"
" int ival3 = sign(ival1);\n" " int ival3 = sign(ival1);\n"
" my_FragColor = vec4(0.0, 0.0, 0.0, 1.0); \n" " my_FragColor = vec4(ival2, ival3, 0, 1); \n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree()); ASSERT_FALSE(foundErrorInIntermediateTree());
...@@ -426,7 +426,7 @@ TEST_F(TypeTrackingTest, BuiltInFloatBitsToIntResultTypeAndPrecision) ...@@ -426,7 +426,7 @@ TEST_F(TypeTrackingTest, BuiltInFloatBitsToIntResultTypeAndPrecision)
"void main() {\n" "void main() {\n"
" int i = floatBitsToInt(f);\n" " int i = floatBitsToInt(f);\n"
" uint u = floatBitsToUint(f);\n" " uint u = floatBitsToUint(f);\n"
" my_FragColor = vec4(0.0, 0.0, 0.0, 1.0); \n" " my_FragColor = vec4(i, int(u), 0, 1); \n"
"}\n"; "}\n";
compile(shaderString); compile(shaderString);
ASSERT_FALSE(foundErrorInIntermediateTree()); ASSERT_FALSE(foundErrorInIntermediateTree());
......
...@@ -64,26 +64,26 @@ TEST_P(ComputeShaderTest, LinkComputeProgramNoLocalSizeLinkError) ...@@ -64,26 +64,26 @@ TEST_P(ComputeShaderTest, LinkComputeProgramNoLocalSizeLinkError)
TEST_P(ComputeShaderTest, LinkComputeProgramWithUniforms) TEST_P(ComputeShaderTest, LinkComputeProgramWithUniforms)
{ {
const std::string csSource = const std::string csSource =
"#version 310 es\n" R"(#version 310 es
"precision mediump sampler2D;\n" precision mediump sampler2D;
"layout(local_size_x=1) in;\n" layout(local_size_x=1) in;
"uniform int myUniformInt;\n" uniform int myUniformInt;
"uniform sampler2D myUniformSampler;\n" uniform sampler2D myUniformSampler;
"void main()\n" layout(rgba32i) uniform highp writeonly iimage2D imageOut;
"{\n" void main()
"int q = myUniformInt;\n" {
"texture(myUniformSampler, vec2(0.0));\n" int q = myUniformInt;
"}\n"; vec4 v = textureLod(myUniformSampler, vec2(0.0), 0.0);
imageStore(imageOut, ivec2(0), ivec4(v) * q);
})";
ANGLE_GL_COMPUTE_PROGRAM(program, csSource); ANGLE_GL_COMPUTE_PROGRAM(program, csSource);
// It's not possible to validate uniforms are present since they are unreferenced. GLint uniformLoc = glGetUniformLocation(program.get(), "myUniformInt");
// TODO(jmadill): Make uniforms referenced. EXPECT_NE(-1, uniformLoc);
// GLint uniformLoc = glGetUniformLocation(program.get(), "myUniformInt");
// EXPECT_NE(-1, uniformLoc);
// uniformLoc = glGetUniformLocation(program.get(), "myUniformSampler"); uniformLoc = glGetUniformLocation(program.get(), "myUniformSampler");
// EXPECT_NE(-1, uniformLoc); EXPECT_NE(-1, uniformLoc);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
} }
...@@ -238,17 +238,19 @@ TEST_P(ComputeShaderTest, DispatchComputeWithRenderingProgram) ...@@ -238,17 +238,19 @@ TEST_P(ComputeShaderTest, DispatchComputeWithRenderingProgram)
TEST_P(ComputeShaderTest, AccessAllSpecialVariables) TEST_P(ComputeShaderTest, AccessAllSpecialVariables)
{ {
const std::string csSource = const std::string csSource =
"#version 310 es\n" R"(#version 310 es
"layout(local_size_x=4, local_size_y=3, local_size_z=2) in;\n" layout(local_size_x=4, local_size_y=3, local_size_z=2) in;
"void main()\n" layout(rgba32ui) uniform highp writeonly uimage2D imageOut;
"{\n" void main()
" uvec3 temp1 = gl_NumWorkGroups;\n" {
" uvec3 temp2 = gl_WorkGroupSize;\n" uvec3 temp1 = gl_NumWorkGroups;
" uvec3 temp3 = gl_WorkGroupID;\n" uvec3 temp2 = gl_WorkGroupSize;
" uvec3 temp4 = gl_LocalInvocationID;\n" uvec3 temp3 = gl_WorkGroupID;
" uvec3 temp5 = gl_GlobalInvocationID;\n" uvec3 temp4 = gl_LocalInvocationID;
" uint temp6 = gl_LocalInvocationIndex;\n" uvec3 temp5 = gl_GlobalInvocationID;
"}\n"; uint temp6 = gl_LocalInvocationIndex;
imageStore(imageOut, ivec2(gl_LocalInvocationIndex, 0), uvec4(temp1 + temp2 + temp3 + temp4 + temp5, temp6));
})";
ANGLE_GL_COMPUTE_PROGRAM(program, csSource); ANGLE_GL_COMPUTE_PROGRAM(program, csSource);
} }
...@@ -257,14 +259,16 @@ TEST_P(ComputeShaderTest, AccessAllSpecialVariables) ...@@ -257,14 +259,16 @@ TEST_P(ComputeShaderTest, AccessAllSpecialVariables)
TEST_P(ComputeShaderTest, AccessPartSpecialVariables) TEST_P(ComputeShaderTest, AccessPartSpecialVariables)
{ {
const std::string csSource = const std::string csSource =
"#version 310 es\n" R"(#version 310 es
"layout(local_size_x=4, local_size_y=3, local_size_z=2) in;\n" layout(local_size_x=4, local_size_y=3, local_size_z=2) in;
"void main()\n" layout(rgba32ui) uniform highp writeonly uimage2D imageOut;
"{\n" void main()
" uvec3 temp1 = gl_WorkGroupSize;\n" {
" uvec3 temp2 = gl_WorkGroupID;\n" uvec3 temp1 = gl_WorkGroupSize;
" uint temp3 = gl_LocalInvocationIndex;\n" uvec3 temp2 = gl_WorkGroupID;
"}\n"; uint temp3 = gl_LocalInvocationIndex;
imageStore(imageOut, ivec2(gl_LocalInvocationIndex, 0), uvec4(temp1 + temp2, temp3));
})";
ANGLE_GL_COMPUTE_PROGRAM(program, csSource); ANGLE_GL_COMPUTE_PROGRAM(program, csSource);
} }
...@@ -273,12 +277,14 @@ TEST_P(ComputeShaderTest, AccessPartSpecialVariables) ...@@ -273,12 +277,14 @@ TEST_P(ComputeShaderTest, AccessPartSpecialVariables)
TEST_P(ComputeShaderTest, DispatchCompute) TEST_P(ComputeShaderTest, DispatchCompute)
{ {
const std::string csSource = const std::string csSource =
"#version 310 es\n" R"(#version 310 es
"layout(local_size_x=4, local_size_y=3, local_size_z=2) in;\n" layout(local_size_x=4, local_size_y=3, local_size_z=2) in;
"void main()\n" layout(rgba32ui) uniform highp writeonly uimage2D imageOut;
"{\n" void main()
" uvec3 temp = gl_NumWorkGroups;\n" {
"}\n"; uvec3 temp = gl_NumWorkGroups;
imageStore(imageOut, ivec2(0), uvec4(temp, 0u));
})";
ANGLE_GL_COMPUTE_PROGRAM(program, csSource); ANGLE_GL_COMPUTE_PROGRAM(program, csSource);
...@@ -412,17 +418,19 @@ TEST_P(ComputeShaderTest, ImageArrayWithoutBindingQualifier) ...@@ -412,17 +418,19 @@ TEST_P(ComputeShaderTest, ImageArrayWithoutBindingQualifier)
TEST_P(ComputeShaderTest, ImageLoad) TEST_P(ComputeShaderTest, ImageLoad)
{ {
const std::string csSource = const std::string csSource =
"#version 310 es\n" R"(#version 310 es
"layout(local_size_x=8) in;\n" layout(local_size_x=8) in;
"layout(rgba8) uniform highp readonly image2D mImage2DInput;\n" layout(rgba8) uniform highp readonly image2D mImage2DInput;
"layout(rgba16i) uniform highp readonly iimageCube mImageCubeInput;\n" layout(rgba16i) uniform highp readonly iimageCube mImageCubeInput;
"layout(rgba32ui) uniform highp readonly uimage3D mImage3DInput;\n" layout(rgba32ui) uniform highp readonly uimage3D mImage3DInput;
"void main()\n" layout(r32i) uniform highp writeonly iimage2D imageOut;
"{\n" void main()
" vec4 result2d = imageLoad(mImage2DInput, ivec2(gl_LocalInvocationID.xy));\n" {
" ivec4 resultCube = imageLoad(mImageCubeInput, ivec3(gl_LocalInvocationID.xyz));\n" vec4 result2d = imageLoad(mImage2DInput, ivec2(gl_LocalInvocationID.xy));
" uvec4 result3d = imageLoad(mImage3DInput, ivec3(gl_LocalInvocationID.xyz));\n" ivec4 resultCube = imageLoad(mImageCubeInput, ivec3(gl_LocalInvocationID.xyz));
"}\n"; uvec4 result3d = imageLoad(mImage3DInput, ivec3(gl_LocalInvocationID.xyz));
imageStore(imageOut, ivec2(gl_LocalInvocationIndex, 0), ivec4(result2d) + resultCube + ivec4(result3d));
})";
ANGLE_GL_COMPUTE_PROGRAM(program, csSource); ANGLE_GL_COMPUTE_PROGRAM(program, csSource);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
...@@ -452,17 +460,19 @@ TEST_P(ComputeShaderTest, ImageStore) ...@@ -452,17 +460,19 @@ TEST_P(ComputeShaderTest, ImageStore)
TEST_P(ComputeShaderTest, ImageSize) TEST_P(ComputeShaderTest, ImageSize)
{ {
const std::string csSource = const std::string csSource =
"#version 310 es\n" R"(#version 310 es
"layout(local_size_x=8) in;\n" layout(local_size_x=8) in;
"layout(rgba8) uniform highp readonly imageCube mImageCubeInput;\n" layout(rgba8) uniform highp readonly imageCube mImageCubeInput;
"layout(r32i) uniform highp readonly iimage2D mImage2DInput;\n" layout(r32i) uniform highp readonly iimage2D mImage2DInput;
"layout(rgba16ui) uniform highp readonly uimage2DArray mImage2DArrayInput;\n" layout(rgba16ui) uniform highp readonly uimage2DArray mImage2DArrayInput;
"void main()\n" layout(r32i) uniform highp writeonly iimage2D imageOut;
"{\n" void main()
" ivec2 sizeCube = imageSize(mImageCubeInput);\n" {
" ivec2 size2D = imageSize(mImage2DInput);\n" ivec2 sizeCube = imageSize(mImageCubeInput);
" ivec3 size2DArray = imageSize(mImage2DArrayInput);\n" ivec2 size2D = imageSize(mImage2DInput);
"}\n"; ivec3 size2DArray = imageSize(mImage2DArrayInput);
imageStore(imageOut, ivec2(gl_LocalInvocationIndex, 0), ivec4(sizeCube, size2D.x, size2DArray.x));
})";
ANGLE_GL_COMPUTE_PROGRAM(program, csSource); ANGLE_GL_COMPUTE_PROGRAM(program, csSource);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
......
...@@ -2474,14 +2474,23 @@ TEST_P(GLSLTest_ES3, LiteralNegativeInfinityOutput) ...@@ -2474,14 +2474,23 @@ TEST_P(GLSLTest_ES3, LiteralNegativeInfinityOutput)
TEST_P(GLSLTest_ES3, MultipleDeclarationWithCommaOperator) TEST_P(GLSLTest_ES3, MultipleDeclarationWithCommaOperator)
{ {
const std::string &fragmentShader = const std::string &fragmentShader =
"#version 300 es\n" R"(#version 300 es
"precision mediump float;\n" precision mediump float;
"out vec4 color;\n" out vec4 color;
"void main(void)\n"
"{\n" uniform float u;
" float a = 0.0, b = ((gl_FragCoord.x < 0.5 ? a : 0.0), 1.0);\n" float c = 0.0;
" color = vec4(b);\n" float sideEffect()
"}\n"; {
c = u;
return c;
}
void main(void)
{
float a = 0.0, b = ((gl_FragCoord.x < 0.5 ? a : sideEffect()), a);
color = vec4(b + c);
})";
ANGLE_GL_PROGRAM(program, mSimpleVSSource, fragmentShader); ANGLE_GL_PROGRAM(program, mSimpleVSSource, fragmentShader);
} }
...@@ -2491,17 +2500,26 @@ TEST_P(GLSLTest_ES3, MultipleDeclarationWithCommaOperator) ...@@ -2491,17 +2500,26 @@ TEST_P(GLSLTest_ES3, MultipleDeclarationWithCommaOperator)
TEST_P(GLSLTest_ES3, MultipleDeclarationWithCommaOperatorInForLoop) TEST_P(GLSLTest_ES3, MultipleDeclarationWithCommaOperatorInForLoop)
{ {
const std::string &fragmentShader = const std::string &fragmentShader =
"#version 300 es\n" R"(#version 300 es
"precision mediump float;\n" precision mediump float;
"out vec4 color;\n" out vec4 color;
"void main(void)\n"
"{\n" uniform float u;
" for(float a = 0.0, b = ((gl_FragCoord.x < 0.5 ? a : 0.0), 1.0); a < 10.0; a++)\n" float c = 0.0;
" {\n" float sideEffect()
" b += 1.0;\n" {
" color = vec4(b);\n" c = u;
" }\n" return c;
"}\n"; }
void main(void)
{
for(float a = 0.0, b = ((gl_FragCoord.x < 0.5 ? a : sideEffect()), a); a < 10.0; a++)
{
b += 1.0;
color = vec4(b);
}
})";
ANGLE_GL_PROGRAM(program, mSimpleVSSource, fragmentShader); ANGLE_GL_PROGRAM(program, mSimpleVSSource, fragmentShader);
} }
......
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