From c9b15a022c47ae2015eb10fabb2de2dd690da803 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Tue, 26 Mar 2024 20:24:48 +0800 Subject: [PATCH] remove-unused-skytex --- zenovis/src/optx/RenderEngineOptx.cpp | 7 +++++++ zenovis/xinxinoptix/OptiXStuff.h | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/zenovis/src/optx/RenderEngineOptx.cpp b/zenovis/src/optx/RenderEngineOptx.cpp index 66e54ee0a8..b7c09e9951 100644 --- a/zenovis/src/optx/RenderEngineOptx.cpp +++ b/zenovis/src/optx/RenderEngineOptx.cpp @@ -694,8 +694,15 @@ struct GraphicsManager { float evnTexStrength = prim_in->userData().get2("evnTexStrength"); bool enableHdr = prim_in->userData().get2("enable"); if (!path.empty()) { + std::string need_remove_tex; + if (OptixUtil::sky_tex.has_value() && OptixUtil::sky_tex.value() != path) { + need_remove_tex = OptixUtil::sky_tex.value(); + } OptixUtil::sky_tex = path; OptixUtil::addTexture(path); + if (need_remove_tex.size()) { + OptixUtil::removeTexture(need_remove_tex); + } } xinxinoptix::update_hdr_sky(evnTexRotation, evnTex3DRotation, evnTexStrength); xinxinoptix::using_hdr_sky(enableHdr); diff --git a/zenovis/xinxinoptix/OptiXStuff.h b/zenovis/xinxinoptix/OptiXStuff.h index fbfc80c73e..ba415518ca 100644 --- a/zenovis/xinxinoptix/OptiXStuff.h +++ b/zenovis/xinxinoptix/OptiXStuff.h @@ -852,6 +852,17 @@ inline void addTexture(std::string path) zeno::log_info("-{}", i->first); } } +inline void removeTexture(std::string path) { + if (path.size()) { + g_tex.erase(path); + sky_nx_map.erase(path); + sky_ny_map.erase(path); + sky_cdf_map.erase(path); + sky_pdf_map.erase(path); + sky_start_map.erase(path); + sky_avg_map.erase(path); + } +} struct OptixShaderCore { raii module {};