X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Fprogramdata.h;h=2eef750cf78f7d4ff821ee9c1354cb395d6b6933;hb=77a534371433054384d213922a2e8c55f8a69ad6;hp=1bcd3aab42c6ea2158f5beb0fbdcaab8f200720e;hpb=3a1b9cbe2441ae670a97541dc8ccb0a2860c8302;p=libs%2Fgl.git diff --git a/source/render/programdata.h b/source/render/programdata.h index 1bcd3aab..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 "program.h" +#include "reflectdata.h" #include "tag.h" -#include "uniform.h" #include "vector.h" namespace Msp { @@ -22,8 +20,8 @@ public: }; class Buffer; -class BufferBackedUniformBlock; class PipelineState; +class Program; class UniformBlock; struct Color; @@ -103,16 +101,15 @@ 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 { - Program::LayoutHash block_hash; + ReflectData::LayoutHash block_hash; Mask used; Mask dirty; UniformBlock *block; @@ -127,14 +124,14 @@ private: } dynamic; } indices; - SharedBlock(Program::LayoutHash); + SharedBlock(ReflectData::LayoutHash); const std::uint8_t *get_uniform_indices() const; }; struct ProgramBlock { - Program::LayoutHash prog_hash; + ReflectData::LayoutHash prog_hash; int bind_point; int block_index; union @@ -147,16 +144,17 @@ private: } masks; }; - ProgramBlock(Program::LayoutHash); + ProgramBlock(ReflectData::LayoutHash); }; // 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; @@ -169,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); @@ -241,14 +233,13 @@ 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; std::vector::iterator get_program(const Program &) const; - void update_block_uniform_indices(SharedBlock &, const Program::UniformBlockInfo &) const; - void update_block(SharedBlock &, const Program::UniformBlockInfo &) const; + void update_block_uniform_indices(SharedBlock &, const ReflectData::UniformBlockInfo &) const; + void update_block(SharedBlock &, const ReflectData::UniformBlockInfo &) const; std::vector::const_iterator prepare_program(const Program &) const; public: @@ -259,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