diff options
author | bunnei <bunneidev@gmail.com> | 2015-02-27 04:40:27 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2015-02-27 04:40:27 +0100 |
commit | c9ef377afaa038797de6c08da9f204acf67ed1fc (patch) | |
tree | ab2c741325e2e81e4352b4934972151fceae8d5e /src/citra_qt | |
parent | Merge pull request #614 from lioncash/mcr (diff) | |
parent | GPU: Implemented bits 3 and 1 from the display transfer flags. (diff) | |
download | yuzu-c9ef377afaa038797de6c08da9f204acf67ed1fc.tar yuzu-c9ef377afaa038797de6c08da9f204acf67ed1fc.tar.gz yuzu-c9ef377afaa038797de6c08da9f204acf67ed1fc.tar.bz2 yuzu-c9ef377afaa038797de6c08da9f204acf67ed1fc.tar.lz yuzu-c9ef377afaa038797de6c08da9f204acf67ed1fc.tar.xz yuzu-c9ef377afaa038797de6c08da9f204acf67ed1fc.tar.zst yuzu-c9ef377afaa038797de6c08da9f204acf67ed1fc.zip |
Diffstat (limited to 'src/citra_qt')
-rw-r--r-- | src/citra_qt/debugger/graphics_framebuffer.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/citra_qt/debugger/graphics_framebuffer.cpp b/src/citra_qt/debugger/graphics_framebuffer.cpp index 1ba60021f..574f19cc1 100644 --- a/src/citra_qt/debugger/graphics_framebuffer.cpp +++ b/src/citra_qt/debugger/graphics_framebuffer.cpp @@ -9,8 +9,10 @@ #include <QPushButton> #include <QSpinBox> +#include "core/hw/gpu.h" #include "video_core/color.h" #include "video_core/pica.h" +#include "video_core/utils.h" #include "graphics_framebuffer.h" @@ -195,16 +197,20 @@ void GraphicsFramebufferWidget::OnUpdate() // TODO: Implement a good way to visualize alpha components! // TODO: Unify this decoding code with the texture decoder + u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(framebuffer_format)); + switch (framebuffer_format) { case Format::RGBA8: { QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32); - u32* color_buffer = (u32*)Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); + u8* color_buffer = Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); for (unsigned int y = 0; y < framebuffer_height; ++y) { for (unsigned int x = 0; x < framebuffer_width; ++x) { - u32 value = *(color_buffer + x + y * framebuffer_width); + const u32 coarse_y = y & ~7; + u32 offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * framebuffer_width * bytes_per_pixel; + u8* value = color_buffer + offset; - decoded_image.setPixel(x, y, qRgba((value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, 255/*value >> 24*/)); + decoded_image.setPixel(x, y, qRgba(value[3], value[2], value[1], 255/*value >> 24*/)); } } pixmap = QPixmap::fromImage(decoded_image); @@ -217,7 +223,9 @@ void GraphicsFramebufferWidget::OnUpdate() u8* color_buffer = Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); for (unsigned int y = 0; y < framebuffer_height; ++y) { for (unsigned int x = 0; x < framebuffer_width; ++x) { - u8* pixel_pointer = color_buffer + x * 3 + y * 3 * framebuffer_width; + const u32 coarse_y = y & ~7; + u32 offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * framebuffer_width * bytes_per_pixel; + u8* pixel_pointer = color_buffer + offset; decoded_image.setPixel(x, y, qRgba(pixel_pointer[0], pixel_pointer[1], pixel_pointer[2], 255/*value >> 24*/)); } @@ -229,10 +237,12 @@ void GraphicsFramebufferWidget::OnUpdate() case Format::RGBA5551: { QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32); - u32* color_buffer = (u32*)Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); + u8* color_buffer = Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); for (unsigned int y = 0; y < framebuffer_height; ++y) { for (unsigned int x = 0; x < framebuffer_width; ++x) { - u16 value = *(u16*)(((u8*)color_buffer) + x * 2 + y * framebuffer_width * 2); + const u32 coarse_y = y & ~7; + u32 offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * framebuffer_width * bytes_per_pixel; + u16 value = *(u16*)(color_buffer + offset); u8 r = Color::Convert5To8((value >> 11) & 0x1F); u8 g = Color::Convert5To8((value >> 6) & 0x1F); u8 b = Color::Convert5To8((value >> 1) & 0x1F); |