diff --git a/gfx/d3d9/d3d9_pc.cpp b/gfx/d3d9/d3d9_pc.cpp index c8bdfac23d..ae02d9af1b 100644 --- a/gfx/d3d9/d3d9_pc.cpp +++ b/gfx/d3d9/d3d9_pc.cpp @@ -846,12 +846,7 @@ bool D3DVideo::init_imports(void) return false; } - std::shared_ptr tracker(state_tracker, [](state_tracker_t *tracker) { - state_tracker_free(tracker); - }); - - chain->add_state_tracker(tracker); - + chain->add_state_tracker(state_tracker); return true; } diff --git a/gfx/d3d9/render_chain.cpp b/gfx/d3d9/render_chain.cpp index 51e5ca122c..093e4a40a8 100644 --- a/gfx/d3d9/render_chain.cpp +++ b/gfx/d3d9/render_chain.cpp @@ -57,13 +57,16 @@ RenderChain::~RenderChain() cgDestroyProgram(fStock); if (vStock) cgDestroyProgram(vStock); + if (tracker) + state_tracker_free(tracker); } RenderChain::RenderChain(const video_info_t *video_info, LPDIRECT3DDEVICE dev_, CGcontext cgCtx_, const D3DVIEWPORT &final_viewport_) - : dev(dev_), cgCtx(cgCtx_), video_info(*video_info), final_viewport(final_viewport_), frame_count(0) + : dev(dev_), cgCtx(cgCtx_), video_info(*video_info), tracker(NULL), + final_viewport(final_viewport_), frame_count(0) {} bool RenderChain::init(const LinkInfo &info, PixelFormat fmt) @@ -225,8 +228,10 @@ bool RenderChain::add_lut(const std::string &id, return true; } -void RenderChain::add_state_tracker(std::shared_ptr tracker) +void RenderChain::add_state_tracker(state_tracker_t *tracker) { + if (this->tracker) + state_tracker_free(this->tracker); this->tracker = tracker; } @@ -1137,7 +1142,7 @@ void RenderChain::bind_tracker(Pass &pass, unsigned pass_index) return; if (pass_index == 1) - uniform_cnt = state_get_uniform(tracker.get(), uniform_info, MAX_VARIABLES, frame_count); + uniform_cnt = state_get_uniform(tracker, uniform_info, MAX_VARIABLES, frame_count); for (unsigned i = 0; i < uniform_cnt; i++) { diff --git a/gfx/d3d9/render_chain.hpp b/gfx/d3d9/render_chain.hpp index e5e8127382..a587a11830 100644 --- a/gfx/d3d9/render_chain.hpp +++ b/gfx/d3d9/render_chain.hpp @@ -21,7 +21,6 @@ #include "../shader_parse.h" #include #include -#include struct Vertex { @@ -56,7 +55,7 @@ class RenderChain void set_final_viewport(const D3DVIEWPORT9 &final_viewport); bool add_pass(const LinkInfo &info); bool add_lut(const std::string &id, const std::string &path, bool smooth); - void add_state_tracker(std::shared_ptr tracker); + void add_state_tracker(state_tracker_t *tracker); bool render(const void *data, unsigned width, unsigned height, unsigned pitch, unsigned rotation); @@ -79,7 +78,7 @@ class RenderChain const video_info_t &video_info; #define MAX_VARIABLES 64 - std::shared_ptr tracker; + state_tracker_t *tracker; struct state_tracker_uniform uniform_info[MAX_VARIABLES]; unsigned uniform_cnt;