blend, logicop changes for intelEmitCopyBlit backported to i915
authorKeith Whitwell <keith@tungstengraphics.com>
Tue, 21 Nov 2006 14:43:30 +0000 (14:43 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 21 Nov 2006 14:43:30 +0000 (14:43 +0000)
src/mesa/drivers/dri/i915tex/intel_blit.c
src/mesa/drivers/dri/i915tex/intel_blit.h
src/mesa/drivers/dri/i915tex/intel_pixel.c
src/mesa/drivers/dri/i915tex/intel_pixel_copy.c
src/mesa/drivers/dri/i915tex/intel_pixel_draw.c
src/mesa/drivers/dri/i915tex/intel_pixel_read.c
src/mesa/drivers/dri/i915tex/intel_regions.c
src/mesa/drivers/dri/i915tex/intel_tex_copy.c
src/mesa/drivers/dri/i915tex/intel_tex_image.c

index b6b65439087b8c9dab3d4df763f1a2886ce883a8..550669ab0c80ab521afcbede3988478e8826c377 100644 (file)
@@ -277,6 +277,30 @@ intelEmitFillBlit(struct intel_context *intel,
 }
 
 
+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
  */
 void
@@ -289,7 +313,9 @@ intelEmitCopyBlit(struct intel_context *intel,
                   struct _DriBufferObject *dst_buffer,
                   GLuint dst_offset,
                   GLshort src_x, GLshort src_y,
-                  GLshort dst_x, GLshort dst_y, GLshort w, GLshort h)
+                  GLshort dst_x, GLshort dst_y, 
+                 GLshort w, GLshort h,
+                 GLenum logic_op)
 {
    GLuint CMD, BR13;
    int dst_y2 = dst_y + h;
@@ -309,13 +335,14 @@ intelEmitCopyBlit(struct intel_context *intel,
    case 1:
    case 2:
    case 3:
-      BR13 = (((GLint) dst_pitch) & 0xffff) | (0xCC << 16) | (1 << 24);
+      BR13 = (((GLint) dst_pitch) & 0xffff) | 
+        (translate_raster_op(logic_op) << 16) | (1 << 24);
       CMD = XY_SRC_COPY_BLT_CMD;
       break;
    case 4:
       BR13 =
-         (((GLint) dst_pitch) & 0xffff) | (0xCC << 16) | (1 << 24) | (1 <<
-                                                                      25);
+         (((GLint) dst_pitch) & 0xffff) | 
+        (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);
index ee85c626334dac53e43eaa179d3eb454ce17fb99..e7bc280f58ad3a1c5be27e7205a169ebe05cf2b5 100644 (file)
@@ -47,7 +47,8 @@ extern void intelEmitCopyBlit(struct intel_context *intel,
                               GLuint dst_offset,
                               GLshort srcx, GLshort srcy,
                               GLshort dstx, GLshort dsty,
-                              GLshort w, GLshort h);
+                              GLshort w, GLshort h,
+                             GLenum logicop );
 
 extern void intelEmitFillBlit(struct intel_context *intel,
                               GLuint cpp,
index 4fe128deea1f989e4f8fe03f765e67ded939b1c8..9018e3daef497714487c1136732cdb477e8c98ec 100644 (file)
@@ -56,8 +56,9 @@ intel_check_blit_fragment_ops(GLcontext * ctx)
             !ctx->Color.ColorMask[1] ||
             !ctx->Color.ColorMask[2] ||
             !ctx->Color.ColorMask[3] ||
-            ctx->Color.ColorLogicOpEnabled ||
-            ctx->Texture._EnabledUnits || ctx->FragmentProgram._Enabled);
+            ctx->Texture._EnabledUnits || 
+           ctx->FragmentProgram._Enabled ||
+           ctx->Color.BlendEnabled);
 }
 
 
index 5eb021f008bda664583f1f894f518ae2122f9467..9d478283e47bd4c60771ce3fd399cb2e8aa9e0fc 100644 (file)
@@ -95,9 +95,9 @@ intel_check_copypixel_blit_fragment_ops(GLcontext * ctx)
             !ctx->Color.ColorMask[1] ||
             !ctx->Color.ColorMask[2] ||
             !ctx->Color.ColorMask[3] ||
-            ctx->Color.ColorLogicOpEnabled ||
             ctx->Texture._EnabledUnits ||
-           ctx->FragmentProgram._Enabled);
+           ctx->FragmentProgram._Enabled ||
+           ctx->Color.BlendEnabled);
 }
 
 /* Doesn't work for overlapping regions.  Could do a double copy or
@@ -344,9 +344,12 @@ do_blit_copypixels(GLcontext * ctx,
          intelEmitCopyBlit(intel, dst->cpp, 
                           src->pitch, src->buffer, 0, 
                           dst->pitch, dst->buffer, 0, 
-                          rect.x1 + delta_x, rect.y1 + delta_y,       /* srcx, srcy */
+                          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);
       }
 
     out:
index 616101aef992e1b5c1dd8bb8360766902809a743..10a079896aef17facb1a561a3c37e0375f084274 100644 (file)
@@ -252,9 +252,9 @@ do_blit_drawpixels(GLcontext * ctx,
       return GL_FALSE;
    }
 
-   if (!intel_check_meta_tex_fragment_ops(ctx)) {
+   if (!intel_check_blit_fragment_ops(ctx)) {
       if (INTEL_DEBUG & DEBUG_PIXEL)
-         _mesa_printf("%s - bad GL fragment state for meta tex\n",
+         _mesa_printf("%s - bad GL fragment state for blitter\n",
                       __FUNCTION__);
       return GL_FALSE;
    }
@@ -320,17 +320,19 @@ do_blit_drawpixels(GLcontext * ctx,
                            rect.x1 - dest_rect.x1,
                            rect.y2 - dest_rect.y2,
                            rect.x1,
-                           rect.y1, rect.x2 - rect.x1, rect.y2 - rect.y1);
+                           rect.y1, rect.x2 - rect.x1, rect.y2 - rect.y1,
+                          ctx->Color.ColorLogicOpEnabled ?
+                          ctx->Color.LogicOp : GL_COPY);
       }
       fence = intel_batchbuffer_flush(intel->batch);
       driFenceReference(fence);
    }
    UNLOCK_HARDWARE(intel);
 
-   if (intel->driDrawable->numClipRects)
+   if (fence) {
       driFenceFinish(fence, DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW, GL_FALSE);
-
-   driFenceUnReference(fence);
+      driFenceUnReference(fence);
+   }
 
    if (INTEL_DEBUG & DEBUG_PIXEL)
       _mesa_printf("%s - DONE\n", __FUNCTION__);
index c1cc65674d18051ee5670273a7bdd32cb9c6adc8..24e49ae0663677d65759816e1352540d0d2ba1b7 100644 (file)
@@ -271,7 +271,8 @@ do_blit_readpixels(GLcontext * ctx,
                            rect.y1,
                            rect.x1 - src_rect.x1,
                            rect.y2 - src_rect.y2,
-                           rect.x2 - rect.x1, rect.y2 - rect.y1);
+                           rect.x2 - rect.x1, rect.y2 - rect.y1,
+                          GL_COPY);
       }
 
       fence = intel_batchbuffer_flush(intel->batch);
@@ -280,11 +281,12 @@ do_blit_readpixels(GLcontext * ctx,
    }
    UNLOCK_HARDWARE(intel);
 
-   if (intel->driDrawable->numClipRects)
+   if (fence) {
       driFenceFinish(fence, DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW, 
                     GL_FALSE);
+      driFenceUnReference(fence);
+   }
 
-   driFenceUnReference(fence);
    if (INTEL_DEBUG & DEBUG_PIXEL)
       _mesa_printf("%s - DONE\n", __FUNCTION__);
 
index 064a34cda814cdcb3ab774045a8d8823cf7cb2f9..1205b180ca684bcc09d0488a317a00136dcaed99 100644 (file)
@@ -318,7 +318,8 @@ intel_region_copy(intelScreenPrivate *intelScreen,
                      dst->cpp,
                      src->pitch, src->buffer, src_offset,
                      dst->pitch, dst->buffer, dst_offset,
-                     srcx, srcy, dstx, dsty, width, height);
+                     srcx, srcy, dstx, dsty, width, height,
+                    GL_COPY);
 }
 
 /* Fill a rectangular sub-region.  Need better logic about when to
@@ -433,7 +434,9 @@ intel_region_cow(intelScreenPrivate *intelScreen, struct intel_region *region)
                        region->buffer, 0,
                        region->pitch,
                        pbo->buffer, 0,
-                       0, 0, 0, 0, region->pitch, region->height);
+                       0, 0, 0, 0, 
+                       region->pitch, region->height,
+                       GL_COPY);
       
       intel_batchbuffer_flush(intel->batch);
       UNLOCK_HARDWARE(intel);
@@ -445,7 +448,9 @@ intel_region_cow(intelScreenPrivate *intelScreen, struct intel_region *region)
                        region->buffer, 0,
                        region->pitch,
                        pbo->buffer, 0,
-                       0, 0, 0, 0, region->pitch, region->height);
+                       0, 0, 0, 0, 
+                       region->pitch, region->height,
+                       GL_COPY);
       
       intel_batchbuffer_flush(intel->batch);
    }
index 88b62e781c03a91781ceb5214331dc7a19c95936..b85a25642a29fea269f4569c6e48ce581ac1ec75 100644 (file)
@@ -145,7 +145,8 @@ do_copy_texsubimage(struct intel_context *intel,
                            intelImage->mt->pitch,
                            intelImage->mt->region->buffer,
                            image_offset,
-                           x, y + height, dstx, dsty, width, height);
+                           x, y + height, dstx, dsty, width, height,
+                          GL_COPY); /* ? */
 
          intel_batchbuffer_flush(intel->batch);
       }
index 79f377a4b72d1f1698c9831eeef9c36d5233069d..22221e7322ce71a58d88fb252319f73ed5576016 100644 (file)
@@ -232,7 +232,8 @@ try_pbo_upload(struct intel_context *intel,
                         intelImage->mt->cpp,
                         src_stride, src_buffer, src_offset,
                         dst_stride, dst_buffer, dst_offset,
-                        0, 0, 0, 0, width, height);
+                        0, 0, 0, 0, width, height,
+                       GL_COPY);
 
       intel_batchbuffer_flush(intel->batch);
    }