diff options
| author | 2014-12-06 21:20:56 +0100 | |
|---|---|---|
| committer | 2014-12-20 18:05:53 +0100 | |
| commit | c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79 (patch) | |
| tree | 13f5c29306e0510de93ea7a387b192a89d390c27 /src/video_core/debug_utils | |
| parent | citra-qt: Fix invalid memory read upon program startup. (diff) | |
| download | yuzu-c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79.tar.gz yuzu-c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79.tar.xz yuzu-c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79.zip | |
Pica/DebugUtils: Add support for RGBA8, RGBA5551, RGBA4 and A8 texture formats.
Diffstat (limited to 'src/video_core/debug_utils')
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 1a20f19ec..89bf08b99 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -357,7 +357,6 @@ std::unique_ptr<PicaTrace> FinishPicaTracing() | |||
| 357 | } | 357 | } |
| 358 | 358 | ||
| 359 | const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const TextureInfo& info) { | 359 | const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const TextureInfo& info) { |
| 360 | _dbg_assert_(Debug_GPU, info.format == Pica::Regs::TextureFormat::RGB8); | ||
| 361 | 360 | ||
| 362 | // Cf. rasterizer code for an explanation of this algorithm. | 361 | // Cf. rasterizer code for an explanation of this algorithm. |
| 363 | int texel_index_within_tile = 0; | 362 | int texel_index_within_tile = 0; |
| @@ -376,8 +375,52 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture | |||
| 376 | int coarse_x = (x / block_width) * block_width; | 375 | int coarse_x = (x / block_width) * block_width; |
| 377 | int coarse_y = (y / block_height) * block_height; | 376 | int coarse_y = (y / block_height) * block_height; |
| 378 | 377 | ||
| 379 | const u8* source_ptr = source + coarse_x * block_height * 3 + coarse_y * info.stride + texel_index_within_tile * 3; | 378 | switch (info.format) { |
| 380 | return { source_ptr[2], source_ptr[1], source_ptr[0], 255 }; | 379 | case Regs::TextureFormat::RGBA8: |
| 380 | { | ||
| 381 | const u8* source_ptr = source + coarse_x * block_height * 4 + coarse_y * info.stride + texel_index_within_tile * 4; | ||
| 382 | return { source_ptr[3], source_ptr[2], source_ptr[1], 255 }; | ||
| 383 | } | ||
| 384 | |||
| 385 | case Regs::TextureFormat::RGB8: | ||
| 386 | { | ||
| 387 | const u8* source_ptr = source + coarse_x * block_height * 3 + coarse_y * info.stride + texel_index_within_tile * 3; | ||
| 388 | return { source_ptr[2], source_ptr[1], source_ptr[0], 255 }; | ||
| 389 | } | ||
| 390 | |||
| 391 | case Regs::TextureFormat::RGBA5551: | ||
| 392 | { | ||
| 393 | const u16 source_ptr = *(const u16*)(source + coarse_x * block_height * 2 + coarse_y * info.stride + texel_index_within_tile * 2); | ||
| 394 | u8 r = (source_ptr >> 11) & 0x1F; | ||
| 395 | u8 g = ((source_ptr) >> 6) & 0x1F; | ||
| 396 | u8 b = (source_ptr >> 1) & 0x1F; | ||
| 397 | u8 a = 1; | ||
| 398 | return Math::MakeVec<u8>((r << 3) | (r >> 2), (g << 3) | (g >> 2), (b << 3) | (b >> 2), a * 255); | ||
| 399 | } | ||
| 400 | |||
| 401 | case Regs::TextureFormat::RGBA4: | ||
| 402 | { | ||
| 403 | const u8* source_ptr = source + coarse_x * block_height * 2 + coarse_y * info.stride + texel_index_within_tile * 2; | ||
| 404 | u8 r = source_ptr[1] >> 4; | ||
| 405 | u8 g = source_ptr[1] & 0xFF; | ||
| 406 | u8 b = source_ptr[0] >> 4; | ||
| 407 | r = (r << 4) | r; | ||
| 408 | g = (g << 4) | g; | ||
| 409 | b = (b << 4) | b; | ||
| 410 | return { r, g, b, 255 }; | ||
| 411 | } | ||
| 412 | |||
| 413 | case Regs::TextureFormat::A8: | ||
| 414 | { | ||
| 415 | const u8* source_ptr = source + coarse_x * block_height + coarse_y * info.stride + texel_index_within_tile; | ||
| 416 | return { *source_ptr, *source_ptr, *source_ptr, 255 }; | ||
| 417 | } | ||
| 418 | |||
| 419 | default: | ||
| 420 | LOG_ERROR(HW_GPU, "Unknown texture format: %x", (u32)info.format); | ||
| 421 | _dbg_assert_(HW_GPU, 0); | ||
| 422 | return {}; | ||
| 423 | } | ||
| 381 | } | 424 | } |
| 382 | 425 | ||
| 383 | TextureInfo TextureInfo::FromPicaRegister(const Regs::TextureConfig& config, | 426 | TextureInfo TextureInfo::FromPicaRegister(const Regs::TextureConfig& config, |