vram texture locks race condition
This commit is contained in:
parent
ee9e64a253
commit
0e20d5976b
|
@ -174,7 +174,7 @@ void vramlock_list_add(vram_block* block)
|
|||
|
||||
std::mutex vramlist_lock;
|
||||
|
||||
vram_block* libCore_vramlock_Lock(u32 start_offset64,u32 end_offset64,void* userdata)
|
||||
void libCore_vramlock_Lock(u32 start_offset64, u32 end_offset64, BaseTextureCacheData *texture)
|
||||
{
|
||||
vram_block* block=(vram_block* )malloc(sizeof(vram_block));
|
||||
|
||||
|
@ -195,17 +195,21 @@ vram_block* libCore_vramlock_Lock(u32 start_offset64,u32 end_offset64,void* user
|
|||
block->end=end_offset64;
|
||||
block->start=start_offset64;
|
||||
block->len=end_offset64-start_offset64+1;
|
||||
block->userdata=userdata;
|
||||
block->userdata = texture;
|
||||
block->type=64;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(vramlist_lock);
|
||||
|
||||
// This also protects vram if needed
|
||||
vramlock_list_add(block);
|
||||
if (texture->lock_block == nullptr)
|
||||
{
|
||||
// This also protects vram if needed
|
||||
vramlock_list_add(block);
|
||||
texture->lock_block = block;
|
||||
}
|
||||
else
|
||||
free(block);
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
bool VramLockedWriteOffset(size_t offset)
|
||||
|
@ -217,7 +221,7 @@ bool VramLockedWriteOffset(size_t offset)
|
|||
std::vector<vram_block *>& list = VramLocks[addr_hash];
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(vramlist_lock);
|
||||
std::lock_guard<std::mutex> lockguard(vramlist_lock);
|
||||
|
||||
for (auto& lock : list)
|
||||
{
|
||||
|
@ -716,8 +720,7 @@ void BaseTextureCacheData::Update()
|
|||
h = original_h;
|
||||
|
||||
//lock the texture to detect changes in it
|
||||
if (lock_block == nullptr)
|
||||
lock_block = libCore_vramlock_Lock(sa_tex,sa+size-1,this);
|
||||
libCore_vramlock_Lock(sa_tex, sa + size - 1, this);
|
||||
|
||||
UploadToGPU(upscaled_w, upscaled_h, (u8*)temp_tex_buffer, IsMipmapped(), mipmapped);
|
||||
if (config::DumpTextures)
|
||||
|
|
|
@ -643,9 +643,11 @@ struct vram_block
|
|||
void* userdata;
|
||||
};
|
||||
|
||||
class BaseTextureCacheData;
|
||||
|
||||
bool VramLockedWriteOffset(size_t offset);
|
||||
void libCore_vramlock_Unlock_block(vram_block *block);
|
||||
vram_block *libCore_vramlock_Lock(u32 start_offset, u32 end_offset, void *userdata);
|
||||
void libCore_vramlock_Lock(u32 start_offset, u32 end_offset, BaseTextureCacheData *texture);
|
||||
|
||||
void UpscalexBRZ(int factor, u32* source, u32* dest, int width, int height, bool has_alpha);
|
||||
|
||||
|
|
|
@ -287,8 +287,7 @@ void ReadRTTBuffer() {
|
|||
texture_data->Create();
|
||||
texture_data->texID = gl.rtt.tex;
|
||||
texture_data->dirty = 0;
|
||||
if (texture_data->lock_block == NULL)
|
||||
texture_data->lock_block = libCore_vramlock_Lock(texture_data->sa_tex, texture_data->sa + texture_data->size - 1, texture_data);
|
||||
libCore_vramlock_Lock(texture_data->sa_tex, texture_data->sa + texture_data->size - 1, texture_data);
|
||||
}
|
||||
gl.rtt.tex = 0;
|
||||
|
||||
|
|
|
@ -574,8 +574,7 @@ void TextureDrawer::EndRenderPass()
|
|||
//memset(&vram[fb_rtt.TexAddr << 3], '\0', size);
|
||||
|
||||
texture->dirty = 0;
|
||||
if (texture->lock_block == NULL)
|
||||
texture->lock_block = libCore_vramlock_Lock(texture->sa_tex, texture->sa + texture->size - 1, texture);
|
||||
libCore_vramlock_Lock(texture->sa_tex, texture->sa + texture->size - 1, texture);
|
||||
}
|
||||
Drawer::EndRenderPass();
|
||||
}
|
||||
|
|
|
@ -675,8 +675,7 @@ void OITTextureDrawer::EndFrame()
|
|||
//memset(&vram[fb_rtt.TexAddr << 3], '\0', size);
|
||||
|
||||
texture->dirty = 0;
|
||||
if (texture->lock_block == NULL)
|
||||
texture->lock_block = libCore_vramlock_Lock(texture->sa_tex, texture->sa + texture->size - 1, texture);
|
||||
libCore_vramlock_Lock(texture->sa_tex, texture->sa + texture->size - 1, texture);
|
||||
}
|
||||
OITDrawer::EndFrame();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue