X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Fprogramdata.cpp;h=79b559019d116b196502267222e5c37e6985642d;hb=1509585cd1adcf7cff7beecc72e953583a2ea07e;hp=b21c395cf04c27f1084492294dbd2635993af5df;hpb=f1244e29afd2a36aafc2373d485457b4cb0411ff;p=libs%2Fgl.git diff --git a/source/render/programdata.cpp b/source/render/programdata.cpp index b21c395c..79b55901 100644 --- a/source/render/programdata.cpp +++ b/source/render/programdata.cpp @@ -7,6 +7,7 @@ #include "color.h" #include "error.h" #include "matrix.h" +#include "pipelinestate.h" #include "program.h" #include "programdata.h" #include "uniform.h" @@ -596,15 +597,10 @@ void ProgramData::update_block(SharedBlock &block, const Program::UniformBlockIn } } -void ProgramData::apply() const +vector::const_iterator ProgramData::prepare_program(const Program &prog) 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(); + vector::iterator prog_begin = get_program(prog); Mask force_dirty = (dirty==ALL_ONES ? ALL_ONES : 0U); Mask affected = (dirty&prog_begin->masks.used) | force_dirty; @@ -623,7 +619,7 @@ void ProgramData::apply() const dirty = 0; } - const vector &block_infos = prog->get_uniform_blocks(); + const vector &block_infos = prog.get_uniform_blocks(); if(prog_begin->masks.dirty==ALL_ONES) { @@ -679,9 +675,25 @@ void ProgramData::apply() const } } - for(vector::iterator i=prog_begin+1; (i!=programs.end() && i->prog_hash==prog_hash); ++i) + return prog_begin; +} + +void ProgramData::apply(const Program &prog, PipelineState &state) const +{ + vector::const_iterator prog_begin = prepare_program(prog); + Program::LayoutHash prog_hash = prog_begin->prog_hash; + for(vector::const_iterator i=prog_begin+1; (i!=programs.end() && i->prog_hash==prog_hash); ++i) if(i->block) - i->block->apply(i->bind_point); + { + if(i->bind_point<0) + state.set_uniforms(static_cast(i->block)); + else + { + const BufferBackedUniformBlock *block = static_cast(i->block); + block->refresh(); + state.set_uniform_block(i->bind_point, block); + } + } } void ProgramData::set_debug_name(const string &name)