diff options
| author | 2015-08-20 10:31:39 -0500 | |
|---|---|---|
| committer | 2015-08-21 09:45:36 -0500 | |
| commit | e74825e3d09c924f03ff63408bccefbccab19bae (patch) | |
| tree | 28c904ede63ba83b3a8f74167a6b25cd20487e95 /src/video_core/rasterizer.cpp | |
| parent | GLRasterizer: Implemented stencil testing in the hw renderer. (diff) | |
| download | yuzu-e74825e3d09c924f03ff63408bccefbccab19bae.tar.gz yuzu-e74825e3d09c924f03ff63408bccefbccab19bae.tar.xz yuzu-e74825e3d09c924f03ff63408bccefbccab19bae.zip | |
Rasterizer: Abstract duplicated stencil code into a lambda.
Diffstat (limited to 'src/video_core/rasterizer.cpp')
| -rw-r--r-- | src/video_core/rasterizer.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 000b4542b..c768a5eea 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -791,6 +791,12 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0, | |||
| 791 | } | 791 | } |
| 792 | 792 | ||
| 793 | u8 old_stencil = 0; | 793 | u8 old_stencil = 0; |
| 794 | |||
| 795 | auto UpdateStencil = [stencil_test, x, y, &old_stencil](Pica::Regs::StencilAction action) { | ||
| 796 | u8 new_stencil = PerformStencilAction(action, old_stencil, stencil_test.reference_value); | ||
| 797 | SetStencil(x >> 4, y >> 4, (new_stencil & stencil_test.write_mask) | (old_stencil & ~stencil_test.write_mask)); | ||
| 798 | }; | ||
| 799 | |||
| 794 | if (stencil_action_enable) { | 800 | if (stencil_action_enable) { |
| 795 | old_stencil = GetStencil(x >> 4, y >> 4); | 801 | old_stencil = GetStencil(x >> 4, y >> 4); |
| 796 | u8 dest = old_stencil & stencil_test.input_mask; | 802 | u8 dest = old_stencil & stencil_test.input_mask; |
| @@ -832,8 +838,7 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0, | |||
| 832 | } | 838 | } |
| 833 | 839 | ||
| 834 | if (!pass) { | 840 | if (!pass) { |
| 835 | u8 new_stencil = PerformStencilAction(stencil_test.action_stencil_fail, old_stencil, stencil_test.reference_value); | 841 | UpdateStencil(stencil_test.action_stencil_fail); |
| 836 | SetStencil(x >> 4, y >> 4, (new_stencil & stencil_test.write_mask) | (old_stencil & ~stencil_test.write_mask)); | ||
| 837 | continue; | 842 | continue; |
| 838 | } | 843 | } |
| 839 | } | 844 | } |
| @@ -884,8 +889,7 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0, | |||
| 884 | 889 | ||
| 885 | if (!pass) { | 890 | if (!pass) { |
| 886 | if (stencil_action_enable) { | 891 | if (stencil_action_enable) { |
| 887 | u8 new_stencil = PerformStencilAction(stencil_test.action_depth_fail, old_stencil, stencil_test.reference_value); | 892 | UpdateStencil(stencil_test.action_depth_fail); |
| 888 | SetStencil(x >> 4, y >> 4, (new_stencil & stencil_test.write_mask) | (old_stencil & ~stencil_test.write_mask)); | ||
| 889 | } | 893 | } |
| 890 | continue; | 894 | continue; |
| 891 | } | 895 | } |
| @@ -895,8 +899,7 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0, | |||
| 895 | 899 | ||
| 896 | if (stencil_action_enable) { | 900 | if (stencil_action_enable) { |
| 897 | // TODO: What happens if stencil testing is enabled, but depth testing is not? Will stencil get updated anyway? | 901 | // TODO: What happens if stencil testing is enabled, but depth testing is not? Will stencil get updated anyway? |
| 898 | u8 new_stencil = PerformStencilAction(stencil_test.action_depth_pass, old_stencil, stencil_test.reference_value); | 902 | UpdateStencil(stencil_test.action_depth_pass); |
| 899 | SetStencil(x >> 4, y >> 4, (new_stencil & stencil_test.write_mask) | (old_stencil & ~stencil_test.write_mask)); | ||
| 900 | } | 903 | } |
| 901 | } | 904 | } |
| 902 | 905 | ||