From c537fbfc72d3b76719b2080266291fcf7623750b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 25 Apr 2018 13:47:14 +0300 Subject: [PATCH] Make a private copy of shader data in RenderPass Sharing it is not very common and can't be done in data files. Owned data is also needed to override uniforms in inherited Techniques. --- source/renderpass.cpp | 9 +++++---- source/renderpass.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/renderpass.cpp b/source/renderpass.cpp index 4b458f6d..09c049a8 100644 --- a/source/renderpass.cpp +++ b/source/renderpass.cpp @@ -46,13 +46,14 @@ RenderPass &RenderPass::operator=(const RenderPass &other) RenderPass::~RenderPass() { delete texturing; + delete shdata; } void RenderPass::set_shader_program(const Program *prog, const ProgramData *data) { shprog = prog; - shdata = data; - shdata.keep(); + delete shdata; + shdata = new ProgramData(*data); } void RenderPass::set_material(const Material *mat) @@ -81,7 +82,7 @@ void RenderPass::apply(Renderer &renderer) const { renderer.set_texturing(texturing); renderer.set_material(material.get()); - renderer.set_shader_program(shprog, shdata.get()); + renderer.set_shader_program(shprog, shdata); renderer.set_reverse_winding(back_faces); } @@ -145,7 +146,7 @@ void RenderPass::Loader::uniforms() throw invalid_operation("RenderPass::Loader::uniforms"); RefPtr shd = new ProgramData(obj.shprog); load_sub(*shd); - obj.shdata = shd; + obj.shdata = shd.release(); } diff --git a/source/renderpass.h b/source/renderpass.h index 11a9c45b..50cefb76 100644 --- a/source/renderpass.h +++ b/source/renderpass.h @@ -56,7 +56,7 @@ private: }; const Program *shprog; - RefPtr shdata; + ProgramData *shdata; RefPtr material; Texturing *texturing; std::map tex_names; @@ -70,7 +70,7 @@ public: void set_shader_program(const Program *, const ProgramData *); const Program *get_shader_program() const { return shprog; } - const ProgramData *get_shader_data() const { return shdata.get(); } + const ProgramData *get_shader_data() const { return shdata; } void set_material(const Material *); const Material *get_material() const { return material.get(); } void set_texture(unsigned, const Texture *); -- 2.45.2