[Mesa-dev] [PATCH] i965: Drop support for the GL_MESA_ycbcr_texture extension.

Kenneth Graunke kenneth at whitecape.org
Tue Dec 6 13:13:59 PST 2011


We forgot to implement the color conversions in the new fragment shader
backend, so YCBCR + GLSL has been broken since Mesa 7.10.  Additionally,
with the fixed function fragment shader rework, YCBCR + FF is broken in
master.  The only combination that should still work is YCBCR + ARB_fp.

Presumably all consumers of this extension already have some kind of
fallback, as the AMD and nVidia binary drivers likely don't support this
extension.

At some point, we may wish to implement the GL_APPLE_rgb_422 extension
so we can still offer subsampling without having to do the color space
conversion in the driver.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_wm.c               |    6 -
 src/mesa/drivers/dri/i965/brw_wm.h               |    2 -
 src/mesa/drivers/dri/i965/brw_wm_fp.c            |  111 ++-------------------
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |    2 -
 src/mesa/drivers/dri/intel/intel_extensions.c    |    3 +-
 5 files changed, 13 insertions(+), 111 deletions(-)

Alternatively, we could just fix it...but I'm not a huge fan of the
complexity for a Mesa specific extension that nobody else supports.

To fix it, we would have to implement it in both the FS and VS backends.

diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 207ffd6..7394475 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -457,12 +457,6 @@ static void brw_wm_populate_key( struct brw_context *brw,
 	    }
 	 }
 
-	 if (img->InternalFormat == GL_YCBCR_MESA) {
-	    key->yuvtex_mask |= 1 << i;
-	    if (img->TexFormat == MESA_FORMAT_YCBCR)
-		key->yuvtex_swap_mask |= 1 << i;
-	 }
-
 	 key->tex_swizzles[i] =
 	    MAKE_SWIZZLE4(swizzles[GET_SWZ(t->_Swizzle, 0)],
 			  swizzles[GET_SWZ(t->_Swizzle, 1)],
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h
index 5967592..666b6a6 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -81,8 +81,6 @@ struct brw_wm_prog_key {
    uint16_t compare_funcs[BRW_MAX_TEX_UNIT];
 
    GLbitfield proj_attrib_mask; /**< one bit per fragment program attribute */
-   GLuint yuvtex_mask:16;
-   GLuint yuvtex_swap_mask:16;	/* UV swaped */
    uint16_t gl_clamp_mask[3];
 
    GLushort tex_swizzles[BRW_MAX_TEX_UNIT];
diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c
index 4d8ac84..425695e 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_fp.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c
@@ -766,106 +766,17 @@ static void precalc_tex( struct brw_wm_compile *c,
       coord = inst->SrcReg[0];
    }
 
-   /* Need to emit YUV texture conversions by hand.  Probably need to
-    * do this here - the alternative is in brw_wm_emit.c, but the
-    * conversion requires allocating a temporary variable which we
-    * don't have the facility to do that late in the compilation.
-    */
-   if (c->key.yuvtex_mask & (1 << unit)) {
-      /* convert ycbcr to RGBA */
-      bool  swap_uv = c->key.yuvtex_swap_mask & (1<<unit);
-
-      /* 
-	 CONST C0 = { -.5, -.0625,  -.5, 1.164 }
-	 CONST C1 = { 1.596, -0.813, 2.018, -.391 }
-	 UYV     = TEX ...
-	 UYV.xyz = ADD UYV,     C0
-	 UYV.y   = MUL UYV.y,   C0.w
- 	 if (UV swaped)
-	    RGB.xyz = MAD UYV.zzx, C1,   UYV.y
-	 else
-	    RGB.xyz = MAD UYV.xxz, C1,   UYV.y 
-	 RGB.y   = MAD UYV.z,   C1.w, RGB.y
-      */
-      struct prog_dst_register tmp = get_temp(c);
-      struct prog_src_register tmpsrc = src_reg_from_dst(tmp);
-      struct prog_src_register C0 = search_or_add_const4f( c,  -.5, -.0625, -.5, 1.164 );
-      struct prog_src_register C1 = search_or_add_const4f( c, 1.596, -0.813, 2.018, -.391 );
-     
-      /* tmp     = TEX ...
-       */
-      emit_tex_op(c, 
-                  OPCODE_TEX,
-                  tmp,
-                  inst->SaturateMode,
-                  unit,
-                  inst->TexSrcTarget,
-                  inst->TexShadow,
-                  coord,
-                  src_undef(),
-                  src_undef());
-
-      /* tmp.xyz =  ADD TMP, C0
-       */
-      emit_op(c,
-	      OPCODE_ADD,
-	      dst_mask(tmp, WRITEMASK_XYZ),
-	      0,
-	      tmpsrc,
-	      C0,
-	      src_undef());
-
-      /* YUV.y   = MUL YUV.y, C0.w
-       */
-
-      emit_op(c,
-	      OPCODE_MUL,
-	      dst_mask(tmp, WRITEMASK_Y),
-	      0,
-	      tmpsrc,
-	      src_swizzle1(C0, W),
-	      src_undef());
-
-      /* 
-       * if (UV swaped)
-       *     RGB.xyz = MAD YUV.zzx, C1, YUV.y
-       * else
-       *     RGB.xyz = MAD YUV.xxz, C1, YUV.y
-       */
-
-      emit_op(c,
-	      OPCODE_MAD,
-	      dst_mask(unswizzled_tmp, WRITEMASK_XYZ),
-	      0,
-	      swap_uv?src_swizzle(tmpsrc, Z,Z,X,X):src_swizzle(tmpsrc, X,X,Z,Z),
-	      C1,
-	      src_swizzle1(tmpsrc, Y));
-
-      /*  RGB.y   = MAD YUV.z, C1.w, RGB.y
-       */
-      emit_op(c,
-	      OPCODE_MAD,
-	      dst_mask(unswizzled_tmp, WRITEMASK_Y),
-	      0,
-	      src_swizzle1(tmpsrc, Z),
-	      src_swizzle1(C1, W),
-	      src_swizzle1(src_reg_from_dst(unswizzled_tmp), Y));
-
-      release_temp(c, tmp);
-   }
-   else {
-      /* ordinary RGBA tex instruction */
-      emit_tex_op(c, 
-                  OPCODE_TEX,
-                  unswizzled_tmp,
-                  inst->SaturateMode,
-                  unit,
-                  inst->TexSrcTarget,
-                  inst->TexShadow,
-                  coord,
-                  src_undef(),
-                  src_undef());
-   }
+   /* ordinary RGBA tex instruction */
+   emit_tex_op(c,
+	       OPCODE_TEX,
+	       unswizzled_tmp,
+	       inst->SaturateMode,
+	       unit,
+	       inst->TexSrcTarget,
+	       inst->TexShadow,
+	       coord,
+	       src_undef(),
+	       src_undef());
 
    /* For GL_EXT_texture_swizzle: */
    if (c->key.tex_swizzles[unit] != SWIZZLE_NOOP) {
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index f9b0b71..ded22a4 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -312,8 +312,6 @@ brw_format_for_mesa_format(gl_format mesa_format)
       [MESA_FORMAT_L16] = BRW_SURFACEFORMAT_L16_UNORM,
       [MESA_FORMAT_I8] = BRW_SURFACEFORMAT_I8_UNORM,
       [MESA_FORMAT_I16] = BRW_SURFACEFORMAT_I16_UNORM,
-      [MESA_FORMAT_YCBCR_REV] = BRW_SURFACEFORMAT_YCRCB_NORMAL,
-      [MESA_FORMAT_YCBCR] = BRW_SURFACEFORMAT_YCRCB_SWAPUVY,
       [MESA_FORMAT_R8] = BRW_SURFACEFORMAT_R8_UNORM,
       [MESA_FORMAT_GR88] = BRW_SURFACEFORMAT_R8G8_UNORM,
       [MESA_FORMAT_RG88] = 0,
diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c
index 681f5f2..058a8e6 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -88,7 +88,8 @@ intelInitExtensions(struct gl_context *ctx)
    ctx->Extensions.APPLE_object_purgeable = true;
    ctx->Extensions.APPLE_vertex_array_object = true;
    ctx->Extensions.MESA_pack_invert = true;
-   ctx->Extensions.MESA_ycbcr_texture = true;
+   if (intel->gen < 4)
+      ctx->Extensions.MESA_ycbcr_texture = true;
    ctx->Extensions.NV_blend_square = true;
    ctx->Extensions.NV_texture_rectangle = true;
    ctx->Extensions.NV_vertex_program = true;
-- 
1.7.7.3



More information about the mesa-dev mailing list