diff options
| -rw-r--r-- | src/citra_qt/debugger/graphics_cmdlists.cpp | 9 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 65 | ||||
| -rw-r--r-- | src/video_core/pica.h | 22 |
3 files changed, 88 insertions, 8 deletions
diff --git a/src/citra_qt/debugger/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics_cmdlists.cpp index bf35f035f..95187e54d 100644 --- a/src/citra_qt/debugger/graphics_cmdlists.cpp +++ b/src/citra_qt/debugger/graphics_cmdlists.cpp | |||
| @@ -69,6 +69,13 @@ TextureInfoDockWidget::TextureInfoDockWidget(const Pica::DebugUtils::TextureInfo | |||
| 69 | format_choice->addItem(tr("RGBA5551")); | 69 | format_choice->addItem(tr("RGBA5551")); |
| 70 | format_choice->addItem(tr("RGB565")); | 70 | format_choice->addItem(tr("RGB565")); |
| 71 | format_choice->addItem(tr("RGBA4")); | 71 | format_choice->addItem(tr("RGBA4")); |
| 72 | format_choice->addItem(tr("IA8")); | ||
| 73 | format_choice->addItem(tr("UNK6")); | ||
| 74 | format_choice->addItem(tr("I8")); | ||
| 75 | format_choice->addItem(tr("A8")); | ||
| 76 | format_choice->addItem(tr("IA4")); | ||
| 77 | format_choice->addItem(tr("UNK10")); | ||
| 78 | format_choice->addItem(tr("A4")); | ||
| 72 | format_choice->setCurrentIndex(static_cast<int>(info.format)); | 79 | format_choice->setCurrentIndex(static_cast<int>(info.format)); |
| 73 | connect(format_choice, SIGNAL(currentIndexChanged(int)), this, SLOT(OnFormatChanged(int))); | 80 | connect(format_choice, SIGNAL(currentIndexChanged(int)), this, SLOT(OnFormatChanged(int))); |
| 74 | 81 | ||
| @@ -265,7 +272,7 @@ void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) { | |||
| 265 | auto format = Pica::registers.GetTextures()[index].format; | 272 | auto format = Pica::registers.GetTextures()[index].format; |
| 266 | 273 | ||
| 267 | auto info = Pica::DebugUtils::TextureInfo::FromPicaRegister(config, format); | 274 | auto info = Pica::DebugUtils::TextureInfo::FromPicaRegister(config, format); |
| 268 | u8* src = Memory::GetPointer(config.GetPhysicalAddress()); | 275 | u8* src = Memory::GetPointer(Pica::PAddrToVAddr(config.GetPhysicalAddress())); |
| 269 | new_info_widget = new TextureInfoWidget(src, info); | 276 | new_info_widget = new TextureInfoWidget(src, info); |
| 270 | } else { | 277 | } else { |
| 271 | new_info_widget = new QWidget; | 278 | new_info_widget = new QWidget; |
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 08ecd4ccb..1a7b851d5 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -418,6 +418,15 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture | |||
| 418 | return Math::MakeVec<u8>((r << 3) | (r >> 2), (g << 3) | (g >> 2), (b << 3) | (b >> 2), disable_alpha ? 255 : (a * 255)); | 418 | return Math::MakeVec<u8>((r << 3) | (r >> 2), (g << 3) | (g >> 2), (b << 3) | (b >> 2), disable_alpha ? 255 : (a * 255)); |
| 419 | } | 419 | } |
| 420 | 420 | ||
| 421 | case Regs::TextureFormat::RGB565: | ||
| 422 | { | ||
| 423 | const u16 source_ptr = *(const u16*)(source + coarse_x * block_height * 2 + coarse_y * info.stride + texel_index_within_tile * 2); | ||
| 424 | u8 r = (source_ptr >> 11) & 0x1F; | ||
| 425 | u8 g = ((source_ptr) >> 5) & 0x3F; | ||
| 426 | u8 b = (source_ptr) & 0x1F; | ||
| 427 | return Math::MakeVec<u8>((r << 3) | (r >> 2), (g << 2) | (g >> 4), (b << 3) | (b >> 2), 255); | ||
| 428 | } | ||
| 429 | |||
| 421 | case Regs::TextureFormat::RGBA4: | 430 | case Regs::TextureFormat::RGBA4: |
| 422 | { | 431 | { |
| 423 | const u8* source_ptr = source + coarse_x * block_height * 2 + coarse_y * info.stride + texel_index_within_tile * 2; | 432 | const u8* source_ptr = source + coarse_x * block_height * 2 + coarse_y * info.stride + texel_index_within_tile * 2; |
| @@ -432,6 +441,26 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture | |||
| 432 | return { r, g, b, disable_alpha ? 255 : a }; | 441 | return { r, g, b, disable_alpha ? 255 : a }; |
| 433 | } | 442 | } |
| 434 | 443 | ||
| 444 | case Regs::TextureFormat::IA8: | ||
| 445 | { | ||
| 446 | const u8* source_ptr = source + coarse_x * block_height * 2 + coarse_y * info.stride + texel_index_within_tile * 2; | ||
| 447 | |||
| 448 | // TODO: Better control this... | ||
| 449 | if (disable_alpha) { | ||
| 450 | return { *source_ptr, *(source_ptr+1), 0, 255 }; | ||
| 451 | } else { | ||
| 452 | return { *source_ptr, *source_ptr, *source_ptr, *(source_ptr+1)}; | ||
| 453 | } | ||
| 454 | } | ||
| 455 | |||
| 456 | case Regs::TextureFormat::I8: | ||
| 457 | { | ||
| 458 | const u8* source_ptr = source + coarse_x * block_height + coarse_y * info.stride + texel_index_within_tile; | ||
| 459 | |||
| 460 | // TODO: Better control this... | ||
| 461 | return { *source_ptr, *source_ptr, *source_ptr, 255 }; | ||
| 462 | } | ||
| 463 | |||
| 435 | case Regs::TextureFormat::A8: | 464 | case Regs::TextureFormat::A8: |
| 436 | { | 465 | { |
| 437 | const u8* source_ptr = source + coarse_x * block_height + coarse_y * info.stride + texel_index_within_tile; | 466 | const u8* source_ptr = source + coarse_x * block_height + coarse_y * info.stride + texel_index_within_tile; |
| @@ -444,6 +473,40 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture | |||
| 444 | } | 473 | } |
| 445 | } | 474 | } |
| 446 | 475 | ||
| 476 | case Regs::TextureFormat::IA4: | ||
| 477 | { | ||
| 478 | const u8* source_ptr = source + coarse_x * block_height / 2 + coarse_y * info.stride + texel_index_within_tile / 2; | ||
| 479 | |||
| 480 | // TODO: Order? | ||
| 481 | u8 i = (*source_ptr)&0xF; | ||
| 482 | u8 a = ((*source_ptr) & 0xF0) >> 4; | ||
| 483 | a |= a << 4; | ||
| 484 | i |= i << 4; | ||
| 485 | |||
| 486 | // TODO: Better control this... | ||
| 487 | if (disable_alpha) { | ||
| 488 | return { i, a, 0, 255 }; | ||
| 489 | } else { | ||
| 490 | return { i, i, i, a }; | ||
| 491 | } | ||
| 492 | } | ||
| 493 | |||
| 494 | case Regs::TextureFormat::A4: | ||
| 495 | { | ||
| 496 | const u8* source_ptr = source + coarse_x * block_height / 2 + coarse_y * info.stride + texel_index_within_tile / 2; | ||
| 497 | |||
| 498 | // TODO: Order? | ||
| 499 | u8 a = (coarse_x % 2) ? ((*source_ptr)&0xF) : (((*source_ptr) & 0xF0) >> 4); | ||
| 500 | a |= a << 4; | ||
| 501 | |||
| 502 | // TODO: Better control this... | ||
| 503 | if (disable_alpha) { | ||
| 504 | return { *source_ptr, *source_ptr, *source_ptr, 255 }; | ||
| 505 | } else { | ||
| 506 | return { 0, 0, 0, *source_ptr }; | ||
| 507 | } | ||
| 508 | } | ||
| 509 | |||
| 447 | default: | 510 | default: |
| 448 | LOG_ERROR(HW_GPU, "Unknown texture format: %x", (u32)info.format); | 511 | LOG_ERROR(HW_GPU, "Unknown texture format: %x", (u32)info.format); |
| 449 | _dbg_assert_(HW_GPU, 0); | 512 | _dbg_assert_(HW_GPU, 0); |
| @@ -459,7 +522,7 @@ TextureInfo TextureInfo::FromPicaRegister(const Regs::TextureConfig& config, | |||
| 459 | info.width = config.width; | 522 | info.width = config.width; |
| 460 | info.height = config.height; | 523 | info.height = config.height; |
| 461 | info.format = format; | 524 | info.format = format; |
| 462 | info.stride = Pica::Regs::BytesPerPixel(info.format) * info.width; | 525 | info.stride = Pica::Regs::NibblesPerPixel(info.format) * info.width / 2; |
| 463 | return info; | 526 | return info; |
| 464 | } | 527 | } |
| 465 | 528 | ||
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 7d82d733d..583614328 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -142,29 +142,39 @@ struct Regs { | |||
| 142 | RGBA5551 = 2, | 142 | RGBA5551 = 2, |
| 143 | RGB565 = 3, | 143 | RGB565 = 3, |
| 144 | RGBA4 = 4, | 144 | RGBA4 = 4, |
| 145 | IA8 = 5, | ||
| 145 | 146 | ||
| 147 | I8 = 7, | ||
| 146 | A8 = 8, | 148 | A8 = 8, |
| 149 | IA4 = 9, | ||
| 147 | 150 | ||
| 151 | A4 = 11, | ||
| 148 | // TODO: Support for the other formats is not implemented, yet. | 152 | // TODO: Support for the other formats is not implemented, yet. |
| 149 | // Seems like they are luminance formats and compressed textures. | 153 | // Seems like they are luminance formats and compressed textures. |
| 150 | }; | 154 | }; |
| 151 | 155 | ||
| 152 | static unsigned BytesPerPixel(TextureFormat format) { | 156 | static unsigned NibblesPerPixel(TextureFormat format) { |
| 153 | switch (format) { | 157 | switch (format) { |
| 154 | case TextureFormat::RGBA8: | 158 | case TextureFormat::RGBA8: |
| 155 | return 4; | 159 | return 8; |
| 156 | 160 | ||
| 157 | case TextureFormat::RGB8: | 161 | case TextureFormat::RGB8: |
| 158 | return 3; | 162 | return 6; |
| 159 | 163 | ||
| 160 | case TextureFormat::RGBA5551: | 164 | case TextureFormat::RGBA5551: |
| 161 | case TextureFormat::RGB565: | 165 | case TextureFormat::RGB565: |
| 162 | case TextureFormat::RGBA4: | 166 | case TextureFormat::RGBA4: |
| 163 | return 2; | 167 | case TextureFormat::IA8: |
| 168 | return 4; | ||
| 164 | 169 | ||
| 165 | default: | 170 | case TextureFormat::A4: |
| 166 | // placeholder for yet unknown formats | ||
| 167 | return 1; | 171 | return 1; |
| 172 | |||
| 173 | case TextureFormat::I8: | ||
| 174 | case TextureFormat::A8: | ||
| 175 | case TextureFormat::IA4: | ||
| 176 | default: // placeholder for yet unknown formats | ||
| 177 | return 2; | ||
| 168 | } | 178 | } |
| 169 | } | 179 | } |
| 170 | 180 | ||