diff --git a/src/GPU3D_Deko.cpp b/src/GPU3D_Deko.cpp index 68b5be09b0..2cb77cfa71 100644 --- a/src/GPU3D_Deko.cpp +++ b/src/GPU3D_Deko.cpp @@ -8,6 +8,9 @@ #include #include +#define XXH_STATIC_LINKING_ONLY +#include "xxhash/xxhash.h" + #include using Gfx::EmuCmdBuf; @@ -635,9 +638,10 @@ DekoRenderer::TexCacheEntry& DekoRenderer::GetTexture(u32 texParam, u32 palBase) if (fmt != 7) { key |= (u64)palBase << 32; - if (fmt != 5) + if (fmt == 5) key &= ~((u64)1 << 29); } + //printf("%" PRIx64 " %" PRIx32 " %" PRIx32 "\n", key, texParam, palBase); assert(fmt != 0 && "no texture is not a texture format!"); @@ -724,6 +728,8 @@ DekoRenderer::TexCacheEntry& DekoRenderer::GetTexture(u32 texParam, u32 palBase) u8* texData = &GPU::VRAMFlat_Texture[addr]; u16* palData = (u16*)(GPU::VRAMFlat_TexPal + palAddr); + //assert(entry.TexPalStart+entry.TexPalSize <= 128*1024*1024); + bool color0Transparent = texParam & (1 << 29); switch (fmt) @@ -736,6 +742,14 @@ DekoRenderer::TexCacheEntry& DekoRenderer::GetTexture(u32 texParam, u32 palBase) } } + for (int i = 0; i < 2; i++) + { + if (entry.TextureRAMSize[i]) + entry.TextureHash[i] = XXH3_64bits(&GPU::VRAMFlat_Texture[entry.TextureRAMStart[i]], entry.TextureRAMSize[i]); + } + if (entry.TexPalSize) + entry.TexPalHash = XXH3_64bits(&GPU::VRAMFlat_TexPal[entry.TexPalStart], entry.TexPalSize); + auto& texArrays = TexArrays[widthLog2][heightLog2]; auto& freeTextures = FreeTextures[widthLog2][heightLog2]; @@ -846,7 +860,12 @@ void DekoRenderer::RenderFrame() for (u32 j = startEntry; j < startEntry + entriesCount; j++) { if (GetRangedBitMask(j, startBit, bitsCount) & textureDirty.Data[j]) - goto invalidate; + { + u64 newTexHash = XXH3_64bits(&GPU::VRAMFlat_Texture[entry.TextureRAMStart[i]], entry.TextureRAMSize[i]); + + if (newTexHash != entry.TextureHash[i]) + goto invalidate; + } } } } @@ -861,7 +880,11 @@ void DekoRenderer::RenderFrame() for (u32 j = startEntry; j < startEntry + entriesCount; j++) { if (GetRangedBitMask(j, startBit, bitsCount) & texPalDirty.Data[j]) - goto invalidate; + { + u64 newPalHash = XXH3_64bits(&GPU::VRAMFlat_TexPal[entry.TexPalStart], entry.TexPalSize); + if (newPalHash != entry.TexPalHash) + goto invalidate; + } } } diff --git a/src/GPU3D_Deko.h b/src/GPU3D_Deko.h index 071c7c1607..2c63ca7bbf 100644 --- a/src/GPU3D_Deko.h +++ b/src/GPU3D_Deko.h @@ -238,6 +238,9 @@ class DekoRenderer : public Renderer3D u32 TexPalStart, TexPalSize; u8 WidthLog2, HeightLog2; TexArrayEntry Texture; + + u64 TextureHash[2]; + u64 TexPalHash; }; std::unordered_map TexCache; diff --git a/src/frontend/switch/UploadBuffer.cpp b/src/frontend/switch/UploadBuffer.cpp index ce3bc79e38..6582e49432 100644 --- a/src/frontend/switch/UploadBuffer.cpp +++ b/src/frontend/switch/UploadBuffer.cpp @@ -28,8 +28,8 @@ DkGpuAddr UploadBuffer::UploadData(dk::CmdBuf cmdbuf, u32 size, u8* data) DkGpuAddr srcGpu = Gfx::DataHeap->GpuAddr(Buffers[CurBuffer]) + CurOffset; memcpy(srcCpu, data, size); - CurOffset += size + 31; - CurOffset &= ~31; + CurOffset += size + 63; + CurOffset &= ~63; return srcGpu; } diff --git a/src/frontend/switch/UploadBuffer.h b/src/frontend/switch/UploadBuffer.h index 29bf43634c..7aab8ad791 100644 --- a/src/frontend/switch/UploadBuffer.h +++ b/src/frontend/switch/UploadBuffer.h @@ -16,7 +16,7 @@ class UploadBuffer u32 LastFlushBuffer = 0; private: - static const u32 SegmentSize = 8*1024*1024; + static const u32 SegmentSize = 16*1024*1024; GpuMemHeap::Allocation Buffers[3]; dk::Fence Fences[3] = {}; u32 CurBuffer = 0, CurOffset = 0;