]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/programdata.h
Update and improve documentation
[libs/gl.git] / source / render / programdata.h
index 474ca4e8d326d3bebbadb567cea32263175ffc5e..9d08219ef84368943f6cb4535466bc61a1c742af 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef MSP_GL_PROGRAMDATA_H_
 #define MSP_GL_PROGRAMDATA_H_
 
-#include <map>
 #include <stdexcept>
 #include <msp/datafile/objectloader.h>
 #include "datatype.h"
@@ -21,17 +20,17 @@ public:
 };
 
 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.
+Stores uniform values 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.
@@ -103,12 +102,10 @@ private:
        struct TaggedUniform
        {
                Tag tag;
-               DataType type;
-               unsigned array_size;
-               unsigned data_offset;
-               unsigned data_size;
-
-               TaggedUniform();
+               DataType type = VOID;
+               unsigned array_size = 0;
+               unsigned data_offset = 0;
+               unsigned data_size = 0;
        };
 
        struct SharedBlock
@@ -155,12 +152,12 @@ private:
        const Program *tied_program;
        std::vector<TaggedUniform> uniforms;
        std::vector<char> uniform_data;
-       unsigned generation;
+       unsigned generation = 0;
        mutable std::vector<SharedBlock> blocks;
        mutable std::vector<ProgramBlock> programs;
-       mutable UniformBlock *last_buffer_block;
-       mutable Buffer *buffer;
-       mutable Mask dirty;
+       mutable UniformBlock *last_buffer_block = 0;
+       mutable Buffer *buffer = 0;
+       mutable Mask dirty = 0;
        std::string debug_name;
 
 public:
@@ -247,6 +244,8 @@ private:
 
        std::vector<ProgramBlock>::const_iterator prepare_program(const Program &) const;
 public:
+       /** Creates or updates UniformBlocks for a specific program if necessary,
+       then sets them to the PipelineState. */
        void apply(const Program &, PipelineState &) const;
 
        void set_debug_name(const std::string &);