add rasterizer state
authorChristian König <deathsimple@vodafone.de>
Wed, 1 Dec 2010 17:47:11 +0000 (18:47 +0100)
committerChristian König <deathsimple@vodafone.de>
Fri, 3 Dec 2010 18:04:01 +0000 (19:04 +0100)
src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_idct.h
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h

index 80894b4..d9872cb 100644 (file)
@@ -285,9 +285,9 @@ create_matrix_frag_shader(struct vl_idct *idct)
        fragment[i] = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, i);
 
    /* pixel center is at 0.5 not 0.0 !!! */
-   ureg_ADD(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_Y), 
-      tex, ureg_imm1f(shader, -2.0f / source->height0));
-
+   //ureg_ADD(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_Y), 
+   //   tex, ureg_imm1f(shader, -2.0f / source->height0));
+   ureg_MOV(shader, ureg_writemask(t_tc, TGSI_WRITEMASK_Y), tex);
    for (i = 0; i < 4; ++i) {
       fetch_four(shader, l[i], ureg_src(t_tc), sampler[0], start[0], block, false, false, source->width0);
       ureg_MUL(shader, l[i][0], ureg_src(l[i][0]), ureg_imm1f(shader, STAGE1_SCALE));
@@ -472,6 +472,7 @@ static void
 init_state(struct vl_idct *idct)
 {
    struct pipe_sampler_state sampler;
+   struct pipe_rasterizer_state rs_state;
    unsigned i;
 
    idct->viewport[0].scale[0] = idct->textures.individual.intermediate->width0;
@@ -528,6 +529,14 @@ init_state(struct vl_idct *idct)
       /*sampler.max_anisotropy = ; */
       idct->samplers.all[i] = idct->pipe->create_sampler_state(idct->pipe, &sampler);
    }
+
+   memset(&rs_state, 0, sizeof(rs_state));
+   /*rs_state.sprite_coord_enable */
+   rs_state.sprite_coord_mode = PIPE_SPRITE_COORD_UPPER_LEFT;
+   rs_state.point_quad_rasterization = true;
+   rs_state.point_size = BLOCK_WIDTH;
+   rs_state.gl_rasterization_rules = false;
+   idct->rs_state = idct->pipe->create_rasterizer_state(idct->pipe, &rs_state);
 }
 
 static void
@@ -543,6 +552,8 @@ cleanup_state(struct vl_idct *idct)
 
    for (i = 0; i < 4; ++i)
       idct->pipe->delete_sampler_state(idct->pipe, idct->samplers.all[i]);
+
+   idct->pipe->delete_rasterizer_state(idct->pipe, idct->rs_state);
 }
 
 struct pipe_resource *
@@ -730,6 +741,8 @@ vl_idct_flush(struct vl_idct *idct)
 
    if(num_blocks > 0) {
 
+      idct->pipe->bind_rasterizer_state(idct->pipe, idct->rs_state);
+
       /* first stage */
       idct->pipe->set_framebuffer_state(idct->pipe, &idct->fb_state[0]);
       idct->pipe->set_viewport_state(idct->pipe, &idct->viewport[0]);
index 94a5c73..462863b 100644 (file)
@@ -42,6 +42,8 @@ struct vl_idct
 
    struct pipe_resource *destination;
 
+   void *rs_state;
+
    void *vertex_elems_state;
 
    union
index 70bb756..5e928e8 100644 (file)
@@ -270,7 +270,7 @@ fetch_ref(struct ureg_program *shader, struct ureg_dst field, unsigned ref_frame
 {
    struct ureg_src tc[ref_frames * mv_per_frame], sampler[ref_frames];
    struct ureg_dst ref[ref_frames], t_tc, result;
-   unsigned i, label;
+   unsigned i;
 
    for (i = 0; i < ref_frames * mv_per_frame; ++i)
       tc[i] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_MV0 + i, TGSI_INTERPOLATE_LINEAR);
@@ -443,6 +443,7 @@ static bool
 init_pipe_state(struct vl_mpeg12_mc_renderer *r)
 {
    struct pipe_sampler_state sampler;
+   struct pipe_rasterizer_state rs_state;
    unsigned filters[5];
    unsigned i;
 
@@ -469,7 +470,7 @@ init_pipe_state(struct vl_mpeg12_mc_renderer *r)
    /* Luma filter */
    filters[0] = PIPE_TEX_FILTER_NEAREST;
    /* Chroma filters */
-   if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444 || true) { //TODO
+   if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444) {
       filters[1] = PIPE_TEX_FILTER_NEAREST;
       filters[2] = PIPE_TEX_FILTER_NEAREST;
    }
@@ -504,6 +505,14 @@ init_pipe_state(struct vl_mpeg12_mc_renderer *r)
       r->samplers.all[i] = r->pipe->create_sampler_state(r->pipe, &sampler);
    }
 
+   memset(&rs_state, 0, sizeof(rs_state));
+   /*rs_state.sprite_coord_enable */
+   rs_state.sprite_coord_mode = PIPE_SPRITE_COORD_UPPER_LEFT;
+   rs_state.point_quad_rasterization = true;
+   rs_state.point_size = BLOCK_WIDTH;
+   rs_state.gl_rasterization_rules = true;
+   r->rs_state = r->pipe->create_rasterizer_state(r->pipe, &rs_state);
+
    return true;
 }
 
@@ -516,6 +525,8 @@ cleanup_pipe_state(struct vl_mpeg12_mc_renderer *r)
 
    for (i = 0; i < 5; ++i)
       r->pipe->delete_sampler_state(r->pipe, r->samplers.all[i]);
+
+   r->pipe->delete_rasterizer_state(r->pipe, r->rs_state);
 }
 
 static bool
@@ -875,6 +886,7 @@ flush(struct vl_mpeg12_mc_renderer *r)
 
    upload_vertex_stream(r, num_macroblocks);
 
+   r->pipe->bind_rasterizer_state(r->pipe, r->rs_state);
    r->pipe->set_framebuffer_state(r->pipe, &r->fb_state);
    r->pipe->set_viewport_state(r->pipe, &r->viewport);
 
index c6e9ef8..2b6c21a 100644 (file)
@@ -85,6 +85,8 @@ struct vl_mpeg12_mc_renderer
 
    struct vl_idct idct_y, idct_cb, idct_cr;
 
+   void *rs_state;
+
    union
    {
       void *all[5];