Permalink
Browse files

GLES: Reduce conversion buf size if possible.

No need to use the stride for the temp buf.  May avoid issues if the
driver crashes when reading outside the FBO.
  • Loading branch information...
unknownbrackets committed Dec 21, 2017
1 parent 30871bf commit 8e2682d93c9b62e035c5f1324de7ae91b83e162e
Showing with 7 additions and 7 deletions.
  1. +7 −7 GPU/GLES/FramebufferManagerGLES.cpp
@@ -937,14 +937,14 @@ void FramebufferManagerGLES::PackFramebufferSync_(VirtualFramebuffer *vfb, int x
h = possibleH;
}
// Pixel size always 4 here because we always request RGBA8888
u32 bufSize = vfb->fb_stride * h * 4;
u32 fb_address = 0x04000000 | vfb->fb_address;
bool convert = vfb->format != GE_FORMAT_8888;
const int dstBpp = vfb->format == GE_FORMAT_8888 ? 4 : 2;
const int packWidth = std::min(vfb->fb_stride, std::min(x + w, (int)vfb->width));
// Pixel size always 4 here because we always request RGBA8888
u32 bufSize = packWidth * h * 4;
u32 fb_address = 0x04000000 | vfb->fb_address;
if (gl_extensions.IsGLES && !gl_extensions.GLES3 && packWidth != vfb->fb_stride && h != 1) {
// Need to use a temp buffer, since GLES2 doesn't support GL_PACK_ROW_LENGTH.
convert = true;
@@ -969,10 +969,10 @@ void FramebufferManagerGLES::PackFramebufferSync_(VirtualFramebuffer *vfb, int x
if (packed) {
DEBUG_LOG(FRAMEBUF, "Reading framebuffer to mem, bufSize = %u, fb_address = %08x", bufSize, fb_address);
// Avoid reading the part between width and stride, if possible.
int packW = !convert || h == 1 ? packWidth : vfb->fb_stride;
draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, 0, y, packW, h, Draw::DataFormat::R8G8B8A8_UNORM, packed, vfb->fb_stride);
int packStride = convert || h == 1 ? packWidth : vfb->fb_stride;
draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, 0, y, packWidth, h, Draw::DataFormat::R8G8B8A8_UNORM, packed, packStride);
if (convert) {
ConvertFromRGBA8888(dst, packed, vfb->fb_stride, vfb->fb_stride, packWidth, h, vfb->format);
ConvertFromRGBA8888(dst, packed, vfb->fb_stride, packStride, packWidth, h, vfb->format);
}
}

0 comments on commit 8e2682d

Please sign in to comment.