]> git.tdb.fi Git - libs/gl.git/commitdiff
Make a private copy of shader data in RenderPass
authorMikko Rasa <tdb@tdb.fi>
Wed, 25 Apr 2018 10:47:14 +0000 (13:47 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 25 Apr 2018 11:18:51 +0000 (14:18 +0300)
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
source/renderpass.h

index 4b458f6d5f9b57ca555b542e4724ed3b08d0b5ae..09c049a8cee8eb1983bf279b084b592e498d7f75 100644 (file)
@@ -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<ProgramData> shd = new ProgramData(obj.shprog);
        load_sub(*shd);
-       obj.shdata = shd;
+       obj.shdata = shd.release();
 }
 
 
index 11a9c45b7e8ef36182dc415933534d60f5518951..50cefb76698ea48c63b965e79489816b1d239657 100644 (file)
@@ -56,7 +56,7 @@ private:
        };
 
        const Program *shprog;
-       RefPtr<const ProgramData> shdata;
+       ProgramData *shdata;
        RefPtr<const Material> material;
        Texturing *texturing;
        std::map<std::string, unsigned> 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 *);