gl: fully recreate opengl texture when loading a custom one
Regenerate texID and call glTexStorage2D when loading a custom texture (GL 4.2+, GLES3). rend: missing old_vqtexture_hash in move constructor.
This commit is contained in:
parent
de89d8cfed
commit
3ffb09ec72
|
@ -592,6 +592,7 @@ public:
|
|||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue