summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/regs_rasterizer.h14
-rw-r--r--src/video_core/swrasterizer/clipper.cpp15
2 files changed, 25 insertions, 4 deletions
diff --git a/src/video_core/regs_rasterizer.h b/src/video_core/regs_rasterizer.h
index 2874fd127..4fef00d76 100644
--- a/src/video_core/regs_rasterizer.h
+++ b/src/video_core/regs_rasterizer.h
@@ -5,10 +5,10 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8
9#include "common/bit_field.h" 8#include "common/bit_field.h"
10#include "common/common_funcs.h" 9#include "common/common_funcs.h"
11#include "common/common_types.h" 10#include "common/common_types.h"
11#include "video_core/pica_types.h"
12 12
13namespace Pica { 13namespace Pica {
14 14
@@ -31,7 +31,17 @@ struct RasterizerRegs {
31 31
32 BitField<0, 24, u32> viewport_size_y; 32 BitField<0, 24, u32> viewport_size_y;
33 33
34 INSERT_PADDING_WORDS(0x9); 34 INSERT_PADDING_WORDS(0x3);
35
36 BitField<0, 1, u32> clip_enable;
37 BitField<0, 24, u32> clip_coef[4]; // float24
38
39 Math::Vec4<float24> GetClipCoef() const {
40 return {float24::FromRaw(clip_coef[0]), float24::FromRaw(clip_coef[1]),
41 float24::FromRaw(clip_coef[2]), float24::FromRaw(clip_coef[3])};
42 }
43
44 INSERT_PADDING_WORDS(0x1);
35 45
36 BitField<0, 24, u32> viewport_depth_range; // float24 46 BitField<0, 24, u32> viewport_depth_range; // float24
37 BitField<0, 24, u32> viewport_depth_near_plane; // float24 47 BitField<0, 24, u32> viewport_depth_near_plane; // float24
diff --git a/src/video_core/swrasterizer/clipper.cpp b/src/video_core/swrasterizer/clipper.cpp
index cdbc71502..cc76ba555 100644
--- a/src/video_core/swrasterizer/clipper.cpp
+++ b/src/video_core/swrasterizer/clipper.cpp
@@ -127,8 +127,7 @@ void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const Outpu
127 127
128 // Simple implementation of the Sutherland-Hodgman clipping algorithm. 128 // Simple implementation of the Sutherland-Hodgman clipping algorithm.
129 // TODO: Make this less inefficient (currently lots of useless buffering overhead happens here) 129 // TODO: Make this less inefficient (currently lots of useless buffering overhead happens here)
130 for (auto edge : clipping_edges) { 130 auto Clip = [&](const ClippingEdge& edge) {
131
132 std::swap(input_list, output_list); 131 std::swap(input_list, output_list);
133 output_list->clear(); 132 output_list->clear();
134 133
@@ -147,12 +146,24 @@ void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const Outpu
147 } 146 }
148 reference_vertex = &vertex; 147 reference_vertex = &vertex;
149 } 148 }
149 };
150
151 for (auto edge : clipping_edges) {
152 Clip(edge);
150 153
151 // Need to have at least a full triangle to continue... 154 // Need to have at least a full triangle to continue...
152 if (output_list->size() < 3) 155 if (output_list->size() < 3)
153 return; 156 return;
154 } 157 }
155 158
159 if (g_state.regs.rasterizer.clip_enable) {
160 ClippingEdge custom_edge{-g_state.regs.rasterizer.GetClipCoef()};
161 Clip(custom_edge);
162
163 if (output_list->size() < 3)
164 return;
165 }
166
156 InitScreenCoordinates((*output_list)[0]); 167 InitScreenCoordinates((*output_list)[0]);
157 InitScreenCoordinates((*output_list)[1]); 168 InitScreenCoordinates((*output_list)[1]);
158 169