Gary Wong's patches for CopyPixels Logiop (enable) and Blend
authorKeith Whitwell <keith@tungstengraphics.com>
Tue, 21 Nov 2006 10:43:16 +0000 (10:43 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 21 Nov 2006 10:43:16 +0000 (10:43 +0000)
(disallow).  Slightly cleaned to disallow on all blend states for code
consiseness and turn a table lookup into a function to match other
code in the driver.

src/mesa/drivers/dri/i965/intel_blit.c
src/mesa/drivers/dri/i965/intel_blit.h
src/mesa/drivers/dri/i965/intel_pixel_copy.c
src/mesa/drivers/dri/i965/intel_regions.c

index 0974f1f80ad462b062e50409e0e98e2599e64cd4..c8c5bf93c95ee84e81168cbfd01f93264d6c3fd4 100644 (file)
@@ -221,6 +221,29 @@ void intelEmitFillBlit( struct intel_context *intel,
    ADVANCE_BATCH();
 }
 
+static GLuint translate_raster_op(GLenum logicop)
+{
+   switch(logicop) {
+   case GL_CLEAR: return 0x00;
+   case GL_AND: return 0x88;
+   case GL_AND_REVERSE: return 0x44;
+   case GL_COPY: return 0xCC;
+   case GL_AND_INVERTED: return 0x22;
+   case GL_NOOP: return 0xAA;
+   case GL_XOR: return 0x66;
+   case GL_OR: return 0xEE;
+   case GL_NOR: return 0x11;
+   case GL_EQUIV: return 0x99;
+   case GL_INVERT: return 0x55;
+   case GL_OR_REVERSE: return 0xDD;
+   case GL_COPY_INVERTED: return 0x33;
+   case GL_OR_INVERTED: return 0xBB;
+   case GL_NAND: return 0x77;
+   case GL_SET: return 0xFF;
+   default: return 0;
+   }
+}
+
 
 /* Copy BitBlt
  */
@@ -236,7 +259,8 @@ void intelEmitCopyBlit( struct intel_context *intel,
                        GLboolean dst_tiled,
                        GLshort src_x, GLshort src_y,
                        GLshort dst_x, GLshort dst_y,
-                       GLshort w, GLshort h )
+                       GLshort w, GLshort h,
+                       GLenum logic_op )
 {
    GLuint CMD, BR13;
    int dst_y2 = dst_y + h;
@@ -244,12 +268,15 @@ void intelEmitCopyBlit( struct intel_context *intel,
    BATCH_LOCALS;
 
 
-   DBG("%s src:buf(%d)/%d %d,%d dst:buf(%d)/%d %d,%d sz:%dx%d\n",
+   DBG("%s src:buf(%d)/%d %d,%d dst:buf(%d)/%d %d,%d sz:%dx%d op:%d\n",
        __FUNCTION__,
        src_buffer, src_pitch, src_x, src_y,
        dst_buffer, dst_pitch, dst_x, dst_y,
-       w,h);
+       w,h,logic_op);
 
+   assert( logic_op - GL_CLEAR >= 0 );
+   assert( logic_op - GL_CLEAR < 0x10 );
+      
    src_pitch *= cpp;
    dst_pitch *= cpp;
 
@@ -257,11 +284,12 @@ void intelEmitCopyBlit( struct intel_context *intel,
    case 1: 
    case 2: 
    case 3: 
-      BR13 = (0xCC << 16) | (1<<24);
+      BR13 = (translate_raster_op(logic_op) << 16) | (1<<24);
       CMD = XY_SRC_COPY_BLT_CMD;
       break;
    case 4:
-      BR13 = (0xCC << 16) | (1<<24) | (1<<25);
+      BR13 = (translate_raster_op(logic_op) << 16) | (1<<24) |
+         (1<<25);
       CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
             XY_SRC_COPY_BLT_WRITE_RGB);
       break;
index b15fb1c2b7f59bbb34d0d679a95850dde1401475..8b0cc65243cc617fba93e269387a8e4625acdfe9 100644 (file)
@@ -49,7 +49,8 @@ extern void intelEmitCopyBlit( struct intel_context *intel,
                               GLboolean dst_tiled,
                               GLshort srcx, GLshort srcy,
                               GLshort dstx, GLshort dsty,
-                              GLshort w, GLshort h );
+                              GLshort w, GLshort h,
+                              GLenum logic_op );
 
 extern void intelEmitFillBlit( struct intel_context *intel,
                               GLuint cpp,
index d5d48994529cb0cc9aee822c21b94170d747b81d..55b58a8f6702b1dc02b74e5e584684415718e7a5 100644 (file)
@@ -92,9 +92,9 @@ intel_check_blit_fragment_ops(GLcontext * ctx)
             !ctx->Color.ColorMask[1] ||
             !ctx->Color.ColorMask[2] ||
             !ctx->Color.ColorMask[3] ||        /* can do this! */
-            ctx->Color.ColorLogicOpEnabled || /* can do this! */
             ctx->Texture._EnabledUnits ||
-           ctx->FragmentProgram._Enabled);
+           ctx->FragmentProgram._Enabled ||
+           ctx->Color.BlendEnabled);
 }
 
 
@@ -210,7 +210,9 @@ do_blit_copypixels(GLcontext * ctx,
                           rect.x1 + delta_x, 
                           rect.y1 + delta_y,       /* srcx, srcy */
                            rect.x1, rect.y1,    /* dstx, dsty */
-                           rect.x2 - rect.x1, rect.y2 - rect.y1);
+                           rect.x2 - rect.x1, rect.y2 - rect.y1,
+                          ctx->Color.ColorLogicOpEnabled ?
+                          ctx->Color.LogicOp : GL_COPY);
       }
 
       intel->need_flush = GL_TRUE;
index 53f056123778a020808a1da1ca8ce2bd318964f0..398b0a0a3b5192be45e36c6d464028d3a0a94ef2 100644 (file)
@@ -269,7 +269,8 @@ void intel_region_copy( struct intel_context *intel,
                     dst->pitch, dst->buffer, dst_offset, dst->tiled,
                     srcx, srcy,
                     dstx, dsty,
-                    width, height);
+                    width, height,
+                    GL_COPY );
 }
 
 /* Fill a rectangular sub-region.  Need better logic about when to