From 2295d60fdc95af80af03174753b7389a44896fc1 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Mon, 14 Aug 2017 23:07:39 -0500 Subject: [PATCH] VideoCommon: Output gamma now comes from the xfb copy --- Source/Core/VideoCommon/BPStructs.cpp | 6 +++--- Source/Core/VideoCommon/RenderBase.cpp | 4 ++-- Source/Core/VideoCommon/RenderBase.h | 3 +-- Source/Core/VideoCommon/TextureCacheBase.cpp | 3 ++- Source/Core/VideoCommon/TextureCacheBase.h | 3 ++- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 22e808fe90..bdba7468a8 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -233,7 +233,7 @@ static void BPWritten(const BPCmd& bp) bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24; g_texture_cache->CopyRenderTargetToTexture(destAddr, PE_copy.tp_realFormat(), destStride, is_depth_copy, srcRect, !!PE_copy.intensity_fmt, - !!PE_copy.half_scale, 1.0f); + !!PE_copy.half_scale, 1.0f, 1.0f); } else { @@ -262,7 +262,7 @@ static void BPWritten(const BPCmd& bp) bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24; g_texture_cache->CopyRenderTargetToTexture(destAddr, EFBCopyFormat::XFB, destStride, is_depth_copy, srcRect, false, - false, yScale); + false, yScale, s_gammaLUT[PE_copy.gamma]); // This stays in to signal end of a "frame" g_renderer->RenderToXFB(destAddr, srcRect, destStride, height, s_gammaLUT[PE_copy.gamma]); @@ -270,7 +270,7 @@ static void BPWritten(const BPCmd& bp) if (g_ActiveConfig.bImmediateXFB) { // below div two to convert from bytes to pixels - it expects width, not stride - g_renderer->Swap(destAddr, destStride / 2, destStride / 2, height, false, srcRect, CoreTiming::GetTicks(), s_gammaLUT[PE_copy.gamma]); + g_renderer->Swap(destAddr, destStride / 2, destStride / 2, height, false, srcRect, CoreTiming::GetTicks()); } else { diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index d438951944..67721caabc 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -599,7 +599,7 @@ void Renderer::RecordVideoMemory() } void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, - u64 ticks, float Gamma) + u64 ticks) { // Heuristic to detect if a GameCube game is in 16:9 anamorphic widescreen mode. if (!SConfig::GetInstance().bWii) @@ -646,7 +646,7 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const m_last_xfb_texture = xfb_entry->texture.get(); // TODO: merge more generic parts into VideoCommon - g_renderer->SwapImpl(xfb_entry->texture.get(), rc, ticks, Gamma); + g_renderer->SwapImpl(xfb_entry->texture.get(), rc, ticks, xfb_entry->gamma); m_fps_counter.Update(); update_frame_count = true; diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 07fd1424cd..75b6b12509 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -131,8 +131,7 @@ public: virtual void BBoxWrite(int index, u16 value) = 0; // Finish up the current frame, print some stats - void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, u64 ticks, - float Gamma = 1.0f); + void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, u64 ticks); virtual void SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ticks, float Gamma = 1.0f) = 0; PEControl::PixelFormat GetPrevPixelFormat() const { return m_prev_efb_format; } diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index beb5b584d8..c6df251723 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1108,7 +1108,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstFormat, u32 dstStride, bool is_depth_copy, const EFBRectangle& srcRect, bool isIntensity, - bool scaleByHalf, float y_scale) + bool scaleByHalf, float y_scale, float gamma) { // Emulation methods: // @@ -1558,6 +1558,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstF entry->SetGeneralParameters(dstAddr, 0, baseFormat, is_xfb_copy); entry->SetDimensions(tex_w, tex_h, 1); entry->y_scale = y_scale; + entry->gamma = gamma; entry->frameCount = FRAMECOUNT_INVALID; if (is_xfb_copy) diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index 96b36b6eba..76eb1b58db 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -88,6 +88,7 @@ public: bool should_force_safe_hashing = false; // for XFB bool is_xfb_copy = false; float y_scale = 1.0f; + float gamma = 1.0f; unsigned int native_width, native_height; // Texture dimensions from the GameCube's point of view @@ -190,7 +191,7 @@ public: virtual void BindTextures(); void CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstFormat, u32 dstStride, bool is_depth_copy, const EFBRectangle& srcRect, bool isIntensity, - bool scaleByHalf, float y_scale); + bool scaleByHalf, float y_scale, float gamma); virtual void ConvertTexture(TCacheEntry* entry, TCacheEntry* unconverted, const void* palette, TLUTFormat format) = 0;