]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/programdata.h
Split UniformBlock into two classes
[libs/gl.git] / source / render / programdata.h
index 0ed16d6f0d4c2bd7babf08e834e9ee61628e1399..a90d868e3bb7e3598200f074791189ee85e0cc15 100644 (file)
@@ -21,6 +21,7 @@ public:
 };
 
 class Buffer;
+class BufferBackedUniformBlock;
 class Uniform;
 class UniformBlock;
 struct Color;
@@ -110,6 +111,7 @@ private:
 
        struct SharedBlock
        {
+               Program::LayoutHash block_hash;
                Mask used;
                Mask dirty;
                UniformBlock *block;
@@ -124,39 +126,35 @@ private:
                        } dynamic;
                } indices;
 
-               SharedBlock(UniformBlock *);
+               SharedBlock(Program::LayoutHash);
 
                const UInt8 *get_uniform_indices() const;
        };
 
        struct ProgramBlock
        {
+               Program::LayoutHash prog_hash;
                int bind_point;
-               UniformBlock *block;
-               SharedBlock *shared;
-
-               ProgramBlock();
-               ProgramBlock(int, SharedBlock *);
-       };
-
-       struct ProgramUniforms
-       {
-               std::vector<ProgramBlock> blocks;
-               Mask used;
-               Mask dirty;
+               int block_index;
+               union
+               {
+                       UniformBlock *block;
+                       struct
+                       {
+                               Mask used;
+                               Mask dirty;
+                       } masks;
+               };
 
-               ProgramUniforms();
+               ProgramBlock(Program::LayoutHash);
        };
 
-       typedef std::map<Program::LayoutHash, SharedBlock> BlockMap;
-       typedef std::map<Program::LayoutHash, ProgramUniforms> ProgramMap;
-
        // XXX All these mutables are a bit silly, but I'm out of better ideas
        const Program *tied_program;
        std::vector<TaggedUniform> uniforms;
-       mutable BlockMap blocks;
-       mutable ProgramMap programs;
-       mutable UniformBlock *last_block;
+       mutable std::vector<SharedBlock> blocks;
+       mutable std::vector<ProgramBlock> programs;
+       mutable BufferBackedUniformBlock *last_buffer_block;
        mutable Buffer *buffer;
        mutable Mask dirty;
 
@@ -236,11 +234,10 @@ public:
        const Uniform *find_uniform(Tag) const;
 
 private:
-       static bool uniform_tag_compare(const TaggedUniform &, Tag);
        int find_uniform_index(Tag) const;
+       std::vector<ProgramBlock>::iterator get_program(const Program &) const;
        void update_block_uniform_indices(SharedBlock &, const Program::UniformBlockInfo &) const;
        void update_block(SharedBlock &, const Program::UniformBlockInfo &) const;
-       SharedBlock *get_shared_block(const Program::UniformBlockInfo &) const;
 
 public:
        /** Applies uniform blocks for the currently bound program, creating them