Skip to content
Permalink
Browse files
Query EGL_BIND_TO_TEXTURE_TARGET_ANGLE to determine 2D/rectangular te…
…xture usage

https://bugs.webkit.org/show_bug.cgi?id=231468

Refactor GraphicsContextGLCocoa to hold a reference to
BIND_TO_TEXTURE_TARGET. This refactor is neccesary to support dropping
TEXTURE_RECT support from the Metal backend, as support is incomplete, and unnecessary

Reviewed by Kenneth Russell.

* Modules/webxr/WebXROpaqueFramebuffer.cpp:
(WebCore::WebXROpaqueFramebuffer::startFrame):
* platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
(WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL):
(WebCore::GraphicsContextGLOpenGL::drawingBufferTextureTarget):
(WebCore::GraphicsContextGLOpenGL::drawingBufferTextureTargetQueryForDrawingTarget):
(WebCore::GraphicsContextGLOpenGL::EGLDrawingBufferTextureTargetForDrawingTarget):
(WebCore::GraphicsContextGLOpenGL::allocateAndBindDisplayBufferBacking):
(WebCore::GraphicsContextGLOpenGL::bindDisplayBufferBacking):
(WebCore::GraphicsContextGLOpenGL::readCompositedResults):
(WebCore::GraphicsContextGLOpenGL::drawingBufferTextureTargetQuery): Deleted.
(WebCore::GraphicsContextGLOpenGL::EGLDrawingBufferTextureTarget): Deleted.
* platform/graphics/cv/GraphicsContextGLCVANGLE.cpp:
(WebCore::GraphicsContextGLCVANGLE::GraphicsContextGLCVANGLE):
(WebCore::GraphicsContextGLCVANGLE::copyPixelBufferToTexture):
* platform/graphics/opengl/GraphicsContextGLOpenGL.h:


Canonical link: https://commits.webkit.org/243200@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284438 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
kpiddington committed Oct 19, 2021
1 parent 08f4953 commit 4ae59e33554d1b8509a594e737809953244f168d
Showing 5 changed files with 67 additions and 35 deletions.
@@ -1,3 +1,30 @@
2021-10-19 Kyle Piddington <kpiddington@apple.com>
Query EGL_BIND_TO_TEXTURE_TARGET_ANGLE to determine 2D/rectangular texture usage
https://bugs.webkit.org/show_bug.cgi?id=231468

Refactor GraphicsContextGLCocoa to hold a reference to
BIND_TO_TEXTURE_TARGET. This refactor is neccesary to support dropping
TEXTURE_RECT support from the Metal backend, as support is incomplete, and unnecessary

Reviewed by Kenneth Russell.

* Modules/webxr/WebXROpaqueFramebuffer.cpp:
(WebCore::WebXROpaqueFramebuffer::startFrame):
* platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
(WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL):
(WebCore::GraphicsContextGLOpenGL::drawingBufferTextureTarget):
(WebCore::GraphicsContextGLOpenGL::drawingBufferTextureTargetQueryForDrawingTarget):
(WebCore::GraphicsContextGLOpenGL::EGLDrawingBufferTextureTargetForDrawingTarget):
(WebCore::GraphicsContextGLOpenGL::allocateAndBindDisplayBufferBacking):
(WebCore::GraphicsContextGLOpenGL::bindDisplayBufferBacking):
(WebCore::GraphicsContextGLOpenGL::readCompositedResults):
(WebCore::GraphicsContextGLOpenGL::drawingBufferTextureTargetQuery): Deleted.
(WebCore::GraphicsContextGLOpenGL::EGLDrawingBufferTextureTarget): Deleted.
* platform/graphics/cv/GraphicsContextGLCVANGLE.cpp:
(WebCore::GraphicsContextGLCVANGLE::GraphicsContextGLCVANGLE):
(WebCore::GraphicsContextGLCVANGLE::copyPixelBufferToTexture):
* platform/graphics/opengl/GraphicsContextGLOpenGL.h:

2021-10-18 Antoine Quint <graouts@webkit.org>

box-shadow and text-shadow do not yield float values while interpolating
@@ -123,7 +123,7 @@ void WebXROpaqueFramebuffer::startFrame(const PlatformXR::Device::FrameData::Lay
ASSERT(data.surface);

auto gCGL = static_cast<GraphicsContextGLOpenGL*>(m_context.graphicsContextGL());
GCGLenum textureTarget = GraphicsContextGLOpenGL::drawingBufferTextureTarget();
GCGLenum textureTarget = gCGL->drawingBufferTextureTarget();


if (!m_opaqueTexture)
@@ -415,6 +415,7 @@ static bool needsEAGLOnMac()
EGL_DestroyContext(m_displayObj, m_contextObj);
}
ASSERT(currentContext != this);
m_drawingBufferTextureTarget = -1;
LOG(WebGL, "Destroyed a GraphicsContextGLOpenGL (%p).", this);
}

@@ -430,41 +431,42 @@ static bool needsEAGLOnMac()

GCGLenum GraphicsContextGLOpenGL::drawingBufferTextureTarget()
{
#if PLATFORM(MACCATALYST)
if (needsEAGLOnMac())
if (m_drawingBufferTextureTarget == -1)
EGL_GetConfigAttrib(m_displayObj, m_configObj, EGL_BIND_TO_TEXTURE_TARGET_ANGLE, &m_drawingBufferTextureTarget);

switch (m_drawingBufferTextureTarget) {
case EGL_TEXTURE_2D:
return TEXTURE_2D;
return TEXTURE_RECTANGLE_ARB;
#elif PLATFORM(MAC)
return TEXTURE_RECTANGLE_ARB;
#else
return TEXTURE_2D;
#endif
case EGL_TEXTURE_RECTANGLE_ANGLE:
return TEXTURE_RECTANGLE_ARB;

}
ASSERT_WITH_MESSAGE(false, "Invalid enum returned from EGL_GetConfigAttrib");
return 0;
}

GCGLenum GraphicsContextGLOpenGL::drawingBufferTextureTargetQuery()
GCGLenum GraphicsContextGLOpenGL::drawingBufferTextureTargetQueryForDrawingTarget(GCGLenum drawingTarget)
{
#if PLATFORM(MACCATALYST)
if (needsEAGLOnMac())
switch (drawingTarget) {
case TEXTURE_2D:
return TEXTURE_BINDING_2D;
return TEXTURE_BINDING_RECTANGLE_ARB;
#elif PLATFORM(MAC)
return TEXTURE_BINDING_RECTANGLE_ARB;
#else
return TEXTURE_BINDING_2D;
#endif
case TEXTURE_RECTANGLE_ARB:
return TEXTURE_BINDING_RECTANGLE_ARB;
}
ASSERT_WITH_MESSAGE(false, "Invalid drawing target");
return -1;
}

GCGLint GraphicsContextGLOpenGL::EGLDrawingBufferTextureTarget()
GCGLint GraphicsContextGLOpenGL::EGLDrawingBufferTextureTargetForDrawingTarget(GCGLenum drawingTarget)
{
#if PLATFORM(MACCATALYST)
if (needsEAGLOnMac())
switch (drawingTarget) {
case TEXTURE_2D:
return EGL_TEXTURE_2D;
return EGL_TEXTURE_RECTANGLE_ANGLE;
#elif PLATFORM(MAC)
return EGL_TEXTURE_RECTANGLE_ANGLE;
#else
return EGL_TEXTURE_2D;
#endif
case TEXTURE_RECTANGLE_ARB:
return EGL_TEXTURE_RECTANGLE_ANGLE;
}
ASSERT_WITH_MESSAGE(false, "Invalid drawing target");
return 0;
}

bool GraphicsContextGLOpenGL::makeContextCurrent()
@@ -562,7 +564,7 @@ static bool needsEAGLOnMac()
EGL_WIDTH, size.width(),
EGL_HEIGHT, size.height(),
EGL_IOSURFACE_PLANE_ANGLE, 0,
EGL_TEXTURE_TARGET, WebCore::GraphicsContextGLOpenGL::EGLDrawingBufferTextureTarget(),
EGL_TEXTURE_TARGET, EGLDrawingBufferTextureTargetForDrawingTarget(drawingBufferTextureTarget()),
EGL_TEXTURE_INTERNAL_FORMAT_ANGLE, usingAlpha ? GL_BGRA_EXT : GL_RGB,
EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA,
EGL_TEXTURE_TYPE_ANGLE, GL_UNSIGNED_BYTE,
@@ -579,7 +581,7 @@ static bool needsEAGLOnMac()
bool GraphicsContextGLOpenGL::bindDisplayBufferBacking(std::unique_ptr<IOSurface> backing, void* pbuffer)
{
GCGLenum textureTarget = drawingBufferTextureTarget();
ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQuery(), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB);
ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(drawingBufferTextureTarget()), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB);
gl::BindTexture(textureTarget, m_texture);
if (!EGL_BindTexImage(m_displayObj, pbuffer, EGL_BACK_BUFFER)) {
EGL_DestroySurface(m_displayObj, pbuffer);
@@ -746,7 +748,7 @@ static bool needsEAGLOnMac()
// the IOSurface be unrefenced after the draw call finishes.
ScopedTexture texture;
GCGLenum textureTarget = drawingBufferTextureTarget();
ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQuery(), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB);
ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(drawingBufferTextureTarget()), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB);
gl::BindTexture(textureTarget, texture);
if (!EGL_BindTexImage(m_displayObj, displayBuffer.handle, EGL_BACK_BUFFER))
return std::nullopt;
@@ -477,7 +477,7 @@ GraphicsContextGLCVANGLE::GraphicsContextGLCVANGLE(GraphicsContextGLOpenGL& owne
EGL_DestroyContext(display, context);
});

const bool useTexture2D = GraphicsContextGLOpenGL::drawingBufferTextureTarget() == GL_TEXTURE_2D;
const bool useTexture2D = m_owner.drawingBufferTextureTarget() == GL_TEXTURE_2D;

#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
if (!useTexture2D) {
@@ -623,7 +623,7 @@ bool GraphicsContextGLCVANGLE::copyPixelBufferToTexture(CVPixelBufferRef image,
auto uvPlaneWidth = IOSurfaceGetWidthOfPlane(surface, 1);
auto uvPlaneHeight = IOSurfaceGetHeightOfPlane(surface, 1);

GLenum videoTextureTarget = GraphicsContextGLOpenGL::drawingBufferTextureTarget();
GLenum videoTextureTarget = m_owner.drawingBufferTextureTarget();

GLuint uvTexture = 0;
gl::GenTextures(1, &uvTexture);
@@ -106,13 +106,13 @@ class WEBCORE_EXPORT GraphicsContextGLOpenGL : public GraphicsContextGL
PlatformLayer* platformLayer() const override;
PlatformGraphicsContextGLDisplay platformDisplay() const { return m_displayObj; }
PlatformGraphicsContextGLConfig platformConfig() const { return m_configObj; }
static GCGLenum drawingBufferTextureTargetQuery();
static GCGLint EGLDrawingBufferTextureTarget();
static GCGLenum drawingBufferTextureTargetQueryForDrawingTarget(GCGLenum drawingTarget);
static GCGLint EGLDrawingBufferTextureTargetForDrawingTarget(GCGLenum drawingTarget);
#else
PlatformLayer* platformLayer() const final;
#endif
#if USE(ANGLE)
static GCGLenum drawingBufferTextureTarget();
GCGLenum drawingBufferTextureTarget();
#endif
enum class ReleaseThreadResourceBehavior {
// Releases current context after GraphicsContextGLOpenGL calls done in the thread.
@@ -749,6 +749,9 @@ class WEBCORE_EXPORT GraphicsContextGLOpenGL : public GraphicsContextGL
GCGLuint m_preserveDrawingBufferTexture { 0 };
// Attaches m_texture when m_preserveDrawingBufferTexture is non-zero.
GCGLuint m_preserveDrawingBufferFBO { 0 };
// Queried at display startup.
EGLint m_drawingBufferTextureTarget { -1 };

#endif

// A bitmask of GL buffer bits (GL_COLOR_BUFFER_BIT,

0 comments on commit 4ae59e3

Please sign in to comment.