summaryrefslogtreecommitdiff
path: root/src/video_core/rasterizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/rasterizer.cpp')
-rw-r--r--src/video_core/rasterizer.cpp35
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
21static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) { 21static 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
43static const Math::Vec4<u8> GetPixel(int x, int y) { 46static 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
58static u32 GetDepth(int x, int y) { 71static u32 GetDepth(int x, int y) {