diff options
| author | 2015-02-01 12:00:10 +0100 | |
|---|---|---|
| committer | 2015-02-01 12:00:10 +0100 | |
| commit | e1f9f9ea048f3f085e50463d9b0c7a0f99d9bc3c (patch) | |
| tree | f30fcdd81d71e3ba51fc0459a280de8a324e71b6 /src | |
| parent | Merge pull request #514 from rohit-n/fix-warnings (diff) | |
| parent | Pica: Implement blend factors. (diff) | |
| download | yuzu-e1f9f9ea048f3f085e50463d9b0c7a0f99d9bc3c.tar.gz yuzu-e1f9f9ea048f3f085e50463d9b0c7a0f99d9bc3c.tar.xz yuzu-e1f9f9ea048f3f085e50463d9b0c7a0f99d9bc3c.zip | |
Merge pull request #517 from bunnei/blend-factors
Pica: Implement blend factors.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/pica.h | 27 | ||||
| -rw-r--r-- | src/video_core/rasterizer.cpp | 50 |
2 files changed, 67 insertions, 10 deletions
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 78603ebdf..2506bf78e 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -332,11 +332,21 @@ struct Regs { | |||
| 332 | }; | 332 | }; |
| 333 | 333 | ||
| 334 | enum BlendFactor : u32 { | 334 | enum BlendFactor : u32 { |
| 335 | Zero = 0, | 335 | Zero = 0, |
| 336 | One = 1, | 336 | One = 1, |
| 337 | 337 | SourceColor = 2, | |
| 338 | SourceAlpha = 6, | 338 | OneMinusSourceColor = 3, |
| 339 | OneMinusSourceAlpha = 7, | 339 | DestColor = 4, |
| 340 | OneMinusDestColor = 5, | ||
| 341 | SourceAlpha = 6, | ||
| 342 | OneMinusSourceAlpha = 7, | ||
| 343 | DestAlpha = 8, | ||
| 344 | OneMinusDestAlpha = 9, | ||
| 345 | ConstantColor = 10, | ||
| 346 | OneMinusConstantColor = 11, | ||
| 347 | ConstantAlpha = 12, | ||
| 348 | OneMinusConstantAlpha = 13, | ||
| 349 | SourceAlphaSaturate = 14 | ||
| 340 | }; | 350 | }; |
| 341 | 351 | ||
| 342 | BitField< 0, 8, BlendEquation> blend_equation_rgb; | 352 | BitField< 0, 8, BlendEquation> blend_equation_rgb; |
| @@ -357,7 +367,12 @@ struct Regs { | |||
| 357 | BitField<0, 4, Op> op; | 367 | BitField<0, 4, Op> op; |
| 358 | } logic_op; | 368 | } logic_op; |
| 359 | 369 | ||
| 360 | INSERT_PADDING_WORDS(0x1); | 370 | union { |
| 371 | BitField< 0, 8, u32> r; | ||
| 372 | BitField< 8, 8, u32> g; | ||
| 373 | BitField<16, 8, u32> b; | ||
| 374 | BitField<24, 8, u32> a; | ||
| 375 | } blend_const; | ||
| 361 | 376 | ||
| 362 | union { | 377 | union { |
| 363 | BitField< 0, 1, u32> enable; | 378 | BitField< 0, 1, u32> enable; |
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 7f66c6d42..845f1c4b2 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -528,18 +528,48 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 528 | auto params = registers.output_merger.alpha_blending; | 528 | auto params = registers.output_merger.alpha_blending; |
| 529 | 529 | ||
| 530 | auto LookupFactorRGB = [&](decltype(params)::BlendFactor factor) -> Math::Vec3<u8> { | 530 | auto LookupFactorRGB = [&](decltype(params)::BlendFactor factor) -> Math::Vec3<u8> { |
| 531 | switch(factor) { | 531 | switch (factor) { |
| 532 | case params.Zero: | 532 | case params.Zero: |
| 533 | return Math::Vec3<u8>(0, 0, 0); | 533 | return Math::Vec3<u8>(0, 0, 0); |
| 534 | 534 | ||
| 535 | case params.One: | 535 | case params.One: |
| 536 | return Math::Vec3<u8>(255, 255, 255); | 536 | return Math::Vec3<u8>(255, 255, 255); |
| 537 | 537 | ||
| 538 | case params.SourceColor: | ||
| 539 | return combiner_output.rgb(); | ||
| 540 | |||
| 541 | case params.OneMinusSourceColor: | ||
| 542 | return Math::Vec3<u8>(255 - combiner_output.r(), 255 - combiner_output.g(), 255 - combiner_output.b()); | ||
| 543 | |||
| 544 | case params.DestColor: | ||
| 545 | return dest.rgb(); | ||
| 546 | |||
| 547 | case params.OneMinusDestColor: | ||
| 548 | return Math::Vec3<u8>(255 - dest.r(), 255 - dest.g(), 255 - dest.b()); | ||
| 549 | |||
| 538 | case params.SourceAlpha: | 550 | case params.SourceAlpha: |
| 539 | return Math::MakeVec(combiner_output.a(), combiner_output.a(), combiner_output.a()); | 551 | return Math::Vec3<u8>(combiner_output.a(), combiner_output.a(), combiner_output.a()); |
| 540 | 552 | ||
| 541 | case params.OneMinusSourceAlpha: | 553 | case params.OneMinusSourceAlpha: |
| 542 | return Math::Vec3<u8>(255-combiner_output.a(), 255-combiner_output.a(), 255-combiner_output.a()); | 554 | return Math::Vec3<u8>(255 - combiner_output.a(), 255 - combiner_output.a(), 255 - combiner_output.a()); |
| 555 | |||
| 556 | case params.DestAlpha: | ||
| 557 | return Math::Vec3<u8>(dest.a(), dest.a(), dest.a()); | ||
| 558 | |||
| 559 | case params.OneMinusDestAlpha: | ||
| 560 | return Math::Vec3<u8>(255 - dest.a(), 255 - dest.a(), 255 - dest.a()); | ||
| 561 | |||
| 562 | case params.ConstantColor: | ||
| 563 | return Math::Vec3<u8>(registers.output_merger.blend_const.r, registers.output_merger.blend_const.g, registers.output_merger.blend_const.b); | ||
| 564 | |||
| 565 | case params.OneMinusConstantColor: | ||
| 566 | return Math::Vec3<u8>(255 - registers.output_merger.blend_const.r, 255 - registers.output_merger.blend_const.g, 255 - registers.output_merger.blend_const.b); | ||
| 567 | |||
| 568 | case params.ConstantAlpha: | ||
| 569 | return Math::Vec3<u8>(registers.output_merger.blend_const.a, registers.output_merger.blend_const.a, registers.output_merger.blend_const.a); | ||
| 570 | |||
| 571 | case params.OneMinusConstantAlpha: | ||
| 572 | return Math::Vec3<u8>(255 - registers.output_merger.blend_const.a, 255 - registers.output_merger.blend_const.a, 255 - registers.output_merger.blend_const.a); | ||
| 543 | 573 | ||
| 544 | default: | 574 | default: |
| 545 | LOG_CRITICAL(HW_GPU, "Unknown color blend factor %x", factor); | 575 | LOG_CRITICAL(HW_GPU, "Unknown color blend factor %x", factor); |
| @@ -549,7 +579,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 549 | }; | 579 | }; |
| 550 | 580 | ||
| 551 | auto LookupFactorA = [&](decltype(params)::BlendFactor factor) -> u8 { | 581 | auto LookupFactorA = [&](decltype(params)::BlendFactor factor) -> u8 { |
| 552 | switch(factor) { | 582 | switch (factor) { |
| 553 | case params.Zero: | 583 | case params.Zero: |
| 554 | return 0; | 584 | return 0; |
| 555 | 585 | ||
| @@ -562,6 +592,18 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 562 | case params.OneMinusSourceAlpha: | 592 | case params.OneMinusSourceAlpha: |
| 563 | return 255 - combiner_output.a(); | 593 | return 255 - combiner_output.a(); |
| 564 | 594 | ||
| 595 | case params.DestAlpha: | ||
| 596 | return dest.a(); | ||
| 597 | |||
| 598 | case params.OneMinusDestAlpha: | ||
| 599 | return 255 - dest.a(); | ||
| 600 | |||
| 601 | case params.ConstantAlpha: | ||
| 602 | return registers.output_merger.blend_const.a; | ||
| 603 | |||
| 604 | case params.OneMinusConstantAlpha: | ||
| 605 | return 255 - registers.output_merger.blend_const.a; | ||
| 606 | |||
| 565 | default: | 607 | default: |
| 566 | LOG_CRITICAL(HW_GPU, "Unknown alpha blend factor %x", factor); | 608 | LOG_CRITICAL(HW_GPU, "Unknown alpha blend factor %x", factor); |
| 567 | exit(0); | 609 | exit(0); |