2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/graphics/vulkan/vulkan-fence.h>
20 #include <dali/graphics/vulkan/vulkan-graphics.h>
33 RefCountedFence Fence::New( Graphics& graphics )
35 return Handle<Fence>( new Fence(graphics) );
38 Fence::Fence( Graphics& graphics ) : mGraphics(&graphics)
42 const Fence& Fence::ConstRef() const
52 Fence::~Fence() = default;
54 vk::Fence Fence::GetVkHandle() const
59 Fence::operator vk::Fence*()
64 bool Fence::OnDestroy()
66 // Copy the Vulkan handles and pointers here.
67 // Cannot capture the "this" pointer in the lambda.
68 // When the lambda is invoked "this" is already destroyed.
69 // This method is only deferring execution to the end of the frame.
70 auto device = mGraphics->GetDevice();
72 auto allocator = &mGraphics->GetAllocator();
74 // capture copies of the pointers and handles
75 mGraphics->DiscardResource( [device, fence, allocator]() {
76 device.destroyFence( fence, allocator );
84 } // namespace Graphics