mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
DisplayDrawer->FramebufferManager
This commit is contained in:
parent
cdc94a6cad
commit
6e32b30afd
5 changed files with 59 additions and 72 deletions
|
@ -76,11 +76,6 @@ bool PSP_Init(const CoreParameter &coreParam, std::string *error_string)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (coreParameter.gpuCore != GPU_NULL)
|
||||
{
|
||||
DisplayDrawer_Init();
|
||||
}
|
||||
|
||||
shaderManager.DirtyShader();
|
||||
shaderManager.DirtyUniform(DIRTY_ALL);
|
||||
|
||||
|
@ -113,10 +108,6 @@ void PSP_Shutdown()
|
|||
}
|
||||
__KernelShutdown();
|
||||
HLEShutdown();
|
||||
if (coreParameter.gpuCore != GPU_NULL)
|
||||
{
|
||||
DisplayDrawer_Shutdown();
|
||||
}
|
||||
Memory::Shutdown() ;
|
||||
currentCPU = 0;
|
||||
}
|
||||
|
|
|
@ -85,11 +85,16 @@ void GLES_GPU::BeginFrame()
|
|||
{
|
||||
TextureCache_Decimate();
|
||||
|
||||
// NOTE - this is all wrong. At the beginning of the frame is a TERRIBLE time to draw the fb.
|
||||
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_);
|
||||
const u8 *pspframebuf = Memory::GetPointer((0x44000000) | (displayFramebufPtr_ & 0x1FFFFF)); // TODO - check
|
||||
glstate.cullFace.disable();
|
||||
glstate.depthTest.disable();
|
||||
glstate.blend.disable();
|
||||
framebufferManager.DrawPixels(pspframebuf, displayFormat_, displayStride_);
|
||||
// TODO: restore state?
|
||||
}
|
||||
currentRenderVfb_ = 0;
|
||||
}
|
||||
|
@ -101,7 +106,7 @@ void GLES_GPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, int format)
|
|||
displayStride_ = stride;
|
||||
displayFormat_ = format;
|
||||
} else {
|
||||
DEBUG_LOG(HLE, "Bogus framebufffer address: %08x", framebuf);
|
||||
DEBUG_LOG(HLE, "Bogus framebuffer address: %08x", framebuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,8 +138,8 @@ void GLES_GPU::CopyDisplayToOutput()
|
|||
|
||||
fbo_bind_color_as_texture(vfb->fbo, 0);
|
||||
|
||||
// These are in the output pixel coordinates
|
||||
DrawActiveTexture(480, 272, true);
|
||||
// These are in the output display coordinates
|
||||
framebufferManager.DrawActiveTexture(480, 272, true);
|
||||
|
||||
shaderManager.DirtyShader();
|
||||
shaderManager.DirtyUniform(DIRTY_ALL);
|
||||
|
@ -320,7 +325,7 @@ void EnterClearMode(u32 data)
|
|||
bool colMask = (data >> 8) & 1;
|
||||
bool alphaMask = (data >> 9) & 1;
|
||||
bool updateZ = (data >> 10) & 1;
|
||||
glColorMask(colMask, colMask, colMask, alphaMask);
|
||||
glstate.colorMask.set(colMask, colMask, colMask, alphaMask);
|
||||
glstate.depthWrite.set(updateZ ? GL_TRUE : GL_FALSE);
|
||||
}
|
||||
|
||||
|
@ -332,7 +337,7 @@ void LeaveClearMode()
|
|||
// Fogging
|
||||
// Antialiasing
|
||||
// Alpha test
|
||||
glColorMask(1,1,1,1);
|
||||
glstate.colorMask.set(1,1,1,1);
|
||||
glstate.depthWrite.set(!(gstate.zmsk & 1) ? GL_TRUE : GL_FALSE);
|
||||
// dirtyshader?
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "../GPUInterface.h"
|
||||
|
||||
#include "Framebuffer.h"
|
||||
#include "gfx_es2/fbo.h"
|
||||
|
||||
class ShaderManager;
|
||||
|
@ -56,6 +56,8 @@ private:
|
|||
void DoBlockTransfer();
|
||||
bool ProcessDLQueue();
|
||||
|
||||
FramebufferManager framebufferManager;
|
||||
|
||||
ShaderManager *shaderManager_;
|
||||
bool interruptsEnabled_;
|
||||
|
||||
|
|
|
@ -26,18 +26,6 @@
|
|||
|
||||
#include "Framebuffer.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// STATE BEGIN
|
||||
static GLuint backbufTex;
|
||||
u8 *realFB;
|
||||
GLSLProgram *draw2dprogram;
|
||||
|
||||
// STATE END
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#endif
|
||||
|
||||
const char tex_fs[] =
|
||||
"#ifdef GL_ES\n"
|
||||
"precision mediump float;\n"
|
||||
|
@ -59,22 +47,7 @@ const char basic_vs[] =
|
|||
" gl_Position = u_viewproj * a_position;\n"
|
||||
"}\n";
|
||||
|
||||
void DisplayDrawer_Init()
|
||||
{
|
||||
#if !defined(USING_GLES2)
|
||||
// Old OpenGL stuff that probably has no effect
|
||||
|
||||
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); //GL_FILL);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
#endif
|
||||
|
||||
glstate.cullFace.disable();
|
||||
glstate.depthTest.disable();
|
||||
glstate.blend.disable();
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
FramebufferManager::FramebufferManager() {
|
||||
glGenTextures(1, &backbufTex);
|
||||
|
||||
//initialize backbuffer texture
|
||||
|
@ -98,26 +71,24 @@ void DisplayDrawer_Init()
|
|||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
realFB = new u8[480*272*4];
|
||||
convBuf = new u8[480 * 272 * 4];
|
||||
}
|
||||
|
||||
void DisplayDrawer_Shutdown()
|
||||
{
|
||||
glDeleteTextures(1,&backbufTex);
|
||||
FramebufferManager::~FramebufferManager() {
|
||||
glDeleteTextures(1, &backbufTex);
|
||||
glsl_destroy(draw2dprogram);
|
||||
delete [] realFB;
|
||||
delete [] convBuf;
|
||||
}
|
||||
|
||||
void DisplayDrawer_DrawFramebuffer(u8 *framebuf, int pixelFormat, int linesize)
|
||||
{
|
||||
for (int y = 0; y < 272; y++)
|
||||
{
|
||||
switch (pixelFormat)
|
||||
{
|
||||
void FramebufferManager::DrawPixels(const u8 *framebuf, int pixelFormat, int linesize) {
|
||||
// TODO: We can trivially do these in the shader, and there's no need to
|
||||
// upconvert to 8888 for the 16-bit formats.
|
||||
for (int y = 0; y < 272; y++) {
|
||||
switch (pixelFormat) {
|
||||
case PSP_DISPLAY_PIXEL_FORMAT_565:
|
||||
{
|
||||
u16 *src = (u16 *)framebuf + linesize * y;
|
||||
u8 *dst = realFB + 4 * 480 * y;
|
||||
const u16 *src = (const u16 *)framebuf + linesize * y;
|
||||
u8 *dst = convBuf + 4 * 480 * y;
|
||||
for (int x = 0; x < 480; x++)
|
||||
{
|
||||
u16 col = src[x];
|
||||
|
@ -131,8 +102,8 @@ void DisplayDrawer_DrawFramebuffer(u8 *framebuf, int pixelFormat, int linesize)
|
|||
|
||||
case PSP_DISPLAY_PIXEL_FORMAT_5551:
|
||||
{
|
||||
u16 *src = (u16 *)framebuf + linesize * y;
|
||||
u8 *dst = realFB + 4 * 480 * y;
|
||||
const u16 *src = (const u16 *)framebuf + linesize * y;
|
||||
u8 *dst = convBuf + 4 * 480 * y;
|
||||
for (int x = 0; x < 480; x++)
|
||||
{
|
||||
u16 col = src[x];
|
||||
|
@ -146,8 +117,8 @@ void DisplayDrawer_DrawFramebuffer(u8 *framebuf, int pixelFormat, int linesize)
|
|||
|
||||
case PSP_DISPLAY_PIXEL_FORMAT_8888:
|
||||
{
|
||||
u8 *src = framebuf + linesize * 4 * y;
|
||||
u8 *dst = realFB + 4 * 480 * y;
|
||||
const u8 *src = framebuf + linesize * 4 * y;
|
||||
u8 *dst = convBuf + 4 * 480 * y;
|
||||
for (int x = 0; x < 480; x++)
|
||||
{
|
||||
dst[x * 4] = src[x * 4];
|
||||
|
@ -160,8 +131,8 @@ void DisplayDrawer_DrawFramebuffer(u8 *framebuf, int pixelFormat, int linesize)
|
|||
|
||||
case PSP_DISPLAY_PIXEL_FORMAT_4444:
|
||||
{
|
||||
u16 *src = (u16 *)framebuf + linesize * y;
|
||||
u8 *dst = realFB + 4 * 480 * y;
|
||||
const u16 *src = (const u16 *)framebuf + linesize * y;
|
||||
u8 *dst = convBuf + 4 * 480 * y;
|
||||
for (int x = 0; x < 480; x++)
|
||||
{
|
||||
u16 col = src[x];
|
||||
|
@ -176,13 +147,11 @@ void DisplayDrawer_DrawFramebuffer(u8 *framebuf, int pixelFormat, int linesize)
|
|||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,backbufTex);
|
||||
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,480,272, GL_RGBA, GL_UNSIGNED_BYTE, realFB);
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,480,272, GL_RGBA, GL_UNSIGNED_BYTE, convBuf);
|
||||
DrawActiveTexture(480, 272);
|
||||
}
|
||||
|
||||
void DrawActiveTexture(float w, float h, bool flip)
|
||||
{
|
||||
void FramebufferManager::DrawActiveTexture(float w, float h, bool flip) {
|
||||
float u2 = 1.0f;
|
||||
float v1 = flip ? 1.0f : 0.0f;
|
||||
float v2 = flip ? 0.0f : 1.0f;
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "../Globals.h"
|
||||
|
||||
struct GLSLProgram;
|
||||
|
||||
enum PspDisplayPixelFormat {
|
||||
PSP_DISPLAY_PIXEL_FORMAT_565 = 0,
|
||||
PSP_DISPLAY_PIXEL_FORMAT_5551 = 1,
|
||||
|
@ -29,7 +31,25 @@ enum PspDisplayPixelFormat {
|
|||
PSP_DISPLAY_PIXEL_FORMAT_8888 = 3,
|
||||
};
|
||||
|
||||
void DisplayDrawer_Init();
|
||||
void DisplayDrawer_DrawFramebuffer(u8 *framebuf, int pixelFormat, int linesize);
|
||||
void DisplayDrawer_Shutdown();
|
||||
void DrawActiveTexture(float w, float h, bool flip = false);
|
||||
class FramebufferManager {
|
||||
public:
|
||||
FramebufferManager();
|
||||
~FramebufferManager();
|
||||
|
||||
/* Better do this first:
|
||||
glstate.cullFace.disable();
|
||||
glstate.depthTest.disable();
|
||||
glstate.blend.disable();
|
||||
*/
|
||||
|
||||
void DrawPixels(const u8 *framebuf, int pixelFormat, int linesize);
|
||||
void DrawActiveTexture(float w, float h, bool flip = false);
|
||||
|
||||
private:
|
||||
|
||||
// Used by DrawPixels
|
||||
unsigned int backbufTex;
|
||||
|
||||
u8 *convBuf;
|
||||
GLSLProgram *draw2dprogram;
|
||||
};
|
Loading…
Add table
Reference in a new issue