Просмотр исходного кода

GLState: Allow enabling/disabling GL_COLOR_LOGIC_OP independently from blending.

Subv 8 лет назад
Родитель
Сommit
f24ab6d9e6
2 измененных файлов с 19 добавлено и 6 удалено
  1. 15 5
      src/video_core/renderer_opengl/gl_state.cpp
  2. 4 1
      src/video_core/renderer_opengl/gl_state.h

+ 15 - 5
src/video_core/renderer_opengl/gl_state.cpp

@@ -45,7 +45,8 @@ OpenGLState::OpenGLState() {
     blend.color.blue = 0.0f;
     blend.color.blue = 0.0f;
     blend.color.alpha = 0.0f;
     blend.color.alpha = 0.0f;
 
 
-    logic_op = GL_COPY;
+    logic_op.enabled = false;
+    logic_op.operation = GL_COPY;
 
 
     for (auto& texture_unit : texture_units) {
     for (auto& texture_unit : texture_units) {
         texture_unit.Reset();
         texture_unit.Reset();
@@ -148,11 +149,10 @@ void OpenGLState::Apply() const {
     // Blending
     // Blending
     if (blend.enabled != cur_state.blend.enabled) {
     if (blend.enabled != cur_state.blend.enabled) {
         if (blend.enabled) {
         if (blend.enabled) {
+            ASSERT(!logic_op.enabled);
             glEnable(GL_BLEND);
             glEnable(GL_BLEND);
-            glDisable(GL_COLOR_LOGIC_OP);
         } else {
         } else {
             glDisable(GL_BLEND);
             glDisable(GL_BLEND);
-            glEnable(GL_COLOR_LOGIC_OP);
         }
         }
     }
     }
 
 
@@ -176,8 +176,18 @@ void OpenGLState::Apply() const {
         glBlendEquationSeparate(blend.rgb_equation, blend.a_equation);
         glBlendEquationSeparate(blend.rgb_equation, blend.a_equation);
     }
     }
 
 
-    if (logic_op != cur_state.logic_op) {
-        glLogicOp(logic_op);
+    // Logic Operation
+    if (logic_op.enabled != cur_state.logic_op.enabled) {
+        if (logic_op.enabled) {
+            ASSERT(!blend.enabled);
+            glEnable(GL_COLOR_LOGIC_OP);
+        } else {
+            glDisable(GL_COLOR_LOGIC_OP);
+        }
+    }
+
+    if (logic_op.operation != cur_state.logic_op.operation) {
+        glLogicOp(logic_op.operation);
     }
     }
 
 
     // Textures
     // Textures

+ 4 - 1
src/video_core/renderer_opengl/gl_state.h

@@ -83,7 +83,10 @@ public:
         } color; // GL_BLEND_COLOR
         } color; // GL_BLEND_COLOR
     } blend;
     } blend;
 
 
-    GLenum logic_op; // GL_LOGIC_OP_MODE
+    struct {
+        bool enabled; // GL_LOGIC_OP_MODE
+        GLenum operation;
+    } logic_op;
 
 
     // 3 texture units - one for each that is used in PICA fragment shader emulation
     // 3 texture units - one for each that is used in PICA fragment shader emulation
     struct TextureUnit {
     struct TextureUnit {