diff --git a/example/Vulkan/DeferredRenderMultiCmdBuffer.cpp b/example/Vulkan/DeferredRenderMultiCmdBuffer.cpp index 9bafa3bb..fe64a413 100644 --- a/example/Vulkan/DeferredRenderMultiCmdBuffer.cpp +++ b/example/Vulkan/DeferredRenderMultiCmdBuffer.cpp @@ -237,16 +237,7 @@ private: texture.color_sampler=CreateSampler(texture.color); texture.normal_sampler=CreateSampler(texture.normal); - { - MaterialParameters *mp_global=sp_gbuffer.material_instance->GetMP(DescriptorSetsType::Global); - - if(!mp_global) - return(false); - - if(!mp_global->BindUBO("g_camera",GetCameraInfoBuffer()))return(false); - - mp_global->Update(); - } + BindCameraUBO(sp_gbuffer.material_instance); { MaterialParameters *mp=sp_gbuffer.material_instance->GetMP(DescriptorSetsType::Value); @@ -259,16 +250,7 @@ private: mp->Update(); } - { - MaterialParameters *mp_global=sp_composition.material_instance->GetMP(DescriptorSetsType::Global); - - if(!mp_global) - return(false); - - if(!mp_global->BindUBO("g_camera",GetCameraInfoBuffer()))return(false); - - mp_global->Update(); - } + BindCameraUBO(sp_composition.material_instance); { MaterialParameters *mp=sp_composition.material_instance->GetMP(DescriptorSetsType::Value); diff --git a/example/common/VulkanAppFramework.h b/example/common/VulkanAppFramework.h index 90186ef1..a5dee649 100644 --- a/example/common/VulkanAppFramework.h +++ b/example/common/VulkanAppFramework.h @@ -367,6 +367,20 @@ public: return ubo_camera_info; } + bool BindCameraUBO(MaterialInstance *mi) + { + MaterialParameters *mp_global=mi->GetMP(DescriptorSetsType::Global); + + if(!mp_global) + return(false); + + if(!mp_global->BindUBO("g_camera",ubo_camera_info))return(false); + + mp_global->Update(); + + return(true); + } + virtual void BuildCommandBuffer(uint32_t index)=0; inline bool isPush(enum class KeyboardButton kb)const{return key_status[size_t(kb)];}