#ifndef MSP_GL_PROGRAMDATA_H_
#define MSP_GL_PROGRAMDATA_H_
-#include <map>
#include <stdexcept>
#include <msp/datafile/objectloader.h>
#include "datatype.h"
};
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.
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
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:
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 &);