• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "gpu_semaphore_gles.h"
17 
18 #include <render/namespace.h>
19 
20 #include "gles/device_gles.h"
21 #include "gles/gl_functions.h"
22 #include "util/log.h"
23 
RENDER_BEGIN_NAMESPACE()24 RENDER_BEGIN_NAMESPACE()
25 GpuSemaphoreGles::GpuSemaphoreGles(Device& device) : device_((DeviceGLES&)device)
26 {
27     PLUGIN_UNUSED(device_);
28     PLUGIN_ASSERT(device_.IsActive());
29 }
30 
GpuSemaphoreGles(Device & device,const uint64_t handle)31 GpuSemaphoreGles::GpuSemaphoreGles(Device& device, const uint64_t handle)
32     : device_((DeviceGLES&)device), ownsResources_(false)
33 {
34     PLUGIN_ASSERT(device_.IsActive());
35     // do not let invalid inputs in
36     PLUGIN_ASSERT(handle != 0);
37     if (handle) {
38         plat_.sync = handle;
39     }
40 }
41 
~GpuSemaphoreGles()42 GpuSemaphoreGles::~GpuSemaphoreGles()
43 {
44     if (ownsResources_ && plat_.sync) {
45         PLUGIN_ASSERT(device_.IsActive());
46         auto sync = reinterpret_cast<GLsync>(plat_.sync);
47         glDeleteSync(sync);
48     }
49     plat_.sync = 0;
50 }
51 
GetHandle() const52 uint64_t GpuSemaphoreGles::GetHandle() const
53 {
54     return plat_.sync;
55 }
56 
GetPlatformData() const57 const GpuSemaphorePlatformDataGles& GpuSemaphoreGles::GetPlatformData() const
58 {
59     return plat_;
60 }
61 RENDER_END_NAMESPACE()
62