From 2547bc36a7de66593726a30c36e614b9b9ffaea2 Mon Sep 17 00:00:00 2001 From: HuYingzhuo Date: Fri, 19 Apr 2019 20:10:59 +0800 Subject: [PATCH] =?UTF-8?q?Device=E5=A2=9E=E5=8A=A0AcquireNextImage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/Vulkan/VKDevice.cpp | 12 ++++++++++++ example/Vulkan/VKDevice.h | 10 ++++++---- example/Vulkan/VKSemaphore.h | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/example/Vulkan/VKDevice.cpp b/example/Vulkan/VKDevice.cpp index 92fbf740..56193ac0 100644 --- a/example/Vulkan/VKDevice.cpp +++ b/example/Vulkan/VKDevice.cpp @@ -57,8 +57,15 @@ namespace } }//namespace +Device::Device(DeviceAttribute *da) +{ + attr=da; + current_framebuffer=0; + image_acquired_semaphore=this->CreateSem(); +} Device::~Device() { + delete image_acquired_semaphore; delete attr; } @@ -213,4 +220,9 @@ Semaphore *Device::CreateSem() return(new Semaphore(attr->device,sem)); } + +bool Device::AcquireNextImage() +{ + return(vkAcquireNextImageKHR(attr->device,attr->swap_chain,UINT64_MAX,*image_acquired_semaphore,VK_NULL_HANDLE,¤t_framebuffer)==VK_SUCCESS); +} VK_NAMESPACE_END diff --git a/example/Vulkan/VKDevice.h b/example/Vulkan/VKDevice.h index 8451fc63..1dc40ad7 100644 --- a/example/Vulkan/VKDevice.h +++ b/example/Vulkan/VKDevice.h @@ -19,14 +19,14 @@ class Device { DeviceAttribute *attr; + Semaphore *image_acquired_semaphore; + uint32_t current_framebuffer; + private: friend Device *CreateRenderDevice(VkInstance,const PhysicalDevice *,Window *); - Device(DeviceAttribute *da) - { - attr=da; - } + Device(DeviceAttribute *da); public: @@ -66,6 +66,8 @@ public: Fence *CreateFence(); Semaphore *CreateSem(); + + bool AcquireNextImage(); };//class Device VK_NAMESPACE_END #endif//HGL_GRAPH_RENDER_SURFACE_INCLUDE diff --git a/example/Vulkan/VKSemaphore.h b/example/Vulkan/VKSemaphore.h index 89f4732a..862c9178 100644 --- a/example/Vulkan/VKSemaphore.h +++ b/example/Vulkan/VKSemaphore.h @@ -21,6 +21,8 @@ private: public: ~Semaphore(); + + operator VkSemaphore(){return sem;} };//class Semaphore VK_NAMESPACE_END #endif//HGL_GRAPH_VULKAN_SEMAPHORE_INCLUDE