diff options
| author | 2017-08-22 09:49:26 +0300 | |
|---|---|---|
| committer | 2017-08-24 15:34:27 +0300 | |
| commit | ea51a3af261254e5455f63a0ef41e55ef1dfc471 (patch) | |
| tree | 1240b8835ade7b50c633e233787b319c498a4d1d /src/video_core/swrasterizer/clipper.cpp | |
| parent | Merge pull request #2839 from Subv/global_kernel_lock (diff) | |
| download | yuzu-ea51a3af261254e5455f63a0ef41e55ef1dfc471.tar.gz yuzu-ea51a3af261254e5455f63a0ef41e55ef1dfc471.tar.xz yuzu-ea51a3af261254e5455f63a0ef41e55ef1dfc471.zip | |
SwRasterizer: implement custom clip plane
Diffstat (limited to 'src/video_core/swrasterizer/clipper.cpp')
| -rw-r--r-- | src/video_core/swrasterizer/clipper.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
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 | ||