-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Skia] Check if glFence is available before using it
https://bugs.webkit.org/show_bug.cgi?id=271376 Reviewed by Miguel Gomez. If not available we need to call GrDirectContext::submit() with GrSyncCpu=kYes. This patch adds a helper class GLFence to wrap it, that can be extended in the future to support nvidia fences if needed too. * Source/WebCore/Headers.cmake: * Source/WebCore/PlatformPlayStation.cmake: * Source/WebCore/SourcesGTK.txt: * Source/WebCore/SourcesWPE.txt: * Source/WebCore/platform/graphics/egl/GLContext.cpp: (WebCore::GLContext::glExtensions const): * Source/WebCore/platform/graphics/egl/GLContext.h: * Source/WebCore/platform/graphics/egl/GLFence.cpp: Added. (WebCore::GLFence::create): (WebCore::GLFence::GLFence): (WebCore::GLFence::~GLFence): (WebCore::GLFence::wait): * Source/WebCore/platform/graphics/egl/GLFence.h: Added. * Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.cpp: (Nicosia::AcceleratedBuffer::beginPainting): (Nicosia::AcceleratedBuffer::completePainting): (Nicosia::AcceleratedBuffer::waitUntilPaintingComplete): (Nicosia::AcceleratedBuffer::~AcceleratedBuffer): Deleted. * Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.h: Canonical link: https://commits.webkit.org/276463@main
- Loading branch information
1 parent
9b4ec97
commit c4b3e26
Showing
10 changed files
with
130 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (C) 2024 Igalia S.L. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include "config.h" | ||
#include "GLFence.h" | ||
|
||
#include "GLContext.h" | ||
|
||
#if USE(LIBEPOXY) | ||
#include <epoxy/gl.h> | ||
#else | ||
#include <GLES2/gl2.h> | ||
#include <GLES2/gl2ext.h> | ||
#endif | ||
|
||
namespace WebCore { | ||
|
||
std::unique_ptr<GLFence> GLFence::create() | ||
{ | ||
auto* context = GLContext::current(); | ||
if (!context) | ||
return nullptr; | ||
|
||
if (context->version() >= 300 || context->glExtensions().APPLE_sync) { | ||
if (auto* sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) | ||
return makeUnique<GLFence>(sync); | ||
return nullptr; | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
GLFence::GLFence(GLsync sync) | ||
: m_sync(sync) | ||
{ | ||
} | ||
|
||
GLFence::~GLFence() | ||
{ | ||
if (m_sync) | ||
glDeleteSync(m_sync); | ||
} | ||
|
||
unsigned GLFence::wait(FlushCommands flushCommands) | ||
{ | ||
return glClientWaitSync(m_sync, flushCommands == FlushCommands::Yes ? GL_SYNC_FLUSH_COMMANDS_BIT : 0, GL_TIMEOUT_IGNORED); | ||
} | ||
|
||
} // namespace WebCore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (C) 2024 Igalia S.L. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <wtf/FastMalloc.h> | ||
#include <wtf/Noncopyable.h> | ||
|
||
typedef struct __GLsync* GLsync; | ||
|
||
namespace WebCore { | ||
|
||
class GLFence { | ||
WTF_MAKE_NONCOPYABLE(GLFence); | ||
WTF_MAKE_FAST_ALLOCATED; | ||
public: | ||
WEBCORE_EXPORT static std::unique_ptr<GLFence> create(); | ||
explicit GLFence(GLsync); | ||
~GLFence(); | ||
|
||
enum class FlushCommands : bool { No, Yes }; | ||
unsigned wait(FlushCommands); | ||
|
||
private: | ||
GLsync m_sync; | ||
}; | ||
|
||
} // namespace WebCore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Maybe we would want to support EGL_KHR_fence_sync (when
GL_OES_EGL_sync
is also present) as well.