diff options
| author | 2015-03-08 21:31:15 -0500 | |
|---|---|---|
| committer | 2015-03-09 20:13:21 -0500 | |
| commit | 1248e291f0c9a29734b0f5175df8fa675cce930c (patch) | |
| tree | 18218cbe496e5a2f42022a5e6741fa0665218874 /src/video_core/rasterizer.cpp | |
| parent | Frontend/Qt: Allow the framebuffer widget to inspect the depth buffer (diff) | |
| download | yuzu-1248e291f0c9a29734b0f5175df8fa675cce930c.tar.gz yuzu-1248e291f0c9a29734b0f5175df8fa675cce930c.tar.xz yuzu-1248e291f0c9a29734b0f5175df8fa675cce930c.zip | |
GPU: Added the stencil test structure to the Pica Regs struct.
Diffstat (limited to 'src/video_core/rasterizer.cpp')
| -rw-r--r-- | src/video_core/rasterizer.cpp | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index dc32128c6..dd46f0ec3 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -100,24 +100,19 @@ static u32 GetDepth(int x, int y) { | |||
| 100 | y = (registers.framebuffer.height - y); | 100 | y = (registers.framebuffer.height - y); |
| 101 | 101 | ||
| 102 | const u32 coarse_y = y & ~7; | 102 | const u32 coarse_y = y & ~7; |
| 103 | u32 bytes_per_pixel = Pica::Regs::BytesPerDepthPixel(registers.framebuffer.depth_format); | ||
| 104 | u32 stride = registers.framebuffer.width * bytes_per_pixel; | ||
| 105 | |||
| 106 | u32 src_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * stride; | ||
| 107 | u8* src_pixel = depth_buffer + src_offset; | ||
| 103 | 108 | ||
| 104 | switch (registers.framebuffer.depth_format) { | 109 | switch (registers.framebuffer.depth_format) { |
| 105 | case registers.framebuffer.D16: | 110 | case Pica::Regs::DepthFormat::D16: |
| 106 | { | 111 | return Color::DecodeD16(src_pixel); |
| 107 | u32 stride = registers.framebuffer.width * 2; | 112 | case Pica::Regs::DepthFormat::D24: |
| 108 | return Color::DecodeD16(depth_buffer + VideoCore::GetMortonOffset(x, y, 2) + coarse_y * stride); | 113 | return Color::DecodeD24(src_pixel); |
| 109 | } | 114 | case Pica::Regs::DepthFormat::D24S8: |
| 110 | case registers.framebuffer.D24: | 115 | return Color::DecodeD24S8(src_pixel).x; |
| 111 | { | ||
| 112 | u32 stride = registers.framebuffer.width * 3; | ||
| 113 | u8* address = depth_buffer + VideoCore::GetMortonOffset(x, y, 3) + coarse_y * stride; | ||
| 114 | return Color::DecodeD24(address); | ||
| 115 | } | ||
| 116 | case registers.framebuffer.D24S8: | ||
| 117 | { | ||
| 118 | u32 stride = registers.framebuffer.width * 4; | ||
| 119 | return Color::DecodeD24S8(depth_buffer + VideoCore::GetMortonOffset(x, y, 4) + coarse_y * stride).x; | ||
| 120 | } | ||
| 121 | default: | 116 | default: |
| 122 | LOG_CRITICAL(HW_GPU, "Unimplemented depth format %u", registers.framebuffer.depth_format); | 117 | LOG_CRITICAL(HW_GPU, "Unimplemented depth format %u", registers.framebuffer.depth_format); |
| 123 | UNIMPLEMENTED(); | 118 | UNIMPLEMENTED(); |
| @@ -132,28 +127,23 @@ static void SetDepth(int x, int y, u32 value) { | |||
| 132 | y = (registers.framebuffer.height - y); | 127 | y = (registers.framebuffer.height - y); |
| 133 | 128 | ||
| 134 | const u32 coarse_y = y & ~7; | 129 | const u32 coarse_y = y & ~7; |
| 130 | u32 bytes_per_pixel = Pica::Regs::BytesPerDepthPixel(registers.framebuffer.depth_format); | ||
| 131 | u32 stride = registers.framebuffer.width * bytes_per_pixel; | ||
| 132 | |||
| 133 | u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * stride; | ||
| 134 | u8* dst_pixel = depth_buffer + dst_offset; | ||
| 135 | 135 | ||
| 136 | switch (registers.framebuffer.depth_format) { | 136 | switch (registers.framebuffer.depth_format) { |
| 137 | case registers.framebuffer.D16: | 137 | case Pica::Regs::DepthFormat::D16: |
| 138 | { | 138 | Color::EncodeD16(value, dst_pixel); |
| 139 | u32 stride = registers.framebuffer.width * 2; | ||
| 140 | Color::EncodeD16(value, depth_buffer + VideoCore::GetMortonOffset(x, y, 2) + coarse_y * stride); | ||
| 141 | break; | 139 | break; |
| 142 | } | 140 | case Pica::Regs::DepthFormat::D24: |
| 143 | case registers.framebuffer.D24: | 141 | Color::EncodeD24(value, dst_pixel); |
| 144 | { | ||
| 145 | u32 stride = registers.framebuffer.width * 3; | ||
| 146 | u8* address = depth_buffer + VideoCore::GetMortonOffset(x, y, 3) + coarse_y * stride; | ||
| 147 | Color::EncodeD24(value, address); | ||
| 148 | break; | 142 | break; |
| 149 | } | 143 | case Pica::Regs::DepthFormat::D24S8: |
| 150 | case registers.framebuffer.D24S8: | ||
| 151 | { | ||
| 152 | u32 stride = registers.framebuffer.width * 4; | ||
| 153 | // TODO(Subv): Implement the stencil buffer | 144 | // TODO(Subv): Implement the stencil buffer |
| 154 | Color::EncodeD24S8(value, 0, depth_buffer + VideoCore::GetMortonOffset(x, y, 4) + coarse_y * stride); | 145 | Color::EncodeD24S8(value, 0, dst_pixel); |
| 155 | break; | 146 | break; |
| 156 | } | ||
| 157 | default: | 147 | default: |
| 158 | LOG_CRITICAL(HW_GPU, "Unimplemented depth format %u", registers.framebuffer.depth_format); | 148 | LOG_CRITICAL(HW_GPU, "Unimplemented depth format %u", registers.framebuffer.depth_format); |
| 159 | UNIMPLEMENTED(); | 149 | UNIMPLEMENTED(); |