mesa: display list support for GL_ARB_draw_buffers_blend functions
authorBrian Paul <brianp@vmware.com>
Sun, 16 Jan 2011 01:25:19 +0000 (18:25 -0700)
committerBrian Paul <brianp@vmware.com>
Sun, 16 Jan 2011 01:35:45 +0000 (18:35 -0700)
src/mesa/main/dlist.c

index b28e36ac0963188cb11489614659c3cceccf25cd..cdf349104a4010b93f5d2d0e3c5d61a066899b9b 100644 (file)
@@ -188,6 +188,12 @@ typedef enum
    OPCODE_BLEND_EQUATION,
    OPCODE_BLEND_EQUATION_SEPARATE,
    OPCODE_BLEND_FUNC_SEPARATE,
+
+   OPCODE_BLEND_EQUATION_I,
+   OPCODE_BLEND_EQUATION_SEPARATE_I,
+   OPCODE_BLEND_FUNC_I,
+   OPCODE_BLEND_FUNC_SEPARATE_I,
+
    OPCODE_CALL_LIST,
    OPCODE_CALL_LIST_OFFSET,
    OPCODE_CLEAR,
@@ -1146,6 +1152,82 @@ save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
    }
 }
 
+/* GL_ARB_draw_buffers_blend */
+static void GLAPIENTRY
+save_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
+                        GLenum sfactorA, GLenum dfactorA)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 5);
+   if (n) {
+      n[1].ui = buf;
+      n[2].e = sfactorRGB;
+      n[3].e = dfactorRGB;
+      n[4].e = sfactorA;
+      n[5].e = dfactorA;
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_BlendFuncSeparateiARB(ctx->Exec, (buf, sfactorRGB, dfactorRGB,
+                                             sfactorA, dfactorA));
+   }
+}
+
+/* GL_ARB_draw_buffers_blend */
+static void GLAPIENTRY
+save_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 3);
+   if (n) {
+      n[1].ui = buf;
+      n[2].e = sfactor;
+      n[3].e = dfactor;
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_BlendFunciARB(ctx->Exec, (buf, sfactor, dfactor));
+   }
+}
+
+/* GL_ARB_draw_buffers_blend */
+static void GLAPIENTRY
+save_BlendEquationi(GLuint buf, GLenum mode)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_I, 2);
+   if (n) {
+      n[1].ui = buf;
+      n[2].e = mode;
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_BlendEquationiARB(ctx->Exec, (buf, mode));
+   }
+}
+
+/* GL_ARB_draw_buffers_blend */
+static void GLAPIENTRY
+save_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE_I, 3);
+   if (n) {
+      n[1].ui = buf;
+      n[2].e = modeRGB;
+      n[3].e = modeA;
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_BlendEquationSeparateiARB(ctx->Exec, (buf, modeRGB, modeA));
+   }
+}
+
+
 static void invalidate_saved_current_state( struct gl_context *ctx )
 {
    GLint i;
@@ -7077,6 +7159,26 @@ execute_list(struct gl_context *ctx, GLuint list)
             CALL_BlendFuncSeparateEXT(ctx->Exec,
                                       (n[1].e, n[2].e, n[3].e, n[4].e));
             break;
+
+         case OPCODE_BLEND_FUNC_I:
+            /* GL_ARB_draw_buffers_blend */
+            CALL_BlendFunciARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e));
+            break;
+         case OPCODE_BLEND_FUNC_SEPARATE_I:
+            /* GL_ARB_draw_buffers_blend */
+            CALL_BlendFuncSeparateiARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e,
+                                                   n[4].e, n[5].e));
+            break;
+         case OPCODE_BLEND_EQUATION_I:
+            /* GL_ARB_draw_buffers_blend */
+            CALL_BlendEquationiARB(ctx->Exec, (n[1].ui, n[2].e));
+            break;
+         case OPCODE_BLEND_EQUATION_SEPARATE_I:
+            /* GL_ARB_draw_buffers_blend */
+            CALL_BlendEquationSeparateiARB(ctx->Exec,
+                                           (n[1].ui, n[2].e, n[3].e));
+            break;
+
          case OPCODE_CALL_LIST:
             /* Generated by glCallList(), don't add ListBase */
             if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
@@ -9776,6 +9878,12 @@ _mesa_create_save_table(void)
    /* GL_ARB_instanced_arrays */
    SET_VertexAttribDivisorARB(table, save_VertexAttribDivisor);
 
+   /* GL_ARB_draw_buffer_blend */
+   SET_BlendFunciARB(table, save_BlendFunci);
+   SET_BlendFuncSeparateiARB(table, save_BlendFuncSeparatei);
+   SET_BlendEquationiARB(table, save_BlendEquationi);
+   SET_BlendEquationSeparateiARB(table, save_BlendEquationSeparatei);
+
    return table;
 }