diff options
Diffstat (limited to 'src/video_core/rasterizer.cpp')
| -rw-r--r-- | src/video_core/rasterizer.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index a80148872..04ff68615 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -279,12 +279,15 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 279 | } | 279 | } |
| 280 | }; | 280 | }; |
| 281 | 281 | ||
| 282 | auto GetColorModifier = [](ColorModifier factor, const Math::Vec4<u8>& values) -> Math::Vec3<u8> { | 282 | static auto GetColorModifier = [](ColorModifier factor, const Math::Vec4<u8>& values) -> Math::Vec3<u8> { |
| 283 | switch (factor) | 283 | switch (factor) |
| 284 | { | 284 | { |
| 285 | case ColorModifier::SourceColor: | 285 | case ColorModifier::SourceColor: |
| 286 | return values.rgb(); | 286 | return values.rgb(); |
| 287 | 287 | ||
| 288 | case ColorModifier::OneMinusSourceColor: | ||
| 289 | return (Math::Vec3<u8>(255, 255, 255) - values.rgb()).Cast<u8>(); | ||
| 290 | |||
| 288 | case ColorModifier::SourceAlpha: | 291 | case ColorModifier::SourceAlpha: |
| 289 | return { values.a(), values.a(), values.a() }; | 292 | return { values.a(), values.a(), values.a() }; |
| 290 | 293 | ||
| @@ -295,7 +298,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 295 | } | 298 | } |
| 296 | }; | 299 | }; |
| 297 | 300 | ||
| 298 | auto GetAlphaModifier = [](AlphaModifier factor, u8 value) -> u8 { | 301 | static auto GetAlphaModifier = [](AlphaModifier factor, u8 value) -> u8 { |
| 299 | switch (factor) { | 302 | switch (factor) { |
| 300 | case AlphaModifier::SourceAlpha: | 303 | case AlphaModifier::SourceAlpha: |
| 301 | return value; | 304 | return value; |
| @@ -310,7 +313,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 310 | } | 313 | } |
| 311 | }; | 314 | }; |
| 312 | 315 | ||
| 313 | auto ColorCombine = [](Operation op, const Math::Vec3<u8> input[3]) -> Math::Vec3<u8> { | 316 | static auto ColorCombine = [](Operation op, const Math::Vec3<u8> input[3]) -> Math::Vec3<u8> { |
| 314 | switch (op) { | 317 | switch (op) { |
| 315 | case Operation::Replace: | 318 | case Operation::Replace: |
| 316 | return input[0]; | 319 | return input[0]; |
| @@ -330,6 +333,15 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 330 | case Operation::Lerp: | 333 | case Operation::Lerp: |
| 331 | return ((input[0] * input[2] + input[1] * (Math::MakeVec<u8>(255, 255, 255) - input[2]).Cast<u8>()) / 255).Cast<u8>(); | 334 | return ((input[0] * input[2] + input[1] * (Math::MakeVec<u8>(255, 255, 255) - input[2]).Cast<u8>()) / 255).Cast<u8>(); |
| 332 | 335 | ||
| 336 | case Operation::Subtract: | ||
| 337 | { | ||
| 338 | auto result = input[0].Cast<int>() - input[1].Cast<int>(); | ||
| 339 | result.r() = std::max(0, result.r()); | ||
| 340 | result.g() = std::max(0, result.g()); | ||
| 341 | result.b() = std::max(0, result.b()); | ||
| 342 | return result.Cast<u8>(); | ||
| 343 | } | ||
| 344 | |||
| 333 | default: | 345 | default: |
| 334 | LOG_ERROR(HW_GPU, "Unknown color combiner operation %d\n", (int)op); | 346 | LOG_ERROR(HW_GPU, "Unknown color combiner operation %d\n", (int)op); |
| 335 | _dbg_assert_(HW_GPU, 0); | 347 | _dbg_assert_(HW_GPU, 0); |
| @@ -337,7 +349,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 337 | } | 349 | } |
| 338 | }; | 350 | }; |
| 339 | 351 | ||
| 340 | auto AlphaCombine = [](Operation op, const std::array<u8,3>& input) -> u8 { | 352 | static auto AlphaCombine = [](Operation op, const std::array<u8,3>& input) -> u8 { |
| 341 | switch (op) { | 353 | switch (op) { |
| 342 | case Operation::Replace: | 354 | case Operation::Replace: |
| 343 | return input[0]; | 355 | return input[0]; |
| @@ -351,6 +363,9 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 351 | case Operation::Lerp: | 363 | case Operation::Lerp: |
| 352 | return (input[0] * input[2] + input[1] * (255 - input[2])) / 255; | 364 | return (input[0] * input[2] + input[1] * (255 - input[2])) / 255; |
| 353 | 365 | ||
| 366 | case Operation::Subtract: | ||
| 367 | return std::max(0, (int)input[0] - (int)input[1]); | ||
| 368 | |||
| 354 | default: | 369 | default: |
| 355 | LOG_ERROR(HW_GPU, "Unknown alpha combiner operation %d\n", (int)op); | 370 | LOG_ERROR(HW_GPU, "Unknown alpha combiner operation %d\n", (int)op); |
| 356 | _dbg_assert_(HW_GPU, 0); | 371 | _dbg_assert_(HW_GPU, 0); |