Port Dot3RGB and Dot3RGBA from zmm-progress in a less broken way
This commit is contained in:
parent
ed5b275d21
commit
be26257f8f
2 changed files with 26 additions and 0 deletions
|
@ -262,6 +262,8 @@ struct Regs {
|
||||||
Lerp = 4,
|
Lerp = 4,
|
||||||
Subtract = 5,
|
Subtract = 5,
|
||||||
|
|
||||||
|
Dot3RGB = 6,
|
||||||
|
Dot3RGBA = 7,
|
||||||
MultiplyThenAdd = 8,
|
MultiplyThenAdd = 8,
|
||||||
AddThenMultiply = 9,
|
AddThenMultiply = 9,
|
||||||
};
|
};
|
||||||
|
|
|
@ -502,6 +502,20 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
|
||||||
return result.Cast<u8>();
|
return result.Cast<u8>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This computes the dot product of the RGB components according to GLES spec.
|
||||||
|
// Dot3RGB just stores the dot product in the RGB components.
|
||||||
|
// Dot3RGBA also stores it in the alpha component.
|
||||||
|
case Operation::Dot3RGB:
|
||||||
|
case Operation::Dot3RGBA:
|
||||||
|
{
|
||||||
|
std::array<int, 3> a = {input[0].r(), input[0].g(), input[0].b()};
|
||||||
|
std::array<int, 3> b = {input[1].r(), input[1].g(), input[1].b()};
|
||||||
|
|
||||||
|
auto res = std::inner_product(a, a.end(), b, 0);
|
||||||
|
|
||||||
|
return {res, res, res};
|
||||||
|
}
|
||||||
|
|
||||||
case Operation::MultiplyThenAdd:
|
case Operation::MultiplyThenAdd:
|
||||||
{
|
{
|
||||||
auto result = (input[0] * input[1] + 255 * input[2].Cast<int>()) / 255;
|
auto result = (input[0] * input[1] + 255 * input[2].Cast<int>()) / 255;
|
||||||
|
@ -545,6 +559,16 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
|
||||||
case Operation::Subtract:
|
case Operation::Subtract:
|
||||||
return std::max(0, (int)input[0] - (int)input[1]);
|
return std::max(0, (int)input[0] - (int)input[1]);
|
||||||
|
|
||||||
|
case Operation::Dot3RGBA:
|
||||||
|
{
|
||||||
|
std::array<int, 3> a = {input[0].r(), input[0].g(), input[0].b()};
|
||||||
|
std::array<int, 3> b = {input[1].r(), input[1].g(), input[1].b()};
|
||||||
|
|
||||||
|
auto res = std::inner_product(a, a.end(), b, 0);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
case Operation::MultiplyThenAdd:
|
case Operation::MultiplyThenAdd:
|
||||||
return std::min(255, (input[0] * input[1] + 255 * input[2]) / 255);
|
return std::min(255, (input[0] * input[1] + 255 * input[2]) / 255);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue