moved VertexAttributeBinding to CMSceneGraph

This commit is contained in:
2021-11-29 17:31:15 +08:00
parent 7d05d67cd2
commit 424b4b8a6f
6 changed files with 8 additions and 115 deletions

View File

@@ -7,6 +7,8 @@
#include<hgl/graph/VKShaderModuleMap.h> #include<hgl/graph/VKShaderModuleMap.h>
#include<hgl/graph/VKVertexAttributeBinding.h> #include<hgl/graph/VKVertexAttributeBinding.h>
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN
using ShaderStageCreateInfoList=List<VkPipelineShaderStageCreateInfo>;
struct MaterialData struct MaterialData
{ {
UTF8String name; UTF8String name;
@@ -17,7 +19,7 @@ struct MaterialData
VertexShaderModule *vertex_sm; VertexShaderModule *vertex_sm;
VertexAttributeBinding *vab; VertexAttributeBinding *vab;
List<VkPipelineShaderStageCreateInfo> shader_stage_list; ShaderStageCreateInfoList shader_stage_list;
PipelineLayoutData *pipeline_layout_data; PipelineLayoutData *pipeline_layout_data;
@@ -56,8 +58,7 @@ public:
const VertexShaderModule * GetVertexShaderModule ()const{return data->vertex_sm;} const VertexShaderModule * GetVertexShaderModule ()const{return data->vertex_sm;}
const uint32_t GetStageCount ()const{return data->shader_stage_list.GetCount();} const ShaderStageCreateInfoList & GetStageList ()const{return data->shader_stage_list;}
const VkPipelineShaderStageCreateInfo * GetStages ()const{return data->shader_stage_list.GetData();}
const MaterialDescriptorSets * GetDescriptorSets ()const{return data->mds;} const MaterialDescriptorSets * GetDescriptorSets ()const{return data->mds;}
const VkPipelineLayout GetPipelineLayout ()const; const VkPipelineLayout GetPipelineLayout ()const;

View File

@@ -1,39 +0,0 @@
#ifndef HGL_GRAPH_VULKAN_VERTEX_ATTRIBUTE_BINDING_INCLUDE
#define HGL_GRAPH_VULKAN_VERTEX_ATTRIBUTE_BINDING_INCLUDE
#include<hgl/graph/VK.h>
#include<hgl/type/String.h>
VK_NAMESPACE_BEGIN
/**
* 顶点输入状态实例<br>
* 本对象用于传递给Material,用于已经确定好顶点格式的情况下,依然可修改部分设定(如instance)。
*/
class VertexAttributeBinding
{
uint32_t attr_count;
VkVertexInputBindingDescription *binding_list;
VkVertexInputAttributeDescription *attribute_list;
private:
friend class VertexShaderModule;
VertexAttributeBinding(const uint32_t,const VkVertexInputBindingDescription *,const VkVertexInputAttributeDescription *);
public:
~VertexAttributeBinding();
bool SetInstance(const uint binding,bool instance);
bool SetStride (const uint binding,const uint32_t & stride);
bool SetFormat (const uint binding,const VkFormat & format);
bool SetOffset (const uint binding,const uint32_t offset);
const uint32_t GetVertexAttrCount ()const{return attr_count;}
const VkVertexInputBindingDescription * GetVertexBindingList ()const{return binding_list;}
const VkVertexInputAttributeDescription * GetVertexAttributeList ()const{return attribute_list;}
};//class VertexAttributeBinding
using VAB=VertexAttributeBinding;
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_VERTEX_ATTRIBUTE_BINDING_INCLUDE

View File

@@ -104,7 +104,6 @@ SET(VK_DEBUG_SOURCE ${SG_INCLUDE_PATH}/VKDebugOut.h
SET(VK_MEMORY_SOURCE ${SG_INCLUDE_PATH}/VKMemory.h SET(VK_MEMORY_SOURCE ${SG_INCLUDE_PATH}/VKMemory.h
${SG_INCLUDE_PATH}/VKMemoryAllocator.h ${SG_INCLUDE_PATH}/VKMemoryAllocator.h
${SG_INCLUDE_PATH}/VKBuffer.h ${SG_INCLUDE_PATH}/VKBuffer.h
${SG_INCLUDE_PATH}/VKVertexAttribBuffer.h
${SG_INCLUDE_PATH}/VKIndexBuffer.h ${SG_INCLUDE_PATH}/VKIndexBuffer.h
${SG_INCLUDE_PATH}/VKArrayBuffer.h ${SG_INCLUDE_PATH}/VKArrayBuffer.h
Vulkan/VKMemory.cpp Vulkan/VKMemory.cpp
@@ -204,10 +203,8 @@ SET(VK_CMD_BUFFER_SOURCE ${SG_INCLUDE_PATH}/VKCommandBuffer.h
SOURCE_GROUP("Vulkan\\Command Buffer" FILES ${VK_CMD_BUFFER_SOURCE}) SOURCE_GROUP("Vulkan\\Command Buffer" FILES ${VK_CMD_BUFFER_SOURCE})
SET(VK_RENDERABLE_SOURCE ${SG_INCLUDE_PATH}/VKVertexAttributeBinding.h SET(VK_RENDERABLE_SOURCE ${SG_INCLUDE_PATH}/VKRenderable.h
${SG_INCLUDE_PATH}/VKRenderable.h
${SG_INCLUDE_PATH}/VKRenderableInstance.h ${SG_INCLUDE_PATH}/VKRenderableInstance.h
Vulkan/VKVertexAttributeBinding.cpp
Vulkan/VKRenderable.cpp Vulkan/VKRenderable.cpp
Vulkan/VKRenderableInstance.cpp Vulkan/VKRenderableInstance.cpp
Vulkan/VKTileData.cpp Vulkan/VKTileData.cpp

View File

@@ -27,13 +27,8 @@ Pipeline *RenderPass::CreatePipeline(const Material *material,PipelineData *data
{ {
VkPipeline graphicsPipeline; VkPipeline graphicsPipeline;
const VAB *vab=material->GetVAB(); data->InitShaderStage(material->GetStageList());
data->InitVertexInputState(material->GetVAB());
data->InitVertexInputState( material->GetStageCount(),
material->GetStages(),
vab->GetVertexAttrCount(),
vab->GetVertexBindingList(),
vab->GetVertexAttributeList());
data->SetColorAttachments(color_formats.GetCount()); data->SetColorAttachments(color_formats.GetCount());

View File

@@ -1,61 +0,0 @@
#include<hgl/graph/VKVertexAttributeBinding.h>
#include<hgl/graph/VKShaderModule.h>
VK_NAMESPACE_BEGIN
VertexAttributeBinding::VertexAttributeBinding(const uint32_t count,const VkVertexInputBindingDescription *bind_list,const VkVertexInputAttributeDescription *attr_list)
{
attr_count=count;
if(attr_count<=0)
{
binding_list=nullptr;
attribute_list=nullptr;
return;
}
binding_list=hgl_copy_new(attr_count,bind_list);
attribute_list=hgl_copy_new(attr_count,attr_list);
}
VertexAttributeBinding::~VertexAttributeBinding()
{
delete[] attribute_list;
delete[] binding_list;
}
bool VertexAttributeBinding::SetInstance(const uint index,bool instance)
{
if(index>=attr_count)return(false);
binding_list[index].inputRate=instance?VK_VERTEX_INPUT_RATE_INSTANCE:VK_VERTEX_INPUT_RATE_VERTEX;
return(true);
}
bool VertexAttributeBinding::SetStride(const uint index,const uint32_t &stride)
{
if(index>=attr_count)return(false);
binding_list[index].stride=stride;
return(true);
}
bool VertexAttributeBinding::SetFormat(const uint index,const VkFormat &format)
{
if(index>=attr_count)return(false);
attribute_list[index].format=format;
return(true);
}
bool VertexAttributeBinding::SetOffset(const uint index,const uint32_t offset)
{
if(index>=attr_count)return(false);
attribute_list[index].offset=offset;
return(true);
}
VK_NAMESPACE_END