mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-17 04:39:34 +00:00
Only create backing texture for DrawPixels when needed.
This commit is contained in:
parent
1c09548395
commit
2221f221e3
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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++) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user