[g3dvl] add blend state to compositor
authorChristian König <deathsimple@vodafone.de>
Sat, 26 Mar 2011 01:03:16 +0000 (02:03 +0100)
committerChristian König <deathsimple@vodafone.de>
Sat, 26 Mar 2011 01:03:16 +0000 (02:03 +0100)
This seems to get at least mplayer working

src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_compositor.h
src/gallium/auxiliary/vl/vl_mpeg12_context.c

index 673f9bdecd2c4cb98a370202641e837553c3b396..b1adef9970016f7092dcc368df23023c29e9aa9f 100644 (file)
@@ -126,8 +126,9 @@ create_frag_shader_ycbcr_2_rgb(struct vl_compositor *c)
     * fragment = csc * texel
     */
    ureg_TEX(shader, texel, TGSI_TEXTURE_2D, tc, sampler);
-   for (i = 0; i < 4; ++i)
+   for (i = 0; i < 3; ++i)
       ureg_DP4(shader, ureg_writemask(fragment, TGSI_WRITEMASK_X << i), csc[i], ureg_src(texel));
+   ureg_MOV(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f));
 
    ureg_release_temporary(shader, texel);
    ureg_END(shader);
@@ -172,6 +173,7 @@ static bool
 init_pipe_state(struct vl_compositor *c)
 {
    struct pipe_sampler_state sampler;
+   struct pipe_blend_state blend;
 
    assert(c);
 
@@ -195,6 +197,21 @@ init_pipe_state(struct vl_compositor *c)
    /*sampler.max_anisotropy = ;*/
    c->sampler = c->pipe->create_sampler_state(c->pipe, &sampler);
 
+   memset(&blend, 0, sizeof blend);
+   blend.independent_blend_enable = 0;
+   blend.rt[0].blend_enable = 1;
+   blend.rt[0].rgb_func = PIPE_BLEND_ADD;
+   blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA;
+   blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
+   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;
+   blend.rt[0].colormask = PIPE_MASK_RGBA;
+   blend.dither = 0;
+   c->blend = c->pipe->create_blend_state(c->pipe, &blend);
+
    return true;
 }
 
@@ -203,6 +220,7 @@ static void cleanup_pipe_state(struct vl_compositor *c)
    assert(c);
 
    c->pipe->delete_sampler_state(c->pipe, c->sampler);
+   c->pipe->delete_blend_state(c->pipe, c->blend);
 }
 
 static bool
@@ -476,6 +494,7 @@ static void draw_layers(struct vl_compositor *c,
 
    num_rects = gen_data(c, src_surface, src_rect, dst_rect, src_surfaces, frag_shaders);
 
+   c->pipe->bind_blend_state(c->pipe, c->blend);
    for (i = 0; i < num_rects; ++i) {
       c->pipe->bind_fs_state(c->pipe, frag_shaders[i]);
       c->pipe->set_fragment_sampler_views(c->pipe, 1, &src_surfaces[i]);
index 59e60ac69f327472fd2fae86985bcda90078f474..aa1e480ed4c92d72d618cfe4e0340ea537a41d56 100644 (file)
@@ -45,6 +45,7 @@ struct vl_compositor
    struct pipe_framebuffer_state fb_state;
    struct vertex2f fb_inv_size;
    void *sampler;
+   void *blend;
    struct pipe_sampler_view *sampler_view;
    void *vertex_shader;
    struct
index af1079e480bac6586ce633df3cf0efbc5f2aacc8..6d4a7713068c22693a22c8540a701253948600d2 100644 (file)
@@ -179,6 +179,7 @@ vl_mpeg12_buffer_flush(struct pipe_video_buffer *buffer,
 
    ctx->pipe->set_vertex_buffers(ctx->pipe, 2, buf->vertex_bufs.all);
    ctx->pipe->bind_vertex_elements_state(ctx->pipe, ctx->vertex_elems_state);
+   ctx->pipe->bind_blend_state(ctx->pipe, ctx->blend);
    vl_idct_flush(&ctx->idct_y, &buf->idct_y, ne_num);
    vl_idct_flush(&ctx->idct_cr, &buf->idct_cr, ne_num);
    vl_idct_flush(&ctx->idct_cb, &buf->idct_cb, ne_num);
@@ -543,7 +544,6 @@ init_pipe_state(struct vl_mpeg12_context *ctx)
    blend.rt[0].colormask = PIPE_MASK_RGBA;
    blend.dither = 0;
    ctx->blend = ctx->pipe->create_blend_state(ctx->pipe, &blend);
-   ctx->pipe->bind_blend_state(ctx->pipe, ctx->blend);
 
    memset(&dsa, 0, sizeof dsa);
    dsa.depth.enabled = 0;