diff options
| author | 2015-02-22 13:31:53 -0500 | |
|---|---|---|
| committer | 2015-02-22 13:57:24 -0500 | |
| commit | 733c19ddd30db59eea822a60618b38e4fb7a0761 (patch) | |
| tree | 6527068cbee84014f17cb83650178d830dcd5ec7 /src/video_core/rasterizer.cpp | |
| parent | Merge pull request #596 from kevinhartman/unaligned-cleanup (diff) | |
| download | yuzu-733c19ddd30db59eea822a60618b38e4fb7a0761.tar.gz yuzu-733c19ddd30db59eea822a60618b38e4fb7a0761.tar.xz yuzu-733c19ddd30db59eea822a60618b38e4fb7a0761.zip | |
Rasterize with the correct color component order.
- Fixes a regression with #594.
Diffstat (limited to 'src/video_core/rasterizer.cpp')
| -rw-r--r-- | src/video_core/rasterizer.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 81df09baf..17f8f70ca 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -20,7 +20,7 @@ namespace Rasterizer { | |||
| 20 | 20 | ||
| 21 | static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) { | 21 | static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) { |
| 22 | const PAddr addr = registers.framebuffer.GetColorBufferPhysicalAddress(); | 22 | const PAddr addr = registers.framebuffer.GetColorBufferPhysicalAddress(); |
| 23 | u32* color_buffer = reinterpret_cast<u32*>(Memory::GetPointer(PAddrToVAddr(addr))); | 23 | u8* color_buffer = Memory::GetPointer(PAddrToVAddr(addr)); |
| 24 | 24 | ||
| 25 | // Similarly to textures, the render framebuffer is laid out from bottom to top, too. | 25 | // Similarly to textures, the render framebuffer is laid out from bottom to top, too. |
| 26 | // NOTE: The framebuffer height register contains the actual FB height minus one. | 26 | // NOTE: The framebuffer height register contains the actual FB height minus one. |
| @@ -29,8 +29,11 @@ static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) { | |||
| 29 | switch (registers.framebuffer.color_format) { | 29 | switch (registers.framebuffer.color_format) { |
| 30 | case registers.framebuffer.RGBA8: | 30 | case registers.framebuffer.RGBA8: |
| 31 | { | 31 | { |
| 32 | u32 value = (color.a() << 24) | (color.r() << 16) | (color.g() << 8) | color.b(); | 32 | u8* pixel = color_buffer + (x + y * registers.framebuffer.GetWidth()) * 4; |
| 33 | *(color_buffer + x + y * registers.framebuffer.GetWidth()) = value; | 33 | pixel[3] = color.r(); |
| 34 | pixel[2] = color.g(); | ||
| 35 | pixel[1] = color.b(); | ||
| 36 | pixel[0] = color.a(); | ||
| 34 | break; | 37 | break; |
| 35 | } | 38 | } |
| 36 | 39 | ||
| @@ -42,17 +45,27 @@ static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) { | |||
| 42 | 45 | ||
| 43 | static const Math::Vec4<u8> GetPixel(int x, int y) { | 46 | static const Math::Vec4<u8> GetPixel(int x, int y) { |
| 44 | const PAddr addr = registers.framebuffer.GetColorBufferPhysicalAddress(); | 47 | const PAddr addr = registers.framebuffer.GetColorBufferPhysicalAddress(); |
| 45 | u32* color_buffer_u32 = reinterpret_cast<u32*>(Memory::GetPointer(PAddrToVAddr(addr))); | 48 | u8* color_buffer = Memory::GetPointer(PAddrToVAddr(addr)); |
| 46 | 49 | ||
| 47 | y = (registers.framebuffer.height - y); | 50 | y = (registers.framebuffer.height - y); |
| 48 | 51 | ||
| 49 | u32 value = *(color_buffer_u32 + x + y * registers.framebuffer.GetWidth()); | 52 | switch (registers.framebuffer.color_format) { |
| 50 | Math::Vec4<u8> ret; | 53 | case registers.framebuffer.RGBA8: |
| 51 | ret.a() = value >> 24; | 54 | { |
| 52 | ret.r() = (value >> 16) & 0xFF; | 55 | Math::Vec4<u8> ret; |
| 53 | ret.g() = (value >> 8) & 0xFF; | 56 | u8* pixel = color_buffer + (x + y * registers.framebuffer.GetWidth()) * 4; |
| 54 | ret.b() = value & 0xFF; | 57 | ret.r() = pixel[3]; |
| 55 | return ret; | 58 | ret.g() = pixel[2]; |
| 59 | ret.b() = pixel[1]; | ||
| 60 | ret.a() = pixel[0]; | ||
| 61 | return ret; | ||
| 62 | } | ||
| 63 | default: | ||
| 64 | LOG_CRITICAL(Render_Software, "Unknown framebuffer color format %x", registers.framebuffer.color_format); | ||
| 65 | UNIMPLEMENTED(); | ||
| 66 | } | ||
| 67 | |||
| 68 | return {}; | ||
| 56 | } | 69 | } |
| 57 | 70 | ||
| 58 | static u32 GetDepth(int x, int y) { | 71 | static u32 GetDepth(int x, int y) { |