summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarius Goad <alegend45@gmail.com>2015-02-07 18:43:08 +0100
committerDarius Goad <alegend45@gmail.com>2015-02-10 03:41:06 +0100
commit536958fb2940c9418b7e42e75eb245ae7527908e (patch)
tree8ff1ab719f3edc601cdc9f9dcef614dcccc50ede
parentMerge pull request #541 from lioncash/nits (diff)
downloadyuzu-536958fb2940c9418b7e42e75eb245ae7527908e.tar
yuzu-536958fb2940c9418b7e42e75eb245ae7527908e.tar.gz
yuzu-536958fb2940c9418b7e42e75eb245ae7527908e.tar.bz2
yuzu-536958fb2940c9418b7e42e75eb245ae7527908e.tar.lz
yuzu-536958fb2940c9418b7e42e75eb245ae7527908e.tar.xz
yuzu-536958fb2940c9418b7e42e75eb245ae7527908e.tar.zst
yuzu-536958fb2940c9418b7e42e75eb245ae7527908e.zip
-rw-r--r--src/video_core/pica.h6
-rw-r--r--src/video_core/rasterizer.cpp45
2 files changed, 49 insertions, 2 deletions
diff --git a/src/video_core/pica.h b/src/video_core/pica.h
index 1566b890d..9c1a12dc8 100644
--- a/src/video_core/pica.h
+++ b/src/video_core/pica.h
@@ -338,7 +338,11 @@ struct Regs {
union {
enum BlendEquation : u32 {
- Add = 0,
+ Add = 0,
+ Subtract = 1,
+ ReverseSubtract = 2,
+ Min = 3,
+ Max = 4
};
enum BlendFactor : u32 {
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index 5920477eb..06fd8d140 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -616,17 +616,60 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
LookupFactorA(params.factor_source_a));
auto dstfactor = Math::MakeVec(LookupFactorRGB(params.factor_dest_rgb),
LookupFactorA(params.factor_dest_a));
+
+ auto src_result = (combiner_output * srcfactor).Cast<int>();
+ auto dst_result = (dest * dstfactor).Cast<int>();
switch (params.blend_equation_rgb) {
case params.Add:
{
- auto result = (combiner_output * srcfactor + dest * dstfactor) / 255;
+ auto result = (src_result + dst_result) / 255;
result.r() = std::min(255, result.r());
result.g() = std::min(255, result.g());
result.b() = std::min(255, result.b());
combiner_output = result.Cast<u8>();
break;
}
+
+ case params.Subtract:
+ {
+ auto result = (src_result - dst_result) / 255;
+ result.r() = std::max(0, result.r());
+ result.g() = std::max(0, result.g());
+ result.b() = std::max(0, result.b());
+ combiner_output = result.Cast<u8>();
+ break;
+ }
+
+ case params.ReverseSubtract:
+ {
+ auto result = (dst_result - src_result) / 255;
+ result.r() = std::max(0, result.r());
+ result.g() = std::max(0, result.g());
+ result.b() = std::max(0, result.b());
+ combiner_output = result.Cast<u8>();
+ break;
+ }
+
+ case params.Min:
+ {
+ Math::Vec4<int> result;
+ result.r() = std::min(src_result.r(),dst_result.r());
+ result.g() = std::min(src_result.g(),dst_result.g());
+ result.b() = std::min(src_result.b(),dst_result.b());
+ combiner_output = result.Cast<u8>();
+ break;
+ }
+
+ case params.Max:
+ {
+ Math::Vec4<int> result;
+ result.r() = std::max(src_result.r(),dst_result.r());
+ result.g() = std::max(src_result.g(),dst_result.g());
+ result.b() = std::max(src_result.b(),dst_result.b());
+ combiner_output = result.Cast<u8>();
+ break;
+ }
default:
LOG_CRITICAL(HW_GPU, "Unknown RGB blend equation %x", params.blend_equation_rgb.Value());