From 8c1f30bb3043bff6b7d204fc162395d1fcd817c5 Mon Sep 17 00:00:00 2001 From: Martino Fontana Date: Mon, 14 Sep 2026 15:30:33 +0200 Subject: VideoCommon: Option for byte to memset in RAM when `EFBToTextureEnable = True` The main use case is for games that in theory should be compatible with `EFBToTextureEnable = True`, as the CPU never reads the EFB texture and only writes to it completely. However, if what the CPU writes is only zeros, if the texture in RAM was already zeros then Dolphin wouldn't notice the change in RAM and thus wouldn't invalidate the texture in VRAM. This happens in Rhythm Heaven Fever, and with this change it doesn't require `EFBToTextureEnable = False` anymore. But there are other use cases, like setting a clear value that is closer to what the EFB copy would be, like in Excite Truck. (`EFBToTextureEnable` is still `False` by default.) Other games are more subjective (and not changed here): for instance Mario Kart Wii samples the EFB copy to decide whether to display a sun flare. Currently with `EFBToTextureEnable = True` (default) it will never be shown, but maybe someone would prefer for the flare to always be shown, even behind walls. The option currently only supports setting a single byte (that will be memset to the entire texture), as setting a color would be more complex given that a texture can be in multiple formats, and there is no use case (yet) for it. --- Source/Core/VideoCommon/TextureCacheBase.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 4e4567da8e..eb4e76c6a3 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -2625,12 +2625,19 @@ void TextureCacheBase::UninitializeEFBMemory(u8* dst, u32 stride, u32 bytes_per_ u32 num_blocks_y) { // Hack: Most games don't actually need the correct texture data in RAM - // and we can just keep a copy in VRAM. We zero the memory so we + // and we can just keep a copy in VRAM. We clear the memory so we // can check it hasn't changed before using our copy in VRAM. + // Note: Some games memset that memory (e.g. Rhythm Heaven Fever). + // In that case the clear byte must be different from the game's, + // otherwise the data in RAM doesn't change and Dolphin won't + // invalidate the stale texture in VRAM. + // Setting a clear byte different from 0 is also useful when the + // game does use the texture from RAM, if we can more closely + // resemble an actual EFB copy (e.g. Excite Truck). u8* ptr = dst; for (u32 i = 0; i < num_blocks_y; i++) { - std::memset(ptr, 0, bytes_per_row); + std::memset(ptr, g_ActiveConfig.uSkipEFBCopyToRamClearByte, bytes_per_row); ptr += stride; } } -- cgit v1.2.3