VideoCommon: Output gamma now comes from the xfb copy

This commit is contained in:
iwubcode 2017-08-14 23:07:39 -05:00
parent 7f0834c919
commit 2295d60fdc
5 changed files with 10 additions and 9 deletions

View File

@ -233,7 +233,7 @@ static void BPWritten(const BPCmd& bp)
bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24; bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24;
g_texture_cache->CopyRenderTargetToTexture(destAddr, PE_copy.tp_realFormat(), destStride, g_texture_cache->CopyRenderTargetToTexture(destAddr, PE_copy.tp_realFormat(), destStride,
is_depth_copy, srcRect, !!PE_copy.intensity_fmt, is_depth_copy, srcRect, !!PE_copy.intensity_fmt,
!!PE_copy.half_scale, 1.0f); !!PE_copy.half_scale, 1.0f, 1.0f);
} }
else else
{ {
@ -262,7 +262,7 @@ static void BPWritten(const BPCmd& bp)
bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24; bool is_depth_copy = bpmem.zcontrol.pixel_format == PEControl::Z24;
g_texture_cache->CopyRenderTargetToTexture(destAddr, EFBCopyFormat::XFB, destStride, g_texture_cache->CopyRenderTargetToTexture(destAddr, EFBCopyFormat::XFB, destStride,
is_depth_copy, srcRect, false, is_depth_copy, srcRect, false,
false, yScale); false, yScale, s_gammaLUT[PE_copy.gamma]);
// This stays in to signal end of a "frame" // This stays in to signal end of a "frame"
g_renderer->RenderToXFB(destAddr, srcRect, destStride, height, s_gammaLUT[PE_copy.gamma]); 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) if (g_ActiveConfig.bImmediateXFB)
{ {
// below div two to convert from bytes to pixels - it expects width, not stride // 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 else
{ {

View File

@ -599,7 +599,7 @@ void Renderer::RecordVideoMemory()
} }
void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, 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. // Heuristic to detect if a GameCube game is in 16:9 anamorphic widescreen mode.
if (!SConfig::GetInstance().bWii) 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(); m_last_xfb_texture = xfb_entry->texture.get();
// TODO: merge more generic parts into VideoCommon // 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(); m_fps_counter.Update();
update_frame_count = true; update_frame_count = true;

View File

@ -131,8 +131,7 @@ public:
virtual void BBoxWrite(int index, u16 value) = 0; virtual void BBoxWrite(int index, u16 value) = 0;
// Finish up the current frame, print some stats // Finish up the current frame, print some stats
void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, u64 ticks, void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc, u64 ticks);
float Gamma = 1.0f);
virtual void SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ticks, float Gamma = 1.0f) = 0; virtual void SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ticks, float Gamma = 1.0f) = 0;
PEControl::PixelFormat GetPrevPixelFormat() const { return m_prev_efb_format; } PEControl::PixelFormat GetPrevPixelFormat() const { return m_prev_efb_format; }

View File

@ -1108,7 +1108,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::GetTexture(u32 address, u32 wid
void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstFormat, void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstFormat,
u32 dstStride, bool is_depth_copy, u32 dstStride, bool is_depth_copy,
const EFBRectangle& srcRect, bool isIntensity, const EFBRectangle& srcRect, bool isIntensity,
bool scaleByHalf, float y_scale) bool scaleByHalf, float y_scale, float gamma)
{ {
// Emulation methods: // Emulation methods:
// //
@ -1558,6 +1558,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstF
entry->SetGeneralParameters(dstAddr, 0, baseFormat, is_xfb_copy); entry->SetGeneralParameters(dstAddr, 0, baseFormat, is_xfb_copy);
entry->SetDimensions(tex_w, tex_h, 1); entry->SetDimensions(tex_w, tex_h, 1);
entry->y_scale = y_scale; entry->y_scale = y_scale;
entry->gamma = gamma;
entry->frameCount = FRAMECOUNT_INVALID; entry->frameCount = FRAMECOUNT_INVALID;
if (is_xfb_copy) if (is_xfb_copy)

View File

@ -88,6 +88,7 @@ public:
bool should_force_safe_hashing = false; // for XFB bool should_force_safe_hashing = false; // for XFB
bool is_xfb_copy = false; bool is_xfb_copy = false;
float y_scale = 1.0f; float y_scale = 1.0f;
float gamma = 1.0f;
unsigned int native_width, unsigned int native_width,
native_height; // Texture dimensions from the GameCube's point of view native_height; // Texture dimensions from the GameCube's point of view
@ -190,7 +191,7 @@ public:
virtual void BindTextures(); virtual void BindTextures();
void CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstFormat, u32 dstStride, void CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstFormat, u32 dstStride,
bool is_depth_copy, const EFBRectangle& srcRect, bool isIntensity, 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, virtual void ConvertTexture(TCacheEntry* entry, TCacheEntry* unconverted, const void* palette,
TLUTFormat format) = 0; TLUTFormat format) = 0;