12
12
13
13
#include < imgui.h>
14
14
15
- #include < gf2/core/Log.h>
16
-
17
15
#include < gf2/graphics/RenderManager.h>
18
16
#include < gf2/graphics/RenderRecorder.h>
19
17
#include < gf2/graphics/Texture.h>
@@ -41,6 +39,8 @@ namespace gf {
41
39
42
40
// update textures
43
41
42
+ m_unused_textures.clear (); // these textures are not used anymore
43
+
44
44
if (data->Textures != nullptr ) {
45
45
for (ImTextureData* texture_data : *data->Textures ) {
46
46
if (texture_data->Status != ImTextureStatus_OK) {
@@ -157,7 +157,7 @@ namespace gf {
157
157
switch (data->Status ) {
158
158
case ImTextureStatus_WantCreate:
159
159
{
160
- Log::debug (" Creating a texture for imgui." );
160
+ // Log::debug("Creating a texture for imgui.");
161
161
162
162
const Vec2I size = { data->Width , data->Height };
163
163
auto texture = std::make_unique<Texture>(size, TextureUsage::TransferDestination | TextureUsage::Sampled, Format::Color8S, render_manager);
@@ -173,7 +173,7 @@ namespace gf {
173
173
174
174
case ImTextureStatus_WantUpdates:
175
175
{
176
- Log::debug (" Updating a texture for imgui." );
176
+ // Log::debug("Updating a texture for imgui.");
177
177
178
178
auto * texture = static_cast <Texture*>(data->BackendUserData );
179
179
texture->update (static_cast <std::size_t >(data->GetSizeInBytes ()), static_cast <const uint8_t *>(data->GetPixels ()), render_manager);
@@ -184,12 +184,13 @@ namespace gf {
184
184
185
185
case ImTextureStatus_WantDestroy:
186
186
{
187
- Log::debug (" Destroying a texture for imgui." );
187
+ // Log::debug("Destroying a texture for imgui.");
188
188
189
189
auto * texture = static_cast <Texture*>(data->BackendUserData );
190
190
191
191
auto iterator = std::find_if (m_textures.begin (), m_textures.end (), [texture](const std::unique_ptr<Texture>& other) { return other.get () == texture; });
192
192
assert (iterator != m_textures.end ());
193
+ m_unused_textures.push_back (std::move (*iterator)); // do not remove now, texture may still be in use for the current frame
193
194
m_textures.erase (iterator);
194
195
195
196
data->SetTexID (ImTextureID_Invalid);
0 commit comments