Ian Romanick wrote:
Roland Scheidegger wrote:

Here's a small patch which makes color / blend logic ops work with r200/radeon (untested on radeon). It's actually a copy&paste job from the mesa sources, mesa has the comment
/* This is needed to support 1.1's RGB logic ops AND
* 1.0's blending logicops.
*/
wherever it tries to figure out if logic ops are actually enabled. Looks like a trap in the OGL specification ;-), maybe other drivers might be affected?


Patch fixes samples/blendeq and samples/blendxor (on my rv250), I hope it doesn't break anything.


Good catch.

[snip]

- if ( ctx->Color.ColorLogicOpEnabled ) {
+ if ( ctx->Color.ColorLogicOpEnabled || (ctx->Color.BlendEnabled && mode == GL_LOGIC_OP)) {


There's derrived state that Mesa calculates just for this case. The test should be 'if ( ctx->Color._LogicOpEnabled )'.

Yes, saw that derived state. For some reason I can't figure out now, I thought it might not be a good idea to use Mesa derived state directly. Ah well, this patch corrects this (even simpler, and should also save 1 or 2 clock cycles ;-)).


Roland
Index: r200_state.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_state.c,v
retrieving revision 1.11
diff -u -r1.11 r200_state.c
--- r200_state.c        23 Jan 2004 03:33:04 -0000      1.11
+++ r200_state.c        23 Jan 2004 14:31:07 -0000
@@ -137,7 +137,7 @@
 
    R200_STATECHANGE( rmesa, ctx );
    rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = b;
-   if ( ctx->Color.ColorLogicOpEnabled ) {
+   if ( ctx->Color._LogicOpEnabled ) {
       rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  R200_ROP_ENABLE;
    } else {
       rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_ROP_ENABLE;
@@ -1706,7 +1706,7 @@
       } else {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_ALPHA_BLEND_ENABLE;
       }
-      if ( ctx->Color.ColorLogicOpEnabled ) {
+      if ( ctx->Color._LogicOpEnabled ) {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  R200_ROP_ENABLE;
       } else {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_ROP_ENABLE;
@@ -1829,7 +1829,7 @@
 
    case GL_COLOR_LOGIC_OP:
       R200_STATECHANGE( rmesa, ctx );
-      if ( state ) {
+      if ( ctx->Color._LogicOpEnabled ) {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  R200_ROP_ENABLE;
       } else {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_ROP_ENABLE;
Index: radeon_state.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/radeon/radeon_state.c,v
retrieving revision 1.9
diff -u -r1.9 radeon_state.c
--- radeon_state.c      23 Jan 2004 03:33:04 -0000      1.9
+++ radeon_state.c      23 Jan 2004 14:29:57 -0000
@@ -130,7 +130,7 @@
    if ( !fallback ) {
       RADEON_STATECHANGE( rmesa, ctx );
       rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = b;
-      if ( ctx->Color.ColorLogicOpEnabled ) {
+      if ( ctx->Color._LogicOpEnabled ) {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  RADEON_ROP_ENABLE;
       } else {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
@@ -1684,7 +1684,7 @@
       } else {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ALPHA_BLEND_ENABLE;
       }
-      if ( ctx->Color.ColorLogicOpEnabled ) {
+      if ( ctx->Color._LogicOpEnabled ) {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  RADEON_ROP_ENABLE;
       } else {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
@@ -1822,7 +1822,7 @@
 
    case GL_COLOR_LOGIC_OP:
       RADEON_STATECHANGE( rmesa, ctx );
-      if ( state ) {
+      if ( ctx->Color._LogicOpEnabled ) {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  RADEON_ROP_ENABLE;
       } else {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;

Reply via email to