i915: Use enum color_logic_ops for blits
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 3 Jan 2018 20:33:20 +0000 (12:33 -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/i915/intel_blit.c
src/mesa/drivers/dri/i915/intel_blit.h
src/mesa/drivers/dri/i915/intel_fbo.c
src/mesa/drivers/dri/i915/intel_mipmap_tree.c
src/mesa/drivers/dri/i915/intel_pixel_bitmap.c
src/mesa/drivers/dri/i915/intel_pixel_copy.c
src/mesa/drivers/dri/i915/intel_pixel_read.c
src/mesa/drivers/dri/i915/intel_tex_copy.c
src/mesa/drivers/dri/i915/intel_tex_image.c
src/mesa/drivers/dri/i915/intel_tex_subimage.c

index 279db28b7eba89d8b3697b96ef0781f11a29f457..551f18ffd2ec1ac95cf54bc0406159d1fae201df 100644 (file)
@@ -48,27 +48,9 @@ intel_miptree_set_alpha_to_one(struct intel_context *intel,
                                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
@@ -114,7 +96,7 @@ intel_miptree_blit(struct intel_context *intel,
                    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)
 {
    /* No sRGB decode or encode is done by the hardware blitter, which is
     * consistent with what we want in the callers (glCopyTexSubImage(),
@@ -227,7 +209,7 @@ intelEmitCopyBlit(struct intel_context *intel,
                  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)
 {
    GLuint CMD, BR13, pass = 0;
    int dst_y2 = dst_y + h;
@@ -523,7 +505,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
                                  uint32_t dst_tiling,
                                  GLshort x, GLshort y,
                                  GLshort w, GLshort h,
-                                 GLenum logic_op)
+                                 enum gl_logicop_mode logic_op)
 {
    int dwords = ALIGN(src_size, 8) / 4;
    uint32_t opcode, br13, blit_cmd;
@@ -535,7 +517,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
         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)
@@ -613,7 +595,7 @@ intel_emit_linear_blit(struct intel_context *intel,
                          0, 0, /* src x/y */
                          0, 0, /* dst x/y */
                          pitch, height, /* w, h */
-                         GL_COPY);
+                         COLOR_LOGICOP_COPY);
    if (!ok)
       _mesa_problem(ctx, "Failed to linear blit %dx%d\n", pitch, height);
 
@@ -629,7 +611,7 @@ intel_emit_linear_blit(struct intel_context *intel,
                             0, 0, /* src x/y */
                             0, 0, /* dst x/y */
                             size, 1, /* w, h */
-                            GL_COPY);
+                            COLOR_LOGICOP_COPY);
       if (!ok)
          _mesa_problem(ctx, "Failed to linear blit %dx%d\n", size, 1);
    }
index 1e76126aad930dc609f0822136180f6f146e524e..5c0d3597f1621da0abc7ba04b8a8fb012b2d4be3 100644 (file)
@@ -49,7 +49,7 @@ intelEmitCopyBlit(struct intel_context *intel,
                               GLshort srcx, GLshort srcy,
                               GLshort dstx, GLshort dsty,
                               GLshort w, GLshort h,
-                             GLenum logicop );
+                              enum gl_logicop_mode logicop);
 
 bool intel_miptree_blit(struct intel_context *intel,
                         struct intel_mipmap_tree *src_mt,
@@ -59,7 +59,7 @@ bool intel_miptree_blit(struct intel_context *intel,
                         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
 intelEmitImmediateColorExpandBlit(struct intel_context *intel,
@@ -72,7 +72,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
                                  uint32_t 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 intel_context *intel,
                            drm_intel_bo *dst_bo,
                            unsigned int dst_offset,
index 8750c601b849de69102e18dd7677f92bb96fef3f..0fb2fcdda0c6db285a7a8273410bfdfcdd4ac3f6 100644 (file)
@@ -714,7 +714,7 @@ 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 b0ebff593a2ae8767d2ba1179d16b6cf590fabfd..9a9f08b0a4aced74479caa4c44f952d8ed477901 100644 (file)
@@ -620,7 +620,7 @@ intel_miptree_copy_slice(struct intel_context *intel,
    if (!intel_miptree_blit(intel,
                            src_mt, level, slice, 0, 0, false,
                            dst_mt, level, slice, 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));
 
@@ -757,7 +757,7 @@ intel_miptree_map_blit(struct intel_context *intel,
                            map->x, map->y, false,
                            map->mt, 0, 0,
                            0, 0, false,
-                           map->w, map->h, GL_COPY)) {
+                           map->w, map->h, COLOR_LOGICOP_COPY)) {
       fprintf(stderr, "Failed to blit\n");
       goto fail;
    }
@@ -795,7 +795,7 @@ intel_miptree_unmap_blit(struct intel_context *intel,
                                    0, 0, false,
                                    mt, level, slice,
                                    map->x, map->y, false,
-                                   map->w, map->h, GL_COPY);
+                                   map->w, map->h, COLOR_LOGICOP_COPY);
       WARN_ONCE(!ok, "Failed to blit from linear temporary mapping");
    }
 
index a41b6929c62ca7531a3ac40f77fd6f0b85398f3a..8dee0bea9f2115e3c37a19b566ce594368ac12b0 100644 (file)
@@ -262,8 +262,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 b4f94666035c245ca8a4da2f5cc169b8454727c5..0dea8f9c796668c7ab29a0c3a1431028617ad178 100644 (file)
@@ -176,7 +176,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 e6fa8f2dce8e7ad95c5ae908340a3d99ffce9666..3560963c8b801013102885cfef70614b449422c2 100644 (file)
@@ -141,7 +141,7 @@ do_blit_readpixels(struct gl_context * ctx,
                            x, y, _mesa_is_winsys_fbo(ctx->ReadBuffer),
                            pbo_mt, 0, 0,
                            0, 0, dst_flip,
-                           width, height, GL_COPY)) {
+                           width, height, COLOR_LOGICOP_COPY)) {
       intel_miptree_release(&pbo_mt);
       return false;
    }
index a5d00af3b9d0bdc1bc611cded44e2625adc31226..4b087b6162979724ecd6f98abebb9064b569195b 100644 (file)
@@ -70,7 +70,7 @@ intel_copy_texsubimage(struct intel_context *intel,
                            intelImage->mt, intelImage->base.Base.Level,
                            intelImage->base.Base.Face + slice,
                            dstx, dsty, false,
-                           width, height, GL_COPY)) {
+                           width, height, COLOR_LOGICOP_COPY)) {
       return false;
    }
 
index 3308e3775667a28201fa7ef146ed17ff232a1f38..a06b14234523aee0db0b63087f2610d9700757d9 100644 (file)
@@ -163,7 +163,7 @@ try_pbo_upload(struct gl_context *ctx,
                            0, 0, false,
                            intelImage->mt, image->Level, image->Face,
                            0, 0, false,
-                           image->Width, image->Height, GL_COPY)) {
+                           image->Width, image->Height, COLOR_LOGICOP_COPY)) {
       DBG("%s: blit failed\n", __func__);
       intel_miptree_release(&pbo_mt);
       return false;
index 4083d696b82fb0acdd865aee1ef7c25065eb4d46..b372e114fa2097c1f174a04029cebc9b780855ed 100644 (file)
@@ -111,7 +111,7 @@ intel_blit_texsubimage(struct gl_context * ctx,
                             0, 0, false,
                             intelImage->mt, texImage->Level, texImage->Face,
                             xoffset, yoffset, false,
-                            width, height, GL_COPY);
+                            width, height, COLOR_LOGICOP_COPY);
    assert(ret);
 
    intel_miptree_release(&temp_mt);