From bb158d6105dd4fcde8aa6b07e6cca8c94b812172 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sun, 20 Sep 2020 03:15:50 +0800 Subject: [PATCH] rewrite PipelineData::InitVertexInputState --- CMSceneGraph | 2 +- inc/hgl/graph/vulkan/VKMaterial.h | 20 ++++++++++++------- .../graph/vulkan/VKVertexAttributeBinding.h | 4 +++- src/RenderDevice/Vulkan/VKMaterial.cpp | 5 ----- src/RenderDevice/Vulkan/VKPipeline.cpp | 8 +++++--- .../Vulkan/VKVertexAttributeBinding.cpp | 9 --------- 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/CMSceneGraph b/CMSceneGraph index fe9dc360..cf0b4cfb 160000 --- a/CMSceneGraph +++ b/CMSceneGraph @@ -1 +1 @@ -Subproject commit fe9dc360c87179f8a8293f7f78127f366b7f191b +Subproject commit cf0b4cfb35fe5385fd8a887a0aabbdf115abfe74 diff --git a/inc/hgl/graph/vulkan/VKMaterial.h b/inc/hgl/graph/vulkan/VKMaterial.h index 85737767..cafadc69 100644 --- a/inc/hgl/graph/vulkan/VKMaterial.h +++ b/inc/hgl/graph/vulkan/VKMaterial.h @@ -5,6 +5,7 @@ #include #include #include +#include VK_NAMESPACE_BEGIN class DescriptorSetLayoutCreater; @@ -48,16 +49,21 @@ public: GET_BO_BINDING(InputAttachment, INPUT_ATTACHMENT) #undef GET_BO_BINDING - const uint32_t GetStageCount ()const{return shader_stage_list->GetCount();} - const VkPipelineShaderStageCreateInfo * GetStages ()const{return shader_stage_list->GetData();} + const uint32_t GetStageCount ()const{return shader_stage_list->GetCount();} + const VkPipelineShaderStageCreateInfo * GetStages ()const{return shader_stage_list->GetData();} - const VkPipelineLayout GetPipelineLayout ()const; - DescriptorSets * CreateDescriptorSets()const; + const VkPipelineLayout GetPipelineLayout ()const; + DescriptorSets * CreateDescriptorSets ()const; + + const VertexAttributeBinding * GetVAB ()const{return vab;} + const uint32_t GetVertexAttrCount ()const{return vab->GetVertexAttrCount();} + const VkVertexInputBindingDescription * GetVertexBindingList ()const{return vab->GetVertexBindingList();} + const VkVertexInputAttributeDescription * GetVertexAttributeList ()const{return vab->GetVertexAttributeList();} - void Write(VkPipelineVertexInputStateCreateInfo &vis)const; +public: - Renderable *CreateRenderable(const uint32_t draw_count=0); - MaterialInstance *CreateInstance(); + Renderable * CreateRenderable (const uint32_t draw_count=0); + MaterialInstance * CreateInstance (); };//class Material VK_NAMESPACE_END #endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE diff --git a/inc/hgl/graph/vulkan/VKVertexAttributeBinding.h b/inc/hgl/graph/vulkan/VKVertexAttributeBinding.h index b38e42b6..5c494d50 100644 --- a/inc/hgl/graph/vulkan/VKVertexAttributeBinding.h +++ b/inc/hgl/graph/vulkan/VKVertexAttributeBinding.h @@ -29,7 +29,9 @@ public: bool SetFormat (const uint binding,const VkFormat & format); bool SetOffset (const uint binding,const uint32_t offset); - void Write(VkPipelineVertexInputStateCreateInfo &vis)const; + const uint32_t GetVertexAttrCount ()const{return attr_count;} + const VkVertexInputBindingDescription * GetVertexBindingList ()const{return binding_list;} + const VkVertexInputAttributeDescription * GetVertexAttributeList ()const{return attribute_list;} };//class VertexAttributeBinding VK_NAMESPACE_END #endif//HGL_GRAPH_VULKAN_VERTEX_ATTRIBUTE_BINDING_INCLUDE diff --git a/src/RenderDevice/Vulkan/VKMaterial.cpp b/src/RenderDevice/Vulkan/VKMaterial.cpp index 1172b837..c1b06279 100644 --- a/src/RenderDevice/Vulkan/VKMaterial.cpp +++ b/src/RenderDevice/Vulkan/VKMaterial.cpp @@ -155,11 +155,6 @@ DescriptorSets *Material::CreateDescriptorSets()const return dsl_creater->Create(); } -void Material::Write(VkPipelineVertexInputStateCreateInfo &vis)const -{ - return vab->Write(vis); -} - Renderable *Material::CreateRenderable(const uint32_t draw_count) { return(new Renderable(vertex_sm,draw_count)); diff --git a/src/RenderDevice/Vulkan/VKPipeline.cpp b/src/RenderDevice/Vulkan/VKPipeline.cpp index b20f6a7f..bbdbcf89 100644 --- a/src/RenderDevice/Vulkan/VKPipeline.cpp +++ b/src/RenderDevice/Vulkan/VKPipeline.cpp @@ -15,9 +15,11 @@ Pipeline *CreatePipeline(VkDevice device,VkPipelineCache pipeline_cache,Pipeline { VkPipeline graphicsPipeline; - data->InitVertexInputState(material->GetStageCount(),material->GetStages()); - - material->Write(data->vis_create_info); + data->InitVertexInputState( material->GetStageCount(), + material->GetStages(), + material->GetVertexAttrCount(), + material->GetVertexBindingList(), + material->GetVertexAttributeList()); data->InitViewportState(rt->GetExtent()); diff --git a/src/RenderDevice/Vulkan/VKVertexAttributeBinding.cpp b/src/RenderDevice/Vulkan/VKVertexAttributeBinding.cpp index e76e4c6d..6caf4cbc 100644 --- a/src/RenderDevice/Vulkan/VKVertexAttributeBinding.cpp +++ b/src/RenderDevice/Vulkan/VKVertexAttributeBinding.cpp @@ -58,13 +58,4 @@ bool VertexAttributeBinding::SetOffset(const uint index,const uint32_t offset) return(true); } - -void VertexAttributeBinding::Write(VkPipelineVertexInputStateCreateInfo &vis_create_info) const -{ - vis_create_info.vertexBindingDescriptionCount = attr_count; - vis_create_info.pVertexBindingDescriptions = binding_list; - - vis_create_info.vertexAttributeDescriptionCount = attr_count; - vis_create_info.pVertexAttributeDescriptions = attribute_list; -} VK_NAMESPACE_END