From ac80c04eabe0cdf75238ff2af2bad68425016664 Mon Sep 17 00:00:00 2001 From: "memberTwo.mb2" Date: Tue, 27 Jan 2009 20:59:27 +0000 Subject: [PATCH] XFB in SC reverted back to its previous behavior (thx donko). But still hacked in DC (still a FIXME). git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2019 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Core.cpp | 1 + Source/Core/Core/Src/HW/SystemTimers.cpp | 2 +- Source/Core/Core/Src/HW/VideoInterface.cpp | 5 +++-- Source/Core/VideoCommon/Src/Fifo.cpp | 9 ++++----- Source/PluginSpecs/pluginspecs_video.h | 1 + Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp | 10 +++++++--- Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 12 +++++++----- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 34fbfd68ee..848ce21c8a 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -318,6 +318,7 @@ THREAD_RETURN EmuThread(void *pArg) VideoInitialize.pMemoryBase = Memory::base; VideoInitialize.pKeyPress = Callback_KeyPress; VideoInitialize.bWii = _CoreParameter.bWii; + VideoInitialize.bUseDualCore = _CoreParameter.bUseDualCore; Plugins.FreeVideo(); // This is needed for Stop and Start Plugins.GetVideo()->Initialize(&VideoInitialize); // Call the dll diff --git a/Source/Core/Core/Src/HW/SystemTimers.cpp b/Source/Core/Core/Src/HW/SystemTimers.cpp index 55a161b6a3..117d1ac2b7 100644 --- a/Source/Core/Core/Src/HW/SystemTimers.cpp +++ b/Source/Core/Core/Src/HW/SystemTimers.cpp @@ -133,7 +133,7 @@ int // For DC watchdog hack // Once every 4 frame-period seems to be enough (arbitrary taking 60fps as the ref). // TODO: make it VI output frame rate compliant (30/60 and 25/50) - // Assuming game's frame-finish-watchdog wait more than 10 emulated frame-period before starting its mess. + // Assuming game's frame-finish-watchdog wait more than 4 emulated frame-period before starting its mess. FAKE_GP_WATCHDOG_PERIOD = GetTicksPerSecond() / 15; /////////////////////////////////// diff --git a/Source/Core/Core/Src/HW/VideoInterface.cpp b/Source/Core/Core/Src/HW/VideoInterface.cpp index de14974faa..5209673243 100644 --- a/Source/Core/Core/Src/HW/VideoInterface.cpp +++ b/Source/Core/Core/Src/HW/VideoInterface.cpp @@ -516,7 +516,7 @@ void Update() int yOffset = 0; // (mb2) hack: We request XFB updates from CPUthread (here) only when homebrews use directly XFB without FIFO and CP - if (CommandProcessor::IsCommandProcessorNotUsed()) + if (!Core::GetStartupParameter().bUseDualCore || CommandProcessor::IsCommandProcessorNotUsed()) { if (NextXFBRender == 1) { @@ -546,7 +546,8 @@ void Update() if (xfbPtr && video->IsValid()) { int fbWidth = m_VIHorizontalStepping.FieldSteps * 16; - int fbHeight = (m_VIHorizontalStepping.FbSteps / m_VIHorizontalStepping.FieldSteps) * m_VIVerticalTimingRegister.ACV; + int fbHeight = (m_VIHorizontalStepping.FbSteps / m_VIHorizontalStepping.FieldSteps) * m_VIVerticalTimingRegister.ACV; + //LOGV(VIDEOINTERFACE,2,"(VI->XFBUpdate): ptr: %08x | %ix%i", (u32)xfbptr, fbWidth, fbHeight); if (Core::GetStartupParameter().bUseDualCore) // scheduled on EmuThread in DC mode video->Video_UpdateXFB(xfbPtr, fbWidth, fbHeight, yOffset, TRUE); diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index 0007e44b77..2c8b415a88 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -100,7 +100,7 @@ void Video_SendFifoData(u8* _uData, u32 len) void Fifo_EnterLoop(const SVideoInitialize &video_initialize) { SCPFifoStruct &_fifo = *video_initialize.pCPFifo; - u32 distToSend; + s32 distToSend; #ifdef _WIN32 // TODO(ector): Don't peek so often! @@ -111,14 +111,14 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) { if (_fifo.CPReadWriteDistance == 0) Common::SleepCurrentThread(1); - //etc... + // Draw XFB if CP/GPfifo isn't used if (g_XFBUpdateRequested) { Video_UpdateXFB(NULL, 0, 0, 0, FALSE); - g_XFBUpdateRequested = FALSE; video_initialize.pCopiedToXFB(); } + // check if we are able to run this buffer if ((_fifo.bFF_GPReadEnable) && _fifo.CPReadWriteDistance && !(_fifo.bFF_BPEnable && _fifo.bFF_Breakpoint)) { @@ -162,7 +162,6 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) if ( readPtr >= _fifo.CPEnd) readPtr = _fifo.CPBase; #else - // sending the whole CPReadWriteDistance distToSend = _fifo.CPReadWriteDistance; // send 1024B chunk max lenght to have better control over PeekMessages' period distToSend = distToSend > 1024 ? 1024 : distToSend; @@ -177,7 +176,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) } Video_SendFifoData(uData, distToSend); Common::SyncInterlockedExchange((LONG*)&_fifo.CPReadPointer, readPtr); - Common::SyncInterlockedExchangeAdd((LONG*)&_fifo.CPReadWriteDistance, -(s64)distToSend); + Common::SyncInterlockedExchangeAdd((LONG*)&_fifo.CPReadWriteDistance, -distToSend); } //video_initialize.pLog("..........................IDLE",FALSE); Common::SyncInterlockedExchange((LONG*)&_fifo.CPReadIdle, 1); diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index d4e11f7df0..546bfa7f83 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -72,6 +72,7 @@ typedef struct unsigned char *pVIRegs; void *pMemoryBase; bool bWii; + bool bUseDualCore; } SVideoInitialize; ///////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp index 091acf0814..2d82ce2051 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp @@ -442,13 +442,17 @@ void BPWritten(int addr, int changes, int newval) // the number of lines copied is determined by the y scale * source efb height float yScale = bpmem.dispcopyyscale / 256.0f; float xfbLines = bpmem.copyTexSrcWH.y + 1.0f * yScale; - //XFB_Write(Memory_GetPtr(bpmem.copyTexDest << 5), multirc, (bpmem.copyMipMapStrideChannels << 4), (int)xfbLines); - // TODO: compact this below if everyone is happy with it u8* pXFB = Memory_GetPtr(bpmem.copyTexDest << 5); u32 dstWidth = (bpmem.copyMipMapStrideChannels << 4); u32 dstHeight = (u32)xfbLines; XFB_Write(pXFB, multirc, dstWidth, dstHeight); - XFB_Draw(pXFB, dstWidth, dstHeight, 0); + // FIXME: we draw XFB from here in DC mode. + // Bad hack since we can have multiple EFB to XFB copy before a draw. + // Plus we should use width and height from VI regs (see VI->Update()). + // Dixit donkopunchstania for the info. + //DebugLog("(EFB to XFB->XFB_Draw): ptr: %08x | %ix%i", (u32)pXFB, dstWidth, dstHeight); + if (g_VideoInitialize.bUseDualCore) + XFB_Draw(pXFB, dstWidth, dstHeight, 0); } else { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 0c1d5e9608..4f6c7d9d57 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -360,22 +360,24 @@ unsigned int Video_Screenshot(TCHAR* _szFilename) return FALSE; } - void Video_UpdateXFB(u8* _pXFB, u32 _dwWidth, u32 _dwHeight, s32 _dwYOffset, bool scheduling) { if(g_Config.bUseXFB && XFB_isInit()) { - if (scheduling) // DC mode + if (scheduling) // from CPU in DC without fifo&CP (some 2D homebrews) { XFB_SetUpdateArgs(_pXFB, _dwWidth, _dwHeight, _dwYOffset); g_XFBUpdateRequested = TRUE; } - else // SC mode or DC without fifo&CP + else { - if (_pXFB) // from CPU + if (_pXFB) // from CPU in SC mode XFB_Draw(_pXFB, _dwWidth, _dwHeight, _dwYOffset); - else // from GP + else // from GP in DC without fifo&CP (some 2D homebrews) + { XFB_Draw(); + g_XFBUpdateRequested = FALSE; + } } } }