Commit dd5705e7 by Mohan Maiya Committed by Commit Bot

Add missing qualifier type handling in translator

Translator checks tessellation shader unsized array type qualifier. sample in/sample out were missing in handling qualifier type. Bug: angleproject:5557 Test: GLSLTest_ES31.VaryingTessellationSampleInAndOut* Change-Id: I8a2f2c4c4fcc9cc88000d3b2d448ab51fb9e5d38 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2776263Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent 775caee1
......@@ -2769,6 +2769,7 @@ void TParseContext::checkTessellationShaderUnsizedArraysAndSetSize(const TSource
case EvqFlatIn:
case EvqCentroidIn:
case EvqSmoothIn:
case EvqSampleIn:
// Declaring an array size is optional. If no size is specified, it will be taken
// from the implementation-dependent maximum patch size (gl_MaxPatchVertices).
ASSERT(mMaxPatchVertices > 0);
......@@ -2778,6 +2779,7 @@ void TParseContext::checkTessellationShaderUnsizedArraysAndSetSize(const TSource
case EvqFlatOut:
case EvqCentroidOut:
case EvqSmoothOut:
case EvqSampleOut:
// Declaring an array size is optional. If no size is specified, it will be taken
// from output patch size declared in the shader.
type->sizeOutermostUnsizedArray(mTessControlShaderOutputVertices);
......
......@@ -5281,6 +5281,79 @@ TEST_P(GLSLTest_ES31, VaryingIOBlockNotDeclaredInVertexShader)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
}
// Test that a shader with sample in / sample out can be linked successfully.
TEST_P(GLSLTest_ES31, VaryingTessellationSampleInAndOut)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_tessellation_shader"));
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_OES_shader_multisample_interpolation"));
constexpr char kVS[] =
R"(#version 310 es
#extension GL_OES_shader_multisample_interpolation : require
precision highp float;
in vec4 inputAttribute;
sample out mediump float tc_in;
void main()
{
tc_in = inputAttribute[0];
gl_Position = inputAttribute;
})";
constexpr char kTCS[] =
R"(#version 310 es
#extension GL_EXT_tessellation_shader : require
#extension GL_OES_shader_multisample_interpolation : require
layout (vertices=3) out;
sample in mediump float tc_in[];
sample out mediump float tc_out[];
void main()
{
tc_out[gl_InvocationID] = tc_in[gl_InvocationID];
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
gl_TessLevelInner[0] = 2.0;
gl_TessLevelInner[1] = 2.0;
gl_TessLevelOuter[0] = 2.0;
gl_TessLevelOuter[1] = 2.0;
gl_TessLevelOuter[2] = 2.0;
gl_TessLevelOuter[3] = 2.0;
})";
constexpr char kTES[] =
R"(#version 310 es
#extension GL_EXT_tessellation_shader : require
#extension GL_OES_shader_multisample_interpolation : require
layout (triangles) in;
sample in mediump float tc_out[];
sample out mediump float te_out;
void main()
{
te_out = tc_out[2];
gl_Position = gl_TessCoord[0] * gl_in[0].gl_Position;
})";
constexpr char kFS[] =
R"(#version 310 es
#extension GL_OES_shader_multisample_interpolation : require
precision highp float;
sample in mediump float te_out;
layout(location = 0) out mediump vec4 color;
void main()
{
float out0 = te_out;
color = vec4(1, 0, 0, 1);
})";
ANGLE_GL_PROGRAM_WITH_TESS(program, kVS, kTCS, kTES, kFS);
drawPatches(program.get(), "inputAttribute", 0.5f, 1.0f, GL_FALSE);
ASSERT_GL_NO_ERROR();
}
// Test that a varying struct that's not declared in the fragment shader links successfully.
// GLSL ES 3.00.6 section 4.3.10.
TEST_P(GLSLTest_ES3, VaryingStructNotDeclaredInFragmentShader)
......
......@@ -775,7 +775,7 @@ void ANGLETestBase::drawQuad(GLuint program,
bool useVertexBuffer)
{
drawQuad(program, positionAttribName, positionAttribZ, positionAttribXYScale, useVertexBuffer,
false, 0u);
false, false, 0u);
}
void ANGLETestBase::drawQuadInstanced(GLuint program,
......@@ -786,7 +786,17 @@ void ANGLETestBase::drawQuadInstanced(GLuint program,
GLuint numInstances)
{
drawQuad(program, positionAttribName, positionAttribZ, positionAttribXYScale, useVertexBuffer,
true, numInstances);
true, false, numInstances);
}
void ANGLETestBase::drawPatches(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale,
bool useVertexBuffer)
{
drawQuad(program, positionAttribName, positionAttribZ, positionAttribXYScale, useVertexBuffer,
false, true, 0u);
}
void ANGLETestBase::drawQuad(GLuint program,
......@@ -795,6 +805,7 @@ void ANGLETestBase::drawQuad(GLuint program,
GLfloat positionAttribXYScale,
bool useVertexBuffer,
bool useInstancedDrawCalls,
bool useTessellationPatches,
GLuint numInstances)
{
GLint previousProgram = 0;
......@@ -837,14 +848,15 @@ void ANGLETestBase::drawQuad(GLuint program,
}
}
glEnableVertexAttribArray(positionLocation);
GLenum drawMode = (useTessellationPatches) ? GL_PATCHES : GL_TRIANGLES;
if (useInstancedDrawCalls)
{
glDrawArraysInstanced(GL_TRIANGLES, 0, 6, numInstances);
glDrawArraysInstanced(drawMode, 0, 6, numInstances);
}
else
{
glDrawArrays(GL_TRIANGLES, 0, 6);
glDrawArrays(drawMode, 0, 6);
}
glDisableVertexAttribArray(positionLocation);
......
......@@ -394,6 +394,11 @@ class ANGLETestBase
GLfloat positionAttribXYScale,
bool useVertexBuffer,
GLuint numInstances);
void drawPatches(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale,
bool useVertexBuffer);
void drawQuadPPO(GLuint vertProgram,
const std::string &positionAttribName,
......@@ -538,6 +543,7 @@ class ANGLETestBase
GLfloat positionAttribXYScale,
bool useVertexBuffer,
bool useInstancedDrawCalls,
bool useTessellationPatches,
GLuint numInstances);
void initOSWindow();
......
......@@ -184,6 +184,15 @@ class GLProgram
mHandle = CompileProgramWithGS(vertexShader, geometryShader, fragmentShader);
}
void makeRaster(const char *vertexShader,
const char *tessControlShader,
const char *tessEvaluateShader,
const char *fragmentShader)
{
mHandle = CompileProgramWithTESS(vertexShader, tessControlShader, tessEvaluateShader,
fragmentShader);
}
void makeRasterWithTransformFeedback(const char *vertexShader,
const char *fragmentShader,
const std::vector<std::string> &tfVaryings,
......@@ -244,6 +253,11 @@ class GLProgram
name.makeRaster(vertex, geometry, fragment); \
ASSERT_TRUE(name.valid())
#define ANGLE_GL_PROGRAM_WITH_TESS(name, vertex, tcs, tes, fragment) \
GLProgram name; \
name.makeRaster(vertex, tcs, tes, fragment); \
ASSERT_TRUE(name.valid())
#define ANGLE_GL_PROGRAM_TRANSFORM_FEEDBACK(name, vertex, fragment, tfVaryings, bufferMode) \
GLProgram name; \
name.makeRasterWithTransformFeedback(vertex, fragment, tfVaryings, bufferMode); \
......
......@@ -28,6 +28,8 @@ bool ReadEntireFile(const std::string &filePath, std::string *contentsOut)
}
GLuint CompileProgramInternal(const char *vsSource,
const char *tcsSource,
const char *tesSource,
const char *gsSource,
const char *fsSource,
const std::function<void(GLuint)> &preLinkCallback)
......@@ -50,7 +52,40 @@ GLuint CompileProgramInternal(const char *vsSource,
glAttachShader(program, fs);
glDeleteShader(fs);
GLuint gs = 0;
GLuint tcs = 0;
GLuint tes = 0;
GLuint gs = 0;
if (strlen(tcsSource) > 0)
{
tcs = CompileShader(GL_TESS_CONTROL_SHADER_EXT, tcsSource);
if (tcs == 0)
{
glDeleteShader(vs);
glDeleteShader(fs);
glDeleteProgram(program);
return 0;
}
glAttachShader(program, tcs);
glDeleteShader(tcs);
}
if (strlen(tesSource) > 0)
{
tes = CompileShader(GL_TESS_EVALUATION_SHADER_EXT, tesSource);
if (tes == 0)
{
glDeleteShader(vs);
glDeleteShader(fs);
glDeleteShader(tcs);
glDeleteProgram(program);
return 0;
}
glAttachShader(program, tes);
glDeleteShader(tes);
}
if (strlen(gsSource) > 0)
{
......@@ -59,6 +94,8 @@ GLuint CompileProgramInternal(const char *vsSource,
{
glDeleteShader(vs);
glDeleteShader(fs);
glDeleteShader(tcs);
glDeleteShader(tes);
glDeleteProgram(program);
return 0;
}
......@@ -220,24 +257,32 @@ GLuint CompileProgramWithTransformFeedback(
}
};
return CompileProgramInternal(vsSource, "", fsSource, preLink);
return CompileProgramInternal(vsSource, "", "", "", fsSource, preLink);
}
GLuint CompileProgram(const char *vsSource, const char *fsSource)
{
return CompileProgramInternal(vsSource, "", fsSource, nullptr);
return CompileProgramInternal(vsSource, "", "", "", fsSource, nullptr);
}
GLuint CompileProgram(const char *vsSource,
const char *fsSource,
const std::function<void(GLuint)> &preLinkCallback)
{
return CompileProgramInternal(vsSource, "", fsSource, preLinkCallback);
return CompileProgramInternal(vsSource, "", "", "", fsSource, preLinkCallback);
}
GLuint CompileProgramWithGS(const char *vsSource, const char *gsSource, const char *fsSource)
{
return CompileProgramInternal(vsSource, gsSource, fsSource, nullptr);
return CompileProgramInternal(vsSource, "", "", gsSource, fsSource, nullptr);
}
GLuint CompileProgramWithTESS(const char *vsSource,
const char *tcsSource,
const char *tesSource,
const char *fsSource)
{
return CompileProgramInternal(vsSource, tcsSource, tesSource, "", fsSource, nullptr);
}
GLuint CompileProgramFromFiles(const std::string &vsPath, const std::string &fsPath)
......
......@@ -34,6 +34,10 @@ ANGLE_UTIL_EXPORT GLuint CompileProgram(const char *vsSource,
ANGLE_UTIL_EXPORT GLuint CompileProgramWithGS(const char *vsSource,
const char *gsSource,
const char *fsSource);
ANGLE_UTIL_EXPORT GLuint CompileProgramWithTESS(const char *vsSource,
const char *tcsSource,
const char *tesSource,
const char *fsSource);
ANGLE_UTIL_EXPORT GLuint CompileProgramFromFiles(const std::string &vsPath,
const std::string &fsPath);
ANGLE_UTIL_EXPORT GLuint CompileComputeProgram(const char *csSource,
......
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