From: Mikko Rasa Date: Wed, 25 Apr 2018 10:47:14 +0000 (+0300) Subject: Make a private copy of shader data in RenderPass X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c537fbfc72d3b76719b2080266291fcf7623750b;p=libs%2Fgl.git 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. --- 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 *);