diff --git a/bin/resources/shaders/dx11/convert.fx b/bin/resources/shaders/dx11/convert.fx index 5228468e52..f617352e92 100644 --- a/bin/resources/shaders/dx11/convert.fx +++ b/bin/resources/shaders/dx11/convert.fx @@ -312,7 +312,7 @@ PS_OUTPUT ps_convert_clut_8(PS_INPUT input) { float2 scale = BGColor.xy; uint2 offset = uint2(uint(EMODA), uint(EMODC)); - uint index = min(uint(input.p.x) + uint(DOFFSET), 240u); + uint index = min(uint(input.p.x) + uint(DOFFSET), 255u); // CLUT is arranged into 8 groups of 16x2, with the top-right and bottom-left quadrants swapped. // This can probably be done better.. diff --git a/bin/resources/shaders/opengl/convert.glsl b/bin/resources/shaders/opengl/convert.glsl index 32d5ae8e45..def3c8e666 100644 --- a/bin/resources/shaders/opengl/convert.glsl +++ b/bin/resources/shaders/opengl/convert.glsl @@ -335,7 +335,7 @@ uniform vec2 scale; void ps_convert_clut_8() { - uint index = min(uint(gl_FragCoord.x) + offset.z, 240u); + uint index = min(uint(gl_FragCoord.x) + offset.z, 255u); // CLUT is arranged into 8 groups of 16x2, with the top-right and bottom-left quadrants swapped. // This can probably be done better.. diff --git a/bin/resources/shaders/vulkan/convert.glsl b/bin/resources/shaders/vulkan/convert.glsl index 13f9a242b8..c911b36008 100644 --- a/bin/resources/shaders/vulkan/convert.glsl +++ b/bin/resources/shaders/vulkan/convert.glsl @@ -303,7 +303,7 @@ layout(push_constant) uniform cb10 void ps_convert_clut_8() { - uint index = min(uint(gl_FragCoord.x) + doffset, 240u); + uint index = min(uint(gl_FragCoord.x) + doffset, 255u); // CLUT is arranged into 8 groups of 16x2, with the top-right and bottom-left quadrants swapped. // This can probably be done better.. diff --git a/pcsx2/Docs/gamedb-schema.json b/pcsx2/Docs/gamedb-schema.json index 10c573473f..9946bdef0d 100644 --- a/pcsx2/Docs/gamedb-schema.json +++ b/pcsx2/Docs/gamedb-schema.json @@ -221,6 +221,11 @@ "minimum": 1, "maximum": 2 }, + "gpuTargetCLUT": { + "type": "integer", + "minimum": 0, + "maximum": 2 + }, "gpuPaletteConversion": { "type": "integer", "minimum": 0, diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index 6b4cc0b757..e3ead082c0 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -2269,7 +2269,7 @@ GSTexture* GSTextureCache::LookupPaletteSource(u32 CBP, u32 CPSM, u32 CBW, GSVec if (t->m_TEX0.PSM != CPSM || (CBW != 0 && t->m_TEX0.TBW != CBW)) continue; - GL_INS("Exact match on BP 0x%04x BW %u", t->m_TEX0.CBP, t->m_TEX0.TBW); + GL_INS("Exact match on BP 0x%04x BW %u", t->m_TEX0.TBP0, t->m_TEX0.TBW); this_offset.x = 0; this_offset.y = 0; } diff --git a/pcsx2/GameDatabase.cpp b/pcsx2/GameDatabase.cpp index d1149335c4..0fcc0d8786 100644 --- a/pcsx2/GameDatabase.cpp +++ b/pcsx2/GameDatabase.cpp @@ -361,6 +361,7 @@ static const char* s_gs_hw_fix_names[] = { "deinterlace", "cpuSpriteRenderBW", "cpuCLUTRender", + "gpuTargetCLUT", "gpuPaletteConversion", "getSkipCount", "beforeDraw", @@ -604,6 +605,9 @@ bool GameDatabaseSchema::GameEntry::configMatchesHWFix(const Pcsx2Config::GSOpti case GSHWFixId::CPUCLUTRender: return (config.UserHacks_CPUCLUTRender == value); + case GSHWFixId::GPUTargetCLUT: + return (static_cast(config.UserHacks_GPUTargetCLUTMode) == value); + case GSHWFixId::GPUPaletteConversion: return (config.GPUPaletteConversion == ((value > 1) ? (config.TexturePreloading == TexturePreloadingLevel::Full) : (value != 0))); @@ -753,6 +757,13 @@ u32 GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions& config.UserHacks_CPUCLUTRender = value; break; + case GSHWFixId::GPUTargetCLUT: + { + if (value >= 0 && value <= static_cast(GSGPUTargetCLUTMode::InsideTarget)) + config.UserHacks_GPUTargetCLUTMode = static_cast(value); + } + break; + case GSHWFixId::GPUPaletteConversion: { // if 2, enable paltex when preloading is full, otherwise leave as-is diff --git a/pcsx2/GameDatabase.h b/pcsx2/GameDatabase.h index c7ad063082..2250609d54 100644 --- a/pcsx2/GameDatabase.h +++ b/pcsx2/GameDatabase.h @@ -83,6 +83,7 @@ namespace GameDatabaseSchema Deinterlace, CPUSpriteRenderBW, CPUCLUTRender, + GPUTargetCLUT, GPUPaletteConversion, GetSkipCount, BeforeDraw,