custom tex: recreate gl/vk texture when loading custom tex. vk crash

This commit is contained in:
Flyinghead 2020-02-19 14:31:35 +01:00
parent 1cf4c36ede
commit e2b3ef147d
5 changed files with 26 additions and 10 deletions

View File

@ -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;
}

View File

@ -707,6 +707,11 @@ struct BaseTextureCacheData
}
}
bool IsCustomTextureAvailable()
{
return custom_load_in_progress == 0 && custom_image_data != NULL;
}
void Create();
void ComputeHash();
void Update();

View File

@ -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++;
}

View File

@ -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();
}

View File

@ -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();
}