Mesa (pipe-video): [g3dvl] handle different mc types more similary

Christian König deathsimple at kemper.freedesktop.org
Thu Mar 24 13:25:41 PDT 2011


Module: Mesa
Branch: pipe-video
Commit: 52766c2c373a7ac484ae01dca3ab409e808709b2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=52766c2c373a7ac484ae01dca3ab409e808709b2

Author: Christian König <deathsimple at vodafone.de>
Date:   Sun Mar 20 22:50:09 2011 +0100

[g3dvl] handle different mc types more similary

---

 src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c |   74 +++++++---------------
 src/gallium/auxiliary/vl/vl_vertex_buffers.c     |   28 ++++----
 2 files changed, 37 insertions(+), 65 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
index 4f0b9ad..6cd811b 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
@@ -106,12 +106,11 @@ create_vert_shader(struct vl_mpeg12_mc_renderer *r)
     * o_eb[0..1] = vrect.x ? eb[0..1][1] : eb[0..1][0]
     *
     * o_frame_pred = frame_pred
-    * o_info.x = ref_frames
-    * o_info.y = ref_frames > 0
-    * o_info.z = bkwd_pred
+    * o_info.x = not_intra
+    * o_info.y = ref_weight / 2
     *
     * // Apply motion vectors
-    * o_vmv[0..count] = t_vpos + vmv[0..count] * mv_scale
+    * o_vmv[0..3] = t_vpos + vmv[0..3] * mv_scale
     *
     * o_line.xy = vrect * 8
     * o_line.z = interlaced
@@ -152,24 +151,13 @@ create_vert_shader(struct vl_mpeg12_mc_renderer *r)
             eb[1][1], eb[1][0]);
 
    ureg_MOV(shader, ureg_writemask(o_info, TGSI_WRITEMASK_X),
-            ureg_scalar(eb[1][1], TGSI_SWIZZLE_W));
-   ureg_SGE(shader, ureg_writemask(o_info, TGSI_WRITEMASK_Y),
-      ureg_scalar(eb[1][1], TGSI_SWIZZLE_W), ureg_imm1f(shader, 0.0f));
-   ureg_MOV(shader, ureg_writemask(o_info, TGSI_WRITEMASK_Z),
             ureg_scalar(eb[1][0], TGSI_SWIZZLE_W));
+   ureg_MUL(shader, ureg_writemask(o_info, TGSI_WRITEMASK_Y),
+            ureg_scalar(eb[1][1], TGSI_SWIZZLE_W),
+            ureg_imm1f(shader, 0.5f));
 
-   ureg_MAD(shader, ureg_writemask(o_vmv[0], TGSI_WRITEMASK_XY), mv_scale, vmv[0], ureg_src(t_vpos));
-   ureg_MAD(shader, ureg_writemask(o_vmv[2], TGSI_WRITEMASK_XY), mv_scale, vmv[2], ureg_src(t_vpos));
-
-   ureg_CMP(shader, ureg_writemask(t_vmv, TGSI_WRITEMASK_XY),
-            ureg_negate(ureg_scalar(eb[0][1], TGSI_SWIZZLE_W)),
-            vmv[0], vmv[1]);
-   ureg_MAD(shader, ureg_writemask(o_vmv[1], TGSI_WRITEMASK_XY), mv_scale, ureg_src(t_vmv), ureg_src(t_vpos));
-
-   ureg_CMP(shader, ureg_writemask(t_vmv, TGSI_WRITEMASK_XY),
-            ureg_negate(ureg_scalar(eb[0][1], TGSI_SWIZZLE_W)),
-            vmv[2], vmv[3]);
-   ureg_MAD(shader, ureg_writemask(o_vmv[3], TGSI_WRITEMASK_XY), mv_scale, ureg_src(t_vmv), ureg_src(t_vpos));
+   for (i = 0; i < 4; ++i)
+      ureg_MAD(shader, ureg_writemask(o_vmv[i], TGSI_WRITEMASK_XY), mv_scale, vmv[i], ureg_src(t_vpos));
 
    ureg_MOV(shader, ureg_writemask(o_vtex[0], TGSI_WRITEMASK_XY), ureg_src(t_vpos));
    ureg_MOV(shader, ureg_writemask(o_vtex[1], TGSI_WRITEMASK_XY), ureg_src(t_vpos));
@@ -310,7 +298,14 @@ fetch_ref(struct ureg_program *shader, struct ureg_dst field)
 
    ureg_MOV(shader, ureg_writemask(result, TGSI_WRITEMASK_XYZ), ureg_imm1f(shader, 0.5f));
 
-   ureg_IF(shader, ureg_scalar(info, TGSI_SWIZZLE_Y), &intra_label);
+   ureg_IF(shader, ureg_scalar(info, TGSI_SWIZZLE_X), &intra_label);
+      /*
+       * if (field.z)
+       *    ref[0..1] = tex(tc[0..1], sampler[0..1])
+       * else
+       *    ref[0..1] = tex(tc[2..3], sampler[0..1])
+       * result = LRP(info.y, ref[0..1])
+       */
       ureg_CMP(shader, ureg_writemask(ref[0], TGSI_WRITEMASK_XY),
                ureg_negate(ureg_scalar(ureg_src(field), TGSI_SWIZZLE_Y)),
                tc[1], tc[0]);
@@ -318,36 +313,13 @@ fetch_ref(struct ureg_program *shader, struct ureg_dst field)
                ureg_negate(ureg_scalar(ureg_src(field), TGSI_SWIZZLE_Y)),
                tc[3], tc[2]);
 
-      ureg_IF(shader, ureg_scalar(info, TGSI_SWIZZLE_X), &bi_label);
-
-         /*
-          * result = tex(field.z ? tc[1] : tc[0], sampler[bkwd_pred ? 1 : 0])
-          */
-         ureg_IF(shader, ureg_scalar(info, TGSI_SWIZZLE_Z), &label);
-            ureg_TEX(shader, result, TGSI_TEXTURE_2D, ureg_src(ref[1]), sampler[1]);
-         ureg_fixup_label(shader, label, ureg_get_instruction_number(shader));
-         ureg_ELSE(shader, &label);
-            ureg_TEX(shader, result, TGSI_TEXTURE_2D, ureg_src(ref[0]), sampler[0]);
-         ureg_fixup_label(shader, label, ureg_get_instruction_number(shader));
-         ureg_ENDIF(shader);
-
-      ureg_fixup_label(shader, bi_label, ureg_get_instruction_number(shader));
-      ureg_ELSE(shader, &bi_label);
-
-         /*
-          * if (field.z)
-          *    ref[0..1] = tex(tc[0..1], sampler[0..1])
-          * else
-          *    ref[0..1] = tex(tc[2..3], sampler[0..1])
-          */
-         ureg_TEX(shader, ref[0], TGSI_TEXTURE_2D, ureg_src(ref[0]), sampler[0]);
-         ureg_TEX(shader, ref[1], TGSI_TEXTURE_2D, ureg_src(ref[1]), sampler[1]);
-
-         ureg_LRP(shader, ureg_writemask(result, TGSI_WRITEMASK_XYZ), ureg_imm1f(shader, 0.5f),
-            ureg_src(ref[0]), ureg_src(ref[1]));
-
-      ureg_fixup_label(shader, bi_label, ureg_get_instruction_number(shader));
-      ureg_ENDIF(shader);
+      ureg_TEX(shader, ref[0], TGSI_TEXTURE_2D, ureg_src(ref[0]), sampler[0]);
+      ureg_TEX(shader, ref[1], TGSI_TEXTURE_2D, ureg_src(ref[1]), sampler[1]);
+
+      ureg_LRP(shader, ureg_writemask(result, TGSI_WRITEMASK_XYZ),
+               ureg_scalar(info, TGSI_SWIZZLE_Y),
+               ureg_src(ref[1]), ureg_src(ref[0]));
+
    ureg_fixup_label(shader, intra_label, ureg_get_instruction_number(shader));
    ureg_ENDIF(shader);
 
diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.c b/src/gallium/auxiliary/vl/vl_vertex_buffers.c
index f791d4e..bbac890 100644
--- a/src/gallium/auxiliary/vl/vl_vertex_buffers.c
+++ b/src/gallium/auxiliary/vl/vl_vertex_buffers.c
@@ -212,8 +212,8 @@ get_motion_vectors(struct pipe_mpeg12_macroblock *mb, struct vertex2s mv[4])
        mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_FWD) {
 
       if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
-         mv[0].x = mb->mv[0].top.x;
-         mv[0].y = mb->mv[0].top.y;
+         mv[0].x = mv[1].x = mb->mv[0].top.x;
+         mv[0].y = mv[1].y = mb->mv[0].top.y;
 
       } else {
          mv[0].x = mb->mv[0].top.x;
@@ -225,14 +225,16 @@ get_motion_vectors(struct pipe_mpeg12_macroblock *mb, struct vertex2s mv[4])
          if (mb->mv[0].top.field_select) mv[0].y += 2;
          if (!mb->mv[0].bottom.field_select) mv[1].y -= 2;
       }
+   } else {
+      mv[0].x = mv[0].y = mv[1].x = mv[1].y = 0x8000;
    }
 
    if (mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_BI ||
        mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_BKWD) {
 
       if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
-         mv[2].x = mb->mv[1].top.x;
-         mv[2].y = mb->mv[1].top.y;
+         mv[2].x = mv[3].x = mb->mv[1].top.x;
+         mv[2].y = mv[3].y = mb->mv[1].top.y;
 
       } else {
          mv[2].x = mb->mv[1].top.x;
@@ -244,6 +246,8 @@ get_motion_vectors(struct pipe_mpeg12_macroblock *mb, struct vertex2s mv[4])
          if (mb->mv[1].top.field_select) mv[2].y += 2;
          if (!mb->mv[1].bottom.field_select) mv[3].y -= 2;
       }
+   } else {
+      mv[2].x = mv[2].y = mv[3].x = mv[3].y = 0x8000;
    }
 }
 
@@ -274,23 +278,19 @@ vl_vb_add_block(struct vl_vertex_buffer *buffer, struct pipe_mpeg12_macroblock *
    }
    stream->eb[0][0].flag = mb->dct_type == PIPE_MPEG12_DCT_TYPE_FIELD;
    stream->eb[0][1].flag = mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME;
-   stream->eb[1][0].flag = mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_BKWD;
+   stream->eb[1][0].flag = mb->mb_type != PIPE_MPEG12_MACROBLOCK_TYPE_INTRA;
    switch (mb->mb_type) {
-      case PIPE_MPEG12_MACROBLOCK_TYPE_INTRA:
-         stream->eb[1][1].flag = -1;
-         break;
-
       case PIPE_MPEG12_MACROBLOCK_TYPE_FWD:
-      case PIPE_MPEG12_MACROBLOCK_TYPE_BKWD:
-         stream->eb[1][1].flag = 1;
+         stream->eb[1][1].flag = 0;
          break;
 
       case PIPE_MPEG12_MACROBLOCK_TYPE_BI:
-         stream->eb[1][1].flag = 0;
+         stream->eb[1][1].flag = 1;
          break;
 
-      default:
-         assert(0);
+      case PIPE_MPEG12_MACROBLOCK_TYPE_BKWD:
+         stream->eb[1][1].flag = 2;
+         break;
    }
 
    get_motion_vectors(mb, stream->mv);



More information about the mesa-commit mailing list