]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/programdata.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / render / programdata.h
diff --git a/source/render/programdata.h b/source/render/programdata.h
deleted file mode 100644 (file)
index 380f352..0000000
+++ /dev/null
@@ -1,280 +0,0 @@
-#ifndef MSP_GL_PROGRAMDATA_H_
-#define MSP_GL_PROGRAMDATA_H_
-
-#include <map>
-#include <stdexcept>
-#include <msp/datafile/objectloader.h>
-#include "datatype.h"
-#include "matrix.h"
-#include "reflectdata.h"
-#include "tag.h"
-#include "uniform.h"
-#include "vector.h"
-
-namespace Msp {
-namespace GL {
-
-class too_many_uniforms: public std::runtime_error
-{
-public:
-       too_many_uniforms(const std::string &w): std::runtime_error(w) { }
-       virtual ~too_many_uniforms() throw() { }
-};
-
-class Buffer;
-class BufferBackedUniformBlock;
-class PipelineState;
-class Program;
-class UniformBlock;
-struct Color;
-
-/**
-Stores uniform variables for shader programs.  The uniforms are stored in a
-program-independent way, and UniformBlocks are created to match the uniform
-layouts of different programs.  If multiple programs have the same layout, the
-same block is used for them.
-
-The class is optimized for an access pattern where the set of uniforms and
-programs stays constants, with only the values changing.
-*/
-class ProgramData
-{
-public:
-       class Loader: public DataFile::ObjectLoader<ProgramData>
-       {
-       public:
-               Loader(ProgramData &);
-       private:
-               void uniform1i(const std::string &, int);
-               void uniform1f(const std::string &, float);
-               void uniform2i(const std::string &, int, int);
-               void uniform2f(const std::string &, float, float);
-               void uniform3i(const std::string &, int, int, int);
-               void uniform3f(const std::string &, float, float, float);
-               void uniform4i(const std::string &, int, int, int, int);
-               void uniform4f(const std::string &, float, float, float, float);
-               void uniform_array_(const std::string &, DataType, unsigned);
-               void uniform1i_array(const std::string &);
-               void uniform1f_array(const std::string &);
-               void uniform2i_array(const std::string &);
-               void uniform2f_array(const std::string &);
-               void uniform3i_array(const std::string &);
-               void uniform3f_array(const std::string &);
-               void uniform4i_array(const std::string &);
-               void uniform4f_array(const std::string &);
-               void uniform_array(const std::string &);
-       };
-
-private:
-       class ArrayLoader: public DataFile::Loader
-       {
-       private:
-               DataType type;
-               unsigned element_size;
-               std::vector<char> data;
-
-       public:
-               ArrayLoader(DataType, unsigned);
-
-               DataType get_data_type() const { return type; }
-               unsigned get_element_size() const { return element_size; }
-               const void *get_data() const { return &data[0]; }
-               unsigned get_size() const { return data.size()/(4*element_size); }
-
-       private:
-               void uniform(DataType, unsigned, const void *);
-               void uniform1i(int);
-               void uniform1f(float);
-               void uniform2i(int, int);
-               void uniform2f(float, float);
-               void uniform3i(int, int, int);
-               void uniform3f(float, float, float);
-               void uniform4i(int, int, int, int);
-               void uniform4f(float, float, float, float);
-       };
-
-       typedef unsigned Mask;
-
-       enum
-       {
-               MASK_BITS = sizeof(Mask)*8,
-               ALL_ONES = static_cast<Mask>(-1)
-       };
-
-       struct TaggedUniform
-       {
-               Tag tag;
-               Uniform *value;
-
-               TaggedUniform();
-
-               void replace_value(Uniform *);
-       };
-
-       struct SharedBlock
-       {
-               ReflectData::LayoutHash block_hash;
-               Mask used;
-               Mask dirty;
-               UniformBlock *block;
-               union
-               {
-                       std::uint8_t type_flag;
-                       std::uint8_t values[16];
-                       struct
-                       {
-                               std::uint8_t type_flag;
-                               std::uint8_t *values;
-                       } dynamic;
-               } indices;
-
-               SharedBlock(ReflectData::LayoutHash);
-
-               const std::uint8_t *get_uniform_indices() const;
-       };
-
-       struct ProgramBlock
-       {
-               ReflectData::LayoutHash prog_hash;
-               int bind_point;
-               int block_index;
-               union
-               {
-                       UniformBlock *block;
-                       struct
-                       {
-                               Mask used;
-                               Mask dirty;
-                       } masks;
-               };
-
-               ProgramBlock(ReflectData::LayoutHash);
-       };
-
-       // XXX All these mutables are a bit silly, but I'm out of better ideas
-       const Program *tied_program;
-       std::vector<TaggedUniform> uniforms;
-       unsigned generation;
-       mutable std::vector<SharedBlock> blocks;
-       mutable std::vector<ProgramBlock> programs;
-       mutable BufferBackedUniformBlock *last_buffer_block;
-       mutable Buffer *buffer;
-       mutable Mask dirty;
-       std::string debug_name;
-
-public:
-       ProgramData(const Program * = 0);
-       ProgramData(const ProgramData &);
-       ProgramData(const ProgramData &, const Program *);
-       ProgramData &operator=(const ProgramData &);
-       ~ProgramData();
-
-private:
-       void uniform(Tag, Uniform *);
-       template<typename T, typename V>
-       void uniform(Tag, V);
-       template<typename T, typename V>
-       void uniform_array(Tag, unsigned, V);
-       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);
-       void uniform(Tag, float, float);
-       void uniform2(Tag, const int *);
-       void uniform2(Tag, const float *);
-       void uniform(Tag, int, int, int);
-       void uniform(Tag, float, float, float);
-       void uniform3(Tag, const int *);
-       void uniform3(Tag, const float *);
-       void uniform(Tag, int, int, int, int);
-       void uniform(Tag, float, float, float, float);
-       void uniform(Tag, const Color &);
-       void uniform4(Tag, const int *);
-       void uniform4(Tag, const float *);
-       void uniform_matrix2(Tag, const float *);
-       void uniform_matrix3x2(Tag, const float *);
-       void uniform_matrix4x2(Tag, const float *);
-       void uniform_matrix2x3(Tag, const float *);
-       void uniform_matrix3(Tag, const float *);
-       void uniform_matrix4x3(Tag, const float *);
-       void uniform_matrix2x4(Tag, const float *);
-       void uniform_matrix3x4(Tag, const float *);
-       void uniform(Tag, const Matrix &);
-       void uniform_matrix4(Tag, const float *);
-       void uniform_array(Tag, unsigned, const int *);
-       void uniform_array(Tag, unsigned, const float *);
-       void uniform1_array(Tag, unsigned, const int *);
-       void uniform1_array(Tag, unsigned, const float *);
-       void uniform2_array(Tag, unsigned, const int *);
-       void uniform2_array(Tag, unsigned, const float *);
-       void uniform3_array(Tag, unsigned, const int *);
-       void uniform3_array(Tag, unsigned, const float *);
-       void uniform4_array(Tag, unsigned, const int *);
-       void uniform4_array(Tag, unsigned, const float *);
-       void uniform_matrix2_array(Tag, unsigned, const float *);
-       void uniform_matrix3x2_array(Tag, unsigned, const float *);
-       void uniform_matrix4x2_array(Tag, unsigned, const float *);
-       void uniform_matrix2x3_array(Tag, unsigned, const float *);
-       void uniform_matrix3_array(Tag, unsigned, const float *);
-       void uniform_matrix4x3_array(Tag, unsigned, const float *);
-       void uniform_matrix2x4_array(Tag, unsigned, const float *);
-       void uniform_matrix3x4_array(Tag, unsigned, const float *);
-       void uniform_matrix4_array(Tag, unsigned, const float *);
-
-       template<typename T, unsigned N>
-       void uniform(Tag, const LinAl::Vector<T, N> &);
-
-       template<typename T, unsigned R, unsigned C>
-       void uniform(Tag, const LinAl::Matrix<T, R, C> &);
-
-       template<typename T, unsigned N>
-       void uniform_array(Tag, unsigned, const LinAl::Vector<T, N> *);
-
-       template<typename T, unsigned R, unsigned C>
-       void uniform_array(Tag, unsigned, const LinAl::Matrix<T, R, C> *);
-
-       void remove_uniform(Tag);
-
-       unsigned get_generation() const { return generation; }
-
-       std::vector<Tag> get_uniform_tags() const;
-       const Uniform &get_uniform(Tag) const;
-       const Uniform *find_uniform(Tag) const;
-
-private:
-       int find_uniform_index(Tag) const;
-       std::vector<ProgramBlock>::iterator get_program(const Program &) const;
-       void update_block_uniform_indices(SharedBlock &, const ReflectData::UniformBlockInfo &) const;
-       void update_block(SharedBlock &, const ReflectData::UniformBlockInfo &) const;
-
-       std::vector<ProgramBlock>::const_iterator prepare_program(const Program &) const;
-public:
-       void apply(const Program &, PipelineState &) const;
-
-       void set_debug_name(const std::string &);
-};
-
-template<typename T, unsigned N>
-void ProgramData::uniform(Tag tag, const LinAl::Vector<T, N> &v)
-{ uniform<UniformVector<T, N> >(tag, &v.x); }
-
-template<typename T, unsigned R, unsigned C>
-void ProgramData::uniform(Tag tag, const LinAl::Matrix<T, R, C> &v)
-{ uniform<UniformMatrix<T, R, C> >(tag, &v(0, 0)); }
-
-template<typename T, unsigned N>
-void ProgramData::uniform_array(Tag tag, unsigned n, const LinAl::Vector<T, N> *v)
-{ uniform_array<UniformVector<T, N> >(tag, n, &v[0].x); }
-
-template<typename T, unsigned R, unsigned C>
-void ProgramData::uniform_array(Tag tag, unsigned n, const LinAl::Matrix<T, R, C> *v)
-{ uniform_array<UniformMatrix<T, R, C> >(tag, n, &v[0](0, 0)); }
-
-} // namespace GL
-} // namespace Msp
-
-#endif