summaryrefslogtreecommitdiffstats
path: root/src/video_core/swrasterizer
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-09-16 10:23:00 +0200
committerGitHub <noreply@github.com>2017-09-16 10:23:00 +0200
commit699c92099140f6017c66433805d2e9a592f91169 (patch)
tree8ff5b734c055dc47c4231d817863f9bd3dcde111 /src/video_core/swrasterizer
parentMerge pull request #2842 from Subv/switchable_page_table (diff)
parentSwRasterizer/Clipper: flip the sign convention to match PICA and OpenGL (diff)
downloadyuzu-699c92099140f6017c66433805d2e9a592f91169.tar
yuzu-699c92099140f6017c66433805d2e9a592f91169.tar.gz
yuzu-699c92099140f6017c66433805d2e9a592f91169.tar.bz2
yuzu-699c92099140f6017c66433805d2e9a592f91169.tar.lz
yuzu-699c92099140f6017c66433805d2e9a592f91169.tar.xz
yuzu-699c92099140f6017c66433805d2e9a592f91169.tar.zst
yuzu-699c92099140f6017c66433805d2e9a592f91169.zip
Diffstat (limited to 'src/video_core/swrasterizer')
-rw-r--r--src/video_core/swrasterizer/clipper.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/video_core/swrasterizer/clipper.cpp b/src/video_core/swrasterizer/clipper.cpp
index cdbc71502..a52129eb7 100644
--- a/src/video_core/swrasterizer/clipper.cpp
+++ b/src/video_core/swrasterizer/clipper.cpp
@@ -31,7 +31,7 @@ public:
: coeffs(coeffs), bias(bias) {}
bool IsInside(const Vertex& vertex) const {
- return Math::Dot(vertex.pos + bias, coeffs) <= float24::FromFloat32(0);
+ return Math::Dot(vertex.pos + bias, coeffs) >= float24::FromFloat32(0);
}
bool IsOutSide(const Vertex& vertex) const {
@@ -116,19 +116,18 @@ void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const Outpu
static const float24 f0 = float24::FromFloat32(0.0);
static const float24 f1 = float24::FromFloat32(1.0);
static const std::array<ClippingEdge, 7> clipping_edges = {{
- {Math::MakeVec(f1, f0, f0, -f1)}, // x = +w
- {Math::MakeVec(-f1, f0, f0, -f1)}, // x = -w
- {Math::MakeVec(f0, f1, f0, -f1)}, // y = +w
- {Math::MakeVec(f0, -f1, f0, -f1)}, // y = -w
- {Math::MakeVec(f0, f0, f1, f0)}, // z = 0
- {Math::MakeVec(f0, f0, -f1, -f1)}, // z = -w
- {Math::MakeVec(f0, f0, f0, -f1), Math::Vec4<float24>(f0, f0, f0, EPSILON)}, // w = EPSILON
+ {Math::MakeVec(-f1, f0, f0, f1)}, // x = +w
+ {Math::MakeVec(f1, f0, f0, f1)}, // x = -w
+ {Math::MakeVec(f0, -f1, f0, f1)}, // y = +w
+ {Math::MakeVec(f0, f1, f0, f1)}, // y = -w
+ {Math::MakeVec(f0, f0, -f1, f0)}, // z = 0
+ {Math::MakeVec(f0, f0, f1, f1)}, // z = -w
+ {Math::MakeVec(f0, f0, f0, f1), Math::Vec4<float24>(f0, f0, f0, EPSILON)}, // w = EPSILON
}};
// Simple implementation of the Sutherland-Hodgman clipping algorithm.
// TODO: Make this less inefficient (currently lots of useless buffering overhead happens here)
- for (auto edge : clipping_edges) {
-
+ auto Clip = [&](const ClippingEdge& edge) {
std::swap(input_list, output_list);
output_list->clear();
@@ -147,12 +146,24 @@ void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const Outpu
}
reference_vertex = &vertex;
}
+ };
+
+ for (auto edge : clipping_edges) {
+ Clip(edge);
// Need to have at least a full triangle to continue...
if (output_list->size() < 3)
return;
}
+ if (g_state.regs.rasterizer.clip_enable) {
+ ClippingEdge custom_edge{g_state.regs.rasterizer.GetClipCoef()};
+ Clip(custom_edge);
+
+ if (output_list->size() < 3)
+ return;
+ }
+
InitScreenCoordinates((*output_list)[0]);
InitScreenCoordinates((*output_list)[1]);