From: Mikko Rasa Date: Sun, 25 Sep 2022 17:02:52 +0000 (+0300) Subject: Recreate ProgramData buffer when needed even if no blocks were updated X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0b9f7e786f7bf4c751c62f345a932916b113e40c;p=libs%2Fgl.git Recreate ProgramData buffer when needed even if no blocks were updated This can happen if setting a uniform triggers promotion of the buffer from static to streaming, but the next shader program does not use that uniform. --- diff --git a/source/materials/programdata.cpp b/source/materials/programdata.cpp index e7c17175..c641a7df 100644 --- a/source/materials/programdata.cpp +++ b/source/materials/programdata.cpp @@ -602,6 +602,7 @@ vector::const_iterator ProgramData::prepare_program(c UniformBlock *old_last_block = last_buffer_block; auto prog_begin = get_program(prog); + bool check_buffer = (buffer && !buffer->get_size()); Mask force_dirty = (dirty==ALL_ONES ? ALL_ONES : 0U); Mask affected = (dirty&prog_begin->masks.used) | force_dirty; if(affected|prog_begin->masks.dirty) @@ -655,16 +656,19 @@ vector::const_iterator ProgramData::prepare_program(c prog_begin->masks.dirty = 0; - if(last_buffer_block!=old_last_block || (buffer && !buffer->get_size())) + if(last_buffer_block!=old_last_block) + check_buffer = true; + } + + if(check_buffer) + { + unsigned required_size = last_buffer_block->get_required_buffer_size(streaming); + if(last_buffer_block->get_required_buffer_size()>buffer->get_size()) { - unsigned required_size = last_buffer_block->get_required_buffer_size(streaming); - if(last_buffer_block->get_required_buffer_size()>buffer->get_size()) - { - if(buffer->get_size()>0) - recreate_buffer(); + if(buffer->get_size()>0) + recreate_buffer(); - buffer->storage(required_size, (streaming ? STREAMING : STATIC)); - } + buffer->storage(required_size, (streaming ? STREAMING : STATIC)); } }