diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 3780819525..ea0695bdd5 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -23,32 +23,24 @@ // and move everything into native... #include "base/timeutil.h" -#include "Thread.h" -#include "../Core/CoreTiming.h" -#include "../Core/CoreParameter.h" +#include "Common/Thread.h" +#include "Core/CoreTiming.h" +#include "Core/CoreParameter.h" #include "Core/Reporting.h" -#include "../MIPS/MIPS.h" -#include "../HLE/HLE.h" -#include "sceAudio.h" -#include "../Host.h" -#include "../Config.h" -#include "../System.h" -#include "../Core/Core.h" -#include "sceDisplay.h" -#include "sceKernel.h" -#include "sceKernelThread.h" -#include "sceKernelInterrupt.h" +#include "Core/Config.h" +#include "Core/System.h" +#include "Core/HLE/HLE.h" +#include "Core/HLE/sceDisplay.h" +#include "Core/HLE/sceKernel.h" +#include "Core/HLE/sceKernelThread.h" +#include "Core/HLE/sceKernelInterrupt.h" -// TODO: This file should not depend directly on GLES code. -#include "../../GPU/GLES/Framebuffer.h" -#include "../../GPU/GLES/ShaderManager.h" -#include "../../GPU/GLES/TextureCache.h" -#include "../../GPU/GPUState.h" -#include "../../GPU/GPUInterface.h" +#include "GPU/GPUState.h" +#include "GPU/GPUInterface.h" struct FrameBufferState { u32 topaddr; - PspDisplayPixelFormat pspFramebufFormat; + GEBufferFormat pspFramebufFormat; int pspFramebufLinesize; }; @@ -135,7 +127,7 @@ void __DisplayInit() { numSkippedFrames = 0; framebufIsLatched = false; framebuf.topaddr = 0x04000000; - framebuf.pspFramebufFormat = PSP_DISPLAY_PIXEL_FORMAT_8888; + framebuf.pspFramebufFormat = GE_FORMAT_8888; framebuf.pspFramebufLinesize = 480; // ?? lastFlipCycles = 0; @@ -501,7 +493,7 @@ u32 sceDisplaySetFramebuf(u32 topaddr, int linesize, int pixelformat, int sync) DEBUG_LOG(HLE,"- screen off"); } else { fbstate.topaddr = topaddr; - fbstate.pspFramebufFormat = (PspDisplayPixelFormat)pixelformat; + fbstate.pspFramebufFormat = (GEBufferFormat)pixelformat; fbstate.pspFramebufLinesize = linesize; } diff --git a/Core/HLE/sceGe.cpp b/Core/HLE/sceGe.cpp index d41ecfae48..ead492db14 100644 --- a/Core/HLE/sceGe.cpp +++ b/Core/HLE/sceGe.cpp @@ -332,13 +332,13 @@ u32 sceGeSetCallback(u32 structAddr) int subIntrBase = __GeSubIntrBase(cbID); - if (ge_callback_data[cbID].finish_func) + if (ge_callback_data[cbID].finish_func != 0) { sceKernelRegisterSubIntrHandler(PSP_GE_INTR, subIntrBase | PSP_GE_SUBINTR_FINISH, ge_callback_data[cbID].finish_func, ge_callback_data[cbID].finish_arg); sceKernelEnableSubIntr(PSP_GE_INTR, subIntrBase | PSP_GE_SUBINTR_FINISH); } - if (ge_callback_data[cbID].signal_func) + if (ge_callback_data[cbID].signal_func != 0) { sceKernelRegisterSubIntrHandler(PSP_GE_INTR, subIntrBase | PSP_GE_SUBINTR_SIGNAL, ge_callback_data[cbID].signal_func, ge_callback_data[cbID].signal_arg); diff --git a/Core/HLE/sceGe.h b/Core/HLE/sceGe.h index 9659ed0b93..e11db00ed2 100644 --- a/Core/HLE/sceGe.h +++ b/Core/HLE/sceGe.h @@ -28,13 +28,13 @@ // typedef void (*PspGeCallback)(int id, void *arg); -typedef struct PspGeCallbackData +struct PspGeCallbackData { - u32 signal_func; - u32 signal_arg; //ptr - u32 finish_func; // PspGeCallback - u32 finish_arg; -} PspGeCallbackData; + u32_le signal_func; + u32_le signal_arg; //ptr + u32_le finish_func; // PspGeCallback + u32_le finish_arg; +}; void Register_sceGe_user(); diff --git a/Core/MIPS/MIPSInt.h b/Core/MIPS/MIPSInt.h index d68fce176e..7f7ad7d1c1 100644 --- a/Core/MIPS/MIPSInt.h +++ b/Core/MIPS/MIPSInt.h @@ -22,7 +22,6 @@ u32 MIPS_GetNextPC(); void MIPS_ClearDelaySlot(); int MIPS_SingleStep(); -float round_ieee_754(float num); namespace MIPSInt { diff --git a/Core/System.cpp b/Core/System.cpp index 3258a7bc07..31f9511b1b 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -19,32 +19,26 @@ #include "Common/CommonWindows.h" #endif -#include "MemMap.h" +#include "Core/MemMap.h" -#include "MIPS/MIPS.h" +#include "Core/MIPS/MIPS.h" +#include "Core/MIPS/JitCommon/JitCommon.h" -#include "MIPS/JitCommon/JitCommon.h" - -#include "System.h" -// Bad dependency -#include "GPU/GLES/Framebuffer.h" -#include "GPU/GLES/TextureCache.h" -#include "GPU/GLES/ShaderManager.h" - -#include "PSPMixer.h" -#include "HLE/HLE.h" -#include "HLE/sceKernel.h" -#include "HLE/sceKernelMemory.h" -#include "HLE/sceAudio.h" -#include "Config.h" -#include "Core.h" -#include "CoreTiming.h" -#include "CoreParameter.h" -#include "FileSystems/MetaFileSystem.h" -#include "Loaders.h" -#include "PSPLoaders.h" -#include "ELF/ParamSFO.h" -#include "../Common/LogManager.h" +#include "Core/System.h" +#include "Core/PSPMixer.h" +#include "Core/HLE/HLE.h" +#include "Core/HLE/sceKernel.h" +#include "Core/HLE/sceKernelMemory.h" +#include "Core/HLE/sceAudio.h" +#include "Core/Config.h" +#include "Core/Core.h" +#include "Core/CoreTiming.h" +#include "Core/CoreParameter.h" +#include "Core/FileSystems/MetaFileSystem.h" +#include "Core/Loaders.h" +#include "Core/PSPLoaders.h" +#include "Core/ELF/ParamSFO.h" +#include "Common/LogManager.h" MetaFileSystem pspFileSystem; ParamSFOData g_paramSFO; diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index 401cbd9af8..5830e1d0ca 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -24,8 +24,6 @@ #include "Core/HLE/sceGe.h" #include "Core/MemMap.h" #include "image/zim_load.h" -#include "gfx/texture_atlas.h" -#include "gfx/gl_common.h" #include "util/text/utf8.h" #include "MathUtil.h" #include "Core/System.h" diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index 043186dde3..f52fd97579 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -289,7 +289,7 @@ void GLES_GPU::BeginFrame() { framebufferManager_.BeginFrame(); } -void GLES_GPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, int format) { +void GLES_GPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) { framebufferManager_.SetDisplayFramebuffer(framebuf, stride, format); } @@ -1055,7 +1055,7 @@ void GLES_GPU::DoBlockTransfer() { if (((backBuffer != 0 && dstBasePtr == backBuffer) || (displayBuffer != 0 && dstBasePtr == displayBuffer)) && dstStride == 512 && height == 272) { - framebufferManager_.DrawPixels(Memory::GetPointer(dstBasePtr), 3, 512); + framebufferManager_.DrawPixels(Memory::GetPointer(dstBasePtr), GE_FORMAT_8888, 512); } } diff --git a/GPU/GLES/DisplayListInterpreter.h b/GPU/GLES/DisplayListInterpreter.h index 15225bf3c9..2235241211 100644 --- a/GPU/GLES/DisplayListInterpreter.h +++ b/GPU/GLES/DisplayListInterpreter.h @@ -40,7 +40,7 @@ public: virtual void ExecuteOp(u32 op, u32 diff); virtual u32 DrawSync(int mode); - virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, int format); + virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format); virtual void CopyDisplayToOutput(); virtual void BeginFrame(); virtual void UpdateStats(); diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index dc2eb639d4..682b3cda32 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -91,7 +91,7 @@ inline u16 RGBA8888toRGBA5551(u32 px) { return ((px >> 3) & 0x001F) | ((px >> 6) & 0x03E0) | ((px >> 9) & 0x7C00) | ((px >> 16) & 0x8000); } -void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 stride, u32 height, int format); +void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 stride, u32 height, GEBufferFormat format); void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH) @@ -147,14 +147,14 @@ FramebufferManager::FramebufferManager() : ramDisplayFramebufPtr_(0), displayFramebufPtr_(0), displayStride_(0), - displayFormat_(0), + displayFormat_(GE_FORMAT_565), displayFramebuf_(0), prevDisplayFramebuf_(0), prevPrevDisplayFramebuf_(0), frameLastFramebufUsed(0), currentRenderVfb_(0), drawPixelsTex_(0), - drawPixelsTexFormat_(-1), + drawPixelsTexFormat_(GE_FORMAT_INVALID), convBuf(0), draw2dprogram(0) #ifndef USING_GLES2 @@ -218,7 +218,7 @@ FramebufferManager::~FramebufferManager() { delete [] convBuf; } -void FramebufferManager::DrawPixels(const u8 *framebuf, int pixelFormat, int linesize) { +void FramebufferManager::DrawPixels(const u8 *framebuf, GEBufferFormat pixelFormat, int linesize) { if (drawPixelsTex_ && drawPixelsTexFormat_ != pixelFormat) { glDeleteTextures(1, &drawPixelsTex_); drawPixelsTex_ = 0; @@ -235,24 +235,19 @@ void FramebufferManager::DrawPixels(const u8 *framebuf, int pixelFormat, int lin glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - switch (pixelFormat) { - case PSP_DISPLAY_PIXEL_FORMAT_8888: - break; - } - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 272, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, 0); drawPixelsTexFormat_ = pixelFormat; } // TODO: We can just change the texture format and flip some bits around instead of this. - if (pixelFormat != PSP_DISPLAY_PIXEL_FORMAT_8888 || linesize != 512) { + if (pixelFormat != GE_FORMAT_8888 || linesize != 512) { if (!convBuf) { convBuf = new u8[512 * 272 * 4]; } for (int y = 0; y < 272; y++) { switch (pixelFormat) { - case PSP_DISPLAY_PIXEL_FORMAT_565: + case GE_FORMAT_565: { const u16 *src = (const u16 *)framebuf + linesize * y; u8 *dst = convBuf + 4 * 512 * y; @@ -267,7 +262,7 @@ void FramebufferManager::DrawPixels(const u8 *framebuf, int pixelFormat, int lin } break; - case PSP_DISPLAY_PIXEL_FORMAT_5551: + case GE_FORMAT_5551: { const u16 *src = (const u16 *)framebuf + linesize * y; u8 *dst = convBuf + 4 * 512 * y; @@ -282,7 +277,7 @@ void FramebufferManager::DrawPixels(const u8 *framebuf, int pixelFormat, int lin } break; - case PSP_DISPLAY_PIXEL_FORMAT_4444: + case GE_FORMAT_4444: { const u16 *src = (const u16 *)framebuf + linesize * y; u8 *dst = convBuf + 4 * 512 * y; @@ -297,7 +292,7 @@ void FramebufferManager::DrawPixels(const u8 *framebuf, int pixelFormat, int lin } break; - case PSP_DISPLAY_PIXEL_FORMAT_8888: + case GE_FORMAT_8888: { const u8 *src = framebuf + linesize * 4 * y; u8 *dst = convBuf + 4 * 512 * y; @@ -313,7 +308,7 @@ void FramebufferManager::DrawPixels(const u8 *framebuf, int pixelFormat, int lin { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } - glTexSubImage2D(GL_TEXTURE_2D,0,0,0,512,272, GL_RGBA, GL_UNSIGNED_BYTE, pixelFormat == PSP_DISPLAY_PIXEL_FORMAT_8888 ? framebuf : convBuf); + glTexSubImage2D(GL_TEXTURE_2D,0,0,0,512,272, GL_RGBA, GL_UNSIGNED_BYTE, pixelFormat == GE_FORMAT_8888 ? framebuf : convBuf); float x, y, w, h; CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight); @@ -453,7 +448,7 @@ void FramebufferManager::SetRenderFrameBuffer() { // As there are no clear "framebuffer width" and "framebuffer height" registers, // we need to infer the size of the current framebuffer somehow. Let's try the viewport. - int fmt = gstate.framebufpixformat & 3; + GEBufferFormat fmt = static_cast(gstate.framebufpixformat & 3); int drawing_width, drawing_height; GuessDrawingSize(drawing_width, drawing_height); @@ -504,20 +499,20 @@ void FramebufferManager::SetRenderFrameBuffer() { vfb->colorDepth = FBO_8888; } else { switch (fmt) { - case GE_FORMAT_4444: - vfb->colorDepth = FBO_4444; + case GE_FORMAT_4444: + vfb->colorDepth = FBO_4444; break; - case GE_FORMAT_5551: - vfb->colorDepth = FBO_5551; + case GE_FORMAT_5551: + vfb->colorDepth = FBO_5551; break; - case GE_FORMAT_565: - vfb->colorDepth = FBO_565; + case GE_FORMAT_565: + vfb->colorDepth = FBO_565; break; - case GE_FORMAT_8888: - vfb->colorDepth = FBO_8888; + case GE_FORMAT_8888: + vfb->colorDepth = FBO_8888; break; - default: - vfb->colorDepth = FBO_8888; + default: + vfb->colorDepth = FBO_8888; break; } } @@ -840,7 +835,7 @@ void FramebufferManager::BlitFramebuffer_(VirtualFramebuffer *src, VirtualFrameb } // TODO: SSE/NEON -void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 stride, u32 height, int format) { +void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 stride, u32 height, GEBufferFormat format) { if(format == GE_FORMAT_8888) { if(src == dst) { return; @@ -868,6 +863,9 @@ void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 stride, u32 height, int format) { dst16[i] = RGBA8888toRGBA4444(src32[i]); } break; + case GE_FORMAT_8888: + // Not possible. + break; default: break; } @@ -1101,7 +1099,7 @@ void FramebufferManager::BeginFrame() { useBufferedRendering_ = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE ? 1 : 0; } -void FramebufferManager::SetDisplayFramebuffer(u32 framebuf, u32 stride, int format) { +void FramebufferManager::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) { if ((framebuf & 0x04000000) == 0) { DEBUG_LOG(HLE, "Non-VRAM display framebuffer address set: %08x", framebuf); diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index d11bd84718..983368ac53 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -19,6 +19,7 @@ #include +#include "gfx/gl_common.h" #include "gfx_es2/fbo.h" // Keeps track of allocated FBOs. // Also provides facilities for drawing and later converting raw @@ -31,13 +32,6 @@ struct GLSLProgram; class TextureCache; -enum PspDisplayPixelFormat { - PSP_DISPLAY_PIXEL_FORMAT_565 = 0, - PSP_DISPLAY_PIXEL_FORMAT_5551 = 1, - PSP_DISPLAY_PIXEL_FORMAT_4444 = 2, - PSP_DISPLAY_PIXEL_FORMAT_8888 = 3, -}; - enum { FB_USAGE_DISPLAYED_FRAMEBUFFER = 1, FB_USAGE_RENDERTARGET = 2, @@ -88,7 +82,7 @@ struct VirtualFramebuffer { u16 usageFlags; - int format; // virtual, right now they are all RGBA8888 + GEBufferFormat format; // virtual, right now they are all RGBA8888 FBOColorDepth colorDepth; FBO *fbo; @@ -108,7 +102,7 @@ struct AsyncPBO { u32 stride; u32 height; u32 size; - int format; + GEBufferFormat format; bool reading; }; @@ -128,7 +122,7 @@ public: shaderManager_ = sm; } - void DrawPixels(const u8 *framebuf, int pixelFormat, int linesize); + void DrawPixels(const u8 *framebuf, GEBufferFormat pixelFormat, int linesize); void DrawActiveTexture(float x, float y, float w, float h, bool flip = false, float uscale = 1.0f, float vscale = 1.0f, GLSLProgram *program = 0); void DestroyAllFBOs(); @@ -146,7 +140,7 @@ public: // TODO: Break out into some form of FBO manager VirtualFramebuffer *GetDisplayFBO(); - void SetDisplayFramebuffer(u32 framebuf, u32 stride, int format); + void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format); size_t NumVFBs() const { return vfbs_.size(); } std::vector GetFramebufferList(); @@ -171,7 +165,7 @@ private: u32 ramDisplayFramebufPtr_; // workaround for MotoGP insanity u32 displayFramebufPtr_; u32 displayStride_; - int displayFormat_; + GEBufferFormat displayFormat_; VirtualFramebuffer *displayFramebuf_; VirtualFramebuffer *prevDisplayFramebuf_; @@ -198,7 +192,7 @@ private: // Used by DrawPixels unsigned int drawPixelsTex_; - int drawPixelsTexFormat_; + GEBufferFormat drawPixelsTexFormat_; u8 *convBuf; GLSLProgram *draw2dprogram; diff --git a/GPU/GLES/TransformPipeline.h b/GPU/GLES/TransformPipeline.h index 93cb5d3da0..226a3a9fe6 100644 --- a/GPU/GLES/TransformPipeline.h +++ b/GPU/GLES/TransformPipeline.h @@ -21,6 +21,7 @@ #include "IndexGenerator.h" #include "VertexDecoder.h" +#include "gfx/gl_common.h" #include "gfx/gl_lost_manager.h" class LinkedShader; diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index b8bf970b0f..15d7d91809 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -171,7 +171,7 @@ public: virtual bool InterpretList(DisplayList& list) = 0; // Framebuffer management - virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, int format) = 0; + virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) = 0; virtual void BeginFrame() = 0; // Can be a good place to draw the "memory" framebuffer for accelerated plugins virtual void CopyDisplayToOutput() = 0; diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 9ec6db998c..a09d5d6694 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -18,7 +18,6 @@ #pragma once #include "../Globals.h" -#include "gfx/gl_common.h" #include "ge_constants.h" struct GPUgstate diff --git a/GPU/Null/NullGpu.h b/GPU/Null/NullGpu.h index 729dab7d33..e451f146ba 100644 --- a/GPU/Null/NullGpu.h +++ b/GPU/Null/NullGpu.h @@ -31,7 +31,7 @@ public: virtual u32 DrawSync(int mode); virtual void BeginFrame() {} - virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, int format) {} + virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {} virtual void CopyDisplayToOutput() {} virtual void UpdateStats(); virtual void InvalidateCache(u32 addr, int size, GPUInvalidationType type); diff --git a/GPU/ge_constants.h b/GPU/ge_constants.h index c09275053c..de4b1fbd86 100644 --- a/GPU/ge_constants.h +++ b/GPU/ge_constants.h @@ -251,6 +251,7 @@ enum GEBufferFormat GE_FORMAT_5551=1, GE_FORMAT_4444=2, GE_FORMAT_8888=3, + GE_FORMAT_INVALID=0xFF, }; #define GE_VTYPE_TRANSFORM (0<<23)