]> git.tdb.fi Git - libs/gl.git/commitdiff
Recreate ProgramData buffer when needed even if no blocks were updated
authorMikko Rasa <tdb@tdb.fi>
Sun, 25 Sep 2022 17:02:52 +0000 (20:02 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 25 Sep 2022 17:21:57 +0000 (20:21 +0300)
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.

source/materials/programdata.cpp

index e7c171754aed006dab1ecbdcedd272ddd894a396..c641a7dfc9ce6061158b648f5a6defcfbfc1420d 100644 (file)
@@ -602,6 +602,7 @@ vector<ProgramData::ProgramBlock>::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<ProgramData::ProgramBlock>::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));
                }
        }