Merge pull request #2991 from unknownbrackets/gpu-minor

Get rid of GLES references outside GLES / UI code
This commit is contained in:
Henrik Rydgård 2013-07-30 00:42:55 -07:00
commit abdeda590e
15 changed files with 81 additions and 105 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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();

View file

@ -22,7 +22,6 @@
u32 MIPS_GetNextPC();
void MIPS_ClearDelaySlot();
int MIPS_SingleStep();
float round_ieee_754(float num);
namespace MIPSInt
{

View file

@ -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;

View file

@ -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"

View file

@ -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);
}
}

View file

@ -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();

View file

@ -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<GEBufferFormat>(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);

View file

@ -19,6 +19,7 @@
#include <list>
#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<FramebufferInfo> 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;

View file

@ -21,6 +21,7 @@
#include "IndexGenerator.h"
#include "VertexDecoder.h"
#include "gfx/gl_common.h"
#include "gfx/gl_lost_manager.h"
class LinkedShader;

View file

@ -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;

View file

@ -18,7 +18,6 @@
#pragma once
#include "../Globals.h"
#include "gfx/gl_common.h"
#include "ge_constants.h"
struct GPUgstate

View file

@ -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);

View file

@ -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)