summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Wasserka <NeoBrainX@gmail.com>2014-12-06 21:20:56 +0100
committerTony Wasserka <NeoBrainX@gmail.com>2014-12-20 18:05:53 +0100
commitc81f1a9ebc9a5f9df9add64e282d9a0c0da96e79 (patch)
tree13f5c29306e0510de93ea7a387b192a89d390c27
parentcitra-qt: Fix invalid memory read upon program startup. (diff)
downloadyuzu-c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79.tar
yuzu-c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79.tar.gz
yuzu-c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79.tar.bz2
yuzu-c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79.tar.lz
yuzu-c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79.tar.xz
yuzu-c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79.tar.zst
yuzu-c81f1a9ebc9a5f9df9add64e282d9a0c0da96e79.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp49
-rw-r--r--src/video_core/pica.h2
2 files changed, 48 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()
}
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,
diff --git a/src/video_core/pica.h b/src/video_core/pica.h
index 92a87c086..7ed49caed 100644
--- a/src/video_core/pica.h
+++ b/src/video_core/pica.h
@@ -132,6 +132,8 @@ struct Regs {
RGB565 = 3,
RGBA4 = 4,
+ A8 = 8,
+
// TODO: Support for the other formats is not implemented, yet.
// Seems like they are luminance formats and compressed textures.
};