VERY experimental Nintendo Switch 2 emulator
C++
add AlphaToCoverage and AlphaToOne
Rodolfo Bogado00ae363ad595
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.hindex f2d69814ee..753aff57f6 100644--- a/src/video_core/engines/maxwell_3d.h+++ b/src/video_core/engines/maxwell_3d.h@@ -726,7 +726,12 @@ public:u32 zeta_enable;- INSERT_PADDING_WORDS(0x8);+ union {+ BitField<1, 1, u32> alpha_to_coverage;+ BitField<2, 1, u32> alpha_to_one;+ } multisample_control;++ INSERT_PADDING_WORDS(0x7);struct {u32 tsc_address_high;@@ -1149,6 +1154,7 @@ ASSERT_REG_POSITION(screen_y_control, 0x4EB);ASSERT_REG_POSITION(vb_element_base, 0x50D);ASSERT_REG_POSITION(point_size, 0x546);ASSERT_REG_POSITION(zeta_enable, 0x54E);+ASSERT_REG_POSITION(multisample_control, 0x54F);ASSERT_REG_POSITION(tsc, 0x557);ASSERT_REG_POSITION(tic, 0x55D);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.cppindex 98799056c4..d2e3fde655 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() {ConfigureFramebuffers(state);SyncColorMask();SyncFragmentColorClampState();+ SyncMultiSampleState();SyncDepthTestState();SyncStencilTestState();SyncBlendState();@@ -1033,6 +1034,12 @@ void RasterizerOpenGL::SyncColorMask() {}}+void RasterizerOpenGL::SyncMultiSampleState() {+ const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs;+ state.multisample_control.alpha_to_coverage = regs.multisample_control.alpha_to_coverage != 0;+ state.multisample_control.alpha_to_one = regs.multisample_control.alpha_to_one != 0;+}+void RasterizerOpenGL::SyncFragmentColorClampState() {const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs;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.hindex d3fa0b6fcb..8994e134a6 100644--- a/src/video_core/renderer_opengl/gl_rasterizer.h+++ b/src/video_core/renderer_opengl/gl_rasterizer.h@@ -163,6 +163,9 @@ private:/// Syncs the the color clamp statevoid SyncFragmentColorClampState();+ /// Syncs the alpha coverage and alpha to one+ void SyncMultiSampleState();+/// Syncs the scissor test state to match the guest statevoid SyncScissorTest();diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cppindex 6998dd92b9..f6d80614bb 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() {// These all match default OpenGL valuesgeometry_shaders.enabled = false;framebuffer_srgb.enabled = false;+ multisample_control.alpha_to_coverage = false;+ multisample_control.alpha_to_one = false;cull.enabled = false;cull.mode = GL_BACK;cull.front_face = GL_CCW;@@ -504,6 +506,21 @@ void OpenGLState::Apply() const {fragment_color_clamp.enabled ? GL_TRUE : GL_FALSE);}}+ if (multisample_control.alpha_to_coverage != cur_state.multisample_control.alpha_to_coverage) {+ if (multisample_control.alpha_to_coverage) {+ glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);+ } else {+ glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);+ }+ }+ if (multisample_control.alpha_to_one != cur_state.multisample_control.alpha_to_one) {+ if (multisample_control.alpha_to_one) {+ glEnable(GL_SAMPLE_ALPHA_TO_ONE);+ } else {+ glDisable(GL_SAMPLE_ALPHA_TO_ONE);+ }+ }+ApplyColorMask();ApplyViewport();ApplyStencilTest();diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.hindex 6079f6e0b0..c8d951a7fb 100644--- a/src/video_core/renderer_opengl/gl_state.h+++ b/src/video_core/renderer_opengl/gl_state.h@@ -39,6 +39,11 @@ public:bool enabled; // GL_FRAMEBUFFER_SRGB} framebuffer_srgb;+ struct {+ bool alpha_to_coverage; // GL_ALPHA_TO_COVERAGE+ bool alpha_to_one; // GL_ALPHA_TO_ONE+ } multisample_control;+struct {bool enabled; // GL_CLAMP_FRAGMENT_COLOR_ARB} fragment_color_clamp;