diff options
Diffstat (limited to 'src/video_core/rasterizer.cpp')
| -rw-r--r-- | src/video_core/rasterizer.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index a7c1bab3e..f418518a1 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -78,10 +78,10 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 78 | u16 max_x = std::max({vtxpos[0].x, vtxpos[1].x, vtxpos[2].x}); | 78 | u16 max_x = std::max({vtxpos[0].x, vtxpos[1].x, vtxpos[2].x}); |
| 79 | u16 max_y = std::max({vtxpos[0].y, vtxpos[1].y, vtxpos[2].y}); | 79 | u16 max_y = std::max({vtxpos[0].y, vtxpos[1].y, vtxpos[2].y}); |
| 80 | 80 | ||
| 81 | min_x = min_x & Fix12P4::IntMask(); | 81 | min_x &= Fix12P4::IntMask(); |
| 82 | min_y = min_y & Fix12P4::IntMask(); | 82 | min_y &= Fix12P4::IntMask(); |
| 83 | max_x = (max_x + Fix12P4::FracMask()) & Fix12P4::IntMask(); | 83 | max_x = ((max_x + Fix12P4::FracMask()) & Fix12P4::IntMask()); |
| 84 | max_y = (max_y + Fix12P4::FracMask()) & Fix12P4::IntMask(); | 84 | max_y = ((max_y + Fix12P4::FracMask()) & Fix12P4::IntMask()); |
| 85 | 85 | ||
| 86 | // Triangle filling rules: Pixels on the right-sided edge or on flat bottom edges are not | 86 | // Triangle filling rules: Pixels on the right-sided edge or on flat bottom edges are not |
| 87 | // drawn. Pixels on any other triangle border are drawn. This is implemented with three bias | 87 | // drawn. Pixels on any other triangle border are drawn. This is implemented with three bias |
| @@ -112,10 +112,10 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 112 | auto orient2d = [](const Math::Vec2<Fix12P4>& vtx1, | 112 | auto orient2d = [](const Math::Vec2<Fix12P4>& vtx1, |
| 113 | const Math::Vec2<Fix12P4>& vtx2, | 113 | const Math::Vec2<Fix12P4>& vtx2, |
| 114 | const Math::Vec2<Fix12P4>& vtx3) { | 114 | const Math::Vec2<Fix12P4>& vtx3) { |
| 115 | const auto vec1 = (vtx2.Cast<int>() - vtx1.Cast<int>()).Append(0); | 115 | const auto vec1 = Math::MakeVec(vtx2 - vtx1, 0); |
| 116 | const auto vec2 = (vtx3.Cast<int>() - vtx1.Cast<int>()).Append(0); | 116 | const auto vec2 = Math::MakeVec(vtx3 - vtx1, 0); |
| 117 | // TODO: There is a very small chance this will overflow for sizeof(int) == 4 | 117 | // TODO: There is a very small chance this will overflow for sizeof(int) == 4 |
| 118 | return Cross(vec1, vec2).z; | 118 | return Math::Cross(vec1, vec2).z; |
| 119 | }; | 119 | }; |
| 120 | 120 | ||
| 121 | int w0 = bias0 + orient2d(vtxpos[1].xy(), vtxpos[2].xy(), {x, y}); | 121 | int w0 = bias0 + orient2d(vtxpos[1].xy(), vtxpos[2].xy(), {x, y}); |
| @@ -143,15 +143,15 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 143 | // | 143 | // |
| 144 | // The generalization to three vertices is straightforward in baricentric coordinates. | 144 | // The generalization to three vertices is straightforward in baricentric coordinates. |
| 145 | auto GetInterpolatedAttribute = [&](float24 attr0, float24 attr1, float24 attr2) { | 145 | auto GetInterpolatedAttribute = [&](float24 attr0, float24 attr1, float24 attr2) { |
| 146 | auto attr_over_w = Math::MakeVec3(attr0 / v0.pos.w, | 146 | auto attr_over_w = Math::MakeVec(attr0 / v0.pos.w, |
| 147 | attr1 / v1.pos.w, | 147 | attr1 / v1.pos.w, |
| 148 | attr2 / v2.pos.w); | 148 | attr2 / v2.pos.w); |
| 149 | auto w_inverse = Math::MakeVec3(float24::FromFloat32(1.f) / v0.pos.w, | 149 | auto w_inverse = Math::MakeVec(float24::FromFloat32(1.f) / v0.pos.w, |
| 150 | float24::FromFloat32(1.f) / v1.pos.w, | 150 | float24::FromFloat32(1.f) / v1.pos.w, |
| 151 | float24::FromFloat32(1.f) / v2.pos.w); | 151 | float24::FromFloat32(1.f) / v2.pos.w); |
| 152 | auto baricentric_coordinates = Math::MakeVec3(float24::FromFloat32(w0), | 152 | auto baricentric_coordinates = Math::MakeVec(float24::FromFloat32(w0), |
| 153 | float24::FromFloat32(w1), | 153 | float24::FromFloat32(w1), |
| 154 | float24::FromFloat32(w2)); | 154 | float24::FromFloat32(w2)); |
| 155 | 155 | ||
| 156 | float24 interpolated_attr_over_w = Math::Dot(attr_over_w, baricentric_coordinates); | 156 | float24 interpolated_attr_over_w = Math::Dot(attr_over_w, baricentric_coordinates); |
| 157 | float24 interpolated_w_inverse = Math::Dot(w_inverse, baricentric_coordinates); | 157 | float24 interpolated_w_inverse = Math::Dot(w_inverse, baricentric_coordinates); |