Fix Katamari

This commit is contained in:
Henrik Rydgård 2022-08-26 23:47:22 +02:00
parent 693fd0870f
commit 6781dd5fe8
4 changed files with 9 additions and 9 deletions

View File

@ -1035,8 +1035,8 @@ void TextureCacheCommon::SetTextureFramebuffer(const AttachCandidate &candidate)
nextFramebufferTextureChannel_ = RASTER_COLOR;
if (framebufferManager_->UseBufferedRendering()) {
// Hack!
u64 depthUpperBits = channel == RASTER_DEPTH ? ((gstate.getTextureAddress(0) & 0x600000) >> 20) : 0;
// Detect when we need to apply the horizontal texture swizzle.
u64 depthUpperBits = (channel == RASTER_DEPTH && framebuffer->fb_format == GE_FORMAT_8888) ? ((gstate.getTextureAddress(0) & 0x600000) >> 20) : 0;
bool needsSpecialSwizzle = depthUpperBits == 2;
// We need to force it, since we may have set it on a texture before attaching.
@ -1931,6 +1931,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat();
ClutTexture clutTexture{};
bool smoothedDepal = false;
u32 depthUpperBits = 0;
if (need_depalettize && !g_Config.bDisableSlowFramebufEffects) {
clutTexture = textureShaderCache_->GetClutTexture(clutFormat, clutHash_, clutBufRaw_);
@ -1965,7 +1966,9 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
return;
}
textureShader = textureShaderCache_->GetDepalettizeShader(clutMode, texFormat, depth ? GE_FORMAT_DEPTH16 : framebuffer->fb_format, smoothedDepal);
depthUpperBits = (depth && framebuffer->fb_format == GE_FORMAT_8888) ? ((gstate.getTextureAddress(0) & 0x600000) >> 20) : 0;
textureShader = textureShaderCache_->GetDepalettizeShader(clutMode, texFormat, depth ? GE_FORMAT_DEPTH16 : framebuffer->fb_format, smoothedDepal, depthUpperBits);
gstate_c.SetUseShaderDepal(false, false);
}
@ -1973,7 +1976,6 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat();
ClutTexture clutTexture = textureShaderCache_->GetClutTexture(clutFormat, clutHash_, clutBufRaw_);
u64 depthUpperBits = depth ? ((gstate.getTextureAddress(0) & 0x600000) >> 20) : 0;
bool needsSpecialSwizzle = depthUpperBits == 2;
int depalWidth = framebuffer->renderWidth;

View File

@ -187,12 +187,10 @@ void TextureShaderCache::Decimate() {
}
}
Draw2DPipeline *TextureShaderCache::GetDepalettizeShader(uint32_t clutMode, GETextureFormat textureFormat, GEBufferFormat bufferFormat, bool smoothedDepal) {
Draw2DPipeline *TextureShaderCache::GetDepalettizeShader(uint32_t clutMode, GETextureFormat textureFormat, GEBufferFormat bufferFormat, bool smoothedDepal, u32 depthUpperBits) {
using namespace Draw;
// Generate an ID for depal shaders.
u64 depthUpperBits = bufferFormat == GE_FORMAT_DEPTH16 ? ((gstate.getTextureAddress(0) & 0x600000) >> 20) : 0;
u64 id = (depthUpperBits << 32) | (clutMode & 0xFFFFFF) | (textureFormat << 24) | (bufferFormat << 28);
auto shader = depalCache_.find(id);

View File

@ -43,7 +43,7 @@ public:
TextureShaderCache(Draw::DrawContext *draw, Draw2D *draw2D);
~TextureShaderCache();
Draw2DPipeline *GetDepalettizeShader(uint32_t clutMode, GETextureFormat texFormat, GEBufferFormat pixelFormat, bool smoothedDepal);
Draw2DPipeline *GetDepalettizeShader(uint32_t clutMode, GETextureFormat texFormat, GEBufferFormat pixelFormat, bool smoothedDepal, u32 depthUpperBits);
ClutTexture GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut);
Draw::SamplerState *GetSampler(bool linearFilter);

View File

@ -358,7 +358,7 @@ VulkanFragmentShader *ShaderManagerVulkan::GetFragmentShaderFromModule(VkShaderM
// instantaneous.
#define CACHE_HEADER_MAGIC 0xff51f420
#define CACHE_VERSION 19
#define CACHE_VERSION 20
struct VulkanCacheHeader {
uint32_t magic;
uint32_t version;