From c564c21668912b803947adddc166ff1315b218e4 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 23 Feb 2015 18:24:35 -0500 Subject: GPU: Implemented bits 3 and 1 from the display transfer flags. Bit 3 is used to specify a raw copy, where no processing is done to the data, seems to behave exactly as a DMA. Bit 1 is used to specify whether to convert from a tiled format to a linear format or viceversa. --- src/citra_qt/debugger/graphics_framebuffer.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/citra_qt/debugger/graphics_framebuffer.cpp') diff --git a/src/citra_qt/debugger/graphics_framebuffer.cpp b/src/citra_qt/debugger/graphics_framebuffer.cpp index 1ba60021..574f19cc 100644 --- a/src/citra_qt/debugger/graphics_framebuffer.cpp +++ b/src/citra_qt/debugger/graphics_framebuffer.cpp @@ -9,8 +9,10 @@ #include #include +#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); -- cgit v1.2.3