Commit 70022972 by Geoff Lang

Revert "Work around deprecated LUMA formats in the core profile."

Caused failures in the WebglConformance.conformance_textures_misc_copy_tex_image_2d_formats test on the ATI FYI waterfall bot. This reverts commit 61f51dc1. Change-Id: Iddea03d53ae2a9b639e36931f01c1e889e550af4 Reviewed-on: https://chromium-review.googlesource.com/294262Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 1e949799
......@@ -45,36 +45,6 @@ static bool CompatibleTextureTarget(GLenum textureType, GLenum textureTarget)
}
}
static bool IsLUMAFormat(GLenum format)
{
return format == GL_LUMINANCE || format == GL_ALPHA || format == GL_LUMINANCE_ALPHA;
}
static LUMAWorkaround GetLUMAWorkaroundInfo(GLenum originalFormat, GLenum destinationFormat)
{
const gl::InternalFormat &originalFormatInfo = gl::GetInternalFormatInfo(originalFormat);
if (IsLUMAFormat(originalFormatInfo.format))
{
const gl::InternalFormat &destinationFormatInfo =
gl::GetInternalFormatInfo(destinationFormat);
return LUMAWorkaround(!IsLUMAFormat(destinationFormatInfo.format),
originalFormatInfo.format, destinationFormatInfo.format);
}
else
{
return LUMAWorkaround(false, GL_NONE, GL_NONE);
}
}
LUMAWorkaround::LUMAWorkaround() : LUMAWorkaround(false, GL_NONE, GL_NONE)
{
}
LUMAWorkaround::LUMAWorkaround(bool enabled_, GLenum sourceFormat_, GLenum workaroundFormat_)
: enabled(enabled_), sourceFormat(sourceFormat_), workaroundFormat(workaroundFormat_)
{
}
TextureGL::TextureGL(GLenum type,
const FunctionsGL *functions,
const WorkaroundsGL &workarounds,
......@@ -84,7 +54,6 @@ TextureGL::TextureGL(GLenum type,
mFunctions(functions),
mWorkarounds(workarounds),
mStateManager(stateManager),
mLUMAWorkaroundLevels(gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS),
mAppliedSamplerState(),
mTextureID(0)
{
......@@ -135,9 +104,6 @@ gl::Error TextureGL::setImage(GLenum target, size_t level, GLenum internalFormat
UNREACHABLE();
}
mLUMAWorkaroundLevels[level] =
GetLUMAWorkaroundInfo(internalFormat, texImageFormat.internalFormat);
return gl::Error(GL_NO_ERROR);
}
......@@ -168,9 +134,6 @@ gl::Error TextureGL::setSubImage(GLenum target, size_t level, const gl::Box &are
UNREACHABLE();
}
ASSERT(mLUMAWorkaroundLevels[level].enabled ==
GetLUMAWorkaroundInfo(format, texSubImageFormat.format).enabled);
return gl::Error(GL_NO_ERROR);
}
......@@ -201,9 +164,6 @@ gl::Error TextureGL::setCompressedImage(GLenum target, size_t level, GLenum inte
UNREACHABLE();
}
ASSERT(!GetLUMAWorkaroundInfo(internalFormat, compressedTexImageFormat.internalFormat).enabled);
mLUMAWorkaroundLevels[level].enabled = false;
return gl::Error(GL_NO_ERROR);
}
......@@ -235,9 +195,6 @@ gl::Error TextureGL::setCompressedSubImage(GLenum target, size_t level, const gl
UNREACHABLE();
}
ASSERT(!mLUMAWorkaroundLevels[level].enabled &&
!GetLUMAWorkaroundInfo(format, compressedTexSubImageFormat.format).enabled);
return gl::Error(GL_NO_ERROR);
}
......@@ -263,9 +220,6 @@ gl::Error TextureGL::copyImage(GLenum target, size_t level, const gl::Rectangle
UNREACHABLE();
}
mLUMAWorkaroundLevels[level] =
GetLUMAWorkaroundInfo(internalFormat, copyTexImageFormat.internalFormat);
return gl::Error(GL_NO_ERROR);
}
......@@ -425,13 +379,6 @@ gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFor
UNREACHABLE();
}
LUMAWorkaround lumaWorkaround =
GetLUMAWorkaroundInfo(internalFormat, texStorageFormat.internalFormat);
for (size_t level = 0; level < mLUMAWorkaroundLevels.size(); level++)
{
mLUMAWorkaroundLevels[level] = lumaWorkaround;
}
return gl::Error(GL_NO_ERROR);
}
......@@ -439,12 +386,6 @@ gl::Error TextureGL::generateMipmaps(const gl::SamplerState &samplerState)
{
mStateManager->bindTexture(mTextureType, mTextureID);
mFunctions->generateMipmap(mTextureType);
for (size_t level = samplerState.baseLevel; level < mLUMAWorkaroundLevels.size(); level++)
{
mLUMAWorkaroundLevels[level] = mLUMAWorkaroundLevels[samplerState.baseLevel];
}
return gl::Error(GL_NO_ERROR);
}
......@@ -454,8 +395,6 @@ void TextureGL::bindTexImage(egl::Surface *surface)
// Make sure this texture is bound
mStateManager->bindTexture(mTextureType, mTextureID);
mLUMAWorkaroundLevels[0].enabled = false;
}
void TextureGL::releaseTexImage()
......@@ -480,148 +419,40 @@ gl::Error TextureGL::setEGLImageTarget(GLenum target, egl::Image *image)
return gl::Error(GL_INVALID_OPERATION);
}
template <typename T, typename ApplyTextureFuncType>
static inline void SyncSamplerStateMember(const FunctionsGL *functions,
ApplyTextureFuncType applyTextureFunc,
const gl::SamplerState &newState,
gl::SamplerState &curState,
GLenum textureType,
GLenum name,
template <typename T>
static inline void SyncSamplerStateMember(const FunctionsGL *functions, const gl::SamplerState &newState,
gl::SamplerState &curState, GLenum textureType, GLenum name,
T(gl::SamplerState::*samplerMember))
{
if (curState.*samplerMember != newState.*samplerMember)
{
applyTextureFunc();
curState.*samplerMember = newState.*samplerMember;
functions->texParameterf(textureType, name, static_cast<GLfloat>(curState.*samplerMember));
}
}
template <typename T, typename ApplyTextureFuncType>
static inline void SyncSamplerStateSwizzle(const FunctionsGL *functions,
ApplyTextureFuncType applyTextureFunc,
const LUMAWorkaround &lumaWorkaround,
const gl::SamplerState &newState,
gl::SamplerState &curState,
GLenum textureType,
GLenum name,
T(gl::SamplerState::*samplerMember))
{
if (lumaWorkaround.enabled)
{
UNUSED_ASSERTION_VARIABLE(lumaWorkaround.workaroundFormat);
GLenum resultSwizzle = GL_NONE;
switch (newState.*samplerMember)
{
case GL_RED:
case GL_GREEN:
case GL_BLUE:
if (lumaWorkaround.sourceFormat == GL_LUMINANCE ||
lumaWorkaround.sourceFormat == GL_LUMINANCE_ALPHA)
{
// Texture is backed by a RED or RG texture, point all color channels at the red
// channel.
ASSERT(lumaWorkaround.workaroundFormat == GL_RED ||
lumaWorkaround.workaroundFormat == GL_RG);
resultSwizzle = GL_RED;
}
else if (lumaWorkaround.sourceFormat == GL_ALPHA)
{
// Color channels are not supposed to exist, make them always sample 0.
resultSwizzle = GL_ZERO;
}
else
{
UNREACHABLE();
}
break;
case GL_ALPHA:
if (lumaWorkaround.sourceFormat == GL_LUMINANCE)
{
// Alpha channel is not supposed to exist, make it always sample 1.
resultSwizzle = GL_ONE;
}
else if (lumaWorkaround.sourceFormat == GL_ALPHA)
{
// Texture is backed by a RED texture, point the alpha channel at the red
// channel.
ASSERT(lumaWorkaround.workaroundFormat == GL_RED);
resultSwizzle = GL_RED;
}
else if (lumaWorkaround.sourceFormat == GL_LUMINANCE_ALPHA)
{
// Texture is backed by an RG texture, point the alpha channel at the green
// channel.
ASSERT(lumaWorkaround.workaroundFormat == GL_RG);
resultSwizzle = GL_GREEN;
}
else
{
UNREACHABLE();
}
break;
case GL_ZERO:
case GL_ONE:
// Don't modify the swizzle state when requesting ZERO or ONE.
resultSwizzle = newState.*samplerMember;
break;
default:
UNREACHABLE();
break;
}
// Apply the new swizzle state if needed
if (curState.*samplerMember != resultSwizzle)
{
applyTextureFunc();
curState.*samplerMember = resultSwizzle;
functions->texParameterf(textureType, name, static_cast<GLfloat>(resultSwizzle));
}
}
else
{
SyncSamplerStateMember(functions, applyTextureFunc, newState, curState, textureType, name,
samplerMember);
}
}
void TextureGL::syncSamplerState(const gl::SamplerState &samplerState) const
{
// Callback lamdba to bind this texture only if needed.
bool textureApplied = false;
auto applyTextureFunc = [&]()
{
if (!textureApplied)
{
mStateManager->bindTexture(mTextureType, mTextureID);
textureApplied = true;
}
};
// clang-format off
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MIN_FILTER, &gl::SamplerState::minFilter);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MAG_FILTER, &gl::SamplerState::magFilter);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_WRAP_S, &gl::SamplerState::wrapS);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_WRAP_T, &gl::SamplerState::wrapT);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_WRAP_R, &gl::SamplerState::wrapR);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MAX_ANISOTROPY_EXT, &gl::SamplerState::maxAnisotropy);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_BASE_LEVEL, &gl::SamplerState::baseLevel);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MAX_LEVEL, &gl::SamplerState::maxLevel);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MIN_LOD, &gl::SamplerState::minLod);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MAX_LOD, &gl::SamplerState::maxLod);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_COMPARE_MODE, &gl::SamplerState::compareMode);
SyncSamplerStateMember(mFunctions, applyTextureFunc, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_COMPARE_FUNC, &gl::SamplerState::compareFunc);
const LUMAWorkaround &LUMAWorkaround = mLUMAWorkaroundLevels[samplerState.baseLevel];
SyncSamplerStateSwizzle(mFunctions, applyTextureFunc, LUMAWorkaround, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_SWIZZLE_R, &gl::SamplerState::swizzleRed);
SyncSamplerStateSwizzle(mFunctions, applyTextureFunc, LUMAWorkaround, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_SWIZZLE_G, &gl::SamplerState::swizzleGreen);
SyncSamplerStateSwizzle(mFunctions, applyTextureFunc, LUMAWorkaround, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_SWIZZLE_B, &gl::SamplerState::swizzleBlue);
SyncSamplerStateSwizzle(mFunctions, applyTextureFunc, LUMAWorkaround, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_SWIZZLE_A, &gl::SamplerState::swizzleAlpha);
// clang-format on
if (mAppliedSamplerState != samplerState)
{
mStateManager->bindTexture(mTextureType, mTextureID);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MIN_FILTER, &gl::SamplerState::minFilter);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MAG_FILTER, &gl::SamplerState::magFilter);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_WRAP_S, &gl::SamplerState::wrapS);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_WRAP_T, &gl::SamplerState::wrapT);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_WRAP_R, &gl::SamplerState::wrapR);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MAX_ANISOTROPY_EXT, &gl::SamplerState::maxAnisotropy);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_BASE_LEVEL, &gl::SamplerState::baseLevel);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MAX_LEVEL, &gl::SamplerState::maxLevel);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MIN_LOD, &gl::SamplerState::minLod);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_MAX_LOD, &gl::SamplerState::maxLod);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_COMPARE_MODE, &gl::SamplerState::compareMode);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_COMPARE_FUNC, &gl::SamplerState::compareFunc);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_SWIZZLE_R, &gl::SamplerState::swizzleRed);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_SWIZZLE_G, &gl::SamplerState::swizzleGreen);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_SWIZZLE_B, &gl::SamplerState::swizzleBlue);
SyncSamplerStateMember(mFunctions, samplerState, mAppliedSamplerState, mTextureType, GL_TEXTURE_SWIZZLE_A, &gl::SamplerState::swizzleAlpha);
}
}
GLuint TextureGL::getTextureID() const
......
......@@ -19,16 +19,6 @@ class FunctionsGL;
class StateManagerGL;
struct WorkaroundsGL;
struct LUMAWorkaround
{
bool enabled;
GLenum sourceFormat;
GLenum workaroundFormat;
LUMAWorkaround();
LUMAWorkaround(bool enabled, GLenum sourceFormat, GLenum workaroundFormat);
};
class TextureGL : public TextureImpl
{
public:
......@@ -80,8 +70,6 @@ class TextureGL : public TextureImpl
const WorkaroundsGL &mWorkarounds;
StateManagerGL *mStateManager;
std::vector<LUMAWorkaround> mLUMAWorkaroundLevels;
mutable gl::SamplerState mAppliedSamplerState;
GLuint mTextureID;
};
......
......@@ -316,21 +316,6 @@ static GLenum GetNativeInternalFormat(const FunctionsGL *functions,
// Update the internal format to GL_RGBA.
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)))
{
......@@ -359,21 +344,6 @@ static GLenum GetNativeFormat(const FunctionsGL *functions,
{
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;
......
......@@ -108,7 +108,8 @@ class SwizzleTest : public ANGLETest
{
glGenTextures(1, &mTexture);
glBindTexture(GL_TEXTURE_2D, mTexture);
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, 1, 1, 0, dataFormat, dataType, data);
glTexStorage2D(GL_TEXTURE_2D, 1, internalFormat, 1, 1);
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_MAG_FILTER, GL_NEAREST);
......@@ -267,48 +268,6 @@ TEST_P(SwizzleTest, D24_2D)
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"
TEST_P(SwizzleTest, CompressedDXT_2D)
......
......@@ -105,6 +105,14 @@ class UnpackAlignmentTest : public ANGLETest
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 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