diff --git a/core/rend/TexCache.cpp b/core/rend/TexCache.cpp index a64312193..b2d9c246c 100644 --- a/core/rend/TexCache.cpp +++ b/core/rend/TexCache.cpp @@ -765,7 +765,7 @@ void BaseTextureCacheData::Update() void BaseTextureCacheData::CheckCustomTexture() { - if (custom_load_in_progress == 0 && custom_image_data != NULL) + if (IsCustomTextureAvailable()) { tex_type = TextureType::_8888; UploadToGPU(custom_width, custom_height, custom_image_data, false); @@ -968,7 +968,7 @@ u8* loadPNGData(const string& fname, int &width, int &height) if (!file) { - EMUERROR("Error opening %s\n", filename); + EMUERROR("Error opening %s", filename); return NULL; } @@ -1102,7 +1102,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height, bool alpha, u32 rowPitch FILE *fp = fopen("screenshot.png", "wb"); if (fp == NULL) { - ERROR_LOG(RENDERER, "Failed to open screenshot.png for writing\n"); + ERROR_LOG(RENDERER, "Failed to open screenshot.png for writing"); return; } diff --git a/core/rend/TexCache.h b/core/rend/TexCache.h index ef5ccf9df..0e85e7eab 100644 --- a/core/rend/TexCache.h +++ b/core/rend/TexCache.h @@ -707,6 +707,11 @@ struct BaseTextureCacheData } } + bool IsCustomTextureAvailable() + { + return custom_load_in_progress == 0 && custom_image_data != NULL; + } + void Create(); void ComputeHash(); void Update(); diff --git a/core/rend/gles/gltex.cpp b/core/rend/gles/gltex.cpp index 83b1c6b8b..845fa84a4 100644 --- a/core/rend/gles/gltex.cpp +++ b/core/rend/gles/gltex.cpp @@ -416,7 +416,12 @@ u64 gl_GetTexture(TSP tsp, TCW tcw) tf->Update(); else { - tf->CheckCustomTexture(); + if (tf->IsCustomTextureAvailable()) + { + glcache.DeleteTextures(1, &tf->texID); + tf->texID = glcache.GenTexture(); + tf->CheckCustomTexture(); + } TexCacheHits++; } diff --git a/core/rend/vulkan/oit/oit_renderer.cpp b/core/rend/vulkan/oit/oit_renderer.cpp index 68a859592..f67c17530 100644 --- a/core/rend/vulkan/oit/oit_renderer.cpp +++ b/core/rend/vulkan/oit/oit_renderer.cpp @@ -256,13 +256,16 @@ public: if (tf->NeedsUpdate()) { textureCache.DestroyLater(tf); - tf->SetCommandBuffer(texCommandPool.Allocate()); tf->Update(); - tf->SetCommandBuffer(nullptr); } - else + else if (tf->IsCustomTextureAvailable()) + { + textureCache.DestroyLater(tf); + tf->SetCommandBuffer(texCommandPool.Allocate()); tf->CheckCustomTexture(); + } + tf->SetCommandBuffer(nullptr); return tf->GetIntId(); } diff --git a/core/rend/vulkan/vulkan_renderer.cpp b/core/rend/vulkan/vulkan_renderer.cpp index f80c0d8c2..238c8cf1e 100644 --- a/core/rend/vulkan/vulkan_renderer.cpp +++ b/core/rend/vulkan/vulkan_renderer.cpp @@ -244,13 +244,16 @@ public: if (tf->NeedsUpdate()) { textureCache.DestroyLater(tf); - tf->SetCommandBuffer(texCommandPool.Allocate()); tf->Update(); - tf->SetCommandBuffer(nullptr); } - else + else if (tf->IsCustomTextureAvailable()) + { + textureCache.DestroyLater(tf); + tf->SetCommandBuffer(texCommandPool.Allocate()); tf->CheckCustomTexture(); + } + tf->SetCommandBuffer(nullptr); return tf->GetIntId(); }