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 bool signaled = false;
39 ANGLE_TRY(mFenceSync.getStatus(contextVk, contextVk, &signaled));
40
41 ASSERT(outFinished);
42 *outFinished = signaled ? GL_TRUE : GL_FALSE;
43 return angle::Result::Continue;
44 }
45
finish(const gl::Context * context)46 angle::Result FenceNVVk::finish(const gl::Context *context)
47 {
48 VkResult outResult;
49 ContextVk *contextVk = vk::GetImpl(context);
50 return mFenceSync.clientWait(contextVk, contextVk, true, UINT64_MAX, &outResult);
51 }
52
53 } // namespace rx
54