diff --git a/example/Vulkan/two_triangle.cpp b/example/Vulkan/two_triangle.cpp index 8e84e2a7..cbe2858f 100644 --- a/example/Vulkan/two_triangle.cpp +++ b/example/Vulkan/two_triangle.cpp @@ -86,16 +86,13 @@ private: render_instance=db->CreateRenderableInstance(render_obj,material_instance,pipeline); - { - SceneNode *sn=render_root.CreateSubNode(scale(0.5,0.5)); - sn->RIList.Add(render_instance); - } + render_root.CreateSubNode(scale(0.5,0.5),render_instance); render_root.RefreshMatrix(); SceneTreeToRenderList st2rl(device); - st2rl.Expend(&render_list,&render_root,&cam); + st2rl.Expend(&render_list,cam.info,&render_root); return(true); } diff --git a/inc/hgl/graph/VKMaterial.h b/inc/hgl/graph/VKMaterial.h index af2798a1..c6d408b9 100644 --- a/inc/hgl/graph/VKMaterial.h +++ b/inc/hgl/graph/VKMaterial.h @@ -23,6 +23,9 @@ class Material DescriptorSetLayoutCreater *dsl_creater; + DescriptorSets *g_desc_sets; + DescriptorSets *ri_desc_sets; + VertexAttributeBinding *vab; public: @@ -60,7 +63,10 @@ public: const VkPipelineShaderStageCreateInfo * GetStages ()const{return shader_stage_list->GetData();} const VkPipelineLayout GetPipelineLayout ()const; - DescriptorSets * CreateDescriptorSets ()const; + DescriptorSets * CreateMIDescriptorSets ()const; + + DescriptorSets * GetGlobalDescriptorSets (){return g_desc_sets;} + DescriptorSets * GetRIDescriptorSets (){return ri_desc_sets;} const VertexAttributeBinding * GetVAB ()const{return vab;} const uint32_t GetVertexAttrCount ()const{return vab->GetVertexAttrCount();} diff --git a/src/SceneGraph/SceneTreeToRenderList.cpp b/src/SceneGraph/SceneTreeToRenderList.cpp index adaac1bf..29bbf424 100644 --- a/src/SceneGraph/SceneTreeToRenderList.cpp +++ b/src/SceneGraph/SceneTreeToRenderList.cpp @@ -166,7 +166,7 @@ namespace hgl bool SceneTreeToRenderList::Expend(RenderList *rl,const CameraInfo &ci,SceneNode *sn) { if(!device)return(false); - if(!rl||sn)return(false); + if(!rl||!sn)return(false); camera_info=ci; diff --git a/src/SceneGraph/Vulkan/VKMaterial.cpp b/src/SceneGraph/Vulkan/VKMaterial.cpp index a8521764..a28681fa 100644 --- a/src/SceneGraph/Vulkan/VKMaterial.cpp +++ b/src/SceneGraph/Vulkan/VKMaterial.cpp @@ -104,10 +104,13 @@ Material::Material(const UTF8String &name,ShaderModuleMap *smm,ListCreate(DescriptorSetsType::RenderableInstance); } Material::~Material() { + SAFE_CLEAR(ri_desc_sets); delete dsl_creater; if(vab) @@ -150,8 +153,8 @@ const VkPipelineLayout Material::GetPipelineLayout()const return dsl_creater->GetPipelineLayout(); } -DescriptorSets *Material::CreateDescriptorSets()const +DescriptorSets *Material::CreateMIDescriptorSets()const { - return dsl_creater->Create(); + return dsl_creater->Create(DescriptorSetsType::MaterialInstance); } VK_NAMESPACE_END diff --git a/src/SceneGraph/Vulkan/VKMaterialInstance.cpp b/src/SceneGraph/Vulkan/VKMaterialInstance.cpp index 0fc6522f..05f7f2bc 100644 --- a/src/SceneGraph/Vulkan/VKMaterialInstance.cpp +++ b/src/SceneGraph/Vulkan/VKMaterialInstance.cpp @@ -70,7 +70,7 @@ void MaterialInstance::Update() MaterialInstance *Material::CreateInstance() { - DescriptorSets *ds=CreateDescriptorSets(); + DescriptorSets *ds=CreateMIDescriptorSets(); if(!ds)return(nullptr);