X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frender%2Fprogramdata.h;h=2eef750cf78f7d4ff821ee9c1354cb395d6b6933;hp=380f352a66376b6b168805bea5f6c46f4ee0cae5;hb=77a534371433054384d213922a2e8c55f8a69ad6;hpb=1b23728908f5ec9beb08b2b70737c3903745fddc diff --git a/source/render/programdata.h b/source/render/programdata.h index 380f352a..2eef750c 100644 --- a/source/render/programdata.h +++ b/source/render/programdata.h @@ -1,14 +1,12 @@ #ifndef MSP_GL_PROGRAMDATA_H_ #define MSP_GL_PROGRAMDATA_H_ -#include #include #include #include "datatype.h" #include "matrix.h" #include "reflectdata.h" #include "tag.h" -#include "uniform.h" #include "vector.h" namespace Msp { @@ -22,7 +20,6 @@ public: }; class Buffer; -class BufferBackedUniformBlock; class PipelineState; class Program; class UniformBlock; @@ -104,11 +101,10 @@ private: struct TaggedUniform { Tag tag; - Uniform *value; - - TaggedUniform(); - - void replace_value(Uniform *); + DataType type = VOID; + unsigned array_size = 0; + unsigned data_offset = 0; + unsigned data_size = 0; }; struct SharedBlock @@ -154,10 +150,11 @@ private: // XXX All these mutables are a bit silly, but I'm out of better ideas const Program *tied_program; std::vector uniforms; + std::vector uniform_data; unsigned generation; mutable std::vector blocks; mutable std::vector programs; - mutable BufferBackedUniformBlock *last_buffer_block; + mutable UniformBlock *last_buffer_block; mutable Buffer *buffer; mutable Mask dirty; std::string debug_name; @@ -170,16 +167,10 @@ public: ~ProgramData(); private: - void uniform(Tag, Uniform *); - template - void uniform(Tag, V); - template - void uniform_array(Tag, unsigned, V); + void uniform(Tag, DataType, unsigned, const void *); bool validate_tag(Tag) const; - void add_uniform(Tag, Uniform *); void mark_dirty(Mask); public: - void uniform(Tag, const Uniform &); void uniform(Tag, int); void uniform(Tag, float); void uniform(Tag, int, int); @@ -242,8 +233,7 @@ public: unsigned get_generation() const { return generation; } std::vector get_uniform_tags() const; - const Uniform &get_uniform(Tag) const; - const Uniform *find_uniform(Tag) const; + void copy_uniform(const ProgramData &, Tag); private: int find_uniform_index(Tag) const; @@ -260,19 +250,19 @@ public: template void ProgramData::uniform(Tag tag, const LinAl::Vector &v) -{ uniform >(tag, &v.x); } +{ uniform(tag, TypeTraits>::type, 1, &v.x); } template void ProgramData::uniform(Tag tag, const LinAl::Matrix &v) -{ uniform >(tag, &v(0, 0)); } +{ uniform(tag, TypeTraits>::type, 1, &v(0, 0)); } template void ProgramData::uniform_array(Tag tag, unsigned n, const LinAl::Vector *v) -{ uniform_array >(tag, n, &v[0].x); } +{ uniform(tag, TypeTraits>::type, n, &v[0].x); } template void ProgramData::uniform_array(Tag tag, unsigned n, const LinAl::Matrix *v) -{ uniform_array >(tag, n, &v[0](0, 0)); } +{ uniform(tag, TypeTraits>::type, n, &v[0](0, 0)); } } // namespace GL } // namespace Msp