X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfxvideo%2Fgpu.c;h=d80a265cd18c7c0b3544a2c75e4bb53f53d44037;hp=7372ba4a46732ed77e5cf1d73757dc4977053e2e;hb=7e44d49d2a65d6e45d6f99f72a8cccdb02654aae;hpb=0d16cda294b8f4655dda849a526b336a5b46aa16 diff --git a/plugins/dfxvideo/gpu.c b/plugins/dfxvideo/gpu.c index 7372ba4a..d80a265c 100644 --- a/plugins/dfxvideo/gpu.c +++ b/plugins/dfxvideo/gpu.c @@ -51,6 +51,8 @@ DATAREGISTERMODES DataWriteMode; DATAREGISTERMODES DataReadMode; BOOL bSkipNextFrame = FALSE; +BOOL fskip_frameReady; +DWORD lace_count_since_flip; DWORD dwLaceCnt=0; short sDispWidths[8] = {256,320,512,640,368,384,512,640}; PSXDisplay_t PSXDisplay; @@ -59,6 +61,8 @@ long lSelectedSlot=0; BOOL bDoLazyUpdate=FALSE; uint32_t lGPUInfoVals[16]; static int iFakePrimBusy=0; +static uint32_t vBlank=0; +static const int *skip_advice; //////////////////////////////////////////////////////////////////////// // some misc external display funcs @@ -204,22 +208,39 @@ static void updateDisplay(void) // UPDATE DISPLAY if(UseFrameSkip) // skip ? { - if(!bSkipNextFrame) DoBufferSwap(); // -> to skip or not to skip - if(dwActFixes&0xa0) // -> pc fps calculation fix/old skipping fix + if(fskip_frameReady) { - if((fps_skip < fFrameRateHz) && !(bSkipNextFrame)) // -> skip max one in a row - {bSkipNextFrame = TRUE; fps_skip=fFrameRateHz;} - else bSkipNextFrame = FALSE; + DoBufferSwap(); // -> to skip or not to skip + fskip_frameReady=FALSE; + bDoVSyncUpdate=FALSE; // vsync done } - else FrameSkip(); } else // no skip ? { bSkipNextFrame = FALSE; DoBufferSwap(); // -> swap + bDoVSyncUpdate=FALSE; // vsync done } } +static void decideSkip(void) +{ + if(!bDoVSyncUpdate) + return; + + lace_count_since_flip=0; + fskip_frameReady=!bSkipNextFrame; + + if(dwActFixes&0xa0) // -> pc fps calculation fix/old skipping fix + { + int skip = (skip_advice && *skip_advice) || UseFrameSkip == 1 || fps_skip < fFrameRateHz; + if(skip && !bSkipNextFrame) // -> skip max one in a row + {bSkipNextFrame = TRUE; fps_skip=fFrameRateHz;} + else bSkipNextFrame = FALSE; + } + else FrameSkip(); +} + //////////////////////////////////////////////////////////////////////// // roughly emulated screen centering bits... not complete !!! //////////////////////////////////////////////////////////////////////// @@ -373,7 +394,7 @@ static void updateDisplayIfChanged(void) // UPDATE DISPLAY if(iFrameLimit==2) SetAutoFrameCap(); // -> set it - if(UseFrameSkip) updateDisplay(); // stupid stuff when frame skipping enabled + if(UseFrameSkip) decideSkip(); // stupid stuff when frame skipping enabled } //////////////////////////////////////////////////////////////////////// @@ -382,8 +403,8 @@ static void updateDisplayIfChanged(void) // UPDATE DISPLAY void CALLBACK GPUupdateLace(void) // VSYNC { - if(!(dwActFixes&1)) - lGPUstatusRet^=0x80000000; // odd/even bit + //if(!(dwActFixes&1)) + // lGPUstatusRet^=0x80000000; // odd/even bit //pcsx-rearmed: removed, this is handled by core //if(!(dwActFixes&32)) // std fps limitation? @@ -391,6 +412,8 @@ void CALLBACK GPUupdateLace(void) // VSYNC if(PSXDisplay.Interlaced) // interlaced mode? { + lGPUstatusRet^=0x80000000; // odd/even bit? + if(bDoVSyncUpdate && PSXDisplay.DisplayMode.x>0 && PSXDisplay.DisplayMode.y>0) { updateDisplay(); @@ -400,17 +423,24 @@ void CALLBACK GPUupdateLace(void) // VSYNC { if(dwActFixes&64) // lazy screen update fix { - if(bDoLazyUpdate && !UseFrameSkip) + if(bDoLazyUpdate) updateDisplay(); bDoLazyUpdate=FALSE; } else { - if(bDoVSyncUpdate && !UseFrameSkip) // some primitives drawn? - updateDisplay(); // -> update display + if(bDoVSyncUpdate) // some primitives drawn? + updateDisplay(); // -> update display } } - bDoVSyncUpdate=FALSE; // vsync done + + if(UseFrameSkip) { // frame over-skip guard + lace_count_since_flip++; + if(lace_count_since_flip > 8) { + bSkipNextFrame=FALSE; + fskip_frameReady=TRUE; + } + } } //////////////////////////////////////////////////////////////////////// @@ -445,7 +475,7 @@ uint32_t CALLBACK GPUreadStatus(void) // READ STATUS GPUIsReadyForCommands; } } - return lGPUstatusRet; + return lGPUstatusRet | vBlank; } //////////////////////////////////////////////////////////////////////// @@ -547,9 +577,9 @@ void CALLBACK GPUwriteStatus(uint32_t gdata) // WRITE STATUS if (!(PSXDisplay.Interlaced)) // stupid frame skipping option { - if(UseFrameSkip) updateDisplay(); if(dwActFixes&64) bDoLazyUpdate=TRUE; } + if(UseFrameSkip) decideSkip(); }return; //--------------------------------------------------// // setting width @@ -619,7 +649,7 @@ void CALLBACK GPUwriteStatus(uint32_t gdata) // WRITE STATUS } lGPUstatusRet|=GPUSTATUS_INTERLACED; } - else lGPUstatusRet&=~GPUSTATUS_INTERLACED; + else lGPUstatusRet&=~(GPUSTATUS_INTERLACED|0x80000000); if (PSXDisplay.PAL) lGPUstatusRet|=GPUSTATUS_PAL; @@ -1012,6 +1042,7 @@ long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) uint32_t dmaMem; unsigned char * baseAddrB; short count;unsigned int DMACommandCounter = 0; + long dmaWords = 0; GPUIsBusy; @@ -1026,6 +1057,7 @@ long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) if(CheckForEndlessLoop(addr)) break; count = baseAddrB[addr+3]; + dmaWords += 1 + count; dmaMem=addr+4; @@ -1037,7 +1069,7 @@ long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) GPUIsIdle; - return 0; + return dmaWords; } //////////////////////////////////////////////////////////////////////// @@ -1098,3 +1130,27 @@ long CALLBACK GPUfreeze(uint32_t ulGetFreezeData,GPUFreeze_t * pF) return 1; } + +void CALLBACK GPUvBlank(int val) +{ + vBlank=val?0x80000000:0; +} + +// rearmed thing +#include "../../frontend/plugin_lib.h" + +const struct rearmed_cbs *rcbs; + +void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) +{ + // sync config + UseFrameSkip = cbs->frameskip; + iUseDither = cbs->gpu_peops.iUseDither; + dwActFixes = cbs->gpu_peops.dwActFixes; + fFrameRateHz = cbs->gpu_peops.fFrameRateHz; + dwFrameRateTicks = cbs->gpu_peops.dwFrameRateTicks; + + skip_advice = &cbs->fskip_advice; + fps_skip = 100.0f; + rcbs = cbs; +}