WebKit Bugzilla
Attachment 346308 Details for
Bug 133745
: use OpenGL ES 3 as backend for WebGL
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-133745-20180802085508.patch (text/plain), 12.65 KB, created by
Dean Jackson
on 2018-08-01 15:55:10 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dean Jackson
Created:
2018-08-01 15:55:10 PDT
Size:
12.65 KB
patch
obsolete
>Subversion Revision: 234321 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 81736d8728bdeed2516020bde36855ba706e6de0..3a6350188e39842a822eed6f0b8523d26da83a1f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,37 @@ >+2018-07-30 Dean Jackson <dino@apple.com> >+ >+ use OpenGL ES 3 as backend for WebGL >+ https://bugs.webkit.org/show_bug.cgi?id=133745 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * html/canvas/WebGLRenderingContextBase.cpp: >+ (WebCore::WebGLRenderingContextBase::initializeNewContext): >+ (WebCore::WebGLRenderingContextBase::setupFlags): >+ (WebCore::WebGLRenderingContextBase::validateNPOTTextureLevel): >+ (WebCore::WebGLRenderingContextBase::drawArrays): >+ (WebCore::WebGLRenderingContextBase::drawElements): >+ (WebCore::WebGLRenderingContextBase::copyTexImage2D): >+ (WebCore::WebGLRenderingContextBase::drawArraysInstanced): >+ (WebCore::WebGLRenderingContextBase::drawElementsInstanced): >+ * html/canvas/WebGLRenderingContextBase.h: >+ (WebCore::WebGLRenderingContextBase::isGLES2Compliant const): >+ (WebCore::WebGLRenderingContextBase::requiresStrictGLES2NPOTValidation const): >+ (WebCore::WebGLRenderingContextBase::isDepthStencilSupported const): >+ (WebCore::WebGLRenderingContextBase::isGLES2Compliant): Deleted. >+ (WebCore::WebGLRenderingContextBase::isGLES2NPOTStrict): Deleted. >+ (WebCore::WebGLRenderingContextBase::isDepthStencilSupported): Deleted. >+ * platform/graphics/GraphicsContext3D.h: >+ * platform/graphics/cocoa/GraphicsContext3DCocoa.mm: >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ (WebCore::GraphicsContext3D::requiresStrictGLES2NPOTValidation): >+ * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: >+ (WebCore::GraphicsContext3D::renderbufferStorage): >+ * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: >+ (WebCore::GraphicsContext3D::requiresStrictGLES2NPOTValidation): >+ > 2018-07-27 Myles C. Maxfield <mmaxfield@apple.com> > > [WIN] Crash when trying to access store pages >diff --git a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >index 19181e44c1335c8e28baaa3f089b71bfd24eee3f..3baed6439c5561dbcceb3d66a757767ffe2d1658 100644 >--- a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >+++ b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >@@ -789,7 +789,7 @@ void WebGLRenderingContextBase::initializeNewContext() > > m_vertexAttribValue.resize(m_maxVertexAttribs); > >- if (!isGLES2NPOTStrict()) >+ if (requiresStrictGLES2NPOTValidation()) > createFallbackBlackTextures1x1(); > > IntSize canvasSize = clampedCanvasSize(); >@@ -812,13 +812,11 @@ void WebGLRenderingContextBase::setupFlags() > } > > m_isGLES2Compliant = m_context->isGLES2Compliant(); >- if (m_isGLES2Compliant) { >- m_isGLES2NPOTStrict = !m_context->getExtensions().isEnabled("GL_OES_texture_npot"); >+ m_requiresStrictGLES2NPOTValidation = m_context->requiresStrictGLES2NPOTValidation(); >+ if (m_isGLES2Compliant) > m_isDepthStencilSupported = m_context->getExtensions().isEnabled("GL_OES_packed_depth_stencil"); >- } else { >- m_isGLES2NPOTStrict = !m_context->getExtensions().isEnabled("GL_ARB_texture_non_power_of_two"); >+ else > m_isDepthStencilSupported = m_context->getExtensions().isEnabled("GL_EXT_packed_depth_stencil"); >- } > m_isRobustnessEXTSupported = m_context->getExtensions().isEnabled("GL_EXT_robustness"); > } > >@@ -1911,7 +1909,7 @@ void WebGLRenderingContextBase::disableVertexAttribArray(GC3Duint index) > > bool WebGLRenderingContextBase::validateNPOTTextureLevel(GC3Dsizei width, GC3Dsizei height, GC3Dint level, const char* functionName) > { >- if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { >+ if (requiresStrictGLES2NPOTValidation() && level && WebGLTexture::isNPOT(width, height)) { > synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "level > 0 not power of 2"); > return false; > } >@@ -2244,7 +2242,7 @@ void WebGLRenderingContextBase::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsiz > vertexAttrib0Simulated = simulateVertexAttrib0Status.value(); > } > bool usesFallbackTexture = false; >- if (!isGLES2NPOTStrict()) >+ if (requiresStrictGLES2NPOTValidation()) > usesFallbackTexture = checkTextureCompleteness("drawArrays", true); > > { >@@ -2285,7 +2283,7 @@ void WebGLRenderingContextBase::drawElements(GC3Denum mode, GC3Dsizei count, GC3 > } > > bool usesFallbackTexture = false; >- if (!isGLES2NPOTStrict()) >+ if (requiresStrictGLES2NPOTValidation()) > usesFallbackTexture = checkTextureCompleteness("drawElements", true); > > { >@@ -4337,7 +4335,7 @@ void WebGLRenderingContextBase::copyTexImage2D(GC3Denum target, GC3Dint level, G > synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexImage2D", "framebuffer is incompatible format"); > return; > } >- if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { >+ if (requiresStrictGLES2NPOTValidation() && level && WebGLTexture::isNPOT(width, height)) { > synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexImage2D", "level > 0 not power of 2"); > return; > } >@@ -6295,14 +6293,14 @@ void WebGLRenderingContextBase::drawArraysInstanced(GC3Denum mode, GC3Dint first > } > vertexAttrib0Simulated = simulateVertexAttrib0Status.value(); > } >- if (!isGLES2NPOTStrict()) >+ if (requiresStrictGLES2NPOTValidation()) > checkTextureCompleteness("drawArraysInstanced", true); > > m_context->drawArraysInstanced(mode, first, count, primcount); > > if (!isGLES2Compliant() && vertexAttrib0Simulated) > restoreStatesAfterVertexAttrib0Simulation(); >- if (!isGLES2NPOTStrict()) >+ if (requiresStrictGLES2NPOTValidation()) > checkTextureCompleteness("drawArraysInstanced", false); > markContextChangedAndNotifyCanvasObserver(); > } >@@ -6332,14 +6330,14 @@ void WebGLRenderingContextBase::drawElementsInstanced(GC3Denum mode, GC3Dsizei c > } > vertexAttrib0Simulated = simulateVertexAttrib0Status.value(); > } >- if (!isGLES2NPOTStrict()) >+ if (requiresStrictGLES2NPOTValidation()) > checkTextureCompleteness("drawElementsInstanced", true); > > m_context->drawElementsInstanced(mode, count, type, static_cast<GC3Dintptr>(offset), primcount); > > if (!isGLES2Compliant() && vertexAttrib0Simulated) > restoreStatesAfterVertexAttrib0Simulation(); >- if (!isGLES2NPOTStrict()) >+ if (requiresStrictGLES2NPOTValidation()) > checkTextureCompleteness("drawElementsInstanced", false); > markContextChangedAndNotifyCanvasObserver(); > } >diff --git a/Source/WebCore/html/canvas/WebGLRenderingContextBase.h b/Source/WebCore/html/canvas/WebGLRenderingContextBase.h >index 71b0d543c2294298e4c90e42e36f6c1d85c81d84..28677fc259c80940982a61bf8df5dcbcbd6fde7c 100644 >--- a/Source/WebCore/html/canvas/WebGLRenderingContextBase.h >+++ b/Source/WebCore/html/canvas/WebGLRenderingContextBase.h >@@ -398,11 +398,11 @@ protected: > void removeActivityStateChangeObserver(); > > // Query whether it is built on top of compliant GLES2 implementation. >- bool isGLES2Compliant() { return m_isGLES2Compliant; } >+ bool isGLES2Compliant() const { return m_isGLES2Compliant; } > // Query if the GL implementation is NPOT strict. >- bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; } >+ bool requiresStrictGLES2NPOTValidation() const { return m_requiresStrictGLES2NPOTValidation; } > // Query if depth_stencil buffer is supported. >- bool isDepthStencilSupported() { return m_isDepthStencilSupported; } >+ bool isDepthStencilSupported() const { return m_isDepthStencilSupported; } > > // Helper to return the size in bytes of OpenGL data types > // like GL_FLOAT, GL_INT, etc. >@@ -560,7 +560,7 @@ protected: > GC3Duint m_stencilFuncMask, m_stencilFuncMaskBack; > > bool m_isGLES2Compliant; >- bool m_isGLES2NPOTStrict; >+ bool m_requiresStrictGLES2NPOTValidation; > bool m_isDepthStencilSupported; > bool m_isRobustnessEXTSupported; > >diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h >index 4308acf142522ab9da30061c7a8365b6a290fee7..6d0e190c4aa2d33774824924ce61e25fa4246046 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext3D.h >+++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h >@@ -755,6 +755,8 @@ public: > PlatformLayer* platformLayer() const; > #endif > >+ bool requiresStrictGLES2NPOTValidation(); >+ > bool makeContextCurrent(); > void setWebGLContext(WebGLRenderingContextBase* base) { m_webglContext = base; } > >@@ -776,6 +778,7 @@ public: > bool texImage2DResourceSafe(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, GC3Dint alignment = 4); > > bool isGLES2Compliant() const; >+ bool isForWebGL2() const { return m_isForWebGL2; } > > //---------------------------------------------------------------------- > // Helpers for texture uploading and pixel readback. >diff --git a/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm b/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm >index 959919dba501a3c783c035b3aa0f0e250b642c24..e75612caced756d8ed412490280599bbf59db2ce 100644 >--- a/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm >+++ b/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm >@@ -218,7 +218,8 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind > { > #if USE(OPENGL_ES) > UNUSED_PARAM(hostWindow); >- EAGLRenderingAPI api = m_attrs.useGLES3 ? kEAGLRenderingAPIOpenGLES3 : kEAGLRenderingAPIOpenGLES2; >+// EAGLRenderingAPI api = m_attrs.useGLES3 ? kEAGLRenderingAPIOpenGLES3 : kEAGLRenderingAPIOpenGLES2; >+ EAGLRenderingAPI api = kEAGLRenderingAPIOpenGLES3; > if (!sharedContext) > m_contextObj = [[EAGLContext alloc] initWithAPI:api]; > else >@@ -491,6 +492,16 @@ void GraphicsContext3D::checkGPUStatus() > #endif > } > >+bool GraphicsContext3D::requiresStrictGLES2NPOTValidation() >+{ >+#if USE(OPENGL_ES) >+ // We're using an OpenGL ES 3.0 context, which accepts more NPOT textures. >+ return true; >+#else >+ return !getExtensions().isEnabled("GL_ARB_texture_non_power_of_two"); >+#endif >+} >+ > #if USE(OPENGL_ES) > void GraphicsContext3D::presentRenderbuffer() > { >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >index a6fffd01280fe6cfe71502b8288cea9e8f586baf..85010979cba5d1b3fb43088001f7e779434d78ba 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >@@ -290,6 +290,27 @@ void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalfo > internalformat = GL_RGB; > break; > } >+#endif >+#if USE(OPENGL_ES) >+ // Assume we're backed by an OpenGL ES 3.0 context, so we have to upgrade some of the >+ // WebGL 1 formats. >+ if (!isForWebGL2()) { >+ switch (internalformat) { >+ case DEPTH_STENCIL: >+ internalformat = GL_DEPTH24_STENCIL8; >+ break; >+ case DEPTH_COMPONENT16: >+ internalformat = GL_DEPTH_COMPONENT16; >+ break; >+ case RGBA4: >+ case RGB5_A1: >+ internalformat = GL_RGBA8; >+ break; >+ case RGB565: >+ internalformat = GL_RGB8; >+ break; >+ } >+ } > #endif > ::glRenderbufferStorageEXT(target, internalformat, width, height); > } >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >index 3437952003ea75be922af6f49dfbefaa79578a13..5638596941bd1316f527f191920a5d0a68af87c6 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >@@ -139,6 +139,16 @@ static uint64_t nameHashForShader(const char* name, size_t length) > return result; > } > >+#if !PLATFORM(COCOA) >+bool GraphicsContext3D::requiresStrictGLES2NPOTValidation() >+{ >+ if (isGLES2Compliant()) >+ return !getExtensions().isEnabled("GL_OES_texture_npot"); >+ else >+ return !getExtensions().isEnabled("GL_ARB_texture_non_power_of_two"); >+} >+#endif >+ > void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension) > { > Extensions3D& extensions = getExtensions();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 133745
:
346114
| 346308