mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 20:04:31 +01:00
Merge pull request #2991 from unknownbrackets/gpu-minor
Get rid of GLES references outside GLES / UI code
This commit is contained in:
commit
abdeda590e
15 files changed
+81
-105
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
+26
-28
@@ -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);
|
||||
|
||||
+7
-13
@@ -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;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "IndexGenerator.h"
|
||||
#include "VertexDecoder.h"
|
||||
#include "gfx/gl_common.h"
|
||||
#include "gfx/gl_lost_manager.h"
|
||||
|
||||
class LinkedShader;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Globals.h"
|
||||
#include "gfx/gl_common.h"
|
||||
#include "ge_constants.h"
|
||||
|
||||
struct GPUgstate
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user