Commit 27db2458 by James Darpinian Committed by Commit Bot

Optimize disabling ARB_texture_rectangle

In https://crrev.com/c/1838418 I added the ability to disable ARB_texture_rectangle so that we can use it in the WebGL implementation but disable it when compiling user shaders. Unfortunately disabling and re-enabling the extension causes the shader translator to be reinitialized which turns out to be more expensive than the actual work of shader translation, at least for small shaders. It's slow enough to cause timeouts in WebKit's WebGL conformance test runs. This introduces an alternate method of disabling ARB_texture_rectangle in the translator which is much faster because it avoids reinitializing the translator. Bug: angleproject:3956 Change-Id: I5d31b683ff19a59bdfd289cfd3c609f64ef5e25b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1991969Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: James Darpinian <jdarpinian@chromium.org>
parent bf8bd805
......@@ -9,6 +9,7 @@ Name Strings
Contributors
Geoff Lang
James Darpinian
Contact
......@@ -25,7 +26,7 @@ Status
Version
Version 2, November 28, 2016
Version 3, October 3, 2019
Number
......@@ -40,6 +41,8 @@ Dependencies
Interacts with EGL_ANGLE_create_context_webgl_compatibility (or equivalent)
extension.
Interacts with the ARB_texture_rectangle/ANGLE_texture_rectangle extension.
Overview
With this extension enabled, the OpenGL ES context will have additional
......@@ -60,6 +63,16 @@ Additions to the OpenGL ES Specification
the WebGL specification entitled "Differences Between WebGL and OpenGL ES
2.0" and "Differences Between WebGL and OpenGL ES 3.0".
When the ANGLE_texture_rectangle extension is supported then Enable,
Disable, and IsEnabled accept the symbolic constant
TEXTURE_RECTANGLE_ANGLE, which controls whether ARB_texture_rectangle is
allowed to be used by shaders at compilation time. This is initially
enabled. WebGL implementations may want to use ARB_texture_rectangle when
compiling their own shaders but not expose the extension to WebGL user
shaders. This only affects shader compilation and not any other part of
the ANGLE_texture_rectangle extension, nor the behavior of already
compiled shaders.
New State
None
......@@ -79,3 +92,4 @@ Revision History
1 Sept 16, 2016 geofflang Initial version
2 Nov 28, 2016 geofflang Break the extension requests into a
separate extension.
3 Oct 3, 2019 jdarpinian Allow disabling ARB_texture_rectangle
......@@ -323,6 +323,11 @@ const ShCompileOptions SH_DONT_TRANSLATE_UNIFORM_BLOCK_TO_STRUCTUREDBUFFER = UIN
// implemented for the Vulkan backend.
const ShCompileOptions SH_ADD_BRESENHAM_LINE_RASTER_EMULATION = UINT64_C(1) << 51;
// This flag allows disabling ARB_texture_rectangle on a per-compile basis. This is necessary
// for WebGL contexts becuase ARB_texture_rectangle may be necessary for the WebGL implementation
// internally but shouldn't be exposed to WebGL user code.
const ShCompileOptions SH_DISABLE_ARB_TEXTURE_RECTANGLE = UINT64_C(1) << 52;
// Defines alternate strategies for implementing array index clamping.
enum ShArrayIndexClampingStrategy
{
......
......@@ -352,6 +352,15 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
// Reset the extension behavior for each compilation unit.
ResetExtensionBehavior(mExtensionBehavior);
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
// Currently we only allow emulation of gl_DrawID
const bool glDrawIDSupported = (compileOptions & SH_EMULATE_GL_DRAW_ID) != 0u;
......
......@@ -300,6 +300,7 @@ State::State(ContextID contextIn,
mFramebufferSRGB(true),
mRobustResourceInit(robustResourceInit),
mProgramBinaryCacheEnabled(programBinaryCacheEnabled),
mTextureRectangleEnabled(true),
mMaxShaderCompilerThreads(std::numeric_limits<GLuint>::max()),
mOverlay(overlay)
{}
......@@ -940,6 +941,9 @@ void State::setEnableFeature(GLenum feature, bool enabled)
case GL_FRAMEBUFFER_SRGB_EXT:
setFramebufferSRGB(enabled);
break;
case GL_TEXTURE_RECTANGLE_ANGLE:
mTextureRectangleEnabled = enabled;
break;
// GLES1 emulation
case GL_ALPHA_TEST:
......@@ -1047,6 +1051,8 @@ bool State::getEnableFeature(GLenum feature) const
return mRobustResourceInit;
case GL_PROGRAM_CACHE_ENABLED_ANGLE:
return mProgramBinaryCacheEnabled;
case GL_TEXTURE_RECTANGLE_ANGLE:
return mTextureRectangleEnabled;
// GLES1 emulation
case GL_ALPHA_TEST:
......@@ -1920,6 +1926,9 @@ void State::getBooleanv(GLenum pname, GLboolean *params)
case GL_PROGRAM_CACHE_ENABLED_ANGLE:
*params = mProgramBinaryCacheEnabled ? GL_TRUE : GL_FALSE;
break;
case GL_TEXTURE_RECTANGLE_ANGLE:
*params = mTextureRectangleEnabled ? GL_TRUE : GL_FALSE;
break;
case GL_LIGHT_MODEL_TWO_SIDE:
*params = IsLightModelTwoSided(&mGLES1State);
break;
......
......@@ -913,6 +913,9 @@ class State : angle::NonCopyable
// GL_ANGLE_program_cache_control
const bool mProgramBinaryCacheEnabled;
// GL_ANGLE_webgl_compatibility
bool mTextureRectangleEnabled;
// GL_KHR_parallel_shader_compile
GLuint mMaxShaderCompilerThreads;
......
......@@ -250,6 +250,11 @@ std::shared_ptr<WaitableCompileEvent> ShaderGL::compile(const gl::Context *conte
additionalOptions |= SH_INIT_OUTPUT_VARIABLES;
}
if (isWebGL && !context->getState().getEnableFeature(GL_TEXTURE_RECTANGLE_ANGLE))
{
additionalOptions |= SH_DISABLE_ARB_TEXTURE_RECTANGLE;
}
const angle::FeaturesGL &features = GetFeaturesGL(context);
if (features.doWhileGLSLCausesGPUHang.enabled)
......
......@@ -879,6 +879,8 @@ bool ValidCap(const Context *context, GLenum cap, bool queryOnly)
case GL_POINT_SPRITE_OES:
return context->getClientVersion() < Version(2, 0) &&
context->getExtensions().pointSprite;
case GL_TEXTURE_RECTANGLE_ANGLE:
return context->getExtensions().webglCompatibility;
default:
return false;
}
......
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