1 //
2 // Copyright 2016 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // FenceNVVk.cpp:
7 // Implements the class methods for FenceNVVk.
8 //
9
10 #include "libANGLE/renderer/vulkan/FenceNVVk.h"
11
12 #include "common/debug.h"
13 #include "libANGLE/Context.h"
14 #include "libANGLE/renderer/vulkan/ContextVk.h"
15 #include "libANGLE/renderer/vulkan/vk_utils.h"
16
17 namespace rx
18 {
19
FenceNVVk()20 FenceNVVk::FenceNVVk() : FenceNVImpl() {}
21
~FenceNVVk()22 FenceNVVk::~FenceNVVk() {}
23
onDestroy(const gl::Context * context)24 void FenceNVVk::onDestroy(const gl::Context *context)
25 {
26 mFenceSync.releaseToRenderer(vk::GetImpl(context)->getRenderer());
27 }
28
set(const gl::Context * context,GLenum condition)29 angle::Result FenceNVVk::set(const gl::Context *context, GLenum condition)
30 {
31 ASSERT(condition == GL_ALL_COMPLETED_NV);
32 return mFenceSync.initialize(vk::GetImpl(context), false);
33 }
34
test(const gl::Context * context,GLboolean * outFinished)35 angle::Result FenceNVVk::test(const gl::Context *context, GLboolean *outFinished)
36 {
37 ContextVk *contextVk = vk::GetImpl(context);
38 if (contextVk->getShareGroupVk()->isSyncObjectPendingFlush())
39 {
40 ANGLE_TRY(contextVk->flushImpl(nullptr));
41 }
42
43 bool signaled = false;
44 ANGLE_TRY(mFenceSync.getStatus(contextVk, &signaled));
45
46 ASSERT(outFinished);
47 *outFinished = signaled ? GL_TRUE : GL_FALSE;
48 return angle::Result::Continue;
49 }
50
finish(const gl::Context * context)51 angle::Result FenceNVVk::finish(const gl::Context *context)
52 {
53 VkResult outResult;
54 ContextVk *contextVk = vk::GetImpl(context);
55 return mFenceSync.clientWait(contextVk, contextVk, true, UINT64_MAX, &outResult);
56 }
57
58 } // namespace rx
59