i965: Use enum color_logic_ops for blits
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 3 Jan 2018 20:03:58 +0000 (12:03 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 26 Jan 2018 03:21:46 +0000 (11:21 +0800)
v2: sed --in-place -e 's/color_logic_ops/gl_logicop_mode/g' $(grep -lr
color_logic_ops src/) suggested by Brian.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> [v1]
src/mesa/drivers/dri/i965/intel_blit.c
src/mesa/drivers/dri/i965/intel_blit.h
src/mesa/drivers/dri/i965/intel_fbo.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_pixel_bitmap.c
src/mesa/drivers/dri/i965/intel_pixel_copy.c
src/mesa/drivers/dri/i965/intel_pixel_draw.c
src/mesa/drivers/dri/i965/intel_tex_copy.c

index 46945b299532d5c98ee743522d8b5ec22dddaed8..96e5aba85df6be8f1b2509d555fb42b95a4379dd 100644 (file)
@@ -44,27 +44,9 @@ intel_miptree_set_alpha_to_one(struct brw_context *brw,
                                struct intel_mipmap_tree *mt,
                                int x, int y, int width, int height);
 
-static GLuint translate_raster_op(GLenum logicop)
+static GLuint translate_raster_op(enum gl_logicop_mode 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;
-   }
+   return logicop | (logicop << 4);
 }
 
 static uint32_t
@@ -227,7 +209,7 @@ emit_miptree_blit(struct brw_context *brw,
                   struct intel_mipmap_tree *dst_mt,
                   uint32_t dst_x, uint32_t dst_y,
                   uint32_t width, uint32_t height,
-                  bool reverse, GLenum logicop)
+                  bool reverse, enum gl_logicop_mode logicop)
 {
    /* According to the Ivy Bridge PRM, Vol1 Part4, section 1.2.1.2 (Graphics
     * Data Size Limitations):
@@ -319,7 +301,7 @@ intel_miptree_blit(struct brw_context *brw,
                    int dst_level, int dst_slice,
                    uint32_t dst_x, uint32_t dst_y, bool dst_flip,
                    uint32_t width, uint32_t height,
-                   GLenum logicop)
+                   enum gl_logicop_mode logicop)
 {
    /* The blitter doesn't understand multisampling at all. */
    if (src_mt->surf.samples > 1 || dst_mt->surf.samples > 1)
@@ -463,7 +445,7 @@ intel_miptree_copy(struct brw_context *brw,
 
    return emit_miptree_blit(brw, src_mt, src_x, src_y,
                             dst_mt, dst_x, dst_y,
-                            src_width, src_height, false, GL_COPY);
+                            src_width, src_height, false, COLOR_LOGICOP_COPY);
 }
 
 static bool
@@ -527,7 +509,7 @@ intelEmitCopyBlit(struct brw_context *brw,
                  GLshort src_x, GLshort src_y,
                  GLshort dst_x, GLshort dst_y,
                  GLshort w, GLshort h,
-                 GLenum logic_op)
+                 enum gl_logicop_mode logic_op)
 {
    const struct gen_device_info *devinfo = &brw->screen->devinfo;
    GLuint CMD, BR13;
@@ -654,7 +636,7 @@ intelEmitImmediateColorExpandBlit(struct brw_context *brw,
                                  enum isl_tiling dst_tiling,
                                  GLshort x, GLshort y,
                                  GLshort w, GLshort h,
-                                 GLenum logic_op)
+                                 enum gl_logicop_mode logic_op)
 {
    const struct gen_device_info *devinfo = &brw->screen->devinfo;
    int dwords = ALIGN(src_size, 8) / 4;
@@ -667,7 +649,7 @@ intelEmitImmediateColorExpandBlit(struct brw_context *brw,
         return false;
    }
 
-   assert((logic_op >= GL_CLEAR) && (logic_op <= (GL_CLEAR + 0x0f)));
+   assert((unsigned) logic_op <= 0x0f);
    assert(dst_pitch > 0);
 
    if (w < 0 || h < 0)
@@ -763,7 +745,7 @@ intel_emit_linear_blit(struct brw_context *brw,
                              src_x, 0, /* src x/y */
                              dst_x, 0, /* dst x/y */
                              MIN2(size, pitch), height, /* w, h */
-                             GL_COPY);
+                             COLOR_LOGICOP_COPY);
       if (!ok) {
          _mesa_problem(ctx, "Failed to linear blit %dx%d\n",
                        MIN2(size, pitch), height);
index 0a0c57de9bc94e5a7174c9a4452ee5703a54c42c..ce36b2609b08bbe7e28a75dbd727f76ebf9f5947 100644 (file)
@@ -42,7 +42,7 @@ intelEmitCopyBlit(struct brw_context *brw,
                   GLshort srcx, GLshort srcy,
                   GLshort dstx, GLshort dsty,
                   GLshort w, GLshort h,
-                  GLenum logicop);
+                  enum gl_logicop_mode logicop);
 
 bool intel_miptree_blit_compatible_formats(mesa_format src, mesa_format dst);
 
@@ -54,7 +54,7 @@ bool intel_miptree_blit(struct brw_context *brw,
                         int dst_level, int dst_slice,
                         uint32_t dst_x, uint32_t dst_y, bool dst_flip,
                         uint32_t width, uint32_t height,
-                        GLenum logicop);
+                        enum gl_logicop_mode logicop);
 
 bool intel_miptree_copy(struct brw_context *brw,
                         struct intel_mipmap_tree *src_mt,
@@ -76,7 +76,7 @@ intelEmitImmediateColorExpandBlit(struct brw_context *brw,
                                   enum isl_tiling dst_tiling,
                                  GLshort x, GLshort y,
                                  GLshort w, GLshort h,
-                                 GLenum logic_op);
+                                 enum gl_logicop_mode logic_op);
 void intel_emit_linear_blit(struct brw_context *brw,
                            struct brw_bo *dst_bo,
                            unsigned int dst_offset,
index 056f494e2f9f476df592e27a432fd50bd1bf2353..ca4008f8a03d83f31642ba5bc07b25b80434a75f 100644 (file)
@@ -849,7 +849,8 @@ intel_blit_framebuffer_with_blitter(struct gl_context *ctx,
                                  dst_irb->mt,
                                  dst_irb->mt_level, dst_irb->mt_layer,
                                  dstX0, dstY0, dst_rb->Name == 0,
-                                 dstX1 - dstX0, dstY1 - dstY0, GL_COPY)) {
+                                 dstX1 - dstX0, dstY1 - dstY0,
+                                 COLOR_LOGICOP_COPY)) {
             perf_debug("glBlitFramebuffer(): unknown blit failure.  "
                        "Falling back to software rendering.\n");
             return mask;
index c480eade93bd8f48568c9a30206df4917ec67363..f27d559149dc56e33efad17ead0ce314cbe5c556 100644 (file)
@@ -1584,7 +1584,7 @@ intel_miptree_copy_slice(struct brw_context *brw,
    if (!intel_miptree_blit(brw,
                            src_mt, src_level, src_layer, 0, 0, false,
                            dst_mt, dst_level, dst_layer, 0, 0, false,
-                           width, height, GL_COPY)) {
+                           width, height, COLOR_LOGICOP_COPY)) {
       perf_debug("miptree validate blit for %s failed\n",
                  _mesa_get_format_name(format));
 
index 8d467adc56e98409822f2f4281c4370405f99642..5bc341bfc0a37bf8d8b17347b9ffe70cbcef6f36 100644 (file)
@@ -264,8 +264,8 @@ do_blit_bitmap( struct gl_context *ctx,
         int h = MIN2(DY, height - py);
         int w = MIN2(DX, width - px);
         GLuint sz = ALIGN(ALIGN(w,8) * h, 64)/8;
-        GLenum logic_op = ctx->Color.ColorLogicOpEnabled ?
-           ctx->Color.LogicOp : GL_COPY;
+        const enum gl_logicop_mode logic_op = ctx->Color.ColorLogicOpEnabled ?
+           ctx->Color._LogicOp : COLOR_LOGICOP_COPY;
 
         assert(sz <= sizeof(stipple));
         memset(stipple, 0, sz);
index 3f8df3002f5f82b05b97e00ded25a92216760e37..a23c5b18ac6b6e751805a04f88f7dbfdd6b4394a 100644 (file)
@@ -178,7 +178,7 @@ do_blit_copypixels(struct gl_context * ctx,
                            dstx, dsty, _mesa_is_winsys_fbo(fb),
                            width, height,
                            (ctx->Color.ColorLogicOpEnabled ?
-                            ctx->Color.LogicOp : GL_COPY))) {
+                            ctx->Color._LogicOp : COLOR_LOGICOP_COPY))) {
       DBG("%s: blit failure\n", __func__);
       return false;
    }
index e72c8babc811f215c290aef03d520890c5cfb315..82dca4a2ebc193b93512083edfffe62a1ee5ddb1 100644 (file)
@@ -128,7 +128,7 @@ do_blit_drawpixels(struct gl_context * ctx,
                            0, 0, src_flip,
                            irb->mt, irb->mt_level, irb->mt_layer,
                            x, y, _mesa_is_winsys_fbo(ctx->DrawBuffer),
-                           width, height, GL_COPY)) {
+                           width, height, COLOR_LOGICOP_COPY)) {
       DBG("%s: blit failed\n", __func__);
       intel_miptree_release(&pbo_mt);
       return false;
index 4fe3585296dbb4a23b12b7c35ccaef3ea97181f9..5a0e09f2551ba59bcd56616b6c8445221aaa5cfc 100644 (file)
@@ -88,7 +88,7 @@ intel_copy_texsubimage(struct brw_context *brw,
                              x, y, irb->Base.Base.Name == 0,
                              intelImage->mt, dst_level, dst_slice,
                              dstx, dsty, false,
-                             width, height, GL_COPY);
+                             width, height, COLOR_LOGICOP_COPY);
 }