diff --git a/Core/CoreParameter.h b/Core/CoreParameter.h index 1e44cd8398..a39385f5b5 100644 --- a/Core/CoreParameter.h +++ b/Core/CoreParameter.h @@ -48,4 +48,9 @@ struct CoreParameter bool enableDebugging; // enables breakpoints and other time-consuming debugger features bool printfEmuLog; // writes "emulator:" logging to stdout bool headLess; // Try to avoid messageboxes etc + + int renderWidth; + int renderHeight; + int outputWidth; + int outputHeight; }; diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 267303cd6c..49a0aa7b21 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -25,6 +25,7 @@ #include "sceAudio.h" #include "../Host.h" #include "../Config.h" +#include "../System.h" #include "../Core/Core.h" #include "sceDisplay.h" #include "sceKernel.h" @@ -44,7 +45,6 @@ extern ShaderManager shaderManager; struct FrameBufferState { u32 topaddr; - u8 *pspframebuf; PspDisplayPixelFormat pspFramebufFormat; int pspFramebufLinesize; }; @@ -88,7 +88,6 @@ void __DisplayInit() { framebufIsLatched = false; framebuf.topaddr = 0x04000000; - framebuf.pspframebuf = Memory::GetPointer(0x04000000); framebuf.pspFramebufFormat = PSP_DISPLAY_PIXEL_FORMAT_8888; framebuf.pspFramebufLinesize = 480; // ?? @@ -152,11 +151,7 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { host->EndFrame(); host->BeginFrame(); - if (g_Config.bDisplayFramebuffer) - { - INFO_LOG(HLE, "Drawing the framebuffer"); - DisplayDrawer_DrawFramebuffer(framebuf.pspframebuf, framebuf.pspFramebufFormat, framebuf.pspFramebufLinesize); - } + gpu->BeginFrame(); shaderManager.DirtyShader(); shaderManager.DirtyUniform(DIRTY_ALL); @@ -190,7 +185,7 @@ u32 sceDisplaySetMode(u32 unknown, u32 xres, u32 yres) DEBUG_LOG(HLE,"sceDisplaySetMode(%d,%d,%d)",unknown,xres,yres); host->BeginFrame(); - gpu->InitClear(); + gpu->InitClear(PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight); return 0; } @@ -203,19 +198,7 @@ void sceDisplaySetFramebuf() int pixelformat = PARAM(2); int sync = PARAM(3); - FrameBufferState *fbstate = 0; - if (sync == PSP_DISPLAY_SETBUF_IMMEDIATE) - { - // Write immediately to the current framebuffer parameters - fbstate = &framebuf; - } - else if (topaddr != 0) - { - // Delay the write until vblank - fbstate = &latchedFramebuf; - framebufIsLatched = true; - } - + FrameBufferState fbstate; DEBUG_LOG(HLE,"sceDisplaySetFramebuf(topaddr=%08x,linesize=%d,pixelsize=%d,sync=%d)",topaddr,linesize,pixelformat,sync); if (topaddr == 0) { @@ -223,10 +206,21 @@ void sceDisplaySetFramebuf() } else { - fbstate->topaddr = topaddr; - fbstate->pspframebuf = Memory::GetPointer((0x44000000)|(topaddr & 0x1FFFFF)); // TODO - check - fbstate->pspFramebufFormat = (PspDisplayPixelFormat)pixelformat; - fbstate->pspFramebufLinesize = linesize; + fbstate.topaddr = topaddr; + fbstate.pspFramebufFormat = (PspDisplayPixelFormat)pixelformat; + fbstate.pspFramebufLinesize = linesize; + } + + if (sync == PSP_DISPLAY_SETBUF_IMMEDIATE) + { + // Write immediately to the current framebuffer parameters + framebuf = fbstate; + } + else if (topaddr != 0) + { + // Delay the write until vblank + latchedFramebuf = fbstate; + framebufIsLatched = true; } RETURN(0); diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index 104c1e8089..e170fd2166 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -26,7 +26,9 @@ #include +#ifndef _MSC_VER using std::isnan; +#endif #define R(i) (currentMIPS->r[i]) #define RF(i) (*(float*)(&(currentMIPS->r[i]))) diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index 0bb6977e43..b7ea0f84b9 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -30,12 +30,14 @@ #include "../../Core/MemMap.h" #include "../../Core/Host.h" +#include "../../Core/Config.h" #include "../GPUState.h" #include "../ge_constants.h" #include "ShaderManager.h" #include "DisplayListInterpreter.h" +#include "Framebuffer.h" #include "TransformPipeline.h" #include "../../Core/HLE/sceKernelThread.h" @@ -46,43 +48,42 @@ inline void glEnDis(GLuint cmd, int value) (value ? glEnable : glDisable)(cmd); } -struct DisplayState -{ - u32 pc; - u32 stallAddr; -}; - -static DisplayState dcontext; ShaderManager shaderManager; extern u32 curTextureWidth; extern u32 curTextureHeight; -int dlIdGenerator = 1; - -struct DisplayList +void GLES_GPU::InitClear(int renderWidth, int renderHeight) { - int id; - u32 listpc; - u32 stall; -}; + renderWidth_ = renderWidth; + renderHeight_ = renderHeight; -std::vector dlQueue; - -static u32 prev; -u32 stack[2]; -u32 stackptr = 0; -bool finished; - -u8 bezierBuf[16000]; - -void GLES_GPU::InitClear() -{ glClearColor(0,0,0,1); // glClearColor(1,0,1,1); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); } +void GLES_GPU::BeginFrame() +{ + if (g_Config.bDisplayFramebuffer && displayFramebufPtr_) + { + INFO_LOG(HLE, "Drawing the framebuffer"); + u8 *pspframebuf = Memory::GetPointer((0x44000000)|(displayFramebufPtr_ & 0x1FFFFF)); // TODO - check + DisplayDrawer_DrawFramebuffer(pspframebuf, displayFormat_, displayStride_); + } +} + +void GLES_GPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, int format) +{ + // TODO +} + +void GLES_GPU::CopyDisplayToOutput() +{ + // TODO +} + + bool GLES_GPU::ProcessDLQueue() { std::vector::iterator iter = dlQueue.begin(); diff --git a/GPU/GLES/DisplayListInterpreter.h b/GPU/GLES/DisplayListInterpreter.h index bf21e28811..4001484dcf 100644 --- a/GPU/GLES/DisplayListInterpreter.h +++ b/GPU/GLES/DisplayListInterpreter.h @@ -17,6 +17,8 @@ #pragma once +#include + #include "../GPUInterface.h" class ShaderManager; @@ -24,8 +26,8 @@ class ShaderManager; class GLES_GPU : public GPUInterface { public: - GLES_GPU() : interruptsEnabled_(true) {} - virtual void InitClear(); + GLES_GPU() : interruptsEnabled_(true), dlIdGenerator(1) {} + virtual void InitClear(int renderWidth, int renderHeight); virtual u32 EnqueueList(u32 listpc, u32 stall); virtual void UpdateStall(int listid, u32 newstall); virtual void ExecuteOp(u32 op, u32 diff); @@ -34,7 +36,46 @@ public: virtual void EnableInterrupts(bool enable) { interruptsEnabled_ = enable; } + + virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, int format); + virtual void CopyDisplayToOutput(); + virtual void BeginFrame(); + private: bool ProcessDLQueue(); bool interruptsEnabled_; + + u32 displayFramebufPtr_; + u32 displayStride_; + int displayFormat_; + + int renderWidth_; + int renderHeight_; + + struct CmdProcessorState + { + u32 pc; + u32 stallAddr; + }; + + CmdProcessorState dcontext; + + int dlIdGenerator; + + struct DisplayList + { + int id; + u32 listpc; + u32 stall; + }; + + std::vector dlQueue; + + u32 prev; + u32 stack[2]; + u32 stackptr; + bool finished; + + u8 bezierBuf[16000]; + }; diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 0caf6b5267..18fde6c1d8 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -123,7 +123,7 @@ void DisplayDrawer_Shutdown() delete [] realFB; } -void DisplayDrawer_DrawFramebuffer(u8 *framebuf, PspDisplayPixelFormat pixelFormat, int linesize) +void DisplayDrawer_DrawFramebuffer(u8 *framebuf, int pixelFormat, int linesize) { float u1 = 1.0f; float v1 = 1.0f; diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index 68fb487fee..f2eb189f5a 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -24,11 +24,11 @@ enum PspDisplayPixelFormat { PSP_DISPLAY_PIXEL_FORMAT_565 = 0, - PSP_DISPLAY_PIXEL_FORMAT_8888 = 3, PSP_DISPLAY_PIXEL_FORMAT_5551 = 1, PSP_DISPLAY_PIXEL_FORMAT_4444 = 2, + PSP_DISPLAY_PIXEL_FORMAT_8888 = 3, }; void DisplayDrawer_Init(); -void DisplayDrawer_DrawFramebuffer(u8 *framebuf, PspDisplayPixelFormat pixelFormat, int linesize); +void DisplayDrawer_DrawFramebuffer(u8 *framebuf, int pixelFormat, int linesize); void DisplayDrawer_Shutdown(); diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index 24476cc082..3a50c14588 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -22,13 +22,23 @@ class GPUInterface { public: - virtual void InitClear() = 0; + virtual ~GPUInterface() {} + + // Initialization + virtual void InitClear(int renderWidth, int renderHeight) = 0; + + // Draw queue management virtual u32 EnqueueList(u32 listpc, u32 stall) = 0; virtual void UpdateStall(int listid, u32 newstall) = 0; virtual void ExecuteOp(u32 op, u32 diff) = 0; virtual bool InterpretList() = 0; virtual void DrawSync(int mode) = 0; + // Framebuffer management + virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, int format) = 0; + virtual void BeginFrame() = 0; // Can be a good place to draw the "memory" framebuffer for accelerated plugins + virtual void CopyDisplayToOutput() = 0; + // Internal hack to avoid interrupts from "PPGe" drawing (utility UI, etc) virtual void EnableInterrupts(bool enable) = 0; }; diff --git a/GPU/Null/NullGpu.h b/GPU/Null/NullGpu.h index bf1953a798..7d15b4a608 100644 --- a/GPU/Null/NullGpu.h +++ b/GPU/Null/NullGpu.h @@ -25,7 +25,7 @@ class NullGPU : public GPUInterface { public: NullGPU() : interruptsEnabled_(true) {} - virtual void InitClear() {} + virtual void InitClear(int renderWidth, int renderHeight) {} virtual u32 EnqueueList(u32 listpc, u32 stall); virtual void UpdateStall(int listid, u32 newstall); virtual void ExecuteOp(u32 op, u32 diff); @@ -34,6 +34,11 @@ public: virtual void EnableInterrupts(bool enable) { interruptsEnabled_ = enable; } + + virtual void BeginFrame() {} + virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, int format) {} + virtual void CopyDisplayToOutput() {} + private: bool ProcessDLQueue(); bool interruptsEnabled_; diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index d03fb4806c..5187227481 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -67,7 +67,11 @@ DWORD TheThread(LPVOID x) coreParameter.cpuCore = g_Config.bJIT ? CPU_JIT : CPU_INTERPRETER; coreParameter.enableDebugging = true; coreParameter.printfEmuLog = false; - coreParameter.headLess = false; //true; + coreParameter.headLess = false; + coreParameter.renderWidth = 480 * g_Config.iWindowZoom; + coreParameter.renderHeight = 272 * g_Config.iWindowZoom; + coreParameter.outputWidth = 480 * g_Config.iWindowZoom; + coreParameter.outputHeight = 272 * g_Config.iWindowZoom; std::string error_string; if (!PSP_Init(coreParameter, &error_string)) diff --git a/android/jni/EmuScreen.cpp b/android/jni/EmuScreen.cpp index 47ba7f6622..38df5a67d7 100644 --- a/android/jni/EmuScreen.cpp +++ b/android/jni/EmuScreen.cpp @@ -60,6 +60,10 @@ EmuScreen::EmuScreen(const std::string &filename) : invalid_(true) coreParam.enableDebugging = false; coreParam.printfEmuLog = false; coreParam.headLess = false; + coreParam.renderWidth = 480; + coreParam.renderHeight = 272; + coreParam.outputWidth = dp_xres; + coreParam.outputHeight = dp_yres; std::string error_string; if (PSP_Init(coreParam, &error_string)) { diff --git a/native b/native index 8e673a20f7..7e36cef3ae 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 8e673a20f70bb636a5cc4ba17cbbe6613869b461 +Subproject commit 7e36cef3aeac81dd8071422be93b00128a0cb110