diff options
| author | 2014-10-24 00:58:04 +0200 | |
|---|---|---|
| committer | 2014-12-20 18:05:53 +0100 | |
| commit | 7e210e0229b9caef77c80fea7c056c3913e68129 (patch) | |
| tree | 5b043321e3f8d04208128843c94bff1626f3289f /src | |
| parent | Pica: Merge texture lookup logic for DebugUtils and Rasterizer. (diff) | |
| download | yuzu-7e210e0229b9caef77c80fea7c056c3913e68129.tar.gz yuzu-7e210e0229b9caef77c80fea7c056c3913e68129.tar.xz yuzu-7e210e0229b9caef77c80fea7c056c3913e68129.zip | |
Pica: Further improve Tev emulation.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 10 | ||||
| -rw-r--r-- | src/video_core/pica.h | 1 | ||||
| -rw-r--r-- | src/video_core/rasterizer.cpp | 52 |
3 files changed, 51 insertions, 12 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 6c26138da..3cc22f436 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -573,20 +573,26 @@ void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages) | |||
| 573 | const std::map<Source, std::string> source_map = { | 573 | const std::map<Source, std::string> source_map = { |
| 574 | { Source::PrimaryColor, "PrimaryColor" }, | 574 | { Source::PrimaryColor, "PrimaryColor" }, |
| 575 | { Source::Texture0, "Texture0" }, | 575 | { Source::Texture0, "Texture0" }, |
| 576 | { Source::Texture1, "Texture1" }, | ||
| 577 | { Source::Texture2, "Texture2" }, | ||
| 576 | { Source::Constant, "Constant" }, | 578 | { Source::Constant, "Constant" }, |
| 577 | { Source::Previous, "Previous" }, | 579 | { Source::Previous, "Previous" }, |
| 578 | }; | 580 | }; |
| 579 | 581 | ||
| 580 | const std::map<ColorModifier, std::string> color_modifier_map = { | 582 | const std::map<ColorModifier, std::string> color_modifier_map = { |
| 581 | { ColorModifier::SourceColor, { "%source.rgb" } } | 583 | { ColorModifier::SourceColor, { "%source.rgb" } }, |
| 584 | { ColorModifier::SourceAlpha, { "%source.aaa" } }, | ||
| 582 | }; | 585 | }; |
| 583 | const std::map<AlphaModifier, std::string> alpha_modifier_map = { | 586 | const std::map<AlphaModifier, std::string> alpha_modifier_map = { |
| 584 | { AlphaModifier::SourceAlpha, "%source.a" } | 587 | { AlphaModifier::SourceAlpha, "%source.a" }, |
| 588 | { AlphaModifier::OneMinusSourceAlpha, "(255 - %source.a)" }, | ||
| 585 | }; | 589 | }; |
| 586 | 590 | ||
| 587 | std::map<Operation, std::string> combiner_map = { | 591 | std::map<Operation, std::string> combiner_map = { |
| 588 | { Operation::Replace, "%source1" }, | 592 | { Operation::Replace, "%source1" }, |
| 589 | { Operation::Modulate, "(%source1 * %source2) / 255" }, | 593 | { Operation::Modulate, "(%source1 * %source2) / 255" }, |
| 594 | { Operation::Add, "(%source1 + %source2)" }, | ||
| 595 | { Operation::Lerp, "lerp(%source1, %source2, %source3)" }, | ||
| 590 | }; | 596 | }; |
| 591 | 597 | ||
| 592 | auto ReplacePattern = | 598 | auto ReplacePattern = |
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index ec20114fe..5712439e1 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <cstddef> | 8 | #include <cstddef> |
| 9 | #include <initializer_list> | 9 | #include <initializer_list> |
| 10 | #include <map> | 10 | #include <map> |
| 11 | #include <vector> | ||
| 11 | 12 | ||
| 12 | #include "common/bit_field.h" | 13 | #include "common/bit_field.h" |
| 13 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index aa2bc93ec..25efd49c8 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -225,28 +225,29 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 225 | using AlphaModifier = Regs::TevStageConfig::AlphaModifier; | 225 | using AlphaModifier = Regs::TevStageConfig::AlphaModifier; |
| 226 | using Operation = Regs::TevStageConfig::Operation; | 226 | using Operation = Regs::TevStageConfig::Operation; |
| 227 | 227 | ||
| 228 | auto GetColorSource = [&](Source source) -> Math::Vec3<u8> { | 228 | auto GetColorSource = [&](Source source) -> Math::Vec4<u8> { |
| 229 | switch (source) { | 229 | switch (source) { |
| 230 | case Source::PrimaryColor: | 230 | case Source::PrimaryColor: |
| 231 | return primary_color.rgb(); | 231 | return primary_color; |
| 232 | 232 | ||
| 233 | case Source::Texture0: | 233 | case Source::Texture0: |
| 234 | return texture_color[0].rgb(); | 234 | return texture_color[0]; |
| 235 | 235 | ||
| 236 | case Source::Texture1: | 236 | case Source::Texture1: |
| 237 | return texture_color[1].rgb(); | 237 | return texture_color[1]; |
| 238 | 238 | ||
| 239 | case Source::Texture2: | 239 | case Source::Texture2: |
| 240 | return texture_color[2].rgb(); | 240 | return texture_color[2]; |
| 241 | 241 | ||
| 242 | case Source::Constant: | 242 | case Source::Constant: |
| 243 | return {tev_stage.const_r, tev_stage.const_g, tev_stage.const_b}; | 243 | return {tev_stage.const_r, tev_stage.const_g, tev_stage.const_b, tev_stage.const_a}; |
| 244 | 244 | ||
| 245 | case Source::Previous: | 245 | case Source::Previous: |
| 246 | return combiner_output.rgb(); | 246 | return combiner_output; |
| 247 | 247 | ||
| 248 | default: | 248 | default: |
| 249 | LOG_ERROR(HW_GPU, "Unknown color combiner source %d\n", (int)source); | 249 | LOG_ERROR(HW_GPU, "Unknown color combiner source %d\n", (int)source); |
| 250 | _dbg_assert_(HW_GPU, 0); | ||
| 250 | return {}; | 251 | return {}; |
| 251 | } | 252 | } |
| 252 | }; | 253 | }; |
| @@ -273,17 +274,23 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 273 | 274 | ||
| 274 | default: | 275 | default: |
| 275 | LOG_ERROR(HW_GPU, "Unknown alpha combiner source %d\n", (int)source); | 276 | LOG_ERROR(HW_GPU, "Unknown alpha combiner source %d\n", (int)source); |
| 277 | _dbg_assert_(HW_GPU, 0); | ||
| 276 | return 0; | 278 | return 0; |
| 277 | } | 279 | } |
| 278 | }; | 280 | }; |
| 279 | 281 | ||
| 280 | auto GetColorModifier = [](ColorModifier factor, const Math::Vec3<u8>& values) -> Math::Vec3<u8> { | 282 | auto GetColorModifier = [](ColorModifier factor, const Math::Vec4<u8>& values) -> Math::Vec3<u8> { |
| 281 | switch (factor) | 283 | switch (factor) |
| 282 | { | 284 | { |
| 283 | case ColorModifier::SourceColor: | 285 | case ColorModifier::SourceColor: |
| 284 | return values; | 286 | return values.rgb(); |
| 287 | |||
| 288 | case ColorModifier::SourceAlpha: | ||
| 289 | return { values.a(), values.a(), values.a() }; | ||
| 290 | |||
| 285 | default: | 291 | default: |
| 286 | LOG_ERROR(HW_GPU, "Unknown color factor %d\n", (int)factor); | 292 | LOG_ERROR(HW_GPU, "Unknown color factor %d\n", (int)factor); |
| 293 | _dbg_assert_(HW_GPU, 0); | ||
| 287 | return {}; | 294 | return {}; |
| 288 | } | 295 | } |
| 289 | }; | 296 | }; |
| @@ -292,8 +299,13 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 292 | switch (factor) { | 299 | switch (factor) { |
| 293 | case AlphaModifier::SourceAlpha: | 300 | case AlphaModifier::SourceAlpha: |
| 294 | return value; | 301 | return value; |
| 302 | |||
| 303 | case AlphaModifier::OneMinusSourceAlpha: | ||
| 304 | return 255 - value; | ||
| 305 | |||
| 295 | default: | 306 | default: |
| 296 | LOG_ERROR(HW_GPU, "Unknown color factor %d\n", (int)factor); | 307 | LOG_ERROR(HW_GPU, "Unknown alpha factor %d\n", (int)factor); |
| 308 | _dbg_assert_(HW_GPU, 0); | ||
| 297 | return 0; | 309 | return 0; |
| 298 | } | 310 | } |
| 299 | }; | 311 | }; |
| @@ -306,8 +318,21 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 306 | case Operation::Modulate: | 318 | case Operation::Modulate: |
| 307 | return ((input[0] * input[1]) / 255).Cast<u8>(); | 319 | return ((input[0] * input[1]) / 255).Cast<u8>(); |
| 308 | 320 | ||
| 321 | case Operation::Add: | ||
| 322 | { | ||
| 323 | auto result = input[0] + input[1]; | ||
| 324 | result.r() = std::min(255, result.r()); | ||
| 325 | result.g() = std::min(255, result.g()); | ||
| 326 | result.b() = std::min(255, result.b()); | ||
| 327 | return result.Cast<u8>(); | ||
| 328 | } | ||
| 329 | |||
| 330 | case Operation::Lerp: | ||
| 331 | return ((input[0] * input[2] + input[1] * (Math::MakeVec<u8>(255, 255, 255) - input[2]).Cast<u8>()) / 255).Cast<u8>(); | ||
| 332 | |||
| 309 | default: | 333 | default: |
| 310 | LOG_ERROR(HW_GPU, "Unknown color combiner operation %d\n", (int)op); | 334 | LOG_ERROR(HW_GPU, "Unknown color combiner operation %d\n", (int)op); |
| 335 | _dbg_assert_(HW_GPU, 0); | ||
| 311 | return {}; | 336 | return {}; |
| 312 | } | 337 | } |
| 313 | }; | 338 | }; |
| @@ -320,8 +345,15 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 320 | case Operation::Modulate: | 345 | case Operation::Modulate: |
| 321 | return input[0] * input[1] / 255; | 346 | return input[0] * input[1] / 255; |
| 322 | 347 | ||
| 348 | case Operation::Add: | ||
| 349 | return std::min(255, input[0] + input[1]); | ||
| 350 | |||
| 351 | case Operation::Lerp: | ||
| 352 | return (input[0] * input[2] + input[1] * (255 - input[2])) / 255; | ||
| 353 | |||
| 323 | default: | 354 | default: |
| 324 | LOG_ERROR(HW_GPU, "Unknown alpha combiner operation %d\n", (int)op); | 355 | LOG_ERROR(HW_GPU, "Unknown alpha combiner operation %d\n", (int)op); |
| 356 | _dbg_assert_(HW_GPU, 0); | ||
| 325 | return 0; | 357 | return 0; |
| 326 | } | 358 | } |
| 327 | }; | 359 | }; |