Created
February 23, 2015 02:33
-
-
Save Subv/b50d7d5054328d064eb0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/citra_qt/debugger/graphics_framebuffer.cpp b/src/citra_qt/debugger/graphics_framebuffer.cpp | |
index 1ba6002..a6ca2a1 100644 | |
--- a/src/citra_qt/debugger/graphics_framebuffer.cpp | |
+++ b/src/citra_qt/debugger/graphics_framebuffer.cpp | |
@@ -161,6 +161,19 @@ void GraphicsFramebufferWidget::OnFramebufferFormatChanged(int new_value) | |
} | |
} | |
+unsigned int SeparateBy1(unsigned int x) { | |
+ x &= 0x0000ffff; // x = ---- ---- ---- ---- fedc ba98 7654 3210 | |
+ x = (x ^ (x << 8)) & 0x00ff00ff; // x = ---- ---- fedc ba98 ---- ---- 7654 3210 | |
+ x = (x ^ (x << 4)) & 0x0f0f0f0f; // x = ---- fedc ---- ba98 ---- 7654 ---- 3210 | |
+ x = (x ^ (x << 2)) & 0x33333333; // x = --fe --dc --ba --98 --76 --54 --32 --10 | |
+ x = (x ^ (x << 1)) & 0x55555555; // x = -f-e -d-c -b-a -9-8 -7-6 -5-4 -3-2 -1-0 | |
+ return x; | |
+} | |
+ | |
+u32 MortonCode2(unsigned int x, unsigned int y) { | |
+ return SeparateBy1(x) | (SeparateBy1(y) << 1); | |
+} | |
+ | |
void GraphicsFramebufferWidget::OnUpdate() | |
{ | |
QPixmap pixmap; | |
@@ -202,7 +215,7 @@ void GraphicsFramebufferWidget::OnUpdate() | |
u32* color_buffer = (u32*)Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); | |
for (unsigned int y = 0; y < framebuffer_height; ++y) { | |
for (unsigned int x = 0; x < framebuffer_width; ++x) { | |
- u32 value = *(color_buffer + x + y * framebuffer_width); | |
+ u32 value = *(color_buffer + MortonCode2(x, y)); | |
decoded_image.setPixel(x, y, qRgba((value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, 255/*value >> 24*/)); | |
} | |
@@ -217,7 +230,7 @@ void GraphicsFramebufferWidget::OnUpdate() | |
u8* color_buffer = Memory::GetPointer(Pica::PAddrToVAddr(framebuffer_address)); | |
for (unsigned int y = 0; y < framebuffer_height; ++y) { | |
for (unsigned int x = 0; x < framebuffer_width; ++x) { | |
- u8* pixel_pointer = color_buffer + x * 3 + y * 3 * framebuffer_width; | |
+ u8* pixel_pointer = color_buffer + MortonCode2(x, y) * 3; | |
decoded_image.setPixel(x, y, qRgba(pixel_pointer[0], pixel_pointer[1], pixel_pointer[2], 255/*value >> 24*/)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment