新增VKFence创建

This commit is contained in:
HuYingzhuo 2019-04-19 19:58:01 +08:00
parent 2e41b03f05
commit 389efebf2e
5 changed files with 56 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include"VKCommandBuffer.h"
//#include"VKDescriptorSet.h"
#include"VKRenderPass.h"
#include"VKFence.h"
VK_NAMESPACE_BEGIN
@ -182,4 +183,19 @@ RenderPass *Device::CreateRenderPass()
return(new RenderPass(attr->device,render_pass));
}
Fence *Device::CreateFence()
{
VkFenceCreateInfo fenceInfo;
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fenceInfo.pNext = nullptr;
fenceInfo.flags = 0;
VkFence drawFence;
if(vkCreateFence(attr->device, &fenceInfo, nullptr, &drawFence)!=VK_SUCCESS)
return(nullptr);
return(new Fence(attr->device,drawFence));
}
VK_NAMESPACE_END

View File

@ -12,6 +12,7 @@ class Buffer;
class VertexBuffer;
class CommandBuffer;
class RenderPass;
class Fence;
class Device
{
@ -60,6 +61,8 @@ public:
// DescriptorSet * CreateDescSet(int);
RenderPass *CreateRenderPass();
Fence *CreateFence();
};//class Device
VK_NAMESPACE_END
#endif//HGL_GRAPH_RENDER_SURFACE_INCLUDE

View File

@ -0,0 +1,7 @@
#include"VKFence.h"
VK_NAMESPACE_BEGIN
Fence::~Fence()
{
vkDestroyFence(device,fence,nullptr);
}
VK_NAMESPACE_END

26
example/Vulkan/VKFence.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef HGL_VULKAN_GRAPH_FENCE_INCLUDE
#define HGL_VULKAN_GRAPH_FENCE_INCLUDE
#include"VK.h"
VK_NAMESPACE_BEGIN
class Fence
{
VkDevice device;
VkFence fence;
private:
friend class Device;
Fence(VkDevice d,VkFence f)
{
device=d;
fence=f;
}
public:
~Fence();
};//class Fence
VK_NAMESPACE_END
#endif//HGL_VULKAN_GRAPH_FENCE_INCLUDE

View File

@ -10,6 +10,7 @@
#include"VKPipelineLayout.h"
#include"VKPipeline.h"
#include"VKCommandBuffer.h"
#include"VKFence.h"
#include<io.h>
#include<fcntl.h>
@ -120,6 +121,8 @@ int main(int,char **)
if(!shader)
return -3;
vulkan::Fence *fence=device->CreateFence();
vulkan::VertexInput vi;
vulkan::PipelineCreater pc(device);
vulkan::RenderPass *rp=device->CreateRenderPass();
@ -141,6 +144,7 @@ int main(int,char **)
delete pipeline;
}
delete fence;
delete rp;
delete ubo;