diff options
| author | 2018-11-14 00:02:54 -0300 | |
|---|---|---|
| committer | 2018-11-17 19:59:34 -0300 | |
| commit | 53b4a1af0f8a8c1e7c0ad27c76adf3b0e86bef13 (patch) | |
| tree | dbcb83fe2bde8d215f6665a614d7530e7cb1411e | |
| parent | add support for fragment_color_clamp (diff) | |
| download | yuzu-53b4a1af0f8a8c1e7c0ad27c76adf3b0e86bef13.tar.gz yuzu-53b4a1af0f8a8c1e7c0ad27c76adf3b0e86bef13.tar.xz yuzu-53b4a1af0f8a8c1e7c0ad27c76adf3b0e86bef13.zip | |
add AlphaToCoverage and AlphaToOne
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 17 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.h | 5 |
5 files changed, 39 insertions, 1 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index f2d69814e..753aff57f 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -726,7 +726,12 @@ public: | |||
| 726 | 726 | ||
| 727 | u32 zeta_enable; | 727 | u32 zeta_enable; |
| 728 | 728 | ||
| 729 | INSERT_PADDING_WORDS(0x8); | 729 | union { |
| 730 | BitField<1, 1, u32> alpha_to_coverage; | ||
| 731 | BitField<2, 1, u32> alpha_to_one; | ||
| 732 | } multisample_control; | ||
| 733 | |||
| 734 | INSERT_PADDING_WORDS(0x7); | ||
| 730 | 735 | ||
| 731 | struct { | 736 | struct { |
| 732 | u32 tsc_address_high; | 737 | u32 tsc_address_high; |
| @@ -1149,6 +1154,7 @@ ASSERT_REG_POSITION(screen_y_control, 0x4EB); | |||
| 1149 | ASSERT_REG_POSITION(vb_element_base, 0x50D); | 1154 | ASSERT_REG_POSITION(vb_element_base, 0x50D); |
| 1150 | ASSERT_REG_POSITION(point_size, 0x546); | 1155 | ASSERT_REG_POSITION(point_size, 0x546); |
| 1151 | ASSERT_REG_POSITION(zeta_enable, 0x54E); | 1156 | ASSERT_REG_POSITION(zeta_enable, 0x54E); |
| 1157 | ASSERT_REG_POSITION(multisample_control, 0x54F); | ||
| 1152 | ASSERT_REG_POSITION(tsc, 0x557); | 1158 | ASSERT_REG_POSITION(tsc, 0x557); |
| 1153 | ASSERT_REG_POSITION(tic, 0x55D); | 1159 | ASSERT_REG_POSITION(tic, 0x55D); |
| 1154 | ASSERT_REG_POSITION(stencil_two_side_enable, 0x565); | 1160 | ASSERT_REG_POSITION(stencil_two_side_enable, 0x565); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 98799056c..d2e3fde65 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -583,6 +583,7 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 583 | ConfigureFramebuffers(state); | 583 | ConfigureFramebuffers(state); |
| 584 | SyncColorMask(); | 584 | SyncColorMask(); |
| 585 | SyncFragmentColorClampState(); | 585 | SyncFragmentColorClampState(); |
| 586 | SyncMultiSampleState(); | ||
| 586 | SyncDepthTestState(); | 587 | SyncDepthTestState(); |
| 587 | SyncStencilTestState(); | 588 | SyncStencilTestState(); |
| 588 | SyncBlendState(); | 589 | SyncBlendState(); |
| @@ -1033,6 +1034,12 @@ void RasterizerOpenGL::SyncColorMask() { | |||
| 1033 | } | 1034 | } |
| 1034 | } | 1035 | } |
| 1035 | 1036 | ||
| 1037 | void RasterizerOpenGL::SyncMultiSampleState() { | ||
| 1038 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; | ||
| 1039 | state.multisample_control.alpha_to_coverage = regs.multisample_control.alpha_to_coverage != 0; | ||
| 1040 | state.multisample_control.alpha_to_one = regs.multisample_control.alpha_to_one != 0; | ||
| 1041 | } | ||
| 1042 | |||
| 1036 | void RasterizerOpenGL::SyncFragmentColorClampState() { | 1043 | void RasterizerOpenGL::SyncFragmentColorClampState() { |
| 1037 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; | 1044 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; |
| 1038 | state.fragment_color_clamp.enabled = regs.frag_color_clamp != 0; | 1045 | state.fragment_color_clamp.enabled = regs.frag_color_clamp != 0; |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index d3fa0b6fc..8994e134a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -163,6 +163,9 @@ private: | |||
| 163 | /// Syncs the the color clamp state | 163 | /// Syncs the the color clamp state |
| 164 | void SyncFragmentColorClampState(); | 164 | void SyncFragmentColorClampState(); |
| 165 | 165 | ||
| 166 | /// Syncs the alpha coverage and alpha to one | ||
| 167 | void SyncMultiSampleState(); | ||
| 168 | |||
| 166 | /// Syncs the scissor test state to match the guest state | 169 | /// Syncs the scissor test state to match the guest state |
| 167 | void SyncScissorTest(); | 170 | void SyncScissorTest(); |
| 168 | 171 | ||
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index 6998dd92b..f6d80614b 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp | |||
| @@ -16,6 +16,8 @@ OpenGLState::OpenGLState() { | |||
| 16 | // These all match default OpenGL values | 16 | // These all match default OpenGL values |
| 17 | geometry_shaders.enabled = false; | 17 | geometry_shaders.enabled = false; |
| 18 | framebuffer_srgb.enabled = false; | 18 | framebuffer_srgb.enabled = false; |
| 19 | multisample_control.alpha_to_coverage = false; | ||
| 20 | multisample_control.alpha_to_one = false; | ||
| 19 | cull.enabled = false; | 21 | cull.enabled = false; |
| 20 | cull.mode = GL_BACK; | 22 | cull.mode = GL_BACK; |
| 21 | cull.front_face = GL_CCW; | 23 | cull.front_face = GL_CCW; |
| @@ -504,6 +506,21 @@ void OpenGLState::Apply() const { | |||
| 504 | fragment_color_clamp.enabled ? GL_TRUE : GL_FALSE); | 506 | fragment_color_clamp.enabled ? GL_TRUE : GL_FALSE); |
| 505 | } | 507 | } |
| 506 | } | 508 | } |
| 509 | if (multisample_control.alpha_to_coverage != cur_state.multisample_control.alpha_to_coverage) { | ||
| 510 | if (multisample_control.alpha_to_coverage) { | ||
| 511 | glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); | ||
| 512 | } else { | ||
| 513 | glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); | ||
| 514 | } | ||
| 515 | } | ||
| 516 | if (multisample_control.alpha_to_one != cur_state.multisample_control.alpha_to_one) { | ||
| 517 | if (multisample_control.alpha_to_one) { | ||
| 518 | glEnable(GL_SAMPLE_ALPHA_TO_ONE); | ||
| 519 | } else { | ||
| 520 | glDisable(GL_SAMPLE_ALPHA_TO_ONE); | ||
| 521 | } | ||
| 522 | } | ||
| 523 | |||
| 507 | ApplyColorMask(); | 524 | ApplyColorMask(); |
| 508 | ApplyViewport(); | 525 | ApplyViewport(); |
| 509 | ApplyStencilTest(); | 526 | ApplyStencilTest(); |
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index 6079f6e0b..c8d951a7f 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h | |||
| @@ -40,6 +40,11 @@ public: | |||
| 40 | } framebuffer_srgb; | 40 | } framebuffer_srgb; |
| 41 | 41 | ||
| 42 | struct { | 42 | struct { |
| 43 | bool alpha_to_coverage; // GL_ALPHA_TO_COVERAGE | ||
| 44 | bool alpha_to_one; // GL_ALPHA_TO_ONE | ||
| 45 | } multisample_control; | ||
| 46 | |||
| 47 | struct { | ||
| 43 | bool enabled; // GL_CLAMP_FRAGMENT_COLOR_ARB | 48 | bool enabled; // GL_CLAMP_FRAGMENT_COLOR_ARB |
| 44 | } fragment_color_clamp; | 49 | } fragment_color_clamp; |
| 45 | 50 | ||