summaryrefslogtreecommitdiff
path: root/src/video_core/debug_utils
diff options
context:
space:
mode:
authorGravatar Tony Wasserka2014-12-10 21:51:00 +0100
committerGravatar Tony Wasserka2014-12-20 18:06:54 +0100
commit1c972ef3b93252a157ec15d0878a2be3e4b46a0e (patch)
treeef6432579232cf4d040eb2694a06c7f807deeae0 /src/video_core/debug_utils
parentPica: Unify ugly address translation hacks. (diff)
downloadyuzu-1c972ef3b93252a157ec15d0878a2be3e4b46a0e.tar.gz
yuzu-1c972ef3b93252a157ec15d0878a2be3e4b46a0e.tar.xz
yuzu-1c972ef3b93252a157ec15d0878a2be3e4b46a0e.zip
Add support for a ridiculous number of texture formats.
Diffstat (limited to 'src/video_core/debug_utils')
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp65
1 files changed, 64 insertions, 1 deletions
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