diff options
| author | 2015-03-03 19:11:07 -0500 | |
|---|---|---|
| committer | 2015-03-03 19:11:07 -0500 | |
| commit | 510246ddce546219ab5586b6cf991752dc78338d (patch) | |
| tree | 20a611dd0e2d30203d756f79d86838ad22e01f02 /src/citra_qt/debugger/graphics_framebuffer.cpp | |
| parent | Merge pull request #622 from Subv/titles (diff) | |
| parent | GPU: Added RGB565/RGB8 framebuffer support and various cleanups. (diff) | |
| download | yuzu-510246ddce546219ab5586b6cf991752dc78338d.tar.gz yuzu-510246ddce546219ab5586b6cf991752dc78338d.tar.xz yuzu-510246ddce546219ab5586b6cf991752dc78338d.zip | |
Merge pull request #617 from bunnei/framebuffer-rgb565
GPU: Added RGB565/RGB8 framebuffer support and various cleanups.
Diffstat (limited to 'src/citra_qt/debugger/graphics_framebuffer.cpp')
| -rw-r--r-- | src/citra_qt/debugger/graphics_framebuffer.cpp | 88 |
1 files changed, 31 insertions, 57 deletions
diff --git a/src/citra_qt/debugger/graphics_framebuffer.cpp b/src/citra_qt/debugger/graphics_framebuffer.cpp index 574f19cc1..5bd6c0235 100644 --- a/src/citra_qt/debugger/graphics_framebuffer.cpp +++ b/src/citra_qt/debugger/graphics_framebuffer.cpp | |||
| @@ -46,7 +46,7 @@ GraphicsFramebufferWidget::GraphicsFramebufferWidget(std::shared_ptr<Pica::Debug | |||
| 46 | framebuffer_format_control = new QComboBox; | 46 | framebuffer_format_control = new QComboBox; |
| 47 | framebuffer_format_control->addItem(tr("RGBA8")); | 47 | framebuffer_format_control->addItem(tr("RGBA8")); |
| 48 | framebuffer_format_control->addItem(tr("RGB8")); | 48 | framebuffer_format_control->addItem(tr("RGB8")); |
| 49 | framebuffer_format_control->addItem(tr("RGBA5551")); | 49 | framebuffer_format_control->addItem(tr("RGB5A1")); |
| 50 | framebuffer_format_control->addItem(tr("RGB565")); | 50 | framebuffer_format_control->addItem(tr("RGB565")); |
| 51 | framebuffer_format_control->addItem(tr("RGBA4")); | 51 | framebuffer_format_control->addItem(tr("RGBA4")); |
| 52 | 52 | ||
| @@ -199,66 +199,40 @@ void GraphicsFramebufferWidget::OnUpdate() | |||
| 199 | // TODO: Unify this decoding code with the texture decoder | 199 | // TODO: Unify this decoding code with the texture decoder |
| 200 | u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(framebuffer_format)); | 200 | u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(framebuffer_format)); |
| 201 | 201 | ||
| 202 | switch (framebuffer_format) { | 202 | QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32); |
| 203 | case Format::RGBA8: | 203 | u8* color_buffer = Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); |
| 204 | { | 204 | for (unsigned int y = 0; y < framebuffer_height; ++y) { |
| 205 | QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32); | 205 | for (unsigned int x = 0; x < framebuffer_width; ++x) { |
| 206 | u8* color_buffer = Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); | 206 | const u32 coarse_y = y & ~7; |
| 207 | for (unsigned int y = 0; y < framebuffer_height; ++y) { | 207 | u32 offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * framebuffer_width * bytes_per_pixel; |
| 208 | for (unsigned int x = 0; x < framebuffer_width; ++x) { | 208 | const u8* pixel = color_buffer + offset; |
| 209 | const u32 coarse_y = y & ~7; | 209 | Math::Vec4<u8> color = { 0, 0, 0, 0 }; |
| 210 | u32 offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * framebuffer_width * bytes_per_pixel; | 210 | |
| 211 | u8* value = color_buffer + offset; | 211 | switch (framebuffer_format) { |
| 212 | 212 | case Format::RGBA8: | |
| 213 | decoded_image.setPixel(x, y, qRgba(value[3], value[2], value[1], 255/*value >> 24*/)); | 213 | color = Color::DecodeRGBA8(pixel); |
| 214 | break; | ||
| 215 | case Format::RGB8: | ||
| 216 | color = Color::DecodeRGB8(pixel); | ||
| 217 | break; | ||
| 218 | case Format::RGB5A1: | ||
| 219 | color = Color::DecodeRGB5A1(pixel); | ||
| 220 | break; | ||
| 221 | case Format::RGB565: | ||
| 222 | color = Color::DecodeRGB565(pixel); | ||
| 223 | break; | ||
| 224 | case Format::RGBA4: | ||
| 225 | color = Color::DecodeRGBA4(pixel); | ||
| 226 | break; | ||
| 227 | default: | ||
| 228 | qDebug() << "Unknown fb color format " << static_cast<int>(framebuffer_format); | ||
| 229 | break; | ||
| 214 | } | 230 | } |
| 215 | } | ||
| 216 | pixmap = QPixmap::fromImage(decoded_image); | ||
| 217 | break; | ||
| 218 | } | ||
| 219 | 231 | ||
| 220 | case Format::RGB8: | 232 | decoded_image.setPixel(x, y, qRgba(color.r(), color.g(), color.b(), 255)); |
| 221 | { | ||
| 222 | QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32); | ||
| 223 | u8* color_buffer = Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); | ||
| 224 | for (unsigned int y = 0; y < framebuffer_height; ++y) { | ||
| 225 | for (unsigned int x = 0; x < framebuffer_width; ++x) { | ||
| 226 | const u32 coarse_y = y & ~7; | ||
| 227 | u32 offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * framebuffer_width * bytes_per_pixel; | ||
| 228 | u8* pixel_pointer = color_buffer + offset; | ||
| 229 | |||
| 230 | decoded_image.setPixel(x, y, qRgba(pixel_pointer[0], pixel_pointer[1], pixel_pointer[2], 255/*value >> 24*/)); | ||
| 231 | } | ||
| 232 | } | 233 | } |
| 233 | pixmap = QPixmap::fromImage(decoded_image); | ||
| 234 | break; | ||
| 235 | } | ||
| 236 | |||
| 237 | case Format::RGBA5551: | ||
| 238 | { | ||
| 239 | QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32); | ||
| 240 | u8* color_buffer = Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); | ||
| 241 | for (unsigned int y = 0; y < framebuffer_height; ++y) { | ||
| 242 | for (unsigned int x = 0; x < framebuffer_width; ++x) { | ||
| 243 | const u32 coarse_y = y & ~7; | ||
| 244 | u32 offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * framebuffer_width * bytes_per_pixel; | ||
| 245 | u16 value = *(u16*)(color_buffer + offset); | ||
| 246 | u8 r = Color::Convert5To8((value >> 11) & 0x1F); | ||
| 247 | u8 g = Color::Convert5To8((value >> 6) & 0x1F); | ||
| 248 | u8 b = Color::Convert5To8((value >> 1) & 0x1F); | ||
| 249 | u8 a = Color::Convert1To8(value & 1); | ||
| 250 | |||
| 251 | decoded_image.setPixel(x, y, qRgba(r, g, b, 255/*a*/)); | ||
| 252 | } | ||
| 253 | } | ||
| 254 | pixmap = QPixmap::fromImage(decoded_image); | ||
| 255 | break; | ||
| 256 | } | ||
| 257 | |||
| 258 | default: | ||
| 259 | qDebug() << "Unknown fb color format " << static_cast<int>(framebuffer_format); | ||
| 260 | break; | ||
| 261 | } | 234 | } |
| 235 | pixmap = QPixmap::fromImage(decoded_image); | ||
| 262 | 236 | ||
| 263 | framebuffer_address_control->SetValue(framebuffer_address); | 237 | framebuffer_address_control->SetValue(framebuffer_address); |
| 264 | framebuffer_width_control->setValue(framebuffer_width); | 238 | framebuffer_width_control->setValue(framebuffer_width); |