command buffer增加bind pipeline layout
This commit is contained in:
parent
ca2a20aabd
commit
133019cf49
@ -15,8 +15,7 @@ SET(VULKAN_TEST_SOURCE_FILES main.cpp
|
|||||||
VKDeviceCreater.cpp
|
VKDeviceCreater.cpp
|
||||||
VKDevice.cpp
|
VKDevice.cpp
|
||||||
VKBuffer.cpp
|
VKBuffer.cpp
|
||||||
VKDescriptorSet.cpp
|
VKDescriptorSets.cpp
|
||||||
VKDescriptorSetLayout.cpp
|
|
||||||
VKPipelineLayout.cpp
|
VKPipelineLayout.cpp
|
||||||
VKRenderPass.cpp
|
VKRenderPass.cpp
|
||||||
VKShader.cpp
|
VKShader.cpp
|
||||||
@ -34,8 +33,7 @@ SET(VULKAN_TEST_HEADER_FILES VK.h
|
|||||||
VKDeviceAttribute.h
|
VKDeviceAttribute.h
|
||||||
VKDevice.h
|
VKDevice.h
|
||||||
VKBuffer.h
|
VKBuffer.h
|
||||||
VKDescriptorSetLayout.h
|
VKDescriptorSets.h
|
||||||
VKDescriptorSet.h
|
|
||||||
VKPipelineLayout.h
|
VKPipelineLayout.h
|
||||||
VKRenderPass.h
|
VKRenderPass.h
|
||||||
VKShader.h
|
VKShader.h
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
#include"VKRenderPass.h"
|
#include"VKRenderPass.h"
|
||||||
#include"VKFramebuffer.h"
|
#include"VKFramebuffer.h"
|
||||||
#include"VKPipeline.h"
|
#include"VKPipeline.h"
|
||||||
|
#include"VKPipelineLayout.h"
|
||||||
#include"VKVertexInput.h"
|
#include"VKVertexInput.h"
|
||||||
|
#include"VKDescriptorSets.h"
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
CommandBuffer::CommandBuffer(VkDevice dev,VkCommandPool cp,VkCommandBuffer cb)
|
CommandBuffer::CommandBuffer(VkDevice dev,VkCommandPool cp,VkCommandBuffer cb)
|
||||||
@ -25,7 +27,7 @@ CommandBuffer::~CommandBuffer()
|
|||||||
vkFreeCommandBuffers(device, pool, 1, cmd_bufs);
|
vkFreeCommandBuffers(device, pool, 1, cmd_bufs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommandBuffer::Bind(RenderPass *rp,Framebuffer *fb,Pipeline *p)
|
bool CommandBuffer::Begin(RenderPass *rp,Framebuffer *fb)
|
||||||
{
|
{
|
||||||
VkRenderPassBeginInfo rp_begin;
|
VkRenderPassBeginInfo rp_begin;
|
||||||
|
|
||||||
@ -38,12 +40,27 @@ bool CommandBuffer::Bind(RenderPass *rp,Framebuffer *fb,Pipeline *p)
|
|||||||
rp_begin.pClearValues = clear_values;
|
rp_begin.pClearValues = clear_values;
|
||||||
|
|
||||||
vkCmdBeginRenderPass(cmd_buf, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdBeginRenderPass(cmd_buf, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
vkCmdBindPipeline(cmd_buf, VK_PIPELINE_BIND_POINT_GRAPHICS, *p);
|
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommandBuffer::Bind(VertexInput *vi)
|
bool CommandBuffer::Bind(Pipeline *p)
|
||||||
|
{
|
||||||
|
if(!p)return(false);
|
||||||
|
|
||||||
|
vkCmdBindPipeline(cmd_buf, VK_PIPELINE_BIND_POINT_GRAPHICS, *p);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CommandBuffer::Bind(PipelineLayout *pl)
|
||||||
|
{
|
||||||
|
if(!pl)return(false);
|
||||||
|
|
||||||
|
vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_GRAPHICS, *pl, 0, pl->GetDescriptorSetCount(),pl->GetDescriptorSets(), 0, nullptr);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CommandBuffer::Bind(VertexInput *vi,const VkDeviceSize offset)
|
||||||
{
|
{
|
||||||
if(!vi)
|
if(!vi)
|
||||||
return(false);
|
return(false);
|
||||||
@ -53,10 +70,24 @@ bool CommandBuffer::Bind(VertexInput *vi)
|
|||||||
if(buf_list.GetCount()<=0)
|
if(buf_list.GetCount()<=0)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
constexpr VkDeviceSize zero_offsets[1]={0};
|
VkDeviceSize zero_offsets[1]={offset};
|
||||||
|
|
||||||
vkCmdBindVertexBuffers(cmd_buf,0,buf_list.GetCount(),buf_list.GetData(),zero_offsets);
|
vkCmdBindVertexBuffers(cmd_buf,0,buf_list.GetCount(),buf_list.GetData(),zero_offsets);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommandBuffer::Draw(const uint32_t vertex_count)
|
||||||
|
{
|
||||||
|
vkCmdDraw(cmd_buf,vertex_count,1,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandBuffer::Draw(const uint32_t vertex_count,const uint32_t instance_count,const uint32_t first_vertex,const uint32_t first_instance)
|
||||||
|
{
|
||||||
|
vkCmdDraw(cmd_buf,vertex_count,instance_count,first_vertex,first_instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandBuffer::End()
|
||||||
|
{
|
||||||
|
vkCmdEndRenderPass(cmd_buf);
|
||||||
|
}
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -6,6 +6,7 @@ VK_NAMESPACE_BEGIN
|
|||||||
class RenderPass;
|
class RenderPass;
|
||||||
class Framebuffer;
|
class Framebuffer;
|
||||||
class Pipeline;
|
class Pipeline;
|
||||||
|
class PipelineLayout;
|
||||||
class VertexInput;
|
class VertexInput;
|
||||||
|
|
||||||
class CommandBuffer
|
class CommandBuffer
|
||||||
@ -23,9 +24,27 @@ public:
|
|||||||
~CommandBuffer();
|
~CommandBuffer();
|
||||||
|
|
||||||
void SetRenderArea(const VkRect2D &ra){render_area=ra;}
|
void SetRenderArea(const VkRect2D &ra){render_area=ra;}
|
||||||
|
void SetClearColor(float r,float g,float b,float a=1.0f)
|
||||||
|
{
|
||||||
|
clear_values[0].color.float32[0]=r;
|
||||||
|
clear_values[0].color.float32[1]=g;
|
||||||
|
clear_values[0].color.float32[2]=b;
|
||||||
|
clear_values[0].color.float32[3]=a;
|
||||||
|
}
|
||||||
|
|
||||||
bool Bind(RenderPass *rp,Framebuffer *fb,Pipeline *p);
|
void SetClearDepthStencil(float d=1.0f,float s=0)
|
||||||
bool Bind(VertexInput *vi);
|
{
|
||||||
|
clear_values[1].depthStencil.depth=d;
|
||||||
|
clear_values[1].depthStencil.stencil=s;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Begin(RenderPass *rp,Framebuffer *fb);
|
||||||
|
bool Bind(Pipeline *p);
|
||||||
|
bool Bind(PipelineLayout *pl);
|
||||||
|
bool Bind(VertexInput *vi,const VkDeviceSize offset=0);
|
||||||
|
void Draw(const uint32_t vertex_count);
|
||||||
|
void Draw(const uint32_t vertex_count,const uint32_t instance_count,const uint32_t first_vertex=0,const uint32_t first_instance=0);
|
||||||
|
void End();
|
||||||
};//class CommandBuffer
|
};//class CommandBuffer
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
#include"VKDescriptorSet.h"
|
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
|
||||||
VK_NAMESPACE_END
|
|
@ -1,8 +0,0 @@
|
|||||||
#ifndef HGL_GRAPH_VULKAN_DESCRIPTOR_SET_INCLUDE
|
|
||||||
#define HGL_GRAPH_VULKAN_DESCRIPTOR_SET_INCLUDE
|
|
||||||
|
|
||||||
#include"VK.h"
|
|
||||||
VK_NAMESPACE_BEGIN
|
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
|
||||||
#endif//HGL_GRAPH_VULKAN_DESCRIPTOR_SET_INCLUDE
|
|
@ -1,48 +0,0 @@
|
|||||||
#include"VKDescriptorSetLayout.h"
|
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
|
||||||
DescriptorSetLayout::~DescriptorSetLayout()
|
|
||||||
{
|
|
||||||
const int count=desc_set_layout_list.GetCount();
|
|
||||||
|
|
||||||
if(count>0)
|
|
||||||
{
|
|
||||||
VkDescriptorSetLayout *dsl=desc_set_layout_list.GetData();
|
|
||||||
|
|
||||||
for(int i=0;i<count;i++)
|
|
||||||
{
|
|
||||||
vkDestroyDescriptorSetLayout(device,*dsl,nullptr);
|
|
||||||
++dsl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DescriptorSetLayoutCreater::Bind(const int binding,VkDescriptorType desc_type,VkShaderStageFlagBits stageFlags)
|
|
||||||
{
|
|
||||||
VkDescriptorSetLayoutBinding layout_binding = {};
|
|
||||||
layout_binding.binding = binding;
|
|
||||||
layout_binding.descriptorType = desc_type;
|
|
||||||
layout_binding.descriptorCount = 1;
|
|
||||||
layout_binding.stageFlags = stageFlags;
|
|
||||||
layout_binding.pImmutableSamplers = nullptr;
|
|
||||||
|
|
||||||
layout_binding_list.Add(layout_binding);
|
|
||||||
}
|
|
||||||
|
|
||||||
DescriptorSetLayout *DescriptorSetLayoutCreater::Create()
|
|
||||||
{
|
|
||||||
VkDescriptorSetLayoutCreateInfo descriptor_layout = {};
|
|
||||||
descriptor_layout.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
|
||||||
descriptor_layout.pNext = nullptr;
|
|
||||||
descriptor_layout.bindingCount = layout_binding_list.GetCount();
|
|
||||||
descriptor_layout.pBindings = layout_binding_list.GetData();
|
|
||||||
|
|
||||||
List<VkDescriptorSetLayout> dsl_list;
|
|
||||||
|
|
||||||
dsl_list.SetCount(layout_binding_list.GetCount());
|
|
||||||
if(vkCreateDescriptorSetLayout(device,&descriptor_layout, nullptr, dsl_list.GetData())!=VK_SUCCESS)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
return(new DescriptorSetLayout(device,dsl_list));
|
|
||||||
}
|
|
||||||
VK_NAMESPACE_END
|
|
84
example/Vulkan/VKDescriptorSets.cpp
Normal file
84
example/Vulkan/VKDescriptorSets.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#include"VKDescriptorSets.h"
|
||||||
|
#include"VKDevice.h"
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
DescriptorSets::~DescriptorSets()
|
||||||
|
{
|
||||||
|
// 这里注释掉是因为从来不见那里的范便有FREE过,但又有vkFreeDescriptorSets这个函数。如发现此注释,请使用工具查是否有资源泄露
|
||||||
|
{
|
||||||
|
//const int count=desc_sets.GetCount();
|
||||||
|
|
||||||
|
//if(count>0)
|
||||||
|
// vkFreeDescriptorSets(device->GetDevice(),device->GetDescriptorPool(),count,desc_sets.GetData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DescriptorSetLayout::~DescriptorSetLayout()
|
||||||
|
{
|
||||||
|
const int count=desc_set_layout_list.GetCount();
|
||||||
|
|
||||||
|
if(count>0)
|
||||||
|
{
|
||||||
|
VkDescriptorSetLayout *dsl=desc_set_layout_list.GetData();
|
||||||
|
|
||||||
|
for(int i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
vkDestroyDescriptorSetLayout(device->GetDevice(),*dsl,nullptr);
|
||||||
|
++dsl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DescriptorSets *DescriptorSetLayout::CreateSets()const
|
||||||
|
{
|
||||||
|
const int count=desc_set_layout_list.GetCount();
|
||||||
|
|
||||||
|
if(count<=0)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
VkDescriptorSetAllocateInfo alloc_info[1];
|
||||||
|
alloc_info[0].sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
|
alloc_info[0].pNext = nullptr;
|
||||||
|
alloc_info[0].descriptorPool = device->GetDescriptorPool();
|
||||||
|
alloc_info[0].descriptorSetCount = count;
|
||||||
|
alloc_info[0].pSetLayouts = desc_set_layout_list.GetData();
|
||||||
|
|
||||||
|
List<VkDescriptorSet> desc_set;
|
||||||
|
|
||||||
|
desc_set.SetCount(count);
|
||||||
|
|
||||||
|
if(vkAllocateDescriptorSets(device->GetDevice(), alloc_info, desc_set.GetData())!=VK_SUCCESS)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
return(new DescriptorSets(device,desc_set));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DescriptorSetLayoutCreater::Bind(const int binding,VkDescriptorType desc_type,VkShaderStageFlagBits stageFlags)
|
||||||
|
{
|
||||||
|
VkDescriptorSetLayoutBinding layout_binding = {};
|
||||||
|
layout_binding.binding = binding;
|
||||||
|
layout_binding.descriptorType = desc_type;
|
||||||
|
layout_binding.descriptorCount = 1;
|
||||||
|
layout_binding.stageFlags = stageFlags;
|
||||||
|
layout_binding.pImmutableSamplers = nullptr;
|
||||||
|
|
||||||
|
layout_binding_list.Add(layout_binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
DescriptorSetLayout *DescriptorSetLayoutCreater::Create()
|
||||||
|
{
|
||||||
|
VkDescriptorSetLayoutCreateInfo descriptor_layout = {};
|
||||||
|
descriptor_layout.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||||
|
descriptor_layout.pNext = nullptr;
|
||||||
|
descriptor_layout.bindingCount = layout_binding_list.GetCount();
|
||||||
|
descriptor_layout.pBindings = layout_binding_list.GetData();
|
||||||
|
|
||||||
|
List<VkDescriptorSetLayout> dsl_list;
|
||||||
|
|
||||||
|
dsl_list.SetCount(layout_binding_list.GetCount());
|
||||||
|
if(vkCreateDescriptorSetLayout(device->GetDevice(),&descriptor_layout, nullptr, dsl_list.GetData())!=VK_SUCCESS)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
return(new DescriptorSetLayout(device,dsl_list));
|
||||||
|
}
|
||||||
|
VK_NAMESPACE_END
|
@ -1,16 +1,31 @@
|
|||||||
#ifndef HGL_GRAPH_VULKAN_DESCRIPTOR_SET_LAYOUT_INCLUDE
|
#ifndef HGL_GRAPH_VULKAN_DESCRIPTOR_SETS_LAYOUT_INCLUDE
|
||||||
#define HGL_GRAPH_VULKAN_DESCRIPTOR_SET_LAYOUT_INCLUDE
|
#define HGL_GRAPH_VULKAN_DESCRIPTOR_SETS_LAYOUT_INCLUDE
|
||||||
|
|
||||||
#include"VK.h"
|
#include"VK.h"
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
class Device;
|
||||||
|
class DescriptorSets
|
||||||
|
{
|
||||||
|
Device *device;
|
||||||
|
List<VkDescriptorSet> desc_sets;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
DescriptorSets(Device *dev,List<VkDescriptorSet> &ds):device(dev),desc_sets(ds){}
|
||||||
|
~DescriptorSets();
|
||||||
|
|
||||||
|
const uint32_t GetCount()const{return desc_sets.GetCount();}
|
||||||
|
const VkDescriptorSet * GetData()const{return desc_sets.GetData();}
|
||||||
|
};//class DescriptorSets
|
||||||
|
|
||||||
class DescriptorSetLayout
|
class DescriptorSetLayout
|
||||||
{
|
{
|
||||||
VkDevice device;
|
Device *device;
|
||||||
List<VkDescriptorSetLayout> desc_set_layout_list;
|
List<VkDescriptorSetLayout> desc_set_layout_list;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DescriptorSetLayout(VkDevice dev,const List<VkDescriptorSetLayout> &dsl_list)
|
DescriptorSetLayout(Device *dev,const List<VkDescriptorSetLayout> &dsl_list)
|
||||||
{
|
{
|
||||||
device=dev;
|
device=dev;
|
||||||
desc_set_layout_list=dsl_list;
|
desc_set_layout_list=dsl_list;
|
||||||
@ -20,6 +35,8 @@ public:
|
|||||||
|
|
||||||
const uint32_t GetCount()const{return desc_set_layout_list.GetCount();}
|
const uint32_t GetCount()const{return desc_set_layout_list.GetCount();}
|
||||||
const VkDescriptorSetLayout * GetData ()const{return desc_set_layout_list.GetData();}
|
const VkDescriptorSetLayout * GetData ()const{return desc_set_layout_list.GetData();}
|
||||||
|
|
||||||
|
DescriptorSets *CreateSets()const;
|
||||||
};//class DescriptorSetLayout
|
};//class DescriptorSetLayout
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,14 +44,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
class DescriptorSetLayoutCreater
|
class DescriptorSetLayoutCreater
|
||||||
{
|
{
|
||||||
VkDevice device;
|
Device *device;
|
||||||
VkDescriptorSet desc_set;
|
VkDescriptorSet desc_set;
|
||||||
|
|
||||||
List<VkDescriptorSetLayoutBinding> layout_binding_list;
|
List<VkDescriptorSetLayoutBinding> layout_binding_list;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DescriptorSetLayoutCreater(VkDevice dev):device(dev){}
|
DescriptorSetLayoutCreater(Device *dev):device(dev){}
|
||||||
~DescriptorSetLayoutCreater()=default;
|
~DescriptorSetLayoutCreater()=default;
|
||||||
|
|
||||||
void Bind(const int binding,VkDescriptorType,VkShaderStageFlagBits);
|
void Bind(const int binding,VkDescriptorType,VkShaderStageFlagBits);
|
||||||
@ -62,4 +79,4 @@ public:
|
|||||||
DescriptorSetLayout *Create();
|
DescriptorSetLayout *Create();
|
||||||
};//class DescriptorSet
|
};//class DescriptorSet
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_DESCRIPTOR_SET_LAYOUT_INCLUDE
|
#endif//HGL_GRAPH_VULKAN_DESCRIPTOR_SETS_LAYOUT_INCLUDE
|
@ -35,6 +35,8 @@ public:
|
|||||||
const PhysicalDevice *GetPhysicalDevice ()const {return attr->physical_device;}
|
const PhysicalDevice *GetPhysicalDevice ()const {return attr->physical_device;}
|
||||||
const VkExtent2D & GetExtent ()const {return attr->swapchain_extent;}
|
const VkExtent2D & GetExtent ()const {return attr->swapchain_extent;}
|
||||||
|
|
||||||
|
VkDescriptorPool GetDescriptorPool () {return attr->desc_pool;}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Buffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize size,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE);
|
Buffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize size,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE);
|
||||||
|
@ -50,6 +50,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
PipelineCreater(Device *dev);
|
PipelineCreater(Device *dev);
|
||||||
~PipelineCreater()=default;
|
~PipelineCreater()=default;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include"VKPipelineLayout.h"
|
#include"VKPipelineLayout.h"
|
||||||
#include"VKDescriptorSetLayout.h"
|
#include"VKDescriptorSets.h"
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
PipelineLayout::~PipelineLayout()
|
PipelineLayout::~PipelineLayout()
|
||||||
@ -14,6 +14,11 @@ PipelineLayout *CreatePipelineLayout(VkDevice dev,const DescriptorSetLayout *dsl
|
|||||||
|
|
||||||
if(dsl->GetCount()<=0)return(nullptr);
|
if(dsl->GetCount()<=0)return(nullptr);
|
||||||
|
|
||||||
|
DescriptorSets *desc_sets=dsl->CreateSets();
|
||||||
|
|
||||||
|
if(!desc_sets)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo = {};
|
VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo = {};
|
||||||
pPipelineLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
pPipelineLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
||||||
pPipelineLayoutCreateInfo.pNext = nullptr;
|
pPipelineLayoutCreateInfo.pNext = nullptr;
|
||||||
@ -25,8 +30,11 @@ PipelineLayout *CreatePipelineLayout(VkDevice dev,const DescriptorSetLayout *dsl
|
|||||||
VkPipelineLayout pipeline_layout;
|
VkPipelineLayout pipeline_layout;
|
||||||
|
|
||||||
if(vkCreatePipelineLayout(dev, &pPipelineLayoutCreateInfo, nullptr, &pipeline_layout)!=VK_SUCCESS)
|
if(vkCreatePipelineLayout(dev, &pPipelineLayoutCreateInfo, nullptr, &pipeline_layout)!=VK_SUCCESS)
|
||||||
|
{
|
||||||
|
delete desc_sets;
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
return(new PipelineLayout(dev,pipeline_layout));
|
return(new PipelineLayout(dev,pipeline_layout,desc_sets));
|
||||||
}
|
}
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -2,24 +2,29 @@
|
|||||||
#define HGL_GRAPH_VULKAN_PIPELINE_LAYOUT_INCLUDE
|
#define HGL_GRAPH_VULKAN_PIPELINE_LAYOUT_INCLUDE
|
||||||
|
|
||||||
#include"VK.h"
|
#include"VK.h"
|
||||||
|
#include"VKDescriptorSets.h"
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
class DescriptorSetLayout;
|
|
||||||
class PipelineLayout
|
class PipelineLayout
|
||||||
{
|
{
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
VkPipelineLayout layout;
|
VkPipelineLayout layout;
|
||||||
|
|
||||||
|
const DescriptorSets *desc_sets;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend PipelineLayout *CreatePipelineLayout(VkDevice dev,const DescriptorSetLayout *dsl);
|
friend PipelineLayout *CreatePipelineLayout(VkDevice dev,const DescriptorSetLayout *dsl);
|
||||||
|
|
||||||
PipelineLayout(VkDevice dev,VkPipelineLayout pl){device=dev;layout=pl;}
|
PipelineLayout(VkDevice dev,VkPipelineLayout pl,const DescriptorSets *ds){device=dev;layout=pl;desc_sets=ds;}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~PipelineLayout();
|
~PipelineLayout();
|
||||||
|
|
||||||
operator VkPipelineLayout (){return layout;}
|
operator VkPipelineLayout (){return layout;}
|
||||||
|
|
||||||
|
const uint32_t GetDescriptorSetCount ()const{return desc_sets->GetCount();}
|
||||||
|
const VkDescriptorSet * GetDescriptorSets ()const{return desc_sets->GetData();}
|
||||||
};//class PipelineLayout
|
};//class PipelineLayout
|
||||||
|
|
||||||
PipelineLayout *CreatePipelineLayout(VkDevice dev,const DescriptorSetLayout *dsl);
|
PipelineLayout *CreatePipelineLayout(VkDevice dev,const DescriptorSetLayout *dsl);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user