Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6d6b91a

Browse files
sugoi1Commit Bot
authored andcommitted
Enable GL_NV_fence with Vulkan backend
Implemented FenceNVVk, based on the existing vk::SyncHelper class. Bug: angleproject:4295 Change-Id: I3f44a66e27ce3bd24461894dae4757b25321a6a4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2013880 Commit-Queue: Alexis Hétu <sugoi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 parent 8247ae7 commit 6d6b91a

File tree

12 files changed

+45
-6
lines changed

12 files changed

+45
-6
lines changed

src/libANGLE/Context.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,10 @@ egl::Error Context::onDestroy(const egl::Display *display)
569569

570570
for (auto fence : mFenceNVMap)
571571
{
572+
if (fence.second)
573+
{
574+
fence.second->onDestroy(this);
575+
}
572576
SafeDelete(fence.second);
573577
}
574578
mFenceNVMap.clear();
@@ -976,6 +980,10 @@ void Context::deleteFencesNV(GLsizei n, const FenceNVID *fences)
976980
if (mFenceNVMap.erase(fence, &fenceObject))
977981
{
978982
mFenceNVHandleAllocator.release(fence.value);
983+
if (fenceObject)
984+
{
985+
fenceObject->onDestroy(this);
986+
}
979987
delete fenceObject;
980988
}
981989
}

src/libANGLE/Fence.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ FenceNV::~FenceNV()
2727
SafeDelete(mFence);
2828
}
2929

30+
void FenceNV::onDestroy(const gl::Context *context)
31+
{
32+
mFence->onDestroy(context);
33+
}
34+
3035
angle::Result FenceNV::set(const Context *context, GLenum condition)
3136
{
3237
ANGLE_TRY(mFence->set(context, condition));

src/libANGLE/Fence.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class FenceNV final : angle::NonCopyable
3232
explicit FenceNV(rx::GLImplFactory *factory);
3333
virtual ~FenceNV();
3434

35+
void onDestroy(const gl::Context *context);
3536
angle::Result set(const Context *context, GLenum condition);
3637
angle::Result test(const Context *context, GLboolean *outResult);
3738
angle::Result finish(const Context *context);

src/libANGLE/Fence_unittest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class MockFenceNVImpl : public rx::FenceNVImpl
2626
public:
2727
virtual ~MockFenceNVImpl() { destroy(); }
2828

29+
MOCK_METHOD1(onDestroy, void(const gl::Context *context));
2930
MOCK_METHOD2(set, angle::Result(const gl::Context *, GLenum));
3031
MOCK_METHOD2(test, angle::Result(const gl::Context *, GLboolean *));
3132
MOCK_METHOD1(finish, angle::Result(const gl::Context *));

src/libANGLE/renderer/FenceNVImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class FenceNVImpl : angle::NonCopyable
2828
FenceNVImpl() {}
2929
virtual ~FenceNVImpl() {}
3030

31+
virtual void onDestroy(const gl::Context *context) = 0;
3132
virtual angle::Result set(const gl::Context *context, GLenum condition) = 0;
3233
virtual angle::Result test(const gl::Context *context, GLboolean *outFinished) = 0;
3334
virtual angle::Result finish(const gl::Context *context) = 0;

src/libANGLE/renderer/d3d/d3d11/Fence11.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class FenceNV11 : public FenceNVImpl
2323
explicit FenceNV11(Renderer11 *renderer);
2424
~FenceNV11() override;
2525

26+
void onDestroy(const gl::Context *context) override {}
2627
angle::Result set(const gl::Context *context, GLenum condition) override;
2728
angle::Result test(const gl::Context *context, GLboolean *outFinished) override;
2829
angle::Result finish(const gl::Context *context) override;

src/libANGLE/renderer/d3d/d3d9/Fence9.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class FenceNV9 : public FenceNVImpl
2323
explicit FenceNV9(Renderer9 *renderer);
2424
~FenceNV9() override;
2525

26+
void onDestroy(const gl::Context *context) override {}
2627
angle::Result set(const gl::Context *context, GLenum condition) override;
2728
angle::Result test(const gl::Context *context, GLboolean *outFinished) override;
2829
angle::Result finish(const gl::Context *context) override;

src/libANGLE/renderer/gl/FenceNVGL.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class FenceNVGL : public FenceNVImpl
2222
explicit FenceNVGL(const FunctionsGL *functions);
2323
~FenceNVGL() override;
2424

25+
void onDestroy(const gl::Context *context) override {}
2526
angle::Result set(const gl::Context *context, GLenum condition) override;
2627
angle::Result test(const gl::Context *context, GLboolean *outFinished) override;
2728
angle::Result finish(const gl::Context *context) override;
@@ -41,6 +42,7 @@ class FenceNVSyncGL : public FenceNVImpl
4142
explicit FenceNVSyncGL(const FunctionsGL *functions);
4243
~FenceNVSyncGL() override;
4344

45+
void onDestroy(const gl::Context *context) override {}
4446
angle::Result set(const gl::Context *context, GLenum condition) override;
4547
angle::Result test(const gl::Context *context, GLboolean *outFinished) override;
4648
angle::Result finish(const gl::Context *context) override;

src/libANGLE/renderer/null/FenceNVNULL.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class FenceNVNULL : public FenceNVImpl
2020
FenceNVNULL();
2121
~FenceNVNULL() override;
2222

23+
void onDestroy(const gl::Context *context) override {}
2324
angle::Result set(const gl::Context *context, GLenum condition) override;
2425
angle::Result test(const gl::Context *context, GLboolean *outFinished) override;
2526
angle::Result finish(const gl::Context *context) override;

src/libANGLE/renderer/vulkan/FenceNVVk.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,32 @@ FenceNVVk::FenceNVVk() : FenceNVImpl() {}
2121

2222
FenceNVVk::~FenceNVVk() {}
2323

24+
void FenceNVVk::onDestroy(const gl::Context *context)
25+
{
26+
mFenceSync.releaseToRenderer(vk::GetImpl(context)->getRenderer());
27+
}
28+
2429
angle::Result FenceNVVk::set(const gl::Context *context, GLenum condition)
2530
{
26-
ANGLE_VK_UNREACHABLE(vk::GetImpl(context));
27-
return angle::Result::Stop;
31+
ASSERT(condition == GL_ALL_COMPLETED_NV);
32+
return mFenceSync.initialize(vk::GetImpl(context));
2833
}
2934

3035
angle::Result FenceNVVk::test(const gl::Context *context, GLboolean *outFinished)
3136
{
32-
ANGLE_VK_UNREACHABLE(vk::GetImpl(context));
33-
return angle::Result::Stop;
37+
bool signaled = false;
38+
ANGLE_TRY(mFenceSync.getStatus(vk::GetImpl(context), &signaled));
39+
40+
ASSERT(outFinished);
41+
*outFinished = signaled ? GL_TRUE : GL_FALSE;
42+
return angle::Result::Continue;
3443
}
3544

3645
angle::Result FenceNVVk::finish(const gl::Context *context)
3746
{
38-
ANGLE_VK_UNREACHABLE(vk::GetImpl(context));
39-
return angle::Result::Stop;
47+
VkResult outResult;
48+
ContextVk *contextVk = vk::GetImpl(context);
49+
return mFenceSync.clientWait(contextVk, contextVk, true, UINT64_MAX, &outResult);
4050
}
4151

4252
} // namespace rx

0 commit comments

Comments
 (0)