summaryrefslogtreecommitdiff
path: root/src/video_core/rasterizer.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2014-12-23 13:05:51 -0200
committerGravatar Yuri Kunde Schlesner2014-12-29 02:08:11 -0200
commit8369ee58035ca98f776428f6cccbcf987fee3bc9 (patch)
tree3c1800823ffe55529ba6dbcba0c4407d2da625f2 /src/video_core/rasterizer.cpp
parentGPU: Bitwise texture swizzling (diff)
downloadyuzu-8369ee58035ca98f776428f6cccbcf987fee3bc9.tar.gz
yuzu-8369ee58035ca98f776428f6cccbcf987fee3bc9.tar.xz
yuzu-8369ee58035ca98f776428f6cccbcf987fee3bc9.zip
Rasterizer: Pre-divide vertex attributes by W
Execute the division-by-W for perspective-correct interpolation of values in the clipper, moving them out of the rasterization inner loop.
Diffstat (limited to 'src/video_core/rasterizer.cpp')
-rw-r--r--src/video_core/rasterizer.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index 63da7104d..a80148872 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -106,10 +106,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
106 int bias1 = IsRightSideOrFlatBottomEdge(vtxpos[1].xy(), vtxpos[2].xy(), vtxpos[0].xy()) ? -1 : 0; 106 int bias1 = IsRightSideOrFlatBottomEdge(vtxpos[1].xy(), vtxpos[2].xy(), vtxpos[0].xy()) ? -1 : 0;
107 int bias2 = IsRightSideOrFlatBottomEdge(vtxpos[2].xy(), vtxpos[0].xy(), vtxpos[1].xy()) ? -1 : 0; 107 int bias2 = IsRightSideOrFlatBottomEdge(vtxpos[2].xy(), vtxpos[0].xy(), vtxpos[1].xy()) ? -1 : 0;
108 108
109 const Math::Vec3<float24> w_inverse = Math::MakeVec( 109 auto w_inverse = Math::MakeVec(v0.pos.w, v1.pos.w, v2.pos.w);
110 float24::FromFloat32(1.0f) / v0.pos.w,
111 float24::FromFloat32(1.0f) / v1.pos.w,
112 float24::FromFloat32(1.0f) / v2.pos.w);
113 110
114 auto textures = registers.GetTextures(); 111 auto textures = registers.GetTextures();
115 auto tev_stages = registers.GetTevStages(); 112 auto tev_stages = registers.GetTevStages();
@@ -158,7 +155,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
158 // 155 //
159 // The generalization to three vertices is straightforward in baricentric coordinates. 156 // The generalization to three vertices is straightforward in baricentric coordinates.
160 auto GetInterpolatedAttribute = [&](float24 attr0, float24 attr1, float24 attr2) { 157 auto GetInterpolatedAttribute = [&](float24 attr0, float24 attr1, float24 attr2) {
161 auto attr_over_w = Math::MakeVec(attr0, attr1, attr2) * w_inverse; 158 auto attr_over_w = Math::MakeVec(attr0, attr1, attr2);
162 float24 interpolated_attr_over_w = Math::Dot(attr_over_w, baricentric_coordinates); 159 float24 interpolated_attr_over_w = Math::Dot(attr_over_w, baricentric_coordinates);
163 return interpolated_attr_over_w * interpolated_w_inverse; 160 return interpolated_attr_over_w * interpolated_w_inverse;
164 }; 161 };