Commit 61f51dc1 by Geoff Lang

Work around deprecated LUMA formats in the core profile.

Use R and RG textures with swizzle states to emulate them. Fixes the following tests when using the core profile: * conformance/extensions/oes-texture-float.html * conformance/extensions/oes-texture-half-float.html * conformance/textures/misc/tex-sub-image-2d.html * conformance/textures/misc/texture-formats-test.html * conformance/textures/misc/texture-npot.html * conformance/more/functions/copyTexImage2D.html * conformance/more/functions/copyTexSubImage2D.html BUG=angleproject:1113 Change-Id: Iaf4b7b2b0000052b1747f46d90ad45d4cb1f6b50 Reviewed-on: https://chromium-review.googlesource.com/293530Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 51706eae
...@@ -19,6 +19,16 @@ class FunctionsGL; ...@@ -19,6 +19,16 @@ class FunctionsGL;
class StateManagerGL; class StateManagerGL;
struct WorkaroundsGL; struct WorkaroundsGL;
struct LUMAWorkaround
{
bool enabled;
GLenum sourceFormat;
GLenum workaroundFormat;
LUMAWorkaround();
LUMAWorkaround(bool enabled, GLenum sourceFormat, GLenum workaroundFormat);
};
class TextureGL : public TextureImpl class TextureGL : public TextureImpl
{ {
public: public:
...@@ -70,6 +80,8 @@ class TextureGL : public TextureImpl ...@@ -70,6 +80,8 @@ class TextureGL : public TextureImpl
const WorkaroundsGL &mWorkarounds; const WorkaroundsGL &mWorkarounds;
StateManagerGL *mStateManager; StateManagerGL *mStateManager;
std::vector<LUMAWorkaround> mLUMAWorkaroundLevels;
mutable gl::SamplerState mAppliedSamplerState; mutable gl::SamplerState mAppliedSamplerState;
GLuint mTextureID; GLuint mTextureID;
}; };
......
...@@ -316,6 +316,21 @@ static GLenum GetNativeInternalFormat(const FunctionsGL *functions, ...@@ -316,6 +316,21 @@ static GLenum GetNativeInternalFormat(const FunctionsGL *functions,
// Update the internal format to GL_RGBA. // Update the internal format to GL_RGBA.
result = GL_RGBA8; result = GL_RGBA8;
} }
if ((functions->profile & GL_CONTEXT_CORE_PROFILE_BIT) != 0)
{
// Work around deprecated luminance alpha formats in the OpenGL core profile by backing
// them with R or RG textures.
if (formatInfo.format == GL_LUMINANCE || formatInfo.format == GL_ALPHA)
{
result = gl::GetSizedInternalFormat(GL_RED, formatInfo.type);
}
if (formatInfo.format == GL_LUMINANCE_ALPHA)
{
result = gl::GetSizedInternalFormat(GL_RG, formatInfo.type);
}
}
} }
else if (functions->isAtLeastGLES(gl::Version(3, 0))) else if (functions->isAtLeastGLES(gl::Version(3, 0)))
{ {
...@@ -344,6 +359,21 @@ static GLenum GetNativeFormat(const FunctionsGL *functions, ...@@ -344,6 +359,21 @@ static GLenum GetNativeFormat(const FunctionsGL *functions,
{ {
result = GL_RGBA; result = GL_RGBA;
} }
if ((functions->profile & GL_CONTEXT_CORE_PROFILE_BIT) != 0)
{
// Work around deprecated luminance alpha formats in the OpenGL core profile by backing
// them with R or RG textures.
if (format == GL_LUMINANCE || format == GL_ALPHA)
{
result = GL_RED;
}
if (format == GL_LUMINANCE_ALPHA)
{
result = GL_RG;
}
}
} }
return result; return result;
......
...@@ -108,8 +108,7 @@ class SwizzleTest : public ANGLETest ...@@ -108,8 +108,7 @@ class SwizzleTest : public ANGLETest
{ {
glGenTextures(1, &mTexture); glGenTextures(1, &mTexture);
glBindTexture(GL_TEXTURE_2D, mTexture); glBindTexture(GL_TEXTURE_2D, mTexture);
glTexStorage2D(GL_TEXTURE_2D, 1, internalFormat, 1, 1); glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, 1, 1, 0, dataFormat, dataType, data);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, dataFormat, dataType, data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
...@@ -268,6 +267,48 @@ TEST_P(SwizzleTest, D24_2D) ...@@ -268,6 +267,48 @@ TEST_P(SwizzleTest, D24_2D)
runTest2D(); runTest2D();
} }
TEST_P(SwizzleTest, L8_2D)
{
GLubyte data[] = { 0x77 };
init2DTexture(GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
runTest2D();
}
TEST_P(SwizzleTest, A8_2D)
{
GLubyte data[] = { 0x55 };
init2DTexture(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, data);
runTest2D();
}
TEST_P(SwizzleTest, LA8_2D)
{
GLubyte data[] = { 0x77, 0x66 };
init2DTexture(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data);
runTest2D();
}
TEST_P(SwizzleTest, L32F_2D)
{
GLfloat data[] = { 0.7f };
init2DTexture(GL_LUMINANCE, GL_LUMINANCE, GL_FLOAT, data);
runTest2D();
}
TEST_P(SwizzleTest, A32F_2D)
{
GLfloat data[] = { 0.4f, };
init2DTexture(GL_ALPHA, GL_ALPHA, GL_FLOAT, data);
runTest2D();
}
TEST_P(SwizzleTest, LA32F_2D)
{
GLfloat data[] = { 0.5f, 0.6f, };
init2DTexture(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_FLOAT, data);
runTest2D();
}
#include "media/pixel.inl" #include "media/pixel.inl"
TEST_P(SwizzleTest, CompressedDXT_2D) TEST_P(SwizzleTest, CompressedDXT_2D)
......
...@@ -105,14 +105,6 @@ class UnpackAlignmentTest : public ANGLETest ...@@ -105,14 +105,6 @@ class UnpackAlignmentTest : public ANGLETest
void testAlignment(int alignment, unsigned int offset, GLenum format, GLenum type) void testAlignment(int alignment, unsigned int offset, GLenum format, GLenum type)
{ {
// TODO(geofflang): Support LUMA formats in the core profile.
if (getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE &&
(format == GL_LUMINANCE_ALPHA || format == GL_LUMINANCE || format == GL_ALPHA))
{
std::cout << "Test skipped on OpenGL with LUMA formats." << std::endl;
return;
}
static const unsigned int width = 7; static const unsigned int width = 7;
static const unsigned int height = 2; static const unsigned int height = 2;
......
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