diff options
author | Christian König <[email protected]> | 2016-06-09 14:43:10 +0200 |
---|---|---|
committer | Christian König <[email protected]> | 2016-06-16 09:41:12 +0200 |
commit | bf89e672cff432a5e2ace72c0fb73eb8f120ff7a (patch) | |
tree | a5309005c6b9cab8011a8cb74e48d5cb50dba525 /src | |
parent | 456b5d9ac96c6147e7326d828ff7f4a508ffb9df (diff) |
vl: support luma keying for interlaced surfaces as well
We had the CSC code twice in there, factor it out into a separate function.
Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/vl/vl_compositor.c | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index 1a383f29425..77fc92ecd66 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -125,17 +125,51 @@ create_vert_shader(struct vl_compositor *c) return ureg_create_shader_and_destroy(shader, c->pipe); } +static void +create_frag_shader_csc(struct ureg_program *shader, struct ureg_dst texel, + struct ureg_dst fragment) +{ + struct ureg_src csc[3]; + struct ureg_src lumakey; + struct ureg_dst temp[2]; + unsigned i; + + for (i = 0; i < 3; ++i) + csc[i] = ureg_DECL_constant(shader, i); + + lumakey = ureg_DECL_constant(shader, 3); + + for (i = 0; i < 2; ++i) + temp[i] = ureg_DECL_temporary(shader); + + ureg_MOV(shader, ureg_writemask(texel, TGSI_WRITEMASK_W), + ureg_imm1f(shader, 1.0f)); + + 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(temp[0], TGSI_WRITEMASK_W), + ureg_scalar(ureg_src(texel), TGSI_SWIZZLE_Z)); + ureg_SLE(shader, ureg_writemask(temp[1],TGSI_WRITEMASK_W), + ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_X)); + ureg_SGT(shader, ureg_writemask(temp[0],TGSI_WRITEMASK_W), + ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_Y)); + ureg_MAX(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W), + ureg_src(temp[0]), ureg_src(temp[1])); + + for (i = 0; i < 2; ++i) + ureg_release_temporary(shader, temp[i]); +} + static void * create_frag_shader_video_buffer(struct vl_compositor *c) { struct ureg_program *shader; struct ureg_src tc; - struct ureg_src csc[3]; struct ureg_src sampler[3]; - struct ureg_src lumakey; struct ureg_dst texel; struct ureg_dst fragment; - struct ureg_dst temp[2]; unsigned i; shader = ureg_create(PIPE_SHADER_FRAGMENT); @@ -143,15 +177,9 @@ create_frag_shader_video_buffer(struct vl_compositor *c) return false; tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX, TGSI_INTERPOLATE_LINEAR); - for (i = 0; i < 3; ++i) { - csc[i] = ureg_DECL_constant(shader, i); + for (i = 0; i < 3; ++i) sampler[i] = ureg_DECL_sampler(shader, i); - } - - for (i = 0; i < 2; ++i) - temp[i] = ureg_DECL_temporary(shader); - lumakey = ureg_DECL_constant(shader, 3); texel = ureg_DECL_temporary(shader); fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0); @@ -162,22 +190,7 @@ create_frag_shader_video_buffer(struct vl_compositor *c) for (i = 0; i < 3; ++i) ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), TGSI_TEXTURE_2D_ARRAY, tc, sampler[i]); - ureg_MOV(shader, ureg_writemask(texel, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f)); - - 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(temp[0], TGSI_WRITEMASK_W), - ureg_scalar(ureg_src(texel), TGSI_SWIZZLE_Z)); - ureg_SLE(shader, ureg_writemask(temp[1],TGSI_WRITEMASK_W), - ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_X)); - ureg_SGT(shader, ureg_writemask(temp[0],TGSI_WRITEMASK_W), - ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_Y)); - ureg_MAX(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W), - ureg_src(temp[0]), ureg_src(temp[1])); - - for (i = 0; i < 2; ++i) - ureg_release_temporary(shader, temp[i]); + create_frag_shader_csc(shader, texel, fragment); ureg_release_temporary(shader, texel); ureg_END(shader); @@ -190,7 +203,6 @@ create_frag_shader_weave(struct vl_compositor *c) { struct ureg_program *shader; struct ureg_src i_tc[2]; - struct ureg_src csc[3]; struct ureg_src sampler[3]; struct ureg_dst t_tc[2]; struct ureg_dst t_texel[2]; @@ -204,10 +216,8 @@ create_frag_shader_weave(struct vl_compositor *c) i_tc[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTOP, TGSI_INTERPOLATE_LINEAR); i_tc[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VBOTTOM, TGSI_INTERPOLATE_LINEAR); - for (i = 0; i < 3; ++i) { - csc[i] = ureg_DECL_constant(shader, i); + for (i = 0; i < 3; ++i) sampler[i] = ureg_DECL_sampler(shader, i); - } for (i = 0; i < 2; ++i) { t_tc[i] = ureg_DECL_temporary(shader); @@ -263,11 +273,7 @@ create_frag_shader_weave(struct vl_compositor *c) /* and finally do colour space transformation * fragment = csc * texel */ - ureg_MOV(shader, ureg_writemask(t_texel[0], TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f)); - for (i = 0; i < 3; ++i) - ureg_DP4(shader, ureg_writemask(o_fragment, TGSI_WRITEMASK_X << i), csc[i], ureg_src(t_texel[0])); - - ureg_MOV(shader, ureg_writemask(o_fragment, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f)); + create_frag_shader_csc(shader, t_texel[0], o_fragment); for (i = 0; i < 2; ++i) { ureg_release_temporary(shader, t_texel[i]); |