Permalink
Browse files

thin3d: Fix requesting BGRA buffers.

Should be fine to request BGRA->BGRA.

Also, the reverse flags were wrong/ignored on the format.
  • Loading branch information...
unknownbrackets committed Jun 16, 2018
1 parent b7ac9a6 commit c97023568cd20a34f44d659ed88e3c3a8b4ac5f5
Showing with 14 additions and 3 deletions.
  1. +2 −2 GPU/Common/FramebufferCommon.cpp
  2. +12 −1 ext/native/thin3d/thin3d.cpp
@@ -1937,7 +1937,7 @@ bool FramebufferManagerCommon::GetFramebuffer(u32 fb_address, int fb_stride, GEB
// TODO: Maybe should handle flipY inside CopyFramebufferToMemorySync somehow?
bool flipY = (GetGPUBackend() == GPUBackend::OPENGL && !useBufferedRendering_) ? true : false;
buffer.Allocate(w, h, GE_FORMAT_8888, flipY, true);
buffer.Allocate(w, h, GE_FORMAT_8888, flipY);
bool retval = draw_->CopyFramebufferToMemorySync(bound, Draw::FB_COLOR_BIT, 0, 0, w, h, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), w);
gpuStats.numReadbacks++;
// After a readback we'll have flushed and started over, need to dirty a bunch of things to be safe.
@@ -2015,7 +2015,7 @@ bool FramebufferManagerCommon::GetStencilbuffer(u32 fb_address, int fb_stride, G
bool FramebufferManagerCommon::GetOutputFramebuffer(GPUDebugBuffer &buffer) {
int w, h;
draw_->GetFramebufferDimensions(nullptr, &w, &h);
buffer.Allocate(w, h, GE_FORMAT_8888, false, true);
buffer.Allocate(w, h, GE_FORMAT_8888, false);
bool retval = draw_->CopyFramebufferToMemorySync(nullptr, Draw::FB_COLOR_BIT, 0, 0, w, h, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), w);
// That may have unbound the framebuffer, rebind to avoid crashes when debugging.
RebindFramebuffer();
@@ -421,7 +421,18 @@ void ConvertFromBGRA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, u
// Must skip stride in the cases below. Some games pack data into the cracks, like MotoGP.
const uint32_t *src32 = (const uint32_t *)src;
if (format == Draw::DataFormat::R8G8B8A8_UNORM) {
if (format == Draw::DataFormat::B8G8R8A8_UNORM) {
uint32_t *dst32 = (uint32_t *)dst;
if (src == dst) {
return;
} else {
for (uint32_t y = 0; y < height; ++y) {
memcpy(dst32, src32, width * 4);
src32 += srcStride;
dst32 += dstStride;
}
}
} else if (format == Draw::DataFormat::R8G8B8A8_UNORM) {
uint32_t *dst32 = (uint32_t *)dst;
for (uint32_t y = 0; y < height; ++y) {
ConvertBGRA8888ToRGBA8888(dst32, src32, width);

0 comments on commit c970235

Please sign in to comment.