[g3dvl] move blender state into idct code
authorChristian König <deathsimple@vodafone.de>
Sun, 17 Apr 2011 11:01:56 +0000 (13:01 +0200)
committerChristian König <deathsimple@vodafone.de>
Sun, 17 Apr 2011 11:01:56 +0000 (13:01 +0200)
src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_idct.h
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
src/gallium/auxiliary/vl/vl_mpeg12_decoder.h

index a20263bc182b19977dce5af0542f1b5a6074b6aa..4a500a7489c42a3869b8744a5f28729a32686451 100644 (file)
@@ -400,8 +400,9 @@ cleanup_shaders(struct vl_idct *idct)
 static bool
 init_state(struct vl_idct *idct)
 {
-   struct pipe_sampler_state sampler;
+   struct pipe_blend_state blend;
    struct pipe_rasterizer_state rs_state;
+   struct pipe_sampler_state sampler;
    unsigned i;
 
    assert(idct);
@@ -412,6 +413,25 @@ init_state(struct vl_idct *idct)
    if (!idct->rs_state)
       goto error_rs_state;
 
+   memset(&blend, 0, sizeof blend);
+
+   blend.independent_blend_enable = 0;
+   blend.rt[0].blend_enable = 0;
+   blend.rt[0].rgb_func = PIPE_BLEND_ADD;
+   blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_func = PIPE_BLEND_ADD;
+   blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+   blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
+   blend.logicop_enable = 0;
+   blend.logicop_func = PIPE_LOGICOP_CLEAR;
+   /* Needed to allow color writes to FB, even if blending disabled */
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
+   blend.dither = 0;
+   idct->blend = idct->pipe->create_blend_state(idct->pipe, &blend);
+   if (!idct->blend)
+      goto error_blend;
+
    for (i = 0; i < 2; ++i) {
       memset(&sampler, 0, sizeof(sampler));
       sampler.wrap_s = PIPE_TEX_WRAP_REPEAT;
@@ -437,6 +457,9 @@ error_samplers:
 
    idct->pipe->delete_rasterizer_state(idct->pipe, idct->rs_state);
 
+error_blend:
+   idct->pipe->delete_blend_state(idct->pipe, idct->blend);
+
 error_rs_state:
    return false;
 }
@@ -450,6 +473,7 @@ cleanup_state(struct vl_idct *idct)
       idct->pipe->delete_sampler_state(idct->pipe, idct->samplers[i]);
 
    idct->pipe->delete_rasterizer_state(idct->pipe, idct->rs_state);
+   idct->pipe->delete_blend_state(idct->pipe, idct->blend);
 }
 
 static bool
@@ -691,6 +715,7 @@ vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_
       num_verts = idct->blocks_x * idct->blocks_y * 4;
 
       idct->pipe->bind_rasterizer_state(idct->pipe, idct->rs_state);
+      idct->pipe->bind_blend_state(idct->pipe, idct->blend);
       idct->pipe->bind_fragment_sampler_states(idct->pipe, 2, idct->samplers);
 
       /* first stage */
index 0875f17476c55abf20762374519d5a9dea79ad1f..7f00e3e28b4007d8c0893b298092ea31b9dc82ee 100644 (file)
@@ -43,6 +43,7 @@ struct vl_idct
    unsigned nr_of_render_targets;
 
    void *rs_state;
+   void *blend;
 
    void *samplers[2];
 
index 08b740c619911e3bf1d3ac57f8838b0467ce4750..6d10cd16e32076ad9c7dfc6e9956b3a0e72b4d9a 100644 (file)
@@ -276,7 +276,6 @@ vl_mpeg12_destroy(struct pipe_video_decoder *decoder)
    dec->pipe->bind_vs_state(dec->pipe, NULL);
    dec->pipe->bind_fs_state(dec->pipe, NULL);
 
-   dec->pipe->delete_blend_state(dec->pipe, dec->blend);
    dec->pipe->delete_depth_stencil_alpha_state(dec->pipe, dec->dsa);
 
    vl_mc_cleanup(&dec->mc_y);
@@ -489,7 +488,6 @@ vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer,
          vl_mc_render_ref(&buf->mc[i], sv[j][i], ne_start, ne_num, e_start, e_num);
       }
 
-      dec->pipe->bind_blend_state(dec->pipe, dec->blend);
       dec->pipe->bind_vertex_elements_state(dec->pipe, dec->ves_eb[i]);
 
       if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
@@ -515,29 +513,11 @@ vl_mpeg12_decoder_clear_buffer(struct pipe_video_decode_buffer *buffer)
 static bool
 init_pipe_state(struct vl_mpeg12_decoder *dec)
 {
-   struct pipe_blend_state blend;
    struct pipe_depth_stencil_alpha_state dsa;
    unsigned i;
 
    assert(dec);
 
-   memset(&blend, 0, sizeof blend);
-
-   blend.independent_blend_enable = 0;
-   blend.rt[0].blend_enable = 0;
-   blend.rt[0].rgb_func = PIPE_BLEND_ADD;
-   blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
-   blend.rt[0].alpha_func = PIPE_BLEND_ADD;
-   blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
-   blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
-   blend.logicop_enable = 0;
-   blend.logicop_func = PIPE_LOGICOP_CLEAR;
-   /* Needed to allow color writes to FB, even if blending disabled */
-   blend.rt[0].colormask = PIPE_MASK_RGBA;
-   blend.dither = 0;
-   dec->blend = dec->pipe->create_blend_state(dec->pipe, &blend);
-
    memset(&dsa, 0, sizeof dsa);
    dsa.depth.enabled = 0;
    dsa.depth.writemask = 0;
index 4d494b0bd2aedc58141f1b8f7aa47e8fd36e0592..ffb9e56a13c2d1ba46feecd439379e788009bc9b 100644 (file)
@@ -59,7 +59,6 @@ struct vl_mpeg12_decoder
    struct vl_mc mc_y, mc_c;
 
    void *dsa;
-   void *blend;
 };
 
 struct vl_mpeg12_buffer