ggpo: don't protect rtt texture vram if ggpo is enabled

tentative fix for flashing water reflection texture in vf4 during
netplay
This commit is contained in:
Flyinghead 2022-05-31 17:41:57 +02:00
parent 971d47eb42
commit ddcd3861d3
7 changed files with 47 additions and 21 deletions

View File

@ -214,23 +214,23 @@ void vramlock_list_add(vram_block* block)
std::mutex vramlist_lock;
void libCore_vramlock_Lock(u32 start_offset64, u32 end_offset64, BaseTextureCacheData *texture)
static void vramlock_Lock(u32 start, u32 end, BaseTextureCacheData *texture)
{
if (end_offset64 > VRAM_SIZE - 1)
if (end >= VRAM_SIZE)
{
WARN_LOG(PVR, "vramlock_Lock_64: end_offset64>(VRAM_SIZE-1) \n Tried to lock area out of vram , possibly bug on the pvr plugin");
end_offset64 = VRAM_SIZE - 1;
WARN_LOG(PVR, "vramlock_Lock: end >= VRAM_SIZE. Tried to lock area out of vram");
end = VRAM_SIZE - 1;
}
if (start_offset64 > end_offset64)
if (start > end)
{
WARN_LOG(PVR, "vramlock_Lock_64: start_offset64>end_offset64 \n Tried to lock negative block , possibly bug on the pvr plugin");
WARN_LOG(PVR, "vramlock_Lock: start > end. Tried to lock negative block");
return;
}
vram_block *block = new vram_block();
block->end = end_offset64;
block->start = start_offset64;
block->end = end;
block->start = start;
block->texture = texture;
{
@ -445,19 +445,28 @@ bool BaseTextureCacheData::NeedsUpdate() {
return rc;
}
void BaseTextureCacheData::protectVRam()
{
vramlock_Lock(sa_tex, sa + size - 1, this);
}
void BaseTextureCacheData::unprotectVRam()
{
std::lock_guard<std::mutex> lock(vramlist_lock);
if (lock_block)
libCore_vramlock_Unlock_block_wb(lock_block);
lock_block = nullptr;
}
bool BaseTextureCacheData::Delete()
{
if (custom_load_in_progress > 0)
return false;
{
std::lock_guard<std::mutex> lock(vramlist_lock);
if (lock_block)
libCore_vramlock_Unlock_block_wb(lock_block);
lock_block = nullptr;
}
unprotectVRam();
free(custom_image_data);
custom_image_data = nullptr;
return true;
}
@ -777,7 +786,7 @@ void BaseTextureCacheData::Update()
height = original_h;
//lock the texture to detect changes in it
libCore_vramlock_Lock(sa_tex, sa + size - 1, this);
protectVRam();
UploadToGPU(upscaled_w, upscaled_h, (u8*)temp_tex_buffer, IsMipmapped(), mipmapped);
if (config::DumpTextures)

View File

@ -564,7 +564,6 @@ struct vram_block
bool VramLockedWriteOffset(size_t offset);
bool VramLockedWrite(u8* address);
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);
@ -648,6 +647,9 @@ public:
bool NeedsUpdate();
virtual bool Delete();
virtual ~BaseTextureCacheData() = default;
void protectVRam();
void unprotectVRam();
static bool IsGpuHandledPaletted(TSP tsp, TCW tcw)
{
// Some palette textures are handled on the GPU

View File

@ -1338,7 +1338,10 @@ void DX11Renderer::readRttRenderTarget(u32 texAddress)
device->CreateShaderResourceView(texture->texture, &viewDesc, &texture->textureView.get());
texture->dirty = 0;
libCore_vramlock_Lock(texture->sa_tex, texture->sa + texture->size - 1, texture);
if (!config::GGPOEnable)
texture->protectVRam();
else
texture->unprotectVRam();
}
}
}

View File

@ -968,7 +968,10 @@ void D3DRenderer::readRttRenderTarget(u32 texAddress)
texture->texture = rttTexture;
texture->dirty = 0;
libCore_vramlock_Lock(texture->sa_tex, texture->sa + texture->size - 1, texture);
if (!config::GGPOEnable)
texture->protectVRam();
else
texture->unprotectVRam();
}
}
}

View File

@ -364,7 +364,10 @@ void ReadRTTBuffer()
texture_data->texID = gl.rtt.tex;
gl.rtt.tex = 0;
texture_data->dirty = 0;
libCore_vramlock_Lock(texture_data->sa_tex, texture_data->sa + texture_data->size - 1, texture_data);
if (!config::GGPOEnable)
texture_data->protectVRam();
else
texture_data->unprotectVRam();
}
gl.rtt.texAddress = ~0;
}

View File

@ -558,7 +558,10 @@ void TextureDrawer::EndRenderPass()
//memset(&vram[fb_rtt.TexAddr << 3], '\0', size);
texture->dirty = 0;
libCore_vramlock_Lock(texture->sa_tex, texture->sa + texture->size - 1, texture);
if (!config::GGPOEnable)
texture->protectVRam();
else
texture->unprotectVRam();
}
Drawer::EndRenderPass();
}

View File

@ -678,7 +678,10 @@ void OITTextureDrawer::EndFrame()
//memset(&vram[fb_rtt.TexAddr << 3], '\0', size);
texture->dirty = 0;
libCore_vramlock_Lock(texture->sa_tex, texture->sa + texture->size - 1, texture);
if (!config::GGPOEnable)
texture->protectVRam();
else
texture->unprotectVRam();
}
OITDrawer::EndFrame();
}