summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian König <[email protected]>2011-03-26 02:03:16 +0100
committerChristian König <[email protected]>2011-03-26 02:03:16 +0100
commitc001c393713f36144701f3a61b6c7de7811898ee (patch)
tree53320d748e54f3719f9b3c89007494ff18bfeb9b
parentadbc9cee0ddf5a542d3e503db673af30e6d8df5b (diff)
[g3dvl] add blend state to compositor
This seems to get at least mplayer working
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.c21
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.h1
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_context.c2
3 files changed, 22 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index 673f9bdecd2..b1adef99700 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -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]);
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
index 59e60ac69f3..aa1e480ed4c 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ b/src/gallium/auxiliary/vl/vl_compositor.h
@@ -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
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_context.c b/src/gallium/auxiliary/vl/vl_mpeg12_context.c
index af1079e480b..6d4a7713068 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_context.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_context.c
@@ -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;