diff options
| author | 2015-02-25 22:44:55 -0500 | |
|---|---|---|
| committer | 2015-03-03 18:26:03 -0500 | |
| commit | 34c31db14a98013ee802bd5ae31c775768f12439 (patch) | |
| tree | 20a611dd0e2d30203d756f79d86838ad22e01f02 /src/video_core/debug_utils | |
| parent | Merge pull request #622 from Subv/titles (diff) | |
| download | yuzu-34c31db14a98013ee802bd5ae31c775768f12439.tar.gz yuzu-34c31db14a98013ee802bd5ae31c775768f12439.tar.xz yuzu-34c31db14a98013ee802bd5ae31c775768f12439.zip | |
GPU: Added RGB565/RGB8 framebuffer support and various cleanups.
- Centralizes color format encode/decode functions.
- Fixes endianness issues.
- Implements remaining framebuffer formats in the debugger.
Diffstat (limited to 'src/video_core/debug_utils')
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 27c246a99..a27d3828c 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -321,44 +321,32 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture | |||
| 321 | switch (info.format) { | 321 | switch (info.format) { |
| 322 | case Regs::TextureFormat::RGBA8: | 322 | case Regs::TextureFormat::RGBA8: |
| 323 | { | 323 | { |
| 324 | const u8* source_ptr = source + VideoCore::GetMortonOffset(x, y, 4); | 324 | auto res = Color::DecodeRGBA8(source + VideoCore::GetMortonOffset(x, y, 4)); |
| 325 | return { source_ptr[3], source_ptr[2], source_ptr[1], disable_alpha ? (u8)255 : source_ptr[0] }; | 325 | return { res.r(), res.g(), res.b(), disable_alpha ? 255 : res.a() }; |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | case Regs::TextureFormat::RGB8: | 328 | case Regs::TextureFormat::RGB8: |
| 329 | { | 329 | { |
| 330 | const u8* source_ptr = source + VideoCore::GetMortonOffset(x, y, 3); | 330 | auto res = Color::DecodeRGB8(source + VideoCore::GetMortonOffset(x, y, 3)); |
| 331 | return { source_ptr[2], source_ptr[1], source_ptr[0], 255 }; | 331 | return { res.r(), res.g(), res.b(), 255 }; |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | case Regs::TextureFormat::RGBA5551: | 334 | case Regs::TextureFormat::RGB5A1: |
| 335 | { | 335 | { |
| 336 | const u16 source_ptr = *(const u16*)(source + VideoCore::GetMortonOffset(x, y, 2)); | 336 | auto res = Color::DecodeRGB5A1(source + VideoCore::GetMortonOffset(x, y, 2)); |
| 337 | u8 r = (source_ptr >> 11) & 0x1F; | 337 | return { res.r(), res.g(), res.b(), disable_alpha ? 255 : res.a() }; |
| 338 | u8 g = ((source_ptr) >> 6) & 0x1F; | ||
| 339 | u8 b = (source_ptr >> 1) & 0x1F; | ||
| 340 | u8 a = source_ptr & 1; | ||
| 341 | return Math::MakeVec<u8>(Color::Convert5To8(r), Color::Convert5To8(g), | ||
| 342 | Color::Convert5To8(b), disable_alpha ? 255 : Color::Convert1To8(a)); | ||
| 343 | } | 338 | } |
| 344 | 339 | ||
| 345 | case Regs::TextureFormat::RGB565: | 340 | case Regs::TextureFormat::RGB565: |
| 346 | { | 341 | { |
| 347 | const u16 source_ptr = *(const u16*)(source + VideoCore::GetMortonOffset(x, y, 2)); | 342 | auto res = Color::DecodeRGB565(source + VideoCore::GetMortonOffset(x, y, 2)); |
| 348 | u8 r = Color::Convert5To8((source_ptr >> 11) & 0x1F); | 343 | return { res.r(), res.g(), res.b(), 255 }; |
| 349 | u8 g = Color::Convert6To8(((source_ptr) >> 5) & 0x3F); | ||
| 350 | u8 b = Color::Convert5To8((source_ptr) & 0x1F); | ||
| 351 | return Math::MakeVec<u8>(r, g, b, 255); | ||
| 352 | } | 344 | } |
| 353 | 345 | ||
| 354 | case Regs::TextureFormat::RGBA4: | 346 | case Regs::TextureFormat::RGBA4: |
| 355 | { | 347 | { |
| 356 | const u8* source_ptr = source + VideoCore::GetMortonOffset(x, y, 2); | 348 | auto res = Color::DecodeRGBA4(source + VideoCore::GetMortonOffset(x, y, 2)); |
| 357 | u8 r = Color::Convert4To8(source_ptr[1] >> 4); | 349 | return { res.r(), res.g(), res.b(), disable_alpha ? 255 : res.a() }; |
| 358 | u8 g = Color::Convert4To8(source_ptr[1] & 0xF); | ||
| 359 | u8 b = Color::Convert4To8(source_ptr[0] >> 4); | ||
| 360 | u8 a = Color::Convert4To8(source_ptr[0] & 0xF); | ||
| 361 | return { r, g, b, disable_alpha ? (u8)255 : a }; | ||
| 362 | } | 350 | } |
| 363 | 351 | ||
| 364 | case Regs::TextureFormat::IA8: | 352 | case Regs::TextureFormat::IA8: |
| @@ -369,7 +357,7 @@ const Math::Vec4<u8> LookupTexture(const u8* source, int x, int y, const Texture | |||
| 369 | // Show intensity as red, alpha as green | 357 | // Show intensity as red, alpha as green |
| 370 | return { source_ptr[1], source_ptr[0], 0, 255 }; | 358 | return { source_ptr[1], source_ptr[0], 0, 255 }; |
| 371 | } else { | 359 | } else { |
| 372 | return { source_ptr[1], source_ptr[1], source_ptr[1], source_ptr[0]}; | 360 | return { source_ptr[1], source_ptr[1], source_ptr[1], source_ptr[0] }; |
| 373 | } | 361 | } |
| 374 | } | 362 | } |
| 375 | 363 | ||