diff --git a/CMSceneGraph b/CMSceneGraph index 66518a8a..31a4223b 160000 --- a/CMSceneGraph +++ b/CMSceneGraph @@ -1 +1 @@ -Subproject commit 66518a8af330139c482755c5b249a6044f9104ff +Subproject commit 31a4223bd8646dfb603502f4c5bb51e5bd12f5e5 diff --git a/inc/hgl/graph/VK.h b/inc/hgl/graph/VK.h index 551e3022..9e4cf817 100644 --- a/inc/hgl/graph/VK.h +++ b/inc/hgl/graph/VK.h @@ -78,7 +78,7 @@ class Semaphore; struct PipelineLayoutData; class DescriptorSet; -struct ShaderAttribute; +struct VertexInputAttribute; class ShaderResource; class ShaderModule; diff --git a/inc/hgl/shadergen/ShaderCreateInfo.h b/inc/hgl/shadergen/ShaderCreateInfo.h index e6515fc0..8651b6c3 100644 --- a/inc/hgl/shadergen/ShaderCreateInfo.h +++ b/inc/hgl/shadergen/ShaderCreateInfo.h @@ -4,6 +4,7 @@ #include #include #include +#include #include namespace hgl{namespace graph @@ -65,9 +66,9 @@ protected: public: - ShaderDescriptorInfo *sdm; + ShaderDescriptorInfo *sdi; - VkShaderStageFlagBits GetShaderStage()const{return shader_stage;} + const VkShaderStageFlagBits GetShaderStage()const{return shader_stage;} public: @@ -78,6 +79,7 @@ public: int AddOutput(const graph::VAType &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth); int AddOutput(const AnsiString &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth); + //int AddOutput(const ShaderVariableType &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth); void AddFunction(const char *str){function_list.Add(str);} diff --git a/inc/hgl/shadergen/ShaderDescriptorInfo.h b/inc/hgl/shadergen/ShaderDescriptorInfo.h index 73c387e2..dcf39b18 100644 --- a/inc/hgl/shadergen/ShaderDescriptorInfo.h +++ b/inc/hgl/shadergen/ShaderDescriptorInfo.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -56,8 +56,8 @@ public: public: - bool AddInput(ShaderAttribute *); - bool AddOutput(ShaderAttribute *); + bool AddInput(VertexInputAttribute *); + bool AddOutput(VertexInputAttribute *); bool hasInput(const char *)const; ///<是否有指定输入 diff --git a/src/SceneGraph/CMakeLists.txt b/src/SceneGraph/CMakeLists.txt index 5f2319e1..ceacd05b 100644 --- a/src/SceneGraph/CMakeLists.txt +++ b/src/SceneGraph/CMakeLists.txt @@ -98,11 +98,6 @@ SET(VK_RR_SOURCE ${SG_INCLUDE_PATH}/VKRenderResource.h SOURCE_GROUP("Vulkan\\RenderResource" FILES ${VK_RR_SOURCE}) -SET(VK_RR_SHADER_FILES ${SG_INCLUDE_PATH}/VKShaderResource.h - Vulkan/VKShaderResource.cpp) - -SOURCE_GROUP("Vulkan\\RenderResource\\Shader" FILES ${VK_RR_SHADER_FILES}) - SET(VK_RR_MATERIAL_FILES ${SG_INCLUDE_PATH}/VKMaterialDescriptorManager.h Vulkan/VKMaterialDescriptorManager.cpp) @@ -282,7 +277,6 @@ ENDIF(UNIX) SOURCE_GROUP("Vulkan\\Surface" FILES ${VULKAN_SURFACE_SOURCE}) SET(VULKAN_RENDER_SOURCE ${VK_RR_SOURCE} - ${VK_RR_SHADER_FILES} ${VK_RR_MATERIAL_FILES} ${VK_INST_SOURCE} ${VK_DEBUG_SOURCE} diff --git a/src/SceneGraph/Vulkan/VKRenderResourceMaterial.cpp b/src/SceneGraph/Vulkan/VKRenderResourceMaterial.cpp index 295e6241..f9d7b260 100644 --- a/src/SceneGraph/Vulkan/VKRenderResourceMaterial.cpp +++ b/src/SceneGraph/Vulkan/VKRenderResourceMaterial.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -124,7 +123,7 @@ Material *RenderResource::CreateMaterial(const mtl::MaterialCreateInfo *mci) ShaderCreateInfoVertex *vert=mci->GetVS(); if(vert) - mtl->vertex_input=GetVertexInput(vert->sdm->GetShaderStageIO().input); + mtl->vertex_input=GetVertexInput(vert->sdi->GetShaderStageIO().input); } { diff --git a/src/ShaderGen/MaterialCreateInfo.cpp b/src/ShaderGen/MaterialCreateInfo.cpp index 0043732d..8b5cf97a 100644 --- a/src/ShaderGen/MaterialCreateInfo.cpp +++ b/src/ShaderGen/MaterialCreateInfo.cpp @@ -58,7 +58,7 @@ bool MaterialCreateInfo::AddUBO(const VkShaderStageFlagBits flag_bit,const Descr ubo->stage_flag|=flag_bit; - return sc->sdm->AddUBO(set_type,ubo); + return sc->sdi->AddUBO(set_type,ubo); } else { @@ -67,7 +67,7 @@ bool MaterialCreateInfo::AddUBO(const VkShaderStageFlagBits flag_bit,const Descr ubo->type=struct_name; hgl::strcpy(ubo->name,DESCRIPTOR_NAME_MAX_LENGTH,name); - return sc->sdm->AddUBO(set_type,mdi.AddUBO(flag_bit,set_type,ubo)); + return sc->sdi->AddUBO(set_type,mdi.AddUBO(flag_bit,set_type,ubo)); } } @@ -116,7 +116,7 @@ bool MaterialCreateInfo::AddSampler(const VkShaderStageFlagBits flag_bit,const D sampler->stage_flag|=flag_bit; - return sc->sdm->AddSampler(set_type,sampler); + return sc->sdi->AddSampler(set_type,sampler); } else { @@ -125,7 +125,7 @@ bool MaterialCreateInfo::AddSampler(const VkShaderStageFlagBits flag_bit,const D sampler->type=st_name; hgl::strcpy(sampler->name,DESCRIPTOR_NAME_MAX_LENGTH,name); - return sc->sdm->AddSampler(set_type,mdi.AddSampler(flag_bit,set_type,sampler)); + return sc->sdi->AddSampler(set_type,mdi.AddSampler(flag_bit,set_type,sampler)); } } diff --git a/src/ShaderGen/ShaderCreateInfo.cpp b/src/ShaderGen/ShaderCreateInfo.cpp index a04e2fff..17ba1e27 100644 --- a/src/ShaderGen/ShaderCreateInfo.cpp +++ b/src/ShaderGen/ShaderCreateInfo.cpp @@ -13,7 +13,7 @@ ShaderCreateInfo::ShaderCreateInfo(VkShaderStageFlagBits ss,MaterialDescriptorIn { shader_stage=ss; mdi=m; - sdm=new ShaderDescriptorInfo(ss); + sdi=new ShaderDescriptorInfo(ss); spv_data=nullptr; @@ -26,7 +26,7 @@ ShaderCreateInfo::~ShaderCreateInfo() if(spv_data) FreeSPVData(spv_data); - delete sdm; + delete sdi; } bool ShaderCreateInfo::AddDefine(const AnsiString &m,const AnsiString &v) @@ -102,7 +102,7 @@ bool ShaderCreateInfo::ProcDefine() int ShaderCreateInfo::AddOutput(const VAType &type,const AnsiString &name,Interpolation inter) { - ShaderAttribute *ss=new ShaderAttribute; + VertexInputAttribute *ss=new VertexInputAttribute; hgl::strcpy(ss->name,sizeof(ss->name),name.c_str()); @@ -110,7 +110,7 @@ int ShaderCreateInfo::AddOutput(const VAType &type,const AnsiString &name,Interp ss->vec_size = type.vec_size; ss->interpolation = inter; - return sdm->AddOutput(ss); + return sdi->AddOutput(ss); } int ShaderCreateInfo::AddOutput(const AnsiString &type,const AnsiString &name,Interpolation inter) @@ -126,9 +126,23 @@ int ShaderCreateInfo::AddOutput(const AnsiString &type,const AnsiString &name,In return AddOutput(vat,name,inter); } +//int ShaderCreateInfo::AddOutput(const ShaderVariableType &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth) +//{ +// VertexInputAttribute *ss=new VertexInputAttribute; +// +// hgl::strcpy(ss->name,sizeof(ss->name),name.c_str()); +// +// ss->basetype =(uint8)type.base_type; +// ss->vec_size = type.vec_size; +// ss->interpolation = inter; +// +// return sdi->AddOutput(ss); +// +//} + bool ShaderCreateInfo::ProcSubpassInput() { - auto sil=sdm->GetSubpassInputList(); + auto sil=sdi->GetSubpassInputList(); if(sil.IsEmpty()) return(true); @@ -167,8 +181,8 @@ namespace void ShaderCreateInfo::SetMaterialInstance(UBODescriptor *ubo,const AnsiString &mi) { - sdm->AddUBO(DescriptorSetType::PerMaterial,ubo); - sdm->AddStruct(mtl::MaterialInstanceStruct); + sdi->AddUBO(DescriptorSetType::PerMaterial,ubo); + sdi->AddStruct(mtl::MaterialInstanceStruct); AddFunction(shader_stage==VK_SHADER_STAGE_VERTEX_BIT?MF_GetMI_VS:MF_GetMI_Other); @@ -212,14 +226,14 @@ bool ShaderCreateInfo::ProcOutput() { output_struct.Clear(); - const ShaderAttributeArray &ssd=sdm->GetShaderStageIO().output; + const VertexInputAttributeArray &ssd=sdi->GetShaderStageIO().output; if(ssd.count<=0)return(true); output_struct=GetShaderStageName(shader_stage); output_struct+="_Output\n{\n"; - const ShaderAttribute *ss=ssd.items; + const VertexInputAttribute *ss=ssd.items; for(uint i=0;iGetStructList(); + const AnsiStringList &struct_list=sdi->GetStructList(); AnsiString codes; @@ -283,7 +297,7 @@ bool ShaderCreateInfo::ProcMI() bool ShaderCreateInfo::ProcUBO() { - auto ubo_list=sdm->GetUBOList(); + auto ubo_list=sdi->GetUBOList(); const int count=ubo_list.GetCount(); @@ -327,7 +341,7 @@ bool ShaderCreateInfo::ProcSSBO() bool ShaderCreateInfo::ProcConstantID() { - auto const_list=sdm->GetConstList(); + auto const_list=sdi->GetConstList(); const int count=const_list.GetCount(); @@ -357,7 +371,7 @@ bool ShaderCreateInfo::ProcConstantID() bool ShaderCreateInfo::ProcSampler() { - auto sampler_list=sdm->GetSamplerList(); + auto sampler_list=sdi->GetSamplerList(); const int count=sampler_list.GetCount(); diff --git a/src/ShaderGen/ShaderCreateInfoFragment.cpp b/src/ShaderGen/ShaderCreateInfoFragment.cpp index 83110549..ba05dfb2 100644 --- a/src/ShaderGen/ShaderCreateInfoFragment.cpp +++ b/src/ShaderGen/ShaderCreateInfoFragment.cpp @@ -1,4 +1,4 @@ -#include +#include #include namespace hgl{namespace graph{ @@ -7,9 +7,9 @@ using namespace hgl::graph; bool ShaderCreateInfoFragment::ProcOutput() { - const auto &output_list=sdm->GetShaderStageIO().output; + const auto &output_list=sdi->GetShaderStageIO().output; - const ShaderAttribute *o=output_list.items; + const VertexInputAttribute *o=output_list.items; final_shader+="\n"; diff --git a/src/ShaderGen/ShaderCreateInfoVertex.cpp b/src/ShaderGen/ShaderCreateInfoVertex.cpp index 7baf0f0b..f1e2b5f9 100644 --- a/src/ShaderGen/ShaderCreateInfoVertex.cpp +++ b/src/ShaderGen/ShaderCreateInfoVertex.cpp @@ -14,7 +14,7 @@ ShaderCreateInfoVertex::ShaderCreateInfoVertex(MaterialDescriptorInfo *m):Shader int ShaderCreateInfoVertex::AddInput(const VAType &type,const AnsiString &name,const VkVertexInputRate input_rate,const VertexInputGroup &group) { - ShaderAttribute *ss=new ShaderAttribute; + VertexInputAttribute *ss=new VertexInputAttribute; hgl::strcpy(ss->name,sizeof(ss->name),name.c_str()); @@ -24,7 +24,7 @@ int ShaderCreateInfoVertex::AddInput(const VAType &type,const AnsiString &name,c ss->input_rate =input_rate; ss->group =group; - return sdm->AddInput(ss); + return sdi->AddInput(ss); } int ShaderCreateInfoVertex::AddInput(const AnsiString &type,const AnsiString &name,const VkVertexInputRate input_rate,const VertexInputGroup &group) @@ -39,7 +39,7 @@ int ShaderCreateInfoVertex::AddInput(const AnsiString &type,const AnsiString &na int ShaderCreateInfoVertex::hasInput(const char *name) { - return sdm->hasInput(name); + return sdi->hasInput(name); } void ShaderCreateInfoVertex::AddJoint() @@ -60,7 +60,7 @@ void ShaderCreateInfoVertex::AddAssign() bool ShaderCreateInfoVertex::ProcInput(ShaderCreateInfo *) { - const auto &input=sdm->GetShaderStageIO().input; + const auto &input=sdi->GetShaderStageIO().input; if(input.count<=0) { @@ -71,7 +71,7 @@ bool ShaderCreateInfoVertex::ProcInput(ShaderCreateInfo *) final_shader+="\n"; - const ShaderAttribute *ss=input.items; + const VertexInputAttribute *ss=input.items; for(uint i=0;i +#include namespace hgl{namespace graph{ ShaderDescriptorInfo::ShaderDescriptorInfo(VkShaderStageFlagBits flag_bit) @@ -12,7 +12,7 @@ ShaderDescriptorInfo::ShaderDescriptorInfo(VkShaderStageFlagBits flag_bit) namespace { - bool Find(const ShaderAttributeArray &sad,const char *name) + bool Find(const VertexInputAttributeArray &sad,const char *name) { if(sad.count<=0) return(false); @@ -25,7 +25,7 @@ namespace } }//namespace -bool ShaderDescriptorInfo::AddInput(ShaderAttribute *ss) +bool ShaderDescriptorInfo::AddInput(VertexInputAttribute *ss) { if(!ss)return(false); @@ -46,7 +46,7 @@ bool ShaderDescriptorInfo::hasInput(const char *name)const } -bool ShaderDescriptorInfo::AddOutput(ShaderAttribute *ss) +bool ShaderDescriptorInfo::AddOutput(VertexInputAttribute *ss) { if(!ss)return(false);