summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_state.cpp7
-rw-r--r--src/video_core/renderer_opengl/gl_state.h2
-rw-r--r--src/video_core/renderer_opengl/pica_to_gl.h20
4 files changed, 31 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index ed2e2f3ae..4222945a4 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -937,6 +937,8 @@ void RasterizerOpenGL::SyncBlendEnabled() {
937 937
938void RasterizerOpenGL::SyncBlendFuncs() { 938void RasterizerOpenGL::SyncBlendFuncs() {
939 const auto& regs = Pica::g_state.regs; 939 const auto& regs = Pica::g_state.regs;
940 state.blend.rgb_equation = PicaToGL::BlendEquation(regs.output_merger.alpha_blending.blend_equation_rgb);
941 state.blend.a_equation = PicaToGL::BlendEquation(regs.output_merger.alpha_blending.blend_equation_a);
940 state.blend.src_rgb_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_source_rgb); 942 state.blend.src_rgb_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_source_rgb);
941 state.blend.dst_rgb_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_dest_rgb); 943 state.blend.dst_rgb_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_dest_rgb);
942 state.blend.src_a_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_source_a); 944 state.blend.src_a_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_source_a);
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp
index 02cd9f417..fa141fc9a 100644
--- a/src/video_core/renderer_opengl/gl_state.cpp
+++ b/src/video_core/renderer_opengl/gl_state.cpp
@@ -36,6 +36,8 @@ OpenGLState::OpenGLState() {
36 stencil.action_stencil_fail = GL_KEEP; 36 stencil.action_stencil_fail = GL_KEEP;
37 37
38 blend.enabled = false; 38 blend.enabled = false;
39 blend.rgb_equation = GL_FUNC_ADD;
40 blend.a_equation = GL_FUNC_ADD;
39 blend.src_rgb_func = GL_ONE; 41 blend.src_rgb_func = GL_ONE;
40 blend.dst_rgb_func = GL_ZERO; 42 blend.dst_rgb_func = GL_ZERO;
41 blend.src_a_func = GL_ONE; 43 blend.src_a_func = GL_ONE;
@@ -165,6 +167,11 @@ void OpenGLState::Apply() const {
165 blend.src_a_func, blend.dst_a_func); 167 blend.src_a_func, blend.dst_a_func);
166 } 168 }
167 169
170 if (blend.rgb_equation != cur_state.blend.rgb_equation ||
171 blend.a_equation != cur_state.blend.a_equation) {
172 glBlendEquationSeparate(blend.rgb_equation, blend.a_equation);
173 }
174
168 if (logic_op != cur_state.logic_op) { 175 if (logic_op != cur_state.logic_op) {
169 glLogicOp(logic_op); 176 glLogicOp(logic_op);
170 } 177 }
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index 24f20e47c..228727054 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -40,6 +40,8 @@ public:
40 40
41 struct { 41 struct {
42 bool enabled; // GL_BLEND 42 bool enabled; // GL_BLEND
43 GLenum rgb_equation; // GL_BLEND_EQUATION_RGB
44 GLenum a_equation; // GL_BLEND_EQUATION_ALPHA
43 GLenum src_rgb_func; // GL_BLEND_SRC_RGB 45 GLenum src_rgb_func; // GL_BLEND_SRC_RGB
44 GLenum dst_rgb_func; // GL_BLEND_DST_RGB 46 GLenum dst_rgb_func; // GL_BLEND_DST_RGB
45 GLenum src_a_func; // GL_BLEND_SRC_ALPHA 47 GLenum src_a_func; // GL_BLEND_SRC_ALPHA
diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h
index 976d1f364..6dc2758c5 100644
--- a/src/video_core/renderer_opengl/pica_to_gl.h
+++ b/src/video_core/renderer_opengl/pica_to_gl.h
@@ -78,6 +78,26 @@ inline GLenum WrapMode(Pica::Regs::TextureConfig::WrapMode mode) {
78 return gl_mode; 78 return gl_mode;
79} 79}
80 80
81inline GLenum BlendEquation(Pica::Regs::BlendEquation equation) {
82 static const GLenum blend_equation_table[] = {
83 GL_FUNC_ADD, // BlendEquation::Add
84 GL_FUNC_SUBTRACT, // BlendEquation::Subtract
85 GL_FUNC_REVERSE_SUBTRACT, // BlendEquation::ReverseSubtract
86 GL_MIN, // BlendEquation::Min
87 GL_MAX, // BlendEquation::Max
88 };
89
90 // Range check table for input
91 if (static_cast<size_t>(equation) >= ARRAY_SIZE(blend_equation_table)) {
92 LOG_CRITICAL(Render_OpenGL, "Unknown blend equation %d", equation);
93 UNREACHABLE();
94
95 return GL_FUNC_ADD;
96 }
97
98 return blend_equation_table[(unsigned)equation];
99}
100
81inline GLenum BlendFunc(Pica::Regs::BlendFactor factor) { 101inline GLenum BlendFunc(Pica::Regs::BlendFactor factor) {
82 static const GLenum blend_func_table[] = { 102 static const GLenum blend_func_table[] = {
83 GL_ZERO, // BlendFactor::Zero 103 GL_ZERO, // BlendFactor::Zero