]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/programdata.cpp
Add a usage parameter to Buffer
[libs/gl.git] / source / render / programdata.cpp
index 40eba5e5d6840a4580c1d311c67da732231253ab..fc9b30a99e14b5011eba96d426f555a5467012f1 100644 (file)
@@ -20,44 +20,20 @@ ProgramData::ProgramData(const Program *p):
        tied_program(p)
 { }
 
-// Blocks are intentionally left uncopied
-ProgramData::ProgramData(const ProgramData &other):
+ProgramData::ProgramData(ProgramData &&other):
        tied_program(other.tied_program),
-       uniforms(other.uniforms),
-       uniform_data(other.uniform_data),
-       generation(other.generation)
-{ }
-
-ProgramData::ProgramData(const ProgramData &other, const Program *p):
-       tied_program(p)
-{
-       if(tied_program)
-       {
-               for(const TaggedUniform &u: other.uniforms)
-                       validate_tag(u.tag);
-       }
-
-       uniforms = other.uniforms;
-       uniform_data = other.uniform_data;
-}
-
-ProgramData &ProgramData::operator=(const ProgramData &other)
+       uniforms(move(other.uniforms)),
+       uniform_data(move(other.uniform_data)),
+       generation(other.generation),
+       blocks(move(other.blocks)),
+       programs(move(other.programs)),
+       last_buffer_block(other.last_buffer_block),
+       buffer(other.buffer),
+       dirty(other.dirty),
+       debug_name(move(other.debug_name))
 {
-       tied_program = other.tied_program;
-
-       uniforms = other.uniforms;
-       uniform_data = other.uniform_data;
-
-       for(SharedBlock &b: blocks)
-               delete b.block;
-       blocks.clear();
-       programs.clear();
-
-       last_buffer_block = 0;
-       buffer = 0;
-       dirty = 0;
-
-       return *this;
+       other.blocks.clear();
+       other.buffer = 0;
 }
 
 ProgramData::~ProgramData()
@@ -466,6 +442,12 @@ void ProgramData::copy_uniform(const ProgramData &source, Tag tag)
        uniform(tag, tu.type, tu.array_size, source.uniform_data.data()+tu.data_offset);
 }
 
+void ProgramData::copy_uniforms(const ProgramData &source)
+{
+       for(const TaggedUniform &u: source.uniforms)
+               uniform(u.tag, u.type, u.array_size, source.uniform_data.data()+u.data_offset);
+}
+
 int ProgramData::find_uniform_index(Tag tag) const
 {
        auto i = lower_bound_member(uniforms, tag, &TaggedUniform::tag);
@@ -674,7 +656,7 @@ vector<ProgramData::ProgramBlock>::const_iterator ProgramData::prepare_program(c
 #endif
                                }
 
-                               buffer->storage(required_size);
+                               buffer->storage(required_size, STREAMING);
                        }
                }
        }