X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Fprogramdata.h;h=9d08219ef84368943f6cb4535466bc61a1c742af;hb=190a7e11237351f6b730c28f7b16f183e8adc69c;hp=474ca4e8d326d3bebbadb567cea32263175ffc5e;hpb=729a477b47e97aea41f3f0b5db551f02bf70d1ee;p=libs%2Fgl.git diff --git a/source/render/programdata.h b/source/render/programdata.h index 474ca4e8..9d08219e 100644 --- a/source/render/programdata.h +++ b/source/render/programdata.h @@ -1,7 +1,6 @@ #ifndef MSP_GL_PROGRAMDATA_H_ #define MSP_GL_PROGRAMDATA_H_ -#include #include #include #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 uniforms; std::vector uniform_data; - unsigned generation; + unsigned generation = 0; mutable std::vector blocks; mutable std::vector 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::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 &);