aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/swrasterizer
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/swrasterizer')
-rw-r--r--src/video_core/swrasterizer/clipper.cpp7
-rw-r--r--src/video_core/swrasterizer/rasterizer.cpp29
-rw-r--r--src/video_core/swrasterizer/rasterizer.h6
-rw-r--r--src/video_core/swrasterizer/texturing.cpp3
4 files changed, 30 insertions, 15 deletions
diff --git a/src/video_core/swrasterizer/clipper.cpp b/src/video_core/swrasterizer/clipper.cpp
index 2d80822d9..6fb923756 100644
--- a/src/video_core/swrasterizer/clipper.cpp
+++ b/src/video_core/swrasterizer/clipper.cpp
@@ -69,13 +69,14 @@ static void InitScreenCoordinates(Vertex& vtx) {
viewport.offset_y = float24::FromFloat32(static_cast<float>(regs.rasterizer.viewport_corner.y));
float24 inv_w = float24::FromFloat32(1.f) / vtx.pos.w;
- vtx.color *= inv_w;
- vtx.view *= inv_w;
+ vtx.pos.w = inv_w;
vtx.quat *= inv_w;
+ vtx.color *= inv_w;
vtx.tc0 *= inv_w;
vtx.tc1 *= inv_w;
+ vtx.tc0_w *= inv_w;
+ vtx.view *= inv_w;
vtx.tc2 *= inv_w;
- vtx.pos.w = inv_w;
vtx.screenpos[0] =
(vtx.pos.x * inv_w + float24::FromFloat32(1.0)) * viewport.halfsize_x + viewport.offset_x;
diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp
index 7557fcb89..20addf0bd 100644
--- a/src/video_core/swrasterizer/rasterizer.cpp
+++ b/src/video_core/swrasterizer/rasterizer.cpp
@@ -276,8 +276,10 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
DEBUG_ASSERT(0 != texture.config.address);
- float24 u = uv[i].u();
- float24 v = uv[i].v();
+ int coordinate_i =
+ (i == 2 && regs.texturing.main_config.texture2_use_coord1) ? 1 : i;
+ float24 u = uv[coordinate_i].u();
+ float24 v = uv[coordinate_i].v();
// Only unit 0 respects the texturing type (according to 3DBrew)
// TODO: Refactor so cubemaps and shadowmaps can be handled
@@ -403,13 +405,22 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
};
auto color_output = ColorCombine(tev_stage.color_op, color_result);
- // alpha combiner
- std::array<u8, 3> alpha_result = {{
- GetAlphaModifier(tev_stage.alpha_modifier1, GetSource(tev_stage.alpha_source1)),
- GetAlphaModifier(tev_stage.alpha_modifier2, GetSource(tev_stage.alpha_source2)),
- GetAlphaModifier(tev_stage.alpha_modifier3, GetSource(tev_stage.alpha_source3)),
- }};
- auto alpha_output = AlphaCombine(tev_stage.alpha_op, alpha_result);
+ u8 alpha_output;
+ if (tev_stage.color_op == TexturingRegs::TevStageConfig::Operation::Dot3_RGBA) {
+ // result of Dot3_RGBA operation is also placed to the alpha component
+ alpha_output = color_output.x;
+ } else {
+ // alpha combiner
+ std::array<u8, 3> alpha_result = {{
+ GetAlphaModifier(tev_stage.alpha_modifier1,
+ GetSource(tev_stage.alpha_source1)),
+ GetAlphaModifier(tev_stage.alpha_modifier2,
+ GetSource(tev_stage.alpha_source2)),
+ GetAlphaModifier(tev_stage.alpha_modifier3,
+ GetSource(tev_stage.alpha_source3)),
+ }};
+ alpha_output = AlphaCombine(tev_stage.alpha_op, alpha_result);
+ }
combiner_output[0] =
std::min((unsigned)255, color_output.r() * tev_stage.GetColorMultiplier());
diff --git a/src/video_core/swrasterizer/rasterizer.h b/src/video_core/swrasterizer/rasterizer.h
index 3a72ac343..2f0877581 100644
--- a/src/video_core/swrasterizer/rasterizer.h
+++ b/src/video_core/swrasterizer/rasterizer.h
@@ -23,13 +23,15 @@ struct Vertex : Shader::OutputVertex {
pos = pos * factor + vtx.pos * (float24::FromFloat32(1) - factor);
// TODO: Should perform perspective correct interpolation here...
+ quat = quat * factor + vtx.quat * (float24::FromFloat32(1) - factor);
+ color = color * factor + vtx.color * (float24::FromFloat32(1) - factor);
tc0 = tc0 * factor + vtx.tc0 * (float24::FromFloat32(1) - factor);
tc1 = tc1 * factor + vtx.tc1 * (float24::FromFloat32(1) - factor);
+ tc0_w = tc0_w * factor + vtx.tc0_w * (float24::FromFloat32(1) - factor);
+ view = view * factor + vtx.view * (float24::FromFloat32(1) - factor);
tc2 = tc2 * factor + vtx.tc2 * (float24::FromFloat32(1) - factor);
screenpos = screenpos * factor + vtx.screenpos * (float24::FromFloat32(1) - factor);
-
- color = color * factor + vtx.color * (float24::FromFloat32(1) - factor);
}
// Linear interpolation
diff --git a/src/video_core/swrasterizer/texturing.cpp b/src/video_core/swrasterizer/texturing.cpp
index eb18e4ba4..aeb6aeb8c 100644
--- a/src/video_core/swrasterizer/texturing.cpp
+++ b/src/video_core/swrasterizer/texturing.cpp
@@ -169,7 +169,8 @@ Math::Vec3<u8> ColorCombine(TevStageConfig::Operation op, const Math::Vec3<u8> i
result = (result * input[2].Cast<int>()) / 255;
return result.Cast<u8>();
}
- case Operation::Dot3_RGB: {
+ case Operation::Dot3_RGB:
+ case Operation::Dot3_RGBA: {
// Not fully accurate. Worst case scenario seems to yield a +/-3 error. Some HW results
// indicate that the per-component computation can't have a higher precision than 1/256,
// while dot3_rgb((0x80,g0,b0), (0x7F,g1,b1)) and dot3_rgb((0x80,g0,b0), (0x80,g1,b1)) give