diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 34a2701d1f..057b0cbcae 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -110,20 +110,10 @@ FramebufferManager::FramebufferManager() : prevDisplayFramebuf_(0), prevPrevDisplayFramebuf_(0), frameLastFramebufUsed(0), - currentRenderVfb_(0) + currentRenderVfb_(0), + drawPixelsTex_(0), + drawPixelsTexFormat_(-1) { - glGenTextures(1, &backbufTex); - - //initialize backbuffer texture - glBindTexture(GL_TEXTURE_2D, backbufTex); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 480, 272, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); - glBindTexture(GL_TEXTURE_2D, 0); - draw2dprogram = glsl_create_source(basic_vs, tex_fs); glsl_bind(draw2dprogram); @@ -142,12 +132,39 @@ FramebufferManager::FramebufferManager() : } FramebufferManager::~FramebufferManager() { - glDeleteTextures(1, &backbufTex); + if (drawPixelsTex_) + glDeleteTextures(1, &drawPixelsTex_); glsl_destroy(draw2dprogram); delete [] convBuf; } void FramebufferManager::DrawPixels(const u8 *framebuf, int pixelFormat, int linesize) { + if (drawPixelsTex_ && drawPixelsTexFormat_ != pixelFormat) { + glDeleteTextures(1, &drawPixelsTex_); + drawPixelsTex_ = 0; + } + + if (!drawPixelsTex_) { + glGenTextures(1, &drawPixelsTex_); + + // Initialize backbuffer texture for DrawPixels + glBindTexture(GL_TEXTURE_2D, drawPixelsTex_); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + 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, 480, 272, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, 0); + drawPixelsTexFormat_ = pixelFormat; + } + // 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++) { @@ -213,7 +230,7 @@ void FramebufferManager::DrawPixels(const u8 *framebuf, int pixelFormat, int lin } } - glBindTexture(GL_TEXTURE_2D,backbufTex); + glBindTexture(GL_TEXTURE_2D,drawPixelsTex_); if (g_Config.bLinearFiltering) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -552,7 +569,7 @@ void FramebufferManager::BeginFrame() { DecimateFBOs(); // 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"); + INFO_LOG(HLE, "Drawing the framebuffer (%08x)", displayFramebufPtr_); const u8 *pspframebuf = Memory::GetPointer((0x44000000) | (displayFramebufPtr_ & 0x1FFFFF)); // TODO - check glstate.cullFace.disable(); glstate.depthTest.disable(); diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index 3d955192a3..20230f9285 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -108,9 +108,11 @@ public: int GetTargetWidth() const { return currentRenderVfb_ ? currentRenderVfb_->width : 480; } int GetTargetHeight() const { return currentRenderVfb_ ? currentRenderVfb_->height : 272; } -private: - // Deletes old FBOs. + u32 PrevDisplayFramebufAddr() { + return prevDisplayFramebuf_ ? prevDisplayFramebuf_->fb_address : 0; + } +private: u32 displayFramebufPtr_; u32 displayStride_; int displayFormat_; @@ -125,7 +127,8 @@ private: VirtualFramebuffer *currentRenderVfb_; // Used by DrawPixels - unsigned int backbufTex; + unsigned int drawPixelsTex_; + int drawPixelsTexFormat_; u8 *convBuf; GLSLProgram *draw2dprogram; diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index d6684f62fe..6b52278cdb 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -126,6 +126,7 @@ void TransformDrawEngine::DrawBezier(int ucount, int vcount) { Reporting::ReportMessage("Unsupported bezier curve"); + // if (gstate.patchprimitive) // Generate indices for a rectangular mesh. int c = 0; for (int y = 0; y < 3; y++) { diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index 73585fec2e..e86347e64e 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -183,7 +183,6 @@ void LogoScreen::render() { // ================== MenuScreen::MenuScreen() : frames_(0) { - // dl.StartDownload("http://www.ppsspp.org/unofficial/Win32/at3plusdecoder.dll.gz", "D:/at3plusdecoder.dll"); } void MenuScreen::update(InputState &input_state) { diff --git a/UI/OnScreenDisplay.cpp b/UI/OnScreenDisplay.cpp index 04f3e215aa..20a96b6e7a 100644 --- a/UI/OnScreenDisplay.cpp +++ b/UI/OnScreenDisplay.cpp @@ -1,10 +1,10 @@ -#include "UI/OnScreenDisplay.h" -#include "UI/ui_atlas.h" - +#include "UI/OnScreenDisplay.h" +#include "UI/ui_atlas.h" + #include "base/colorutil.h" -#include "base/display.h" -#include "base/timeutil.h" -#include "gfx_es2/draw_buffer.h" +#include "base/display.h" +#include "base/timeutil.h" +#include "gfx_es2/draw_buffer.h" OnScreenMessages osm;