From ac8a9a9d5d5158f05b3e5d18ae8c5567fe59706c Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Wed, 3 Feb 2016 22:18:40 +0600 Subject: [PATCH] Add FBInfo config options. --- src/Config.cpp | 5 ++++- src/Config.h | 15 +++++++++++---- src/FrameBufferInfo.cpp | 27 ++++++++++++++++++++------- src/FrameBufferInfo.h | 1 + src/RSP.cpp | 3 ++- src/gDP.cpp | 5 +++-- 6 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/Config.cpp b/src/Config.cpp index 8fc48ce9..c43aa509 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -52,8 +52,11 @@ void Config::resetToDefaults() frameBufferEmulation.copyAuxToRDRAM = 0; frameBufferEmulation.copyToRDRAM = ctAsync; frameBufferEmulation.N64DepthCompare = 0; - frameBufferEmulation.aspect = 1; + frameBufferEmulation.aspect = a43; frameBufferEmulation.bufferSwapMode = bsOnVerticalInterrupt; + frameBufferEmulation.fbInfoDisabled = 0; + frameBufferEmulation.fbInfoReadColorChunk = 0; + frameBufferEmulation.fbInfoReadDepthChunk = 1; textureFilter.txCacheSize = 100 * gc_uMegabyte; textureFilter.txDump = 0; diff --git a/src/Config.h b/src/Config.h index 3b1fd0ba..654fc08c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -10,7 +10,8 @@ #define CONFIG_VERSION_FOUR 4U // Remove ValidityCheckMethod setting #define CONFIG_VERSION_FIVE 5U // Add shader storage option #define CONFIG_VERSION_SIX 6U // Change gamma correction options -#define CONFIG_VERSION_CURRENT CONFIG_VERSION_SIX +#define CONFIG_VERSION_SEVEN 7U // Add FBInfo options +#define CONFIG_VERSION_CURRENT CONFIG_VERSION_SEVEN #define BILINEAR_3POINT 0 #define BILINEAR_STANDARD 1 @@ -78,13 +79,19 @@ struct Config struct { u32 enable; + u32 aspect; // 0: stretch ; 1: 4/3 ; 2: 16/9; 3: adjust + u32 bufferSwapMode; // 0: on VI update call; 1: on VI origin change; 2: on main frame buffer update + u32 N64DepthCompare; u32 copyAuxToRDRAM; + // Buffer read/write u32 copyToRDRAM; u32 copyDepthToRDRAM; u32 copyFromRDRAM; - u32 N64DepthCompare; - u32 aspect; // 0: stretch ; 1: 4/3 ; 2: 16/9; 3: adjust - u32 bufferSwapMode; // 0: on VI update call; 1: on VI origin change; 2: on main frame buffer update + // FBInfo + u32 fbInfoSupported; + u32 fbInfoDisabled; + u32 fbInfoReadColorChunk; + u32 fbInfoReadDepthChunk; } frameBufferEmulation; struct diff --git a/src/FrameBufferInfo.cpp b/src/FrameBufferInfo.cpp index 6367cc77..26b65868 100644 --- a/src/FrameBufferInfo.cpp +++ b/src/FrameBufferInfo.cpp @@ -1,6 +1,6 @@ -#include #include "FrameBufferInfoAPI.h" #include "FrameBufferInfo.h" +#include "Config.h" #include "OpenGL.h" #include "FrameBuffer.h" #include "DepthBuffer.h" @@ -12,7 +12,7 @@ FBInfo fbInfo; void FBInfo::reset() { m_supported = false; - m_pWriteBuffer = nullptr; + m_pWriteBuffer = m_pReadBuffer = nullptr; } void FBInfo::Write(u32 addr, u32 size) @@ -45,10 +45,19 @@ void FBInfo::Read(u32 addr) if (pBuffer == nullptr || pBuffer == m_pWriteBuffer) return; - if (pBuffer->m_isDepthBuffer) - FrameBuffer_CopyDepthBufferChunk(address); - else - FrameBuffer_CopyChunkToRDRAM(address); + if (pBuffer->m_isDepthBuffer) { + if (config.frameBufferEmulation.fbInfoReadDepthChunk != 0) + FrameBuffer_CopyDepthBufferChunk(address); + else if (pBuffer != m_pReadBuffer) + FrameBuffer_CopyDepthBuffer(address); + } else { + if (config.frameBufferEmulation.fbInfoReadColorChunk != 0) + FrameBuffer_CopyChunkToRDRAM(address); + else if (pBuffer != m_pReadBuffer) + FrameBuffer_CopyToRDRAM(address, true); + } + + m_pReadBuffer = pBuffer; } void FBInfo::GetInfo(void *pinfo) @@ -56,6 +65,10 @@ void FBInfo::GetInfo(void *pinfo) // debugPrint("FBGetInfo\n"); FrameBufferInfo * pFBInfo = (FrameBufferInfo*)pinfo; memset(pFBInfo, 0, sizeof(FrameBufferInfo)* 6); + + if (config.frameBufferEmulation.fbInfoDisabled != 0) + return; + u32 idx = 0; DepthBuffer * pDepthBuffer = depthBufferList().getCurrent(); if (pDepthBuffer != nullptr) { @@ -66,6 +79,6 @@ void FBInfo::GetInfo(void *pinfo) } frameBufferList().fillBufferInfo(&pFBInfo[idx], 6 - idx); - m_pWriteBuffer = nullptr; + m_pWriteBuffer = m_pReadBuffer = nullptr; m_supported = true; } diff --git a/src/FrameBufferInfo.h b/src/FrameBufferInfo.h index d1acf9cc..b66337f3 100644 --- a/src/FrameBufferInfo.h +++ b/src/FrameBufferInfo.h @@ -35,6 +35,7 @@ public: private: const FrameBuffer * m_pWriteBuffer; + const FrameBuffer * m_pReadBuffer; bool m_supported; }; diff --git a/src/RSP.cpp b/src/RSP.cpp index a45d287c..f09cd001 100644 --- a/src/RSP.cpp +++ b/src/RSP.cpp @@ -9,6 +9,7 @@ #include "Combiner.h" #include "FrameBuffer.h" #include "DepthBuffer.h" +#include "FrameBufferInfo.h" #include "GBI.h" #include "PluginAPI.h" #include "Config.h" @@ -209,7 +210,7 @@ void RSP_ProcessDList() } } - if (config.frameBufferEmulation.copyDepthToRDRAM != Config::ctDisable) + if (config.frameBufferEmulation.copyDepthToRDRAM != Config::ctDisable && !fbInfo.isSupported()) FrameBuffer_CopyDepthBuffer(gDP.colorImage.address); RSP.busy = FALSE; diff --git a/src/gDP.cpp b/src/gDP.cpp index 1591509a..1163674b 100644 --- a/src/gDP.cpp +++ b/src/gDP.cpp @@ -14,6 +14,7 @@ #include "CRC.h" #include "FrameBuffer.h" #include "DepthBuffer.h" +#include "FrameBufferInfo.h" #include "VI.h" #include "Config.h" #include "Combiner.h" @@ -883,11 +884,11 @@ void gDPFullSync() } const bool sync = config.frameBufferEmulation.copyToRDRAM == Config::ctSync; - if (config.frameBufferEmulation.copyToRDRAM != Config::ctDisable) + if (config.frameBufferEmulation.copyToRDRAM != Config::ctDisable && !fbInfo.isSupported()) FrameBuffer_CopyToRDRAM(gDP.colorImage.address, sync); if (RSP.bLLE) { - if (config.frameBufferEmulation.copyDepthToRDRAM != Config::ctDisable) + if (config.frameBufferEmulation.copyDepthToRDRAM != Config::ctDisable && !fbInfo.isSupported()) FrameBuffer_CopyDepthBuffer(gDP.colorImage.address); }