[g3dvl] move empty block handling into idct code
authorChristian König <deathsimple@vodafone.de>
Sat, 20 Nov 2010 21:24:42 +0000 (22:24 +0100)
committerChristian König <deathsimple@vodafone.de>
Sat, 20 Nov 2010 21:24:42 +0000 (22:24 +0100)
src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_idct.h
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c

index 9f81e0b..51988b3 100644 (file)
@@ -260,7 +260,7 @@ create_matrix_frag_shader(struct vl_idct *idct)
    struct ureg_program *shader;
    struct ureg_src tc[2], sampler[2];
    struct ureg_src start[2], step[2];
-   struct ureg_dst tmp, fragment;
+   struct ureg_dst fragment;
    float scale[2];
 
    shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
@@ -293,6 +293,25 @@ create_matrix_frag_shader(struct vl_idct *idct)
    return ureg_create_shader_and_destroy(shader, idct->pipe);
 }
 
+static void *
+create_empty_block_frag_shader(struct vl_idct *idct)
+{
+   struct ureg_program *shader;
+   struct ureg_dst fragment;
+
+   shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+   if (!shader)
+      return NULL;
+
+   fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
+
+   ureg_MOV(shader, fragment, ureg_imm1f(shader, 0.0f));
+
+   ureg_END(shader);
+
+   return ureg_create_shader_and_destroy(shader, idct->pipe);
+}
+
 static void
 xfer_buffers_map(struct vl_idct *idct)
 {
@@ -340,6 +359,7 @@ init_shaders(struct vl_idct *idct)
    assert(idct->vs = create_vert_shader(idct));
    assert(idct->transpose_fs = create_transpose_frag_shader(idct));
    assert(idct->matrix_fs = create_matrix_frag_shader(idct));
+   assert(idct->eb_fs = create_empty_block_frag_shader(idct));
 
    return true;
 }
@@ -352,6 +372,7 @@ cleanup_shaders(struct vl_idct *idct)
    idct->pipe->delete_vs_state(idct->pipe, idct->vs);
    idct->pipe->delete_fs_state(idct->pipe, idct->transpose_fs);
    idct->pipe->delete_fs_state(idct->pipe, idct->matrix_fs);
+   idct->pipe->delete_fs_state(idct->pipe, idct->eb_fs);
 }
 
 static bool
@@ -361,7 +382,7 @@ init_buffers(struct vl_idct *idct)
    struct pipe_sampler_view sampler_view;
    struct pipe_vertex_element vertex_elems[2];
 
-   const unsigned max_blocks =
+   idct->max_blocks =
       align(idct->destination->width0, BLOCK_WIDTH) / BLOCK_WIDTH *
       align(idct->destination->height0, BLOCK_HEIGHT) / BLOCK_HEIGHT *
       idct->destination->depth0;
@@ -398,23 +419,23 @@ init_buffers(struct vl_idct *idct)
    }
 
    idct->vertex_bufs.individual.quad.stride = sizeof(struct vertex2f);
-   idct->vertex_bufs.individual.quad.max_index = 4 * max_blocks - 1;
+   idct->vertex_bufs.individual.quad.max_index = 4 * idct->max_blocks - 1;
    idct->vertex_bufs.individual.quad.buffer_offset = 0;
    idct->vertex_bufs.individual.quad.buffer = pipe_buffer_create
    (
       idct->pipe->screen,
       PIPE_BIND_VERTEX_BUFFER,
-      sizeof(struct vertex2f) * 4 * max_blocks
+      sizeof(struct vertex2f) * 4 * idct->max_blocks
    );
 
    idct->vertex_bufs.individual.pos.stride = sizeof(struct vertex2f);
-   idct->vertex_bufs.individual.pos.max_index = 4 * max_blocks - 1;
+   idct->vertex_bufs.individual.pos.max_index = 4 * idct->max_blocks - 1;
    idct->vertex_bufs.individual.pos.buffer_offset = 0;
    idct->vertex_bufs.individual.pos.buffer = pipe_buffer_create
    (
       idct->pipe->screen,
       PIPE_BIND_VERTEX_BUFFER,
-      sizeof(struct vertex2f) * 4 * max_blocks
+      sizeof(struct vertex2f) * 4 * idct->max_blocks
    );
 
    /* Rect element */
@@ -477,8 +498,8 @@ init_constants(struct vl_idct *idct)
       &buf_transfer
    );
 
-   for ( i = 0; i <= idct->vertex_bufs.individual.quad.max_index; i += 4)
-     memcpy(v + i, &const_quad, sizeof(const_quad));
+   for ( i = 0; i < idct->max_blocks; ++i)
+     memcpy(v + i * 4, &const_quad, sizeof(const_quad));
 
    pipe_buffer_unmap(idct->pipe, idct->vertex_bufs.individual.quad.buffer, buf_transfer);
 
@@ -527,6 +548,7 @@ init_state(struct vl_idct *idct)
    unsigned i;
 
    idct->num_blocks = 0;
+   idct->num_empty_blocks = 0;
 
    idct->viewport.scale[0] = idct->destination->width0;
    idct->viewport.scale[1] = idct->destination->height0;
@@ -621,7 +643,7 @@ vl_idct_cleanup(struct vl_idct *idct)
 void
 vl_idct_add_block(struct vl_idct *idct, unsigned x, unsigned y, short *block)
 {
-   struct vertex2f v;
+   struct vertex2f v, *v_dst;
 
    unsigned tex_pitch;
    short *texels;
@@ -630,24 +652,31 @@ vl_idct_add_block(struct vl_idct *idct, unsigned x, unsigned y, short *block)
 
    assert(idct);
 
-   tex_pitch = idct->tex_transfer->stride / util_format_get_blocksize(idct->tex_transfer->resource->format);
-   texels = idct->texels + y * tex_pitch * BLOCK_HEIGHT + x * BLOCK_WIDTH;
-
    if(block) {
-      v.x = x;
-      v.y = y;
-
-      for (i = 0; i < 4; ++i) {
-         idct->vectors[idct->num_blocks * 4 + i] = v;
-      }
+      tex_pitch = idct->tex_transfer->stride / util_format_get_blocksize(idct->tex_transfer->resource->format);
+      texels = idct->texels + y * tex_pitch * BLOCK_HEIGHT + x * BLOCK_WIDTH;
 
       for (i = 0; i < BLOCK_HEIGHT; ++i)
          memcpy(texels + i * tex_pitch, block + i * BLOCK_WIDTH, BLOCK_WIDTH * 2);
 
+      /* non empty blocks fills the vector buffer from left to right */
+      v_dst = idct->vectors + idct->num_blocks * 4;
+
       idct->num_blocks++;
+
    } else {
-      for (i = 0; i < BLOCK_HEIGHT; ++i)
-         memset(texels + i * tex_pitch, 0, BLOCK_WIDTH * 2);      
+
+      /* while empty blocks fills the vector buffer from right to left */
+      v_dst = idct->vectors + (idct->max_blocks - idct->num_empty_blocks) * 4 - 4;
+
+      idct->num_empty_blocks++;
+   }
+
+   v.x = x;
+   v.y = y;
+
+   for (i = 0; i < 4; ++i) {
+      v_dst[i] = v;
    }
 }
 
@@ -689,10 +718,30 @@ vl_idct_flush(struct vl_idct *idct)
       idct->pipe->bind_fs_state(idct->pipe, idct->matrix_fs);
 
       util_draw_arrays(idct->pipe, PIPE_PRIM_QUADS, 0, idct->num_blocks * 4);
+   }
 
-      idct->pipe->flush(idct->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+   if(idct->num_empty_blocks > 0) {
+
+      /* empty block handling */
+      idct->fb_state.cbufs[0] = idct->surfaces.destination;
+      idct->pipe->set_framebuffer_state(idct->pipe, &idct->fb_state);
+      idct->pipe->set_viewport_state(idct->pipe, &idct->viewport);
+
+      idct->pipe->set_vertex_buffers(idct->pipe, 2, idct->vertex_bufs.all);
+      idct->pipe->bind_vertex_elements_state(idct->pipe, idct->vertex_elems_state);
+      idct->pipe->set_fragment_sampler_views(idct->pipe, 4, idct->sampler_views.all);
+      idct->pipe->bind_fragment_sampler_states(idct->pipe, 4, idct->samplers.all);
+      idct->pipe->bind_vs_state(idct->pipe, idct->vs);
+      idct->pipe->bind_fs_state(idct->pipe, idct->eb_fs);
+
+      util_draw_arrays(idct->pipe, PIPE_PRIM_QUADS,
+         (idct->max_blocks - idct->num_empty_blocks) * 4,
+         idct->num_empty_blocks * 4);
    }
 
+   idct->pipe->flush(idct->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+
    idct->num_blocks = 0;
+   idct->num_empty_blocks = 0;
    xfer_buffers_map(idct);
 }
index 6bb7f6b..84ba528 100644 (file)
@@ -34,6 +34,8 @@ struct vl_idct
 {
    struct pipe_context *pipe;
 
+   unsigned max_blocks;
+
    struct pipe_viewport_state viewport;
    struct pipe_resource *vs_const_buf;
    struct pipe_framebuffer_state fb_state;
@@ -61,7 +63,7 @@ struct vl_idct
    } sampler_views;
 
    void *vs;
-   void *transpose_fs, *matrix_fs;
+   void *transpose_fs, *matrix_fs, *eb_fs;
 
    union
    {
@@ -79,6 +81,7 @@ struct vl_idct
    } vertex_bufs;
 
    unsigned num_blocks;
+   unsigned num_empty_blocks;
 
    struct pipe_transfer *tex_transfer;
    short *texels;
index fd50193..15def60 100644 (file)
@@ -57,13 +57,6 @@ struct fragment_shader_consts
 struct vert_stream_0
 {
    struct vertex2f pos;
-
-   struct {
-      float luma_eb;
-      float cb_eb;
-      float cr_eb;
-   } field[2][2];
-
    float interlaced;
 };
 
@@ -71,10 +64,6 @@ enum VS_INPUT
 {
    VS_I_RECT,
    VS_I_VPOS,
-   VS_I_EB_0_0,
-   VS_I_EB_0_1,
-   VS_I_EB_1_0,
-   VS_I_EB_1_1,
    VS_I_INTERLACED,
    VS_I_MV0,
    VS_I_MV1,
@@ -91,10 +80,6 @@ enum VS_OUTPUT
    VS_O_TEX0,
    VS_O_TEX1,
    VS_O_TEX2,
-   VS_O_EB_0_0,
-   VS_O_EB_0_1,
-   VS_O_EB_1_0,
-   VS_O_EB_1_1,
    VS_O_INTERLACED,
    VS_O_MV0,
    VS_O_MV1,
@@ -125,9 +110,9 @@ create_vert_shader(struct vl_mpeg12_mc_renderer *r, unsigned ref_frames, unsigne
 {
    struct ureg_program *shader;
    struct ureg_src norm, mbs;
-   struct ureg_src vrect, vpos, eb[2][2], interlaced, vmv[4];
+   struct ureg_src vrect, vpos, interlaced, vmv[4];
    struct ureg_dst scale, t_vpos, t_vtex;
-   struct ureg_dst o_vpos, o_line, o_vtex[3], o_eb[2][2], o_interlaced, o_vmv[4];
+   struct ureg_dst o_vpos, o_line, o_vtex[3], o_interlaced, o_vmv[4];
    unsigned i, j, count, label;
 
    shader = ureg_create(TGSI_PROCESSOR_VERTEX);
@@ -143,10 +128,6 @@ create_vert_shader(struct vl_mpeg12_mc_renderer *r, unsigned ref_frames, unsigne
 
    vrect = ureg_DECL_vs_input(shader, VS_I_RECT);
    vpos = ureg_DECL_vs_input(shader, VS_I_VPOS);
-   eb[0][0] = ureg_DECL_vs_input(shader, VS_I_EB_0_0);
-   eb[1][0] = ureg_DECL_vs_input(shader, VS_I_EB_1_0);
-   eb[0][1] = ureg_DECL_vs_input(shader, VS_I_EB_0_1);
-   eb[1][1] = ureg_DECL_vs_input(shader, VS_I_EB_1_1);
    interlaced = ureg_DECL_vs_input(shader, VS_I_INTERLACED);
 
    o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS);
@@ -154,10 +135,6 @@ create_vert_shader(struct vl_mpeg12_mc_renderer *r, unsigned ref_frames, unsigne
    o_vtex[0] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_TEX0);
    o_vtex[1] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_TEX1);
    o_vtex[2] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_TEX2);
-   o_eb[0][0] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_EB_0_0);
-   o_eb[0][1] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_EB_0_1);
-   o_eb[1][0] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_EB_1_0);
-   o_eb[1][1] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_EB_1_1);
    o_interlaced = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_INTERLACED);
    
    count=0;
@@ -230,11 +207,6 @@ create_vert_shader(struct vl_mpeg12_mc_renderer *r, unsigned ref_frames, unsigne
    ureg_ENDIF(shader);
    ureg_MOV(shader, ureg_writemask(o_vtex[2], TGSI_WRITEMASK_XY), ureg_src(t_vpos));
 
-   ureg_MOV(shader, o_eb[0][0], eb[0][0]);
-   ureg_MOV(shader, o_eb[0][1], eb[0][1]);
-   ureg_MOV(shader, o_eb[1][0], eb[1][0]);
-   ureg_MOV(shader, o_eb[1][1], eb[1][1]);
-
    ureg_MOV(shader, o_interlaced, interlaced);
 
    if(count > 0) {
@@ -266,11 +238,9 @@ calc_field(struct ureg_program *shader)
     *
     * tmp.z = fraction(line.y)
     * tmp.z = tmp.z >= 0.5 ? 1 : 0
-    * tmp.xy = line > 4 ? 1 : 0
     */
-   ureg_FRC(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Z), ureg_scalar(line, TGSI_SWIZZLE_Y));
-   ureg_SGE(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Z), ureg_src(tmp), ureg_imm1f(shader, 0.5f));
-   ureg_SGE(shader, ureg_writemask(tmp, TGSI_WRITEMASK_XY), line, ureg_imm2f(shader, BLOCK_WIDTH / 2, BLOCK_HEIGHT / 2));
+   ureg_FRC(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Y), line);
+   ureg_SGE(shader, ureg_writemask(tmp, TGSI_WRITEMASK_Y), ureg_src(tmp), ureg_imm1f(shader, 0.5f));
 
    return tmp;
 }
@@ -278,25 +248,19 @@ calc_field(struct ureg_program *shader)
 static struct ureg_dst
 fetch_ycbcr(struct vl_mpeg12_mc_renderer *r, struct ureg_program *shader, struct ureg_dst field)
 {
-   struct ureg_src tc[3], eb[2][2], interlaced;
+   struct ureg_src tc[3], interlaced;
    struct ureg_src sampler[3];
-   struct ureg_dst texel, t_tc, t_field, tmp;
-   unsigned i, l_interlaced, l_y, l_x;
+   struct ureg_dst texel, t_tc, tmp;
+   unsigned i, label;
 
    texel = ureg_DECL_temporary(shader);
    t_tc = ureg_DECL_temporary(shader);
-   t_field = ureg_DECL_temporary(shader);
    tmp = ureg_DECL_temporary(shader);
 
    tc[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_TEX0, TGSI_INTERPOLATE_LINEAR);
    tc[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_TEX1, TGSI_INTERPOLATE_LINEAR);
    tc[2] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_TEX2, TGSI_INTERPOLATE_LINEAR);
 
-   eb[0][0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_EB_0_0, TGSI_INTERPOLATE_CONSTANT);
-   eb[0][1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_EB_0_1, TGSI_INTERPOLATE_CONSTANT);
-   eb[1][0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_EB_1_0, TGSI_INTERPOLATE_CONSTANT);
-   eb[1][1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_EB_1_1, TGSI_INTERPOLATE_CONSTANT);
-
    interlaced = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_INTERLACED, TGSI_INTERPOLATE_CONSTANT);
 
    for (i = 0; i < 3; ++i)  {
@@ -308,36 +272,19 @@ fetch_ycbcr(struct vl_mpeg12_mc_renderer *r, struct ureg_program *shader, struct
     * texel.cb = tex(tc[2], sampler[1])
     * texel.cr = tex(tc[2], sampler[2])
     */
-   ureg_MOV(shader, ureg_writemask(t_field, TGSI_WRITEMASK_XY), ureg_src(field));
-   ureg_IF(shader, interlaced, &l_interlaced);
-      ureg_MOV(shader, ureg_writemask(t_field, TGSI_WRITEMASK_Y), ureg_scalar(ureg_src(field), TGSI_SWIZZLE_Z));
-   ureg_ENDIF(shader);
+   ureg_MUL(shader, tmp, interlaced, ureg_scalar(ureg_src(field), TGSI_SWIZZLE_Y));
 
    for (i = 0; i < 3; ++i) {
       if(i==0 || r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444) {
-         ureg_IF(shader, ureg_scalar(ureg_src(t_field), TGSI_SWIZZLE_Y), &l_y);
-            ureg_MOV(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_XY), tc[1]);
-
-            ureg_IF(shader, ureg_scalar(ureg_src(t_field), TGSI_SWIZZLE_X), &l_x);
-               ureg_MOV(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_Z), ureg_scalar(eb[1][1], TGSI_SWIZZLE_X + i));
-            ureg_ELSE(shader, &l_x);
-               ureg_MOV(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_Z), ureg_scalar(eb[1][0], TGSI_SWIZZLE_X + i));
-            ureg_ENDIF(shader);
 
-         ureg_ELSE(shader, &l_y);
+         ureg_IF(shader, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), &label);
+            ureg_MOV(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_XY), tc[1]);
+         ureg_ELSE(shader, &label);
             ureg_MOV(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_XY), tc[0]);
-
-            ureg_IF(shader, ureg_scalar(ureg_src(t_field), TGSI_SWIZZLE_X), &l_x);
-               ureg_MOV(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_Z), ureg_scalar(eb[0][1], TGSI_SWIZZLE_X + i));
-            ureg_ELSE(shader, &l_x);
-               ureg_MOV(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_Z), ureg_scalar(eb[0][0], TGSI_SWIZZLE_X + i));
-            ureg_ENDIF(shader);
-
          ureg_ENDIF(shader);
 
       } else {
          ureg_MOV(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_XY), tc[2]);
-         ureg_MOV(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_Z), ureg_scalar(eb[0][0], TGSI_SWIZZLE_X + i));
       }
 
       /* Nouveau and r600g can't writemask tex dst regs (yet?), do in two steps */
@@ -345,7 +292,6 @@ fetch_ycbcr(struct vl_mpeg12_mc_renderer *r, struct ureg_program *shader, struct
       ureg_MOV(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X));
    }
 
-   ureg_release_temporary(shader, t_field);
    ureg_release_temporary(shader, t_tc);
    ureg_release_temporary(shader, tmp);
 
@@ -450,7 +396,7 @@ create_field_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
    field = calc_field(shader);
    texel = fetch_ycbcr(r, shader, field);
 
-   ureg_IF(shader, ureg_scalar(ureg_src(field), TGSI_SWIZZLE_Z), &label);
+   ureg_IF(shader, ureg_scalar(ureg_src(field), TGSI_SWIZZLE_Y), &label);
       ureg_TEX(shader, ref, TGSI_TEXTURE_2D, tc[1], sampler);
    ureg_ELSE(shader, &label);
       ureg_TEX(shader, ref, TGSI_TEXTURE_2D, tc[0], sampler);
@@ -548,7 +494,7 @@ create_field_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
    field = calc_field(shader);
    texel = fetch_ycbcr(r, shader, field);
 
-   ureg_IF(shader, ureg_scalar(ureg_src(field), TGSI_SWIZZLE_Z), &label);
+   ureg_IF(shader, ureg_scalar(ureg_src(field), TGSI_SWIZZLE_Y), &label);
       ureg_TEX(shader, ref[0], TGSI_TEXTURE_2D, tc[1], sampler[0]);
       ureg_TEX(shader, ref[1], TGSI_TEXTURE_2D, tc[3], sampler[1]);
    ureg_ELSE(shader, &label);
@@ -708,7 +654,7 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
    r->macroblock_buf = MALLOC(r->macroblocks_per_batch * sizeof(struct pipe_mpeg12_macroblock));
 
    memset(&template, 0, sizeof(struct pipe_resource));
-   template.target = PIPE_TEXTURE_3D;
+   template.target = PIPE_TEXTURE_2D;
    /* TODO: Accomodate HW that can't do this and also for cases when this isn't precise enough */
    template.format = PIPE_FORMAT_R16_SNORM;
    template.last_level = 0;
@@ -796,32 +742,8 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
    vertex_elems[VS_I_VPOS].vertex_buffer_index = 1;
    vertex_elems[VS_I_VPOS].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
-   /* y, cr, cb z-coordinate element top left block */
-   vertex_elems[VS_I_EB_0_0].src_offset = sizeof(struct vertex2f);
-   vertex_elems[VS_I_EB_0_0].instance_divisor = 0;
-   vertex_elems[VS_I_EB_0_0].vertex_buffer_index = 1;
-   vertex_elems[VS_I_EB_0_0].src_format = PIPE_FORMAT_R32G32B32_FLOAT;
-
-   /* y, cr, cb z-coordinate element top right block */
-   vertex_elems[VS_I_EB_0_1].src_offset = sizeof(struct vertex2f) + sizeof(float) * 3;
-   vertex_elems[VS_I_EB_0_1].instance_divisor = 0;
-   vertex_elems[VS_I_EB_0_1].vertex_buffer_index = 1;
-   vertex_elems[VS_I_EB_0_1].src_format = PIPE_FORMAT_R32G32B32_FLOAT;
-
-   /* y, cr, cb z-coordinate element bottom left block */
-   vertex_elems[VS_I_EB_1_0].src_offset = sizeof(struct vertex2f) + sizeof(float) * 6;
-   vertex_elems[VS_I_EB_1_0].instance_divisor = 0;
-   vertex_elems[VS_I_EB_1_0].vertex_buffer_index = 1;
-   vertex_elems[VS_I_EB_1_0].src_format = PIPE_FORMAT_R32G32B32_FLOAT;
-
-   /* y, cr, cb z-coordinate element bottom right block */
-   vertex_elems[VS_I_EB_1_1].src_offset = sizeof(struct vertex2f) + sizeof(float) * 9;
-   vertex_elems[VS_I_EB_1_1].instance_divisor = 0;
-   vertex_elems[VS_I_EB_1_1].vertex_buffer_index = 1;
-   vertex_elems[VS_I_EB_1_1].src_format = PIPE_FORMAT_R32G32B32_FLOAT;
-
    /* progressive=1.0f interlaced=0.0f */
-   vertex_elems[VS_I_INTERLACED].src_offset = sizeof(struct vertex2f) + sizeof(float) * 12;
+   vertex_elems[VS_I_INTERLACED].src_offset = sizeof(struct vertex2f);
    vertex_elems[VS_I_INTERLACED].instance_divisor = 0;
    vertex_elems[VS_I_INTERLACED].vertex_buffer_index = 1;
    vertex_elems[VS_I_INTERLACED].src_format = PIPE_FORMAT_R32_FLOAT;
@@ -850,9 +772,9 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
    vertex_elems[VS_I_MV3].vertex_buffer_index = 3;
    vertex_elems[VS_I_MV3].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
-   r->vertex_elems_state.individual.i = r->pipe->create_vertex_elements_state(r->pipe, 7, vertex_elems);
-   r->vertex_elems_state.individual.p = r->pipe->create_vertex_elements_state(r->pipe, 9, vertex_elems);
-   r->vertex_elems_state.individual.b = r->pipe->create_vertex_elements_state(r->pipe, 11, vertex_elems);
+   r->vertex_elems_state.individual.i = r->pipe->create_vertex_elements_state(r->pipe, 3, vertex_elems);
+   r->vertex_elems_state.individual.p = r->pipe->create_vertex_elements_state(r->pipe, 5, vertex_elems);
+   r->vertex_elems_state.individual.b = r->pipe->create_vertex_elements_state(r->pipe, 7, vertex_elems);
 
    r->vs_const_buf = pipe_buffer_create
    (
@@ -1048,21 +970,6 @@ gen_macroblock_verts(struct vl_mpeg12_mc_renderer *r,
          v.pos.x = mb->mbx;
          v.pos.y = mb->mby;
 
-         v.field[0][0].luma_eb = mb->cbp & 32 ? 0.0f : -1.0f;
-         v.field[0][1].luma_eb = mb->cbp & 16 ? 0.0f : -1.0f;
-         v.field[1][0].luma_eb = mb->cbp & 8 ? 0.0f : -1.0f;
-         v.field[1][1].luma_eb = mb->cbp & 4 ? 0.0f : -1.0f;
-
-         v.field[0][0].cb_eb = mb->cbp & 2 ? 0.0f : -1.0f;
-         v.field[0][1].cb_eb = mb->cbp & 2 ? 0.0f : -1.0f;
-         v.field[1][0].cb_eb = mb->cbp & 2 ? 0.0f : -1.0f;
-         v.field[1][1].cb_eb = mb->cbp & 2 ? 0.0f : -1.0f;
-
-         v.field[0][0].cr_eb = mb->cbp & 1 ? 0.0f : -1.0f;
-         v.field[0][1].cr_eb = mb->cbp & 1 ? 0.0f : -1.0f;
-         v.field[1][0].cr_eb = mb->cbp & 1 ? 0.0f : -1.0f;
-         v.field[1][1].cr_eb = mb->cbp & 1 ? 0.0f : -1.0f;
-   
          v.interlaced = mb->dct_type == PIPE_MPEG12_DCT_TYPE_FIELD ? 1.0f : 0.0f;
 
          for ( i = 0; i < 4; ++i )