From e488b4c3d3816fc715face405b3327fed4e5414f Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Wed, 29 Mar 2023 21:34:50 +0800 Subject: [PATCH] added half codes. --- inc/hgl/graph/RenderList2D.h | 2 +- inc/hgl/graph/VKMaterialInstance.h | 8 +++++++- src/SceneGraph/Vulkan/VKMaterialInstance.cpp | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/inc/hgl/graph/RenderList2D.h b/inc/hgl/graph/RenderList2D.h index 2e49a8a4..9b62fad7 100644 --- a/inc/hgl/graph/RenderList2D.h +++ b/inc/hgl/graph/RenderList2D.h @@ -12,7 +12,7 @@ namespace hgl { using RenderableList=List; - struct RenderableList + struct MaterialRenderableList { Material *mtl; diff --git a/inc/hgl/graph/VKMaterialInstance.h b/inc/hgl/graph/VKMaterialInstance.h index 14c29a3b..16b7bcab 100644 --- a/inc/hgl/graph/VKMaterialInstance.h +++ b/inc/hgl/graph/VKMaterialInstance.h @@ -26,7 +26,13 @@ public: const VIL *GetVIL()const{return vil;} MaterialParameters *GetMP(){return mp_per_mi;} - MaterialParameters *GetMP(const DescriptorSetType &type){return material->GetMP(type);} + MaterialParameters *GetMP(const DescriptorSetType &type) + { + if(type==DescriptorSetType::PerMaterial) + return mp_per_mi; + else + return material->GetMP(type); + } bool BindUBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false); bool BindSSBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false); diff --git a/src/SceneGraph/Vulkan/VKMaterialInstance.cpp b/src/SceneGraph/Vulkan/VKMaterialInstance.cpp index a7700979..7abd9662 100644 --- a/src/SceneGraph/Vulkan/VKMaterialInstance.cpp +++ b/src/SceneGraph/Vulkan/VKMaterialInstance.cpp @@ -21,7 +21,10 @@ MaterialInstance::MaterialInstance(Material *mtl,VIL *v) vil=v; - mp_per_mi=mtl->GetMP(DescriptorSetType::PerMaterial); + mp_per_mi= + device->CreateMP(desc_manager,pld,(DescriptorSetType)dst); +PerMaterial的属性每个MaterialInstance不一样,所以需要在这里分配自己的MP做绑定记录 +mtl->GetMP(DescriptorSetType::PerMaterial); } bool MaterialInstance::BindUBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic)