mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-12-14 14:55:39 +00:00
Merge pull request #543 from Alegend45/master
Add more blend equations from 3dbrew
This commit is contained in:
commit
eb83ac48aa
|
@ -339,6 +339,10 @@ struct Regs {
|
||||||
union {
|
union {
|
||||||
enum BlendEquation : u32 {
|
enum BlendEquation : u32 {
|
||||||
Add = 0,
|
Add = 0,
|
||||||
|
Subtract = 1,
|
||||||
|
ReverseSubtract = 2,
|
||||||
|
Min = 3,
|
||||||
|
Max = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BlendFactor : u32 {
|
enum BlendFactor : u32 {
|
||||||
|
|
|
@ -617,10 +617,13 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
|
||||||
auto dstfactor = Math::MakeVec(LookupFactorRGB(params.factor_dest_rgb),
|
auto dstfactor = Math::MakeVec(LookupFactorRGB(params.factor_dest_rgb),
|
||||||
LookupFactorA(params.factor_dest_a));
|
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) {
|
switch (params.blend_equation_rgb) {
|
||||||
case params.Add:
|
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.r() = std::min(255, result.r());
|
||||||
result.g() = std::min(255, result.g());
|
result.g() = std::min(255, result.g());
|
||||||
result.b() = std::min(255, result.b());
|
result.b() = std::min(255, result.b());
|
||||||
|
@ -628,6 +631,46 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0,
|
||||||
break;
|
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:
|
default:
|
||||||
LOG_CRITICAL(HW_GPU, "Unknown RGB blend equation %x", params.blend_equation_rgb.Value());
|
LOG_CRITICAL(HW_GPU, "Unknown RGB blend equation %x", params.blend_equation_rgb.Value());
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
Loading…
Reference in a new issue