diff --git a/core/rend/TexCache.h b/core/rend/TexCache.h index d5e3e6045a..5122184c03 100644 --- a/core/rend/TexCache.h +++ b/core/rend/TexCache.h @@ -592,6 +592,7 @@ class BaseTextureCacheData Updates = other.Updates; palette_hash = other.palette_hash; texture_hash = other.texture_hash; + old_vqtexture_hash = other.old_vqtexture_hash; old_texture_hash = other.old_texture_hash; std::swap(custom_image_data, other.custom_image_data); custom_width = other.custom_width; diff --git a/core/rend/gles/gles.h b/core/rend/gles/gles.h index b608aba51e..cf4084cfa8 100755 --- a/core/rend/gles/gles.h +++ b/core/rend/gles/gles.h @@ -452,13 +452,13 @@ extern struct ShaderUniforms_t class TextureCacheData final : public BaseTextureCacheData { public: - TextureCacheData(TSP tsp, TCW tcw) : BaseTextureCacheData(tsp, tcw), texID(glcache.GenTexture()) { + TextureCacheData(TSP tsp, TCW tcw) : BaseTextureCacheData(tsp, tcw) { } TextureCacheData(TextureCacheData&& other) : BaseTextureCacheData(std::move(other)) { std::swap(texID, other.texID); } - GLuint texID; //gl texture + GLuint texID = 0; //gl texture std::string GetId() override { return std::to_string(texID); } void UploadToGPU(int width, int height, const u8 *temp_tex_buffer, bool mipmapped, bool mipmapsIncluded = false) override; bool Delete() override; diff --git a/core/rend/gles/gltex.cpp b/core/rend/gles/gltex.cpp index 2c00bd7a26..fa4f838875 100644 --- a/core/rend/gles/gltex.cpp +++ b/core/rend/gles/gltex.cpp @@ -46,6 +46,8 @@ static void getOpenGLTexParams(TextureType texType, u32& bytesPerPixel, GLuint& void TextureCacheData::UploadToGPUGl2(int width, int height, const u8 *temp_tex_buffer, bool mipmapped, bool mipmapsIncluded) { + if (texID == 0) + texID = glcache.GenTexture(); glcache.BindTexture(GL_TEXTURE_2D, texID); GLuint comps; GLuint gltype; @@ -77,7 +79,6 @@ void TextureCacheData::UploadToGPUGl2(int width, int height, const u8 *temp_tex_ void TextureCacheData::UploadToGPUGl4(int width, int height, const u8 *temp_tex_buffer, bool mipmapped, bool mipmapsIncluded) { #if !defined(GLES2) && (!defined(__APPLE__) || defined(TARGET_IPHONE)) - glcache.BindTexture(GL_TEXTURE_2D, texID); GLuint comps; GLuint gltype; GLuint internalFormat; @@ -94,8 +95,15 @@ void TextureCacheData::UploadToGPUGl4(int width, int height, const u8 *temp_tex_ dim >>= 1; } } - if (Updates == 1) + if (texID == 0) + { + texID = glcache.GenTexture(); + glcache.BindTexture(GL_TEXTURE_2D, texID); glTexStorage2D(GL_TEXTURE_2D, mipmapLevels, internalFormat, width, height); + } + else { + glcache.BindTexture(GL_TEXTURE_2D, texID); + } if (mipmapsIncluded) { for (int i = 0; i < mipmapLevels; i++) { @@ -133,8 +141,10 @@ bool TextureCacheData::Delete() if (!BaseTextureCacheData::Delete()) return false; - if (texID) + if (texID != 0) { glcache.DeleteTextures(1, &texID); + texID = 0; + } return true; } @@ -276,7 +286,7 @@ BaseTextureCacheData *OpenGLRenderer::GetTexture(TSP tsp, TCW tcw) else if (tf->IsCustomTextureAvailable()) { TexCache.DeleteLater(tf->texID); - tf->texID = glcache.GenTexture(); + tf->texID = 0; tf->CheckCustomTexture(); }