Commit d92e93b8 by Jamie Madill Committed by Commit Bot

Fix uniform type info for multisample textures.

The way that the strings were generated was erroneously marking 2D multisample textures as "2D" instead of "2D_MULTISAMPLE". Fix this by changing how the types are parsed and generated. Fixes incomplete texture handling of 2D multisample textures. BUG=angleproject:1390 BUG=angleproject:2167 Change-Id: I8ffffca119cc7ca654ed1fe81cba37b758f9ef9f Reviewed-on: https://chromium-review.googlesource.com/713585Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 6b076a09
...@@ -72,15 +72,20 @@ all_uniform_types = [ ...@@ -72,15 +72,20 @@ all_uniform_types = [
"GL_UNSIGNED_INT_VEC4" "GL_UNSIGNED_INT_VEC4"
] ]
# Uniform texture types. # Uniform texture types. Be wary of substrings finding the wrong types.
# e.g. with 2D_MULTISAMPLE/2D_ARRAY and 2D.
texture_types = { texture_types = {
"2D": "2D", "2D": "2D",
"CUBE": "CUBE_MAP",
"2D_ARRAY": "2D_ARRAY", "2D_ARRAY": "2D_ARRAY",
"2D_ARRAY_SHADOW": "2D_ARRAY",
"2D_MULTISAMPLE": "2D_MULTISAMPLE",
"2D_RECT_ANGLE": "2D",
"2D_SHADOW": "2D",
"3D": "3D", "3D": "3D",
"MULTISAMPLE": "MULTISAMPLE", "CUBE": "CUBE_MAP",
"CUBE_SHADOW": "CUBE_MAP",
"EXTERNAL_OES": "EXTERNAL_OES",
"RECT": "RECTANGLE", "RECT": "RECTANGLE",
"EXTERNAL_OES": "EXTERNAL_OES"
} }
template_cpp = """// GENERATED FILE - DO NOT EDIT. template_cpp = """// GENERATED FILE - DO NOT EDIT.
...@@ -150,9 +155,12 @@ def get_component_type(uniform_type): ...@@ -150,9 +155,12 @@ def get_component_type(uniform_type):
return "GL_INT" return "GL_INT"
def get_texture_type(uniform_type): def get_texture_type(uniform_type):
for sampler_type, tex_type in texture_types.items(): if "SAMPLER" in uniform_type:
if sampler_type in uniform_type: index = uniform_type.find("SAMPLER") + len("SAMPLER") + 1
return "GL_TEXTURE_" + tex_type return "GL_TEXTURE_" + texture_types[uniform_type[index:]]
if "IMAGE" in uniform_type:
index = uniform_type.find("IMAGE") + len("IMAGE") + 1
return "GL_TEXTURE_" + texture_types[uniform_type[index:]]
return "GL_NONE" return "GL_NONE"
def get_transposed_type(uniform_type): def get_transposed_type(uniform_type):
......
...@@ -76,7 +76,7 @@ constexpr std::array<UniformTypeInfo, 59> kInfoTable = { ...@@ -76,7 +76,7 @@ constexpr std::array<UniformTypeInfo, 59> kInfoTable = {
sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
{GL_INT_SAMPLER_2D_ARRAY, GL_INT, GL_TEXTURE_2D_ARRAY, GL_NONE, GL_NONE, 1, 1, 1, {GL_INT_SAMPLER_2D_ARRAY, GL_INT, GL_TEXTURE_2D_ARRAY, GL_NONE, GL_NONE, 1, 1, 1,
sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
{GL_INT_SAMPLER_2D_MULTISAMPLE, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, {GL_INT_SAMPLER_2D_MULTISAMPLE, GL_INT, GL_TEXTURE_2D_MULTISAMPLE, GL_NONE, GL_NONE, 1, 1, 1,
sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
{GL_INT_SAMPLER_3D, GL_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), {GL_INT_SAMPLER_3D, GL_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
...@@ -94,8 +94,8 @@ constexpr std::array<UniformTypeInfo, 59> kInfoTable = { ...@@ -94,8 +94,8 @@ constexpr std::array<UniformTypeInfo, 59> kInfoTable = {
sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
{GL_SAMPLER_2D_ARRAY_SHADOW, GL_INT, GL_TEXTURE_2D_ARRAY, GL_NONE, GL_NONE, 1, 1, 1, {GL_SAMPLER_2D_ARRAY_SHADOW, GL_INT, GL_TEXTURE_2D_ARRAY, GL_NONE, GL_NONE, 1, 1, 1,
sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
{GL_SAMPLER_2D_MULTISAMPLE, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), {GL_SAMPLER_2D_MULTISAMPLE, GL_INT, GL_TEXTURE_2D_MULTISAMPLE, GL_NONE, GL_NONE, 1, 1, 1,
sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
{GL_SAMPLER_2D_RECT_ANGLE, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), {GL_SAMPLER_2D_RECT_ANGLE, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false}, sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
{GL_SAMPLER_2D_SHADOW, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), {GL_SAMPLER_2D_SHADOW, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
...@@ -124,8 +124,8 @@ constexpr std::array<UniformTypeInfo, 59> kInfoTable = { ...@@ -124,8 +124,8 @@ constexpr std::array<UniformTypeInfo, 59> kInfoTable = {
sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false}, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false},
{GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, GL_UNSIGNED_INT, GL_TEXTURE_2D_ARRAY, GL_NONE, GL_NONE, 1, {GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, GL_UNSIGNED_INT, GL_TEXTURE_2D_ARRAY, GL_NONE, GL_NONE, 1,
1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false}, 1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false},
{GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, GL_UNSIGNED_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, {GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, GL_UNSIGNED_INT, GL_TEXTURE_2D_MULTISAMPLE, GL_NONE,
1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false}, GL_NONE, 1, 1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false},
{GL_UNSIGNED_INT_SAMPLER_3D, GL_UNSIGNED_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1, {GL_UNSIGNED_INT_SAMPLER_3D, GL_UNSIGNED_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1,
sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false}, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false},
{GL_UNSIGNED_INT_SAMPLER_CUBE, GL_UNSIGNED_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1, {GL_UNSIGNED_INT_SAMPLER_CUBE, GL_UNSIGNED_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1,
......
...@@ -24,7 +24,7 @@ class IncompleteTextureTest : public ANGLETest ...@@ -24,7 +24,7 @@ class IncompleteTextureTest : public ANGLETest
setConfigAlphaBits(8); setConfigAlphaBits(8);
} }
virtual void SetUp() void SetUp() override
{ {
ANGLETest::SetUp(); ANGLETest::SetUp();
...@@ -58,29 +58,32 @@ class IncompleteTextureTest : public ANGLETest ...@@ -58,29 +58,32 @@ class IncompleteTextureTest : public ANGLETest
mTextureUniformLocation = glGetUniformLocation(mProgram, "tex"); mTextureUniformLocation = glGetUniformLocation(mProgram, "tex");
} }
virtual void TearDown() void TearDown() override
{ {
glDeleteProgram(mProgram); glDeleteProgram(mProgram);
ANGLETest::TearDown(); ANGLETest::TearDown();
} }
void fillTextureData(std::vector<GLubyte> &buffer, GLubyte r, GLubyte g, GLubyte b, GLubyte a)
{
size_t count = buffer.size() / 4;
for (size_t i = 0; i < count; i++)
{
buffer[i * 4 + 0] = r;
buffer[i * 4 + 1] = g;
buffer[i * 4 + 2] = b;
buffer[i * 4 + 3] = a;
}
}
GLuint mProgram; GLuint mProgram;
GLint mTextureUniformLocation; GLint mTextureUniformLocation;
}; };
class IncompleteTextureTestES31 : public ANGLETest
{
protected:
IncompleteTextureTestES31()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
};
// Test rendering with an incomplete texture.
TEST_P(IncompleteTextureTest, IncompleteTexture2D) TEST_P(IncompleteTextureTest, IncompleteTexture2D)
{ {
GLTexture tex; GLTexture tex;
...@@ -118,6 +121,7 @@ TEST_P(IncompleteTextureTest, IncompleteTexture2D) ...@@ -118,6 +121,7 @@ TEST_P(IncompleteTextureTest, IncompleteTexture2D)
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
} }
// Tests redefining a texture with half the size works as expected.
TEST_P(IncompleteTextureTest, UpdateTexture) TEST_P(IncompleteTextureTest, UpdateTexture)
{ {
GLTexture tex; GLTexture tex;
...@@ -127,36 +131,74 @@ TEST_P(IncompleteTextureTest, UpdateTexture) ...@@ -127,36 +131,74 @@ TEST_P(IncompleteTextureTest, UpdateTexture)
glUseProgram(mProgram); glUseProgram(mProgram);
glUniform1i(mTextureUniformLocation, 0); glUniform1i(mTextureUniformLocation, 0);
const GLsizei redTextureWidth = 64; constexpr GLsizei redTextureSize = 64;
const GLsizei redTextureHeight = 64; std::vector<GLColor> redTextureData(redTextureSize * redTextureSize, GLColor::red);
std::vector<GLubyte> redTextureData(redTextureWidth * redTextureHeight * 4); for (GLint mip = 0; mip < 7; ++mip)
fillTextureData(redTextureData, 255, 0, 0, 255);
for (size_t i = 0; i < 7; i++)
{ {
glTexImage2D(GL_TEXTURE_2D, static_cast<GLint>(i), GL_RGBA, redTextureWidth >> i, const GLsizei mipSize = redTextureSize >> mip;
redTextureHeight >> i, 0, GL_RGBA, GL_UNSIGNED_BYTE, &redTextureData[0]);
glTexImage2D(GL_TEXTURE_2D, mip, GL_RGBA, mipSize, mipSize, 0, GL_RGBA, GL_UNSIGNED_BYTE,
redTextureData.data());
} }
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
drawQuad(mProgram, "position", 0.5f); drawQuad(mProgram, "position", 0.5f);
EXPECT_PIXEL_EQ(0, 0, 255, 0, 0, 255); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
const GLsizei greenTextureWidth = 32; constexpr GLsizei greenTextureSize = 32;
const GLsizei greenTextureHeight = 32; std::vector<GLColor> greenTextureData(greenTextureSize * greenTextureSize, GLColor::green);
std::vector<GLubyte> greenTextureData(greenTextureWidth * greenTextureHeight * 4);
fillTextureData(greenTextureData, 0, 255, 0, 255);
for (size_t i = 0; i < 6; i++) for (GLint mip = 0; mip < 6; ++mip)
{ {
glTexSubImage2D(GL_TEXTURE_2D, static_cast<GLint>(i), greenTextureWidth >> i, const GLsizei mipSize = greenTextureSize >> mip;
greenTextureHeight >> i, greenTextureWidth >> i, greenTextureHeight >> i,
GL_RGBA, GL_UNSIGNED_BYTE, &greenTextureData[0]); glTexSubImage2D(GL_TEXTURE_2D, mip, mipSize, mipSize, mipSize, mipSize, GL_RGBA,
GL_UNSIGNED_BYTE, greenTextureData.data());
} }
drawQuad(mProgram, "position", 0.5f); drawQuad(mProgram, "position", 0.5f);
EXPECT_PIXEL_EQ(getWindowWidth() - greenTextureWidth, getWindowHeight() - greenTextureWidth, 0, 255, 0, 255); EXPECT_PIXEL_COLOR_EQ(getWindowWidth() - greenTextureSize, getWindowHeight() - greenTextureSize,
GLColor::green);
}
// Tests that the incomplete multisample texture has the correct alpha value.
TEST_P(IncompleteTextureTestES31, MultisampleTexture)
{
const std::string vertexShader = R"(#version 310 es
in vec2 position;
out vec2 texCoord;
void main()
{
gl_Position = vec4(position, 0, 1);
texCoord = (position * 0.5) + 0.5;
}
)";
const std::string fragmentShader = R"(#version 310 es
precision mediump float;
in vec2 texCoord;
out vec4 color;
uniform mediump sampler2DMS tex;
void main()
{
ivec2 texSize = textureSize(tex);
ivec2 texel = ivec2(vec2(texSize) * texCoord);
color = texelFetch(tex, texel, 0);
}
)";
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
// The zero texture will be incomplete by default.
ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
drawQuad(program, "position", 0.5f);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
} }
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
...@@ -165,3 +207,5 @@ ANGLE_INSTANTIATE_TEST(IncompleteTextureTest, ...@@ -165,3 +207,5 @@ ANGLE_INSTANTIATE_TEST(IncompleteTextureTest,
ES2_D3D11(), ES2_D3D11(),
ES2_OPENGL(), ES2_OPENGL(),
ES2_OPENGLES()); ES2_OPENGLES());
ANGLE_INSTANTIATE_TEST(IncompleteTextureTestES31, ES31_D3D11(), ES31_OPENGL(), ES31_OPENGLES());
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