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.
This commit is contained in:
Subv 2015-02-23 18:24:35 -05:00
parent c7dac73b0c
commit c564c21668
6 changed files with 169 additions and 81 deletions

View file

@ -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);