X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fpipelinestate.cpp;h=fd474d28f3f106d0dcdf1226a28d42755877b09d;hb=c356a20547afae97b412da36e0b0a7d51e879401;hp=076eb333d29b127a0d08ef38ec158223fb957179;hpb=58c5647c775e38dd08a64ad435dfe0673a62fcd1;p=libs%2Fgl.git diff --git a/source/core/pipelinestate.cpp b/source/core/pipelinestate.cpp index 076eb333..fd474d28 100644 --- a/source/core/pipelinestate.cpp +++ b/source/core/pipelinestate.cpp @@ -1,6 +1,8 @@ #include #include +#include "error.h" #include "pipelinestate.h" +#include "uniformblock.h" using namespace std; @@ -43,27 +45,37 @@ void PipelineState::set_uniform_block(int binding, const UniformBlock *block) if(i==uniform_blocks.end() || i->binding!=binding) i = uniform_blocks.insert(i, BoundUniformBlock(binding)); i->used = block; - if(block!=i->block || binding<0) + const Buffer *buffer = (block ? block->get_buffer() : 0); + if(block!=i->block || buffer!=i->buffer || binding<0) { i->block = block; + i->buffer = buffer; i->changed = true; changes |= UNIFORMS; } } void PipelineState::set_texture(unsigned binding, const Texture *tex, const Sampler *samp) +{ + set_texture(binding, tex, -1, samp); +} + +void PipelineState::set_texture(unsigned binding, const Texture *tex, int level, const Sampler *samp) { if((tex!=0)!=(samp!=0)) throw invalid_argument("PipelineState::set_texture"); + if(level>=0 && !can_bind_tex_level(level)) + throw invalid_operation("PipelineState::set_texture"); auto i = lower_bound_member(textures, binding, &BoundTexture::binding); if(i==textures.end() || i->binding!=binding) i = textures.insert(i, BoundTexture(binding)); i->used = (tex && samp); - if(tex!=i->texture || samp!=i->sampler) + if(tex!=i->texture || level!=i->level || samp!=i->sampler) { i->texture = tex; i->sampler = samp; + i->level = level; i->changed = true; changes |= TEXTURES; }