From 29d5fcb1674903600af6911f019641afcde1c72f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 20 Dec 2021 01:26:15 +0200 Subject: [PATCH] Use a streaming buffer for ProgramData only when needed --- source/render/programdata.cpp | 14 +++++++++++--- source/render/programdata.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/source/render/programdata.cpp b/source/render/programdata.cpp index 0aebdcd9..e7c17175 100644 --- a/source/render/programdata.cpp +++ b/source/render/programdata.cpp @@ -116,7 +116,15 @@ bool ProgramData::validate_tag(Tag tag) const void ProgramData::mark_dirty(Mask bits) { if(!dirty) + { + if(generation && !streaming) + { + streaming = true; + if(buffer && buffer->get_size()) + recreate_buffer(); + } ++generation; + } dirty |= bits; } @@ -647,15 +655,15 @@ vector::const_iterator ProgramData::prepare_program(c prog_begin->masks.dirty = 0; - if(last_buffer_block!=old_last_block) + if(last_buffer_block!=old_last_block || (buffer && !buffer->get_size())) { - unsigned required_size = last_buffer_block->get_required_buffer_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(); - buffer->storage(required_size, STREAMING); + buffer->storage(required_size, (streaming ? STREAMING : STATIC)); } } } diff --git a/source/render/programdata.h b/source/render/programdata.h index ac7a36ac..dbbf5f48 100644 --- a/source/render/programdata.h +++ b/source/render/programdata.h @@ -158,6 +158,7 @@ private: mutable std::vector programs; mutable UniformBlock *last_buffer_block = 0; mutable Buffer *buffer = 0; + bool streaming = false; mutable Mask dirty = 0; std::string debug_name; -- 2.45.2