X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frender%2Fprogramdata.cpp;h=fc9b30a99e14b5011eba96d426f555a5467012f1;hp=4133b9acaabb207fbd63d077ca9bc8da7bcca2c4;hb=HEAD;hpb=fcde8390ad577fe434dcd4b29e0f410d29f867c9 diff --git a/source/render/programdata.cpp b/source/render/programdata.cpp deleted file mode 100644 index 4133b9ac..00000000 --- a/source/render/programdata.cpp +++ /dev/null @@ -1,976 +0,0 @@ -#include -#include -#include -#include -#include -#include "buffer.h" -#include "color.h" -#include "error.h" -#include "matrix.h" -#include "program.h" -#include "programdata.h" -#include "uniform.h" -#include "uniformblock.h" -#include "vector.h" - -using namespace std; - -namespace Msp { -namespace GL { - -ProgramData::ProgramData(const Program *p): - tied_program(p), - generation(0), - last_buffer_block(0), - buffer(0), - dirty(0) -{ } - -// Blocks are intentionally left uncopied -ProgramData::ProgramData(const ProgramData &other): - tied_program(other.tied_program), - uniforms(other.uniforms), - generation(other.generation), - last_buffer_block(0), - buffer(0), - dirty(0) -{ - for(vector::iterator i=uniforms.begin(); i!=uniforms.end(); ++i) - i->value = i->value->clone(); -} - -ProgramData::ProgramData(const ProgramData &other, const Program *p): - tied_program(p), - last_buffer_block(0), - buffer(0), - dirty(0) -{ - if(tied_program) - { - for(vector::const_iterator i=other.uniforms.begin(); i!=other.uniforms.end(); ++i) - validate_tag(i->tag); - } - - uniforms = other.uniforms; - for(vector::iterator i=uniforms.begin(); i!=uniforms.end(); ++i) - i->value = i->value->clone(); -} - -ProgramData &ProgramData::operator=(const ProgramData &other) -{ - tied_program = other.tied_program; - - uniforms = other.uniforms; - for(vector::iterator i=uniforms.begin(); i!=uniforms.end(); ++i) - i->value = i->value->clone(); - - for(vector::iterator i=blocks.begin(); i!=blocks.end(); ++i) - delete i->block; - programs.clear(); - - last_buffer_block = 0; - buffer = 0; - dirty = 0; - - return *this; -} - -ProgramData::~ProgramData() -{ - for(vector::iterator i=uniforms.begin(); i!=uniforms.end(); ++i) - delete i->value; - for(vector::iterator i=blocks.begin(); i!=blocks.end(); ++i) - { - if(i->indices.type_flag==0xFE) - delete[] i->indices.dynamic.values; - delete i->block; - } - delete buffer; -} - -void ProgramData::uniform(Tag tag, Uniform *uni) -{ - try - { - if(!validate_tag(tag)) - { - delete uni; - return; - } - } - catch(...) - { - delete uni; - throw; - } - - int i = find_uniform_index(tag); - if(i<0) - return add_uniform(tag, uni); - - uniforms[i].replace_value(uni); - mark_dirty(1< -void ProgramData::uniform(Tag tag, V value) -{ - if(!validate_tag(tag)) - return; - - int i = find_uniform_index(tag); - if(i<0) - return add_uniform(tag, new T(value)); - - if(T *uni = dynamic_cast(uniforms[i].value)) - uni->set(value); - else - uniforms[i].replace_value(new T(value)); - - mark_dirty(1< -void ProgramData::uniform_array(Tag tag, unsigned n, V value) -{ - if(!validate_tag(tag)) - return; - - int i = find_uniform_index(tag); - if(i<0) - return add_uniform(tag, new UniformArray(n, value)); - - UniformArray *uni = dynamic_cast *>(uniforms[i].value); - if(uni && n==uni->size()) - uni->set(value); - else - uniforms[i].replace_value(new UniformArray(n, value)); - - mark_dirty(1<get_uniform_info(tag); - if(is_image(info.type)) - throw invalid_operation("ProgramData::uniform"); - } - return true; - } -#ifdef DEBUG - catch(const exception &e) - { - IO::print(IO::cerr, "Error while setting uniform %s: %s: %s\n", tag, Debug::demangle(typeid(e).name()), e.what()); - return false; - } -#endif -} - -void ProgramData::add_uniform(Tag tag, Uniform *uni) -{ - if(uniforms.size()>=MASK_BITS) - { - delete uni; - throw too_many_uniforms(tag.str()); - } - - vector::iterator j = lower_bound_member(uniforms, tag, &TaggedUniform::tag); - - TaggedUniform nu; - nu.tag = tag; - nu.value = uni; - uniforms.insert(j, nu); - - mark_dirty(ALL_ONES); -} - -void ProgramData::mark_dirty(Mask bits) -{ - if(!dirty) - ++generation; - dirty |= bits; -} - -void ProgramData::uniform(Tag tag, const Uniform &u) -{ - uniform(tag, u.clone()); -} - -void ProgramData::uniform(Tag tag, int v) -{ - uniform(tag, v); -} - -void ProgramData::uniform(Tag tag, float v) -{ - uniform(tag, v); -} - -void ProgramData::uniform(Tag tag, int v0, int v1) -{ - int va[2] = { v0, v1 }; - uniform2(tag, va); -} - -void ProgramData::uniform(Tag tag, float v0, float v1) -{ - float va[2] = { v0, v1 }; - uniform2(tag, va); -} - -void ProgramData::uniform2(Tag tag, const int *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform2(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform(Tag tag, int v0, int v1, int v2) -{ - int va[3] = { v0, v1, v2 }; - uniform3(tag, va); -} - -void ProgramData::uniform(Tag tag, float v0, float v1, float v2) -{ - float va[3] = { v0, v1, v2 }; - uniform3(tag, va); -} - -void ProgramData::uniform3(Tag tag, const int *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform3(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform(Tag tag, int v0, int v1, int v2, int v3) -{ - int va[4] = { v0, v1, v2, v3 }; - uniform4(tag, va); -} - -void ProgramData::uniform(Tag tag, float v0, float v1, float v2, float v3) -{ - float va[4] = { v0, v1, v2, v3 }; - uniform4(tag, va); -} - -void ProgramData::uniform(Tag tag, const Color &c) -{ - uniform(tag, c.r, c.g, c.b, c.a); -} - -void ProgramData::uniform4(Tag tag, const int *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform4(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform_matrix2(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform_matrix3x2(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform_matrix4x2(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform_matrix2x3(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform_matrix3(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform_matrix4x3(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform_matrix2x4(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform_matrix3x4(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform(Tag tag, const Matrix &m) -{ - uniform_matrix4(tag, m.data()); -} - -void ProgramData::uniform_matrix4(Tag tag, const float *v) -{ - uniform(tag, v); -} - -void ProgramData::uniform_array(Tag tag, unsigned n, const int *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform1_array(Tag tag, unsigned n, const int *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform1_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform2_array(Tag tag, unsigned n, const int *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform2_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform3_array(Tag tag, unsigned n, const int *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform3_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform4_array(Tag tag, unsigned n, const int *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform4_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform_matrix2_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform_matrix3x2_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform_matrix4x2_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform_matrix2x3_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform_matrix3_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform_matrix4x3_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform_matrix2x4_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform_matrix3x4_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::uniform_matrix4_array(Tag tag, unsigned n, const float *v) -{ - uniform_array(tag, n, v); -} - -void ProgramData::remove_uniform(Tag tag) -{ - vector::const_iterator i = lower_bound_member(uniforms, tag, &TaggedUniform::tag); - if(i==uniforms.end() || i->tag!=tag) - return; - - delete i->value; - uniforms.erase(i); - - mark_dirty(ALL_ONES); -} - -vector ProgramData::get_uniform_tags() const -{ - vector tags; - tags.reserve(uniforms.size()); - for(vector::const_iterator i=uniforms.begin(); i!=uniforms.end(); ++i) - tags.push_back(i->tag); - return tags; -} - -const Uniform &ProgramData::get_uniform(Tag tag) const -{ - int i = find_uniform_index(tag); - if(i<0) - throw key_error(tag); - return *uniforms[i].value; -} - -const Uniform *ProgramData::find_uniform(Tag tag) const -{ - int i = find_uniform_index(tag); - return (i>=0 ? uniforms[i].value : 0); -} - -int ProgramData::find_uniform_index(Tag tag) const -{ - vector::const_iterator i = lower_bound_member(uniforms, tag, &TaggedUniform::tag); - return ((i!=uniforms.end() && i->tag==tag) ? i-uniforms.begin() : -1); -} - -vector::iterator ProgramData::get_program(const Program &prog) const -{ - Program::LayoutHash prog_hash = prog.get_uniform_layout_hash(); - vector::iterator i = lower_bound_member(programs, prog_hash, &ProgramBlock::prog_hash); - if(i!=programs.end() && i->prog_hash==prog_hash) - return i; - - const vector &block_infos = prog.get_uniform_blocks(); - unsigned index = i-programs.begin(); - programs.insert(i, 1+block_infos.size(), ProgramBlock(prog_hash)); - - /* Block indices may change if new shared blocks need to be inserted. Store - the hashes so they can be matched up later. */ - vector block_hashes; - block_hashes.reserve(programs.size()); - for(vector::iterator j=programs.begin(); j!=programs.end(); ++j) - block_hashes.push_back(j->block_index>=0 ? blocks[j->block_index].block_hash : 0); - - for(unsigned j=0; j::iterator k = lower_bound_member(blocks, info.layout_hash, &SharedBlock::block_hash); - if(k==blocks.end() || k->block_hash!=info.layout_hash) - { - k = blocks.insert(k, SharedBlock(info.layout_hash)); - update_block_uniform_indices(*k, info); - } - } - - /* Reassign shared block indices from the stored hashes. */ - for(unsigned j=0; j::const_iterator k = lower_bound_member(blocks, hash, &SharedBlock::block_hash); - programs[j].block_index = k-blocks.begin(); - } - else - programs[j].block_index = -1; - } - - return programs.begin()+index; -} - -void ProgramData::update_block_uniform_indices(SharedBlock &block, const Program::UniformBlockInfo &info) const -{ - UInt8 *indices = block.indices.values; - if(info.uniforms.size()>16) - { - if(block.indices.type_flag==0xFD) - { - block.indices.dynamic.values = new UInt8[info.uniforms.size()]; - block.indices.type_flag = 0xFE; - } - indices = block.indices.dynamic.values; - } - - bool any_missing = false; - - block.used = 0; - for(unsigned i=0; itag); - if(j>=0) - { - indices[i] = j; - if(static_cast(j)=0) - { -#ifdef DEBUG - IO::print(IO::cerr, "Warning: not all uniforms for block %s are present\n", info.name); -#else - throw incomplete_uniform_block(info.name); -#endif - } - - block.dirty = block.used; - - if(block.used && !block.block) - { - if(info.bind_point>=0) - { - if(!buffer) - { - buffer = new Buffer(UNIFORM_BUFFER); - -#ifdef DEBUG - if(!debug_name.empty()) - buffer->set_debug_name(debug_name); -#endif - } - - BufferBackedUniformBlock *bb_block = new BufferBackedUniformBlock(info.data_size); - block.block = bb_block; - bb_block->use_buffer(buffer, last_buffer_block); - last_buffer_block = bb_block; - } - else - block.block = new DefaultUniformBlock; - } -} - -void ProgramData::update_block(SharedBlock &block, const Program::UniformBlockInfo &info) const -{ - const UInt8 *indices = block.get_uniform_indices(); - for(unsigned i=0; itype)) - ; // Temporarily ignore deprecated use of sampler uniforms in ProgramData - else if(indices[i]!=0xFF) - block.block->attach(*info.uniforms[i], *uniforms[indices[i]].value); - } -} - -void ProgramData::apply() const -{ - const Program *prog = Program::current(); - if(!prog) - throw invalid_operation("ProgramData::apply"); - - BufferBackedUniformBlock *old_last_block = last_buffer_block; - vector::iterator prog_begin = get_program(*prog); - Program::LayoutHash prog_hash = prog->get_uniform_layout_hash(); - - Mask force_dirty = (dirty==ALL_ONES ? ALL_ONES : 0U); - Mask affected = (dirty&prog_begin->masks.used) | force_dirty; - if(affected|prog_begin->masks.dirty) - { - /* If the global dirty flag affects this program, add it to per-block and - per-program dirty flags and clear the global flag. A previously unseen - program will cause this to happen if there's any dirty uniforms. */ - if(affected) - { - for(vector::iterator i=blocks.begin(); i!=blocks.end(); ++i) - i->dirty |= (dirty&i->used) | force_dirty; - for(vector::iterator i=programs.begin(); i!=programs.end(); ++i) - if(i->block_index<0) - i->masks.dirty |= (dirty&i->masks.used) | force_dirty; - dirty = 0; - } - - const vector &block_infos = prog->get_uniform_blocks(); - - if(prog_begin->masks.dirty==ALL_ONES) - { - /* The set of uniforms has changed since this program was last used. - Refresh uniform indices within the program's blocks. */ - prog_begin->masks.used = 0; - vector::iterator j = prog_begin+1; - for(vector::const_iterator i=block_infos.begin(); i!=block_infos.end(); ++i, ++j) - { - SharedBlock &shared = blocks[j->block_index]; - if(shared.dirty==ALL_ONES) - update_block_uniform_indices(shared, *i); - prog_begin->masks.used |= shared.used; - j->block = (shared.used ? shared.block : 0); - } - } - - // Update the contents of all dirty blocks. - bool buffered_blocks_updated = false; - vector::iterator j = prog_begin+1; - for(vector::const_iterator i=block_infos.begin(); i!=block_infos.end(); ++i, ++j) - { - SharedBlock &shared = blocks[j->block_index]; - if(shared.dirty) - { - update_block(shared, *i); - shared.dirty = 0; - buffered_blocks_updated |= (j->bind_point>=0); - } - } - - prog_begin->masks.dirty = 0; - - /* If any blocks stored in the buffer were updated, bind the buffer here - to avoid state thrashing. */ - if(buffered_blocks_updated && !ARB_direct_state_access) - buffer->bind(); - - if(last_buffer_block!=old_last_block) - { - unsigned required_size = last_buffer_block->get_required_buffer_size(); - if(last_buffer_block->get_required_buffer_size()>buffer->get_size()) - { - if(buffer->get_size()>0) - { - delete buffer; - buffer = new Buffer(UNIFORM_BUFFER); - last_buffer_block->change_buffer(buffer); - -#ifdef DEBUG - if(!debug_name.empty()) - buffer->set_debug_name(debug_name); -#endif - } - - buffer->storage(required_size); - } - } - } - - for(vector::iterator i=prog_begin+1; (i!=programs.end() && i->prog_hash==prog_hash); ++i) - if(i->block) - i->block->apply(i->bind_point); -} - -void ProgramData::set_debug_name(const string &name) -{ -#ifdef DEBUG - debug_name = name; - if(buffer) - buffer->set_debug_name(name); -#else - (void)name; -#endif -} - - -ProgramData::TaggedUniform::TaggedUniform(): - value(0) -{ } - -void ProgramData::TaggedUniform::replace_value(Uniform *v) -{ - /* UniformBlock does not copy the uniforms, so existing default blocks - will be left with stale pointers. This is not a problem as long as no - one stores pointers to the blocks and expects them to stay valid. */ - delete value; - value = v; -} - - -ProgramData::SharedBlock::SharedBlock(Program::LayoutHash h): - block_hash(h), - used(0), - dirty(0), - block(0) -{ - indices.type_flag = 0xFD; -} - -const UInt8 *ProgramData::SharedBlock::get_uniform_indices() const -{ - return (indices.type_flag==0xFE ? indices.dynamic.values : indices.values); -} - - -ProgramData::ProgramBlock::ProgramBlock(Program::LayoutHash h): - prog_hash(h), - bind_point(-1), - block_index(-1) -{ - masks.used = ALL_ONES; - masks.dirty = ALL_ONES; -} - - -ProgramData::Loader::Loader(ProgramData &pd): - DataFile::ObjectLoader(pd) -{ - add("uniform", &Loader::uniform1i); - add("uniform1i", &Loader::uniform1i); - add("uniform", &Loader::uniform1f); - add("uniform1f", &Loader::uniform1f); - add("uniform", &Loader::uniform2i); - add("uniform2i", &Loader::uniform2i); - add("uniform", &Loader::uniform2f); - add("uniform2f", &Loader::uniform2f); - add("uniform", &Loader::uniform3i); - add("uniform3i", &Loader::uniform3i); - add("uniform", &Loader::uniform3f); - add("uniform3f", &Loader::uniform3f); - add("uniform", &Loader::uniform4i); - add("uniform4i", &Loader::uniform4i); - add("uniform", &Loader::uniform4f); - add("uniform4f", &Loader::uniform4f); - add("uniform1i_array", &Loader::uniform1i_array); - add("uniform1f_array", &Loader::uniform1f_array); - add("uniform2f_array", &Loader::uniform2f_array); - add("uniform3f_array", &Loader::uniform3f_array); - add("uniform4f_array", &Loader::uniform4f_array); - add("uniform_array", &Loader::uniform_array); -} - -void ProgramData::Loader::uniform1i(const string &n, int v) -{ - obj.uniform(n, v); -} - -void ProgramData::Loader::uniform1f(const string &n, float v) -{ - obj.uniform(n, v); -} - -void ProgramData::Loader::uniform2i(const string &n, int v0, int v1) -{ - obj.uniform(n, v0, v1); -} - -void ProgramData::Loader::uniform2f(const string &n, float v0, float v1) -{ - obj.uniform(n, v0, v1); -} - -void ProgramData::Loader::uniform3i(const string &n, int v0, int v1, int v2) -{ - obj.uniform(n, v0, v1, v2); -} - -void ProgramData::Loader::uniform3f(const string &n, float v0, float v1, float v2) -{ - obj.uniform(n, v0, v1, v2); -} - -void ProgramData::Loader::uniform4i(const string &n, int v0, int v1, int v2, int v3) -{ - obj.uniform(n, v0, v1, v2, v3); -} - -void ProgramData::Loader::uniform4f(const string &n, float v0, float v1, float v2, float v3) -{ - obj.uniform(n, v0, v1, v2, v3); -} - -void ProgramData::Loader::uniform_array_(const string &n, DataType t, unsigned e) -{ - ArrayLoader ldr(t, e); - load_sub_with(ldr); - unsigned size = ldr.get_size(); - if(!size) - throw logic_error("empty uniform array"); - - DataType type = ldr.get_data_type(); - unsigned elem_size = ldr.get_element_size(); - if(type==INT) - { - const int *data = reinterpret_cast(ldr.get_data()); - if(elem_size==1) - obj.uniform1_array(n, size, data); - else if(elem_size==2) - obj.uniform2_array(n, size, data); - else if(elem_size==3) - obj.uniform3_array(n, size, data); - else if(elem_size==4) - obj.uniform4_array(n, size, data); - else - throw logic_error("unsupported combination of array type and element size"); - } - else if(type==FLOAT) - { - const float *data = reinterpret_cast(ldr.get_data()); - if(elem_size==1) - obj.uniform1_array(n, size, data); - else if(elem_size==2) - obj.uniform2_array(n, size, data); - else if(elem_size==3) - obj.uniform3_array(n, size, data); - else if(elem_size==4) - obj.uniform4_array(n, size, data); - else - throw logic_error("unsupported combination of array type and element size"); - } - else - throw logic_error("unsupported array type"); -} - -void ProgramData::Loader::uniform1i_array(const string &n) -{ - uniform_array_(n, INT, 1); -} - -void ProgramData::Loader::uniform1f_array(const string &n) -{ - uniform_array_(n, FLOAT, 1); -} - -void ProgramData::Loader::uniform2i_array(const string &n) -{ - uniform_array_(n, INT, 2); -} - -void ProgramData::Loader::uniform2f_array(const string &n) -{ - uniform_array_(n, FLOAT, 2); -} - -void ProgramData::Loader::uniform3i_array(const string &n) -{ - uniform_array_(n, INT, 3); -} - -void ProgramData::Loader::uniform3f_array(const string &n) -{ - uniform_array_(n, FLOAT, 3); -} - -void ProgramData::Loader::uniform4i_array(const string &n) -{ - uniform_array_(n, INT, 4); -} - -void ProgramData::Loader::uniform4f_array(const string &n) -{ - uniform_array_(n, FLOAT, 4); -} - -void ProgramData::Loader::uniform_array(const string &n) -{ - uniform_array_(n, static_cast(0), 0); -} - - -ProgramData::ArrayLoader::ArrayLoader(DataType t, unsigned e): - type(t), - element_size(e) -{ - add("uniform", &ArrayLoader::uniform1i); - add("uniform1i", &ArrayLoader::uniform1i); - add("uniform", &ArrayLoader::uniform1f); - add("uniform1f", &ArrayLoader::uniform1f); - add("uniform", &ArrayLoader::uniform2f); - add("uniform2f", &ArrayLoader::uniform2f); - add("uniform", &ArrayLoader::uniform3f); - add("uniform3f", &ArrayLoader::uniform3f); - add("uniform", &ArrayLoader::uniform4f); - add("uniform4f", &ArrayLoader::uniform4f); -} - -void ProgramData::ArrayLoader::uniform(DataType t, unsigned e, const void *v) -{ - if(element_size && (t!=type || e!=element_size)) - throw logic_error("heterogeneous array contents"); - - if(!element_size) - { - type = t; - element_size = e; - } - - const char *cv = reinterpret_cast(v); - data.insert(data.end(), cv, cv+element_size*4); -} - -void ProgramData::ArrayLoader::uniform1i(int v) -{ - uniform(INT, 1, &v); -} - -void ProgramData::ArrayLoader::uniform1f(float v) -{ - uniform(FLOAT, 1, &v); -} - -void ProgramData::ArrayLoader::uniform2i(int v0, int v1) -{ - int va[2] = { v0, v1 }; - uniform(INT, 2, va); -} - -void ProgramData::ArrayLoader::uniform2f(float v0, float v1) -{ - float va[2] = { v0, v1 }; - uniform(FLOAT, 2, va); -} - -void ProgramData::ArrayLoader::uniform3i(int v0, int v1, int v2) -{ - int va[3] = { v0, v1, v2 }; - uniform(INT, 3, va); -} - -void ProgramData::ArrayLoader::uniform3f(float v0, float v1, float v2) -{ - float va[3] = { v0, v1, v2 }; - uniform(FLOAT, 3, va); -} - -void ProgramData::ArrayLoader::uniform4i(int v0, int v1, int v2, int v3) -{ - int va[4] = { v0, v1, v2, v3 }; - uniform(INT, 4, va); -} - -void ProgramData::ArrayLoader::uniform4f(float v0, float v1, float v2, float v3) -{ - float va[4] = { v0, v1, v2, v3 }; - uniform(FLOAT, 4, va); -} - -} // namespace GL -} // namespace Msp