Skip to content

Commit

Permalink
Add FramebuffersToMem option to allow disabling of reading framebuffe…
Browse files Browse the repository at this point in the history
…r contents to memory (defaults to false).
  • Loading branch information
arnastia committed Jun 26, 2013
1 parent 32efe2a commit 98b9acf
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 29 deletions.
2 changes: 2 additions & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void Config::Load(const char *iniFileName)
#endif
graphics->Get("StretchToDisplay", &bStretchToDisplay, false);
graphics->Get("TrueColor", &bTrueColor, true);
graphics->Get("FramebuffersToMem", &bFramebuffersToMem, false);
graphics->Get("MipMap", &bMipMap, true);
graphics->Get("TexScalingLevel", &iTexScalingLevel, 1);
graphics->Get("TexScalingType", &iTexScalingType, 0);
Expand Down Expand Up @@ -216,6 +217,7 @@ void Config::Save()
#endif
graphics->Set("StretchToDisplay", bStretchToDisplay);
graphics->Set("TrueColor", bTrueColor);
graphics->Set("FramebuffersToMem", bFramebuffersToMem);
graphics->Set("MipMap", bMipMap);
graphics->Set("TexScalingLevel", iTexScalingLevel);
graphics->Set("TexScalingType", iTexScalingType);
Expand Down
1 change: 1 addition & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct Config
bool bFullScreen;
int iAnisotropyLevel;
bool bTrueColor;
bool bFramebuffersToMem;
bool bMipMap;
int iTexScalingLevel; // 1 = off, 2 = 2x, ..., 5 = 5x
int iTexScalingType; // 0 = xBRZ, 1 = Hybrid
Expand Down
60 changes: 31 additions & 29 deletions GPU/GLES/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,9 @@ void FramebufferManager::SetRenderFrameBuffer() {

// Save current render framebuffer to memory
if(currentRenderVfb_) {
// TODO: Add a way to disable the call since it is rather expensive.
ReadFramebufferToMemory(currentRenderVfb_);
if(g_Config.bFramebuffersToMem) {
ReadFramebufferToMemory(currentRenderVfb_);
}
}

// None found? Create one.
Expand Down Expand Up @@ -604,8 +605,9 @@ void FramebufferManager::CopyDisplayToOutput() {
glBindTexture(GL_TEXTURE_2D, 0);
}

// TODO: Add a way to disable the call since it is rather expensive.
ReadFramebufferToMemory(vfb);
if(g_Config.bFramebuffersToMem) {
ReadFramebufferToMemory(vfb);
}

if (resized_) {
glstate.depthWrite.set(GL_TRUE);
Expand Down Expand Up @@ -775,31 +777,31 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb) {

int pixelType, pixelSize, pixelFormat, align;
switch (vfb->format) {
case GE_FORMAT_4444: // 16 bit ABGR
pixelType = GL_UNSIGNED_SHORT_4_4_4_4_REV;
pixelFormat = GL_RGBA;
pixelSize = 2;
align = 8;
break;
case GE_FORMAT_5551: // 16 bit ABGR
pixelType = GL_UNSIGNED_SHORT_1_5_5_5_REV;
pixelFormat = GL_RGBA;
pixelSize = 2;
align = 8;
break;
case GE_FORMAT_565: // 16 bit BGR
pixelType = GL_UNSIGNED_SHORT_5_6_5_REV;
pixelFormat = GL_RGB;
pixelSize = 2;
align = 8;
break;
case GE_FORMAT_8888: // 32 bit ABGR
default: // And same as above
pixelType = GL_UNSIGNED_INT_8_8_8_8_REV;
pixelFormat = GL_RGBA;
pixelSize = 4;
align = 4;
break;
case GE_FORMAT_4444: // 16 bit ABGR
pixelType = GL_UNSIGNED_SHORT_4_4_4_4_REV;
pixelFormat = GL_RGBA;
pixelSize = 2;
align = 8;
break;
case GE_FORMAT_5551: // 16 bit ABGR
pixelType = GL_UNSIGNED_SHORT_1_5_5_5_REV;
pixelFormat = GL_RGBA;
pixelSize = 2;
align = 8;
break;
case GE_FORMAT_565: // 16 bit BGR
pixelType = GL_UNSIGNED_SHORT_5_6_5_REV;
pixelFormat = GL_RGB;
pixelSize = 2;
align = 8;
break;
case GE_FORMAT_8888: // 32 bit ABGR
default: // And same as above
pixelType = GL_UNSIGNED_INT_8_8_8_8_REV;
pixelFormat = GL_RGBA;
pixelSize = 4;
align = 4;
break;
}

if (useBufferedRendering_) {
Expand Down

0 comments on commit 98b9acf

Please sign in to comment.