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 ...@@ -9,6 +9,7 @@ Name Strings
Contributors Contributors
Geoff Lang Geoff Lang
James Darpinian
Contact Contact
...@@ -25,7 +26,7 @@ Status ...@@ -25,7 +26,7 @@ Status
Version Version
Version 2, November 28, 2016 Version 3, October 3, 2019
Number Number
...@@ -40,6 +41,8 @@ Dependencies ...@@ -40,6 +41,8 @@ Dependencies
Interacts with EGL_ANGLE_create_context_webgl_compatibility (or equivalent) Interacts with EGL_ANGLE_create_context_webgl_compatibility (or equivalent)
extension. extension.
Interacts with the ARB_texture_rectangle/ANGLE_texture_rectangle extension.
Overview Overview
With this extension enabled, the OpenGL ES context will have additional With this extension enabled, the OpenGL ES context will have additional
...@@ -60,6 +63,16 @@ Additions to the OpenGL ES Specification ...@@ -60,6 +63,16 @@ Additions to the OpenGL ES Specification
the WebGL specification entitled "Differences Between WebGL and OpenGL ES the WebGL specification entitled "Differences Between WebGL and OpenGL ES
2.0" and "Differences Between WebGL and OpenGL ES 3.0". 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 New State
None None
...@@ -79,3 +92,4 @@ Revision History ...@@ -79,3 +92,4 @@ Revision History
1 Sept 16, 2016 geofflang Initial version 1 Sept 16, 2016 geofflang Initial version
2 Nov 28, 2016 geofflang Break the extension requests into a 2 Nov 28, 2016 geofflang Break the extension requests into a
separate extension. 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 ...@@ -323,6 +323,11 @@ const ShCompileOptions SH_DONT_TRANSLATE_UNIFORM_BLOCK_TO_STRUCTUREDBUFFER = UIN
// implemented for the Vulkan backend. // implemented for the Vulkan backend.
const ShCompileOptions SH_ADD_BRESENHAM_LINE_RASTER_EMULATION = UINT64_C(1) << 51; 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. // Defines alternate strategies for implementing array index clamping.
enum ShArrayIndexClampingStrategy enum ShArrayIndexClampingStrategy
{ {
......
...@@ -352,6 +352,15 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[], ...@@ -352,6 +352,15 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
// Reset the extension behavior for each compilation unit. // Reset the extension behavior for each compilation unit.
ResetExtensionBehavior(mExtensionBehavior); 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 // 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
const bool glDrawIDSupported = (compileOptions & SH_EMULATE_GL_DRAW_ID) != 0u; const bool glDrawIDSupported = (compileOptions & SH_EMULATE_GL_DRAW_ID) != 0u;
......
...@@ -300,6 +300,7 @@ State::State(ContextID contextIn, ...@@ -300,6 +300,7 @@ State::State(ContextID contextIn,
mFramebufferSRGB(true), mFramebufferSRGB(true),
mRobustResourceInit(robustResourceInit), mRobustResourceInit(robustResourceInit),
mProgramBinaryCacheEnabled(programBinaryCacheEnabled), mProgramBinaryCacheEnabled(programBinaryCacheEnabled),
mTextureRectangleEnabled(true),
mMaxShaderCompilerThreads(std::numeric_limits<GLuint>::max()), mMaxShaderCompilerThreads(std::numeric_limits<GLuint>::max()),
mOverlay(overlay) mOverlay(overlay)
{} {}
...@@ -940,6 +941,9 @@ void State::setEnableFeature(GLenum feature, bool enabled) ...@@ -940,6 +941,9 @@ void State::setEnableFeature(GLenum feature, bool enabled)
case GL_FRAMEBUFFER_SRGB_EXT: case GL_FRAMEBUFFER_SRGB_EXT:
setFramebufferSRGB(enabled); setFramebufferSRGB(enabled);
break; break;
case GL_TEXTURE_RECTANGLE_ANGLE:
mTextureRectangleEnabled = enabled;
break;
// GLES1 emulation // GLES1 emulation
case GL_ALPHA_TEST: case GL_ALPHA_TEST:
...@@ -1047,6 +1051,8 @@ bool State::getEnableFeature(GLenum feature) const ...@@ -1047,6 +1051,8 @@ bool State::getEnableFeature(GLenum feature) const
return mRobustResourceInit; return mRobustResourceInit;
case GL_PROGRAM_CACHE_ENABLED_ANGLE: case GL_PROGRAM_CACHE_ENABLED_ANGLE:
return mProgramBinaryCacheEnabled; return mProgramBinaryCacheEnabled;
case GL_TEXTURE_RECTANGLE_ANGLE:
return mTextureRectangleEnabled;
// GLES1 emulation // GLES1 emulation
case GL_ALPHA_TEST: case GL_ALPHA_TEST:
...@@ -1920,6 +1926,9 @@ void State::getBooleanv(GLenum pname, GLboolean *params) ...@@ -1920,6 +1926,9 @@ void State::getBooleanv(GLenum pname, GLboolean *params)
case GL_PROGRAM_CACHE_ENABLED_ANGLE: case GL_PROGRAM_CACHE_ENABLED_ANGLE:
*params = mProgramBinaryCacheEnabled ? GL_TRUE : GL_FALSE; *params = mProgramBinaryCacheEnabled ? GL_TRUE : GL_FALSE;
break; break;
case GL_TEXTURE_RECTANGLE_ANGLE:
*params = mTextureRectangleEnabled ? GL_TRUE : GL_FALSE;
break;
case GL_LIGHT_MODEL_TWO_SIDE: case GL_LIGHT_MODEL_TWO_SIDE:
*params = IsLightModelTwoSided(&mGLES1State); *params = IsLightModelTwoSided(&mGLES1State);
break; break;
......
...@@ -913,6 +913,9 @@ class State : angle::NonCopyable ...@@ -913,6 +913,9 @@ class State : angle::NonCopyable
// GL_ANGLE_program_cache_control // GL_ANGLE_program_cache_control
const bool mProgramBinaryCacheEnabled; const bool mProgramBinaryCacheEnabled;
// GL_ANGLE_webgl_compatibility
bool mTextureRectangleEnabled;
// GL_KHR_parallel_shader_compile // GL_KHR_parallel_shader_compile
GLuint mMaxShaderCompilerThreads; GLuint mMaxShaderCompilerThreads;
......
...@@ -250,6 +250,11 @@ std::shared_ptr<WaitableCompileEvent> ShaderGL::compile(const gl::Context *conte ...@@ -250,6 +250,11 @@ std::shared_ptr<WaitableCompileEvent> ShaderGL::compile(const gl::Context *conte
additionalOptions |= SH_INIT_OUTPUT_VARIABLES; 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); const angle::FeaturesGL &features = GetFeaturesGL(context);
if (features.doWhileGLSLCausesGPUHang.enabled) if (features.doWhileGLSLCausesGPUHang.enabled)
......
...@@ -879,6 +879,8 @@ bool ValidCap(const Context *context, GLenum cap, bool queryOnly) ...@@ -879,6 +879,8 @@ bool ValidCap(const Context *context, GLenum cap, bool queryOnly)
case GL_POINT_SPRITE_OES: case GL_POINT_SPRITE_OES:
return context->getClientVersion() < Version(2, 0) && return context->getClientVersion() < Version(2, 0) &&
context->getExtensions().pointSprite; context->getExtensions().pointSprite;
case GL_TEXTURE_RECTANGLE_ANGLE:
return context->getExtensions().webglCompatibility;
default: default:
return false; 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