diff options
author | bunnei <bunneidev@gmail.com> | 2015-02-04 00:32:29 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2015-02-05 04:15:51 +0100 |
commit | 1eb591d6fd0d6a51d61b737c1be9f28f596d3836 (patch) | |
tree | 1b35c2ae9bacd1f2d85f051c789829779a604195 /src | |
parent | VideoCore: Added same-component swizzlers to math utility functions. (diff) | |
download | yuzu-1eb591d6fd0d6a51d61b737c1be9f28f596d3836.tar yuzu-1eb591d6fd0d6a51d61b737c1be9f28f596d3836.tar.gz yuzu-1eb591d6fd0d6a51d61b737c1be9f28f596d3836.tar.bz2 yuzu-1eb591d6fd0d6a51d61b737c1be9f28f596d3836.tar.lz yuzu-1eb591d6fd0d6a51d61b737c1be9f28f596d3836.tar.xz yuzu-1eb591d6fd0d6a51d61b737c1be9f28f596d3836.tar.zst yuzu-1eb591d6fd0d6a51d61b737c1be9f28f596d3836.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/pica.h | 30 | ||||
-rw-r--r-- | src/video_core/rasterizer.cpp | 97 |
2 files changed, 69 insertions, 58 deletions
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 2506bf78e..1566b890d 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h @@ -233,19 +233,29 @@ struct Regs { }; enum class ColorModifier : u32 { - SourceColor = 0, - OneMinusSourceColor = 1, - SourceAlpha = 2, - OneMinusSourceAlpha = 3, - - // Other values seem to be non-standard extensions + SourceColor = 0x0, + OneMinusSourceColor = 0x1, + SourceAlpha = 0x2, + OneMinusSourceAlpha = 0x3, + SourceRed = 0x4, + OneMinusSourceRed = 0x5, + + SourceGreen = 0x8, + OneMinusSourceGreen = 0x9, + + SourceBlue = 0xc, + OneMinusSourceBlue = 0xd, }; enum class AlphaModifier : u32 { - SourceAlpha = 0, - OneMinusSourceAlpha = 1, - - // Other values seem to be non-standard extensions + SourceAlpha = 0x0, + OneMinusSourceAlpha = 0x1, + SourceRed = 0x2, + OneMinusSourceRed = 0x3, + SourceGreen = 0x4, + OneMinusSourceGreen = 0x5, + SourceBlue = 0x6, + OneMinusSourceBlue = 0x7, }; enum class Operation : u32 { diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 845f1c4b2..5920477eb 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp @@ -260,7 +260,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, using AlphaModifier = Regs::TevStageConfig::AlphaModifier; using Operation = Regs::TevStageConfig::Operation; - auto GetColorSource = [&](Source source) -> Math::Vec4<u8> { + auto GetSource = [&](Source source) -> Math::Vec4<u8> { switch (source) { case Source::PrimaryColor: return primary_color; @@ -287,36 +287,8 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, } }; - auto GetAlphaSource = [&](Source source) -> u8 { - switch (source) { - case Source::PrimaryColor: - return primary_color.a(); - - case Source::Texture0: - return texture_color[0].a(); - - case Source::Texture1: - return texture_color[1].a(); - - case Source::Texture2: - return texture_color[2].a(); - - case Source::Constant: - return tev_stage.const_a; - - case Source::Previous: - return combiner_output.a(); - - default: - LOG_ERROR(HW_GPU, "Unknown alpha combiner source %d\n", (int)source); - _dbg_assert_(HW_GPU, 0); - return 0; - } - }; - static auto GetColorModifier = [](ColorModifier factor, const Math::Vec4<u8>& values) -> Math::Vec3<u8> { - switch (factor) - { + switch (factor) { case ColorModifier::SourceColor: return values.rgb(); @@ -324,27 +296,56 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, return (Math::Vec3<u8>(255, 255, 255) - values.rgb()).Cast<u8>(); case ColorModifier::SourceAlpha: - return { values.a(), values.a(), values.a() }; + return values.aaa(); - default: - LOG_ERROR(HW_GPU, "Unknown color factor %d\n", (int)factor); - _dbg_assert_(HW_GPU, 0); - return {}; + case ColorModifier::OneMinusSourceAlpha: + return (Math::Vec3<u8>(255, 255, 255) - values.aaa()).Cast<u8>(); + + case ColorModifier::SourceRed: + return values.rrr(); + + case ColorModifier::OneMinusSourceRed: + return (Math::Vec3<u8>(255, 255, 255) - values.rrr()).Cast<u8>(); + + case ColorModifier::SourceGreen: + return values.ggg(); + + case ColorModifier::OneMinusSourceGreen: + return (Math::Vec3<u8>(255, 255, 255) - values.ggg()).Cast<u8>(); + + case ColorModifier::SourceBlue: + return values.bbb(); + + case ColorModifier::OneMinusSourceBlue: + return (Math::Vec3<u8>(255, 255, 255) - values.bbb()).Cast<u8>(); } }; - static auto GetAlphaModifier = [](AlphaModifier factor, u8 value) -> u8 { + static auto GetAlphaModifier = [](AlphaModifier factor, const Math::Vec4<u8>& values) -> u8 { switch (factor) { case AlphaModifier::SourceAlpha: - return value; + return values.a(); case AlphaModifier::OneMinusSourceAlpha: - return 255 - value; + return 255 - values.a(); - default: - LOG_ERROR(HW_GPU, "Unknown alpha factor %d\n", (int)factor); - _dbg_assert_(HW_GPU, 0); - return 0; + case AlphaModifier::SourceRed: + return values.r(); + + case AlphaModifier::OneMinusSourceRed: + return 255 - values.r(); + + case AlphaModifier::SourceGreen: + return values.g(); + + case AlphaModifier::OneMinusSourceGreen: + return 255 - values.g(); + + case AlphaModifier::SourceBlue: + return values.b(); + + case AlphaModifier::OneMinusSourceBlue: + return 255 - values.b(); } }; @@ -414,17 +415,17 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, // combiner_output.rgb(), but instead store it in a temporary variable until // alpha combining has been done. Math::Vec3<u8> color_result[3] = { - GetColorModifier(tev_stage.color_modifier1, GetColorSource(tev_stage.color_source1)), - GetColorModifier(tev_stage.color_modifier2, GetColorSource(tev_stage.color_source2)), - GetColorModifier(tev_stage.color_modifier3, GetColorSource(tev_stage.color_source3)) + GetColorModifier(tev_stage.color_modifier1, GetSource(tev_stage.color_source1)), + GetColorModifier(tev_stage.color_modifier2, GetSource(tev_stage.color_source2)), + GetColorModifier(tev_stage.color_modifier3, GetSource(tev_stage.color_source3)) }; auto color_output = ColorCombine(tev_stage.color_op, color_result); // alpha combiner std::array<u8,3> alpha_result = { - GetAlphaModifier(tev_stage.alpha_modifier1, GetAlphaSource(tev_stage.alpha_source1)), - GetAlphaModifier(tev_stage.alpha_modifier2, GetAlphaSource(tev_stage.alpha_source2)), - GetAlphaModifier(tev_stage.alpha_modifier3, GetAlphaSource(tev_stage.alpha_source3)) + GetAlphaModifier(tev_stage.alpha_modifier1, GetSource(tev_stage.alpha_source1)), + GetAlphaModifier(tev_stage.alpha_modifier2, GetSource(tev_stage.alpha_source2)), + GetAlphaModifier(tev_stage.alpha_modifier3, GetSource(tev_stage.alpha_source3)) }; auto alpha_output = AlphaCombine(tev_stage.alpha_op, alpha_result); |