Commit e4859ae5 by James Darpinian Committed by Commit Bot

Fix re-enabling ARB_texture_rectangle

My earlier change https://crrev.com/c/1991969 had a bug. If ARB_texture_rectangle is disabled once, it can't be re-enabled because the extension behavior entry is deleted. ResetExtensionBehavior needs to restore it. Bug: angleproject:3770 Change-Id: Icf96acece8ea8d17287c8d09fb4849b61c9c2a36 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2023398Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: James Darpinian <jdarpinian@chromium.org>
parent 80da4214
...@@ -350,16 +350,7 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[], ...@@ -350,16 +350,7 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
ASSERT(GetGlobalPoolAllocator()); ASSERT(GetGlobalPoolAllocator());
// Reset the extension behavior for each compilation unit. // Reset the extension behavior for each compilation unit.
ResetExtensionBehavior(mExtensionBehavior); ResetExtensionBehavior(mResources, mExtensionBehavior, compileOptions);
if (compileOptions & SH_DISABLE_ARB_TEXTURE_RECTANGLE)
{
auto it = mExtensionBehavior.find(TExtension::ARB_texture_rectangle);
if (it != mExtensionBehavior.end())
{
mExtensionBehavior.erase(it);
}
}
// If gl_DrawID is not supported, remove it from the available extensions // If gl_DrawID is not supported, remove it from the available extensions
// Currently we only allow emulation of gl_DrawID // Currently we only allow emulation of gl_DrawID
......
...@@ -107,17 +107,27 @@ void InitExtensionBehavior(const ShBuiltInResources &resources, TExtensionBehavi ...@@ -107,17 +107,27 @@ void InitExtensionBehavior(const ShBuiltInResources &resources, TExtensionBehavi
} }
} }
void ResetExtensionBehavior(TExtensionBehavior &extBehavior) void ResetExtensionBehavior(const ShBuiltInResources &resources,
TExtensionBehavior &extBehavior,
const ShCompileOptions compileOptions)
{ {
for (auto &ext : extBehavior) for (auto &ext : extBehavior)
{ {
if (ext.first == TExtension::ARB_texture_rectangle) ext.second = EBhUndefined;
}
if (resources.ARB_texture_rectangle)
{
if (compileOptions & SH_DISABLE_ARB_TEXTURE_RECTANGLE)
{ {
ext.second = EBhEnable; // Remove ARB_texture_rectangle so it can't be enabled by extension directives.
extBehavior.erase(TExtension::ARB_texture_rectangle);
} }
else else
{ {
ext.second = EBhUndefined; // Restore ARB_texture_rectangle in case it was removed during an earlier reset. As
// noted above, it doesn't follow the standard for extension directives and is enabled
// by default.
extBehavior[TExtension::ARB_texture_rectangle] = EBhEnable;
} }
} }
} }
......
...@@ -21,7 +21,9 @@ void InitExtensionBehavior(const ShBuiltInResources &resources, ...@@ -21,7 +21,9 @@ void InitExtensionBehavior(const ShBuiltInResources &resources,
// undefined state. These extensions will only be those initially supported in // undefined state. These extensions will only be those initially supported in
// the ShBuiltInResources object for this compiler instance. All other // the ShBuiltInResources object for this compiler instance. All other
// extensions will remain unsupported. // extensions will remain unsupported.
void ResetExtensionBehavior(TExtensionBehavior &extensionBehavior); void ResetExtensionBehavior(const ShBuiltInResources &resources,
TExtensionBehavior &extensionBehavior,
const ShCompileOptions compileOptions);
} // namespace sh } // namespace sh
......
...@@ -154,3 +154,44 @@ TEST_F(ARBTextureRectangleTest, DisableARBTextureRectangle) ...@@ -154,3 +154,44 @@ TEST_F(ARBTextureRectangleTest, DisableARBTextureRectangle)
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog; FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
} }
} }
// The compiler option to disable ARB_texture_rectangle should prevent shaders from
// enabling it.
TEST_F(ARBTextureRectangleTest, CompilerOption)
{
const std::string &shaderString =
R"(
#extension GL_ARB_texture_rectangle : enable
precision mediump float;
uniform sampler2DRect s;
void main() {})";
mExtraCompileOptions |= SH_DISABLE_ARB_TEXTURE_RECTANGLE;
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
// The compiler option to disable ARB_texture_rectangle should be toggleable.
TEST_F(ARBTextureRectangleTest, ToggleCompilerOption)
{
const std::string &shaderString =
R"(
precision mediump float;
uniform sampler2DRect s;
void main() {})";
if (!compile(shaderString))
{
FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog;
}
mExtraCompileOptions |= SH_DISABLE_ARB_TEXTURE_RECTANGLE;
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
mExtraCompileOptions &= ~SH_DISABLE_ARB_TEXTURE_RECTANGLE;
if (!compile(shaderString))
{
FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog;
}
}
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