aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/video_core/debug_utils
diff options
context:
space:
mode:
authorGravatar Tony Wasserka <NeoBrainX@gmail.com>2014-12-06 21:20:56 +0100
committerGravatar Tony Wasserka <NeoBrainX@gmail.com>2014-12-20 18:05:53 +0100
commitc81f1a9ebc9a5f9df9add64e282d9a0c0da96e79 (patch)
tree13f5c29306e0510de93ea7a387b192a89d390c27 /src/video_core/debug_utils
parent782592e6d393f4e38db5db58daba3f7fbf1786b4 (diff)
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.cpp49
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 1a20f19e..89bf08b9 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()
}
const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const TextureInfo& info) {
- _dbg_assert_(Debug_GPU, info.format == Pica::Regs::TextureFormat::RGB8);
// Cf. rasterizer code for an explanation of this algorithm.
int texel_index_within_tile = 0;
@@ -376,8 +375,52 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture
int coarse_x = (x / block_width) * block_width;
int coarse_y = (y / block_height) * block_height;
- const u8* source_ptr = source + coarse_x * block_height * 3 + coarse_y * info.stride + texel_index_within_tile * 3;
- return { source_ptr[2], source_ptr[1], source_ptr[0], 255 };
+ switch (info.format) {
+ case Regs::TextureFormat::RGBA8:
+ {
+ const u8* source_ptr = source + coarse_x * block_height * 4 + coarse_y * info.stride + texel_index_within_tile * 4;
+ return { source_ptr[3], source_ptr[2], source_ptr[1], 255 };
+ }
+
+ case Regs::TextureFormat::RGB8:
+ {
+ const u8* source_ptr = source + coarse_x * block_height * 3 + coarse_y * info.stride + texel_index_within_tile * 3;
+ return { source_ptr[2], source_ptr[1], source_ptr[0], 255 };
+ }
+
+ case Regs::TextureFormat::RGBA5551:
+ {
+ const u16 source_ptr = *(const u16*)(source + coarse_x * block_height * 2 + coarse_y * info.stride + texel_index_within_tile * 2);
+ u8 r = (source_ptr >> 11) & 0x1F;
+ u8 g = ((source_ptr) >> 6) & 0x1F;
+ u8 b = (source_ptr >> 1) & 0x1F;
+ u8 a = 1;
+ return Math::MakeVec<u8>((r << 3) | (r >> 2), (g << 3) | (g >> 2), (b << 3) | (b >> 2), a * 255);
+ }
+
+ case Regs::TextureFormat::RGBA4:
+ {
+ const u8* source_ptr = source + coarse_x * block_height * 2 + coarse_y * info.stride + texel_index_within_tile * 2;
+ u8 r = source_ptr[1] >> 4;
+ u8 g = source_ptr[1] & 0xFF;
+ u8 b = source_ptr[0] >> 4;
+ r = (r << 4) | r;
+ g = (g << 4) | g;
+ b = (b << 4) | b;
+ return { r, g, b, 255 };
+ }
+
+ case Regs::TextureFormat::A8:
+ {
+ const u8* source_ptr = source + coarse_x * block_height + coarse_y * info.stride + texel_index_within_tile;
+ return { *source_ptr, *source_ptr, *source_ptr, 255 };
+ }
+
+ default:
+ LOG_ERROR(HW_GPU, "Unknown texture format: %x", (u32)info.format);
+ _dbg_assert_(HW_GPU, 0);
+ return {};
+ }
}
TextureInfo TextureInfo::FromPicaRegister(const Regs::TextureConfig& config,