diff --git a/example/Vulkan/VKDevice.cpp b/example/Vulkan/VKDevice.cpp index db39a2e0..92fbf740 100644 --- a/example/Vulkan/VKDevice.cpp +++ b/example/Vulkan/VKDevice.cpp @@ -5,6 +5,7 @@ //#include"VKDescriptorSet.h" #include"VKRenderPass.h" #include"VKFence.h" +#include"VKSemaphore.h" VK_NAMESPACE_BEGIN @@ -198,4 +199,18 @@ Fence *Device::CreateFence() return(new Fence(attr->device,drawFence)); } + +Semaphore *Device::CreateSem() +{ + VkSemaphoreCreateInfo SemaphoreCreateInfo; + SemaphoreCreateInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; + SemaphoreCreateInfo.pNext = nullptr; + SemaphoreCreateInfo.flags = 0; + + VkSemaphore sem; + if(vkCreateSemaphore(attr->device, &SemaphoreCreateInfo, nullptr, &sem)!=VK_SUCCESS) + return(nullptr); + + return(new Semaphore(attr->device,sem)); +} VK_NAMESPACE_END diff --git a/example/Vulkan/VKDevice.h b/example/Vulkan/VKDevice.h index 2d335d13..8451fc63 100644 --- a/example/Vulkan/VKDevice.h +++ b/example/Vulkan/VKDevice.h @@ -13,6 +13,7 @@ class VertexBuffer; class CommandBuffer; class RenderPass; class Fence; +class Semaphore; class Device { @@ -63,6 +64,8 @@ public: RenderPass *CreateRenderPass(); Fence *CreateFence(); + + Semaphore *CreateSem(); };//class Device VK_NAMESPACE_END #endif//HGL_GRAPH_RENDER_SURFACE_INCLUDE diff --git a/example/Vulkan/VKSemaphore.cpp b/example/Vulkan/VKSemaphore.cpp index 5217ca0d..1b707099 100644 --- a/example/Vulkan/VKSemaphore.cpp +++ b/example/Vulkan/VKSemaphore.cpp @@ -1,4 +1,7 @@ #include"VKSemaphore.h" - VK_NAMESPACE_BEGIN +Semaphore::~Semaphore() +{ + vkDestroySemaphore(device,sem,nullptr); +} VK_NAMESPACE_END diff --git a/example/Vulkan/VKSemaphore.h b/example/Vulkan/VKSemaphore.h index 70a00c34..89f4732a 100644 --- a/example/Vulkan/VKSemaphore.h +++ b/example/Vulkan/VKSemaphore.h @@ -5,7 +5,22 @@ VK_NAMESPACE_BEGIN class Semaphore { + VkDevice device; + VkSemaphore sem; +private: + + friend class Device; + + Semaphore(VkDevice d,VkSemaphore s) + { + device=d; + sem=s; + } + +public: + + ~Semaphore(); };//class Semaphore VK_NAMESPACE_END #endif//HGL_GRAPH_VULKAN_SEMAPHORE_INCLUDE diff --git a/example/Vulkan/main.cpp b/example/Vulkan/main.cpp index a720db49..6a647f98 100644 --- a/example/Vulkan/main.cpp +++ b/example/Vulkan/main.cpp @@ -11,6 +11,7 @@ #include"VKPipeline.h" #include"VKCommandBuffer.h" #include"VKFence.h" +#include"VKSemaphore.h" #include #include @@ -122,6 +123,7 @@ int main(int,char **) return -3; vulkan::Fence *fence=device->CreateFence(); + vulkan::Semaphore *sem=device->CreateSem(); vulkan::VertexInput vi; vulkan::PipelineCreater pc(device); @@ -144,6 +146,7 @@ int main(int,char **) delete pipeline; } + delete sem; delete fence; delete rp;