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,47 +125,29 @@ create_vert_shader(struct vl_compositor *c) return ureg_create_shader_and_destroy(shader, c->pipe); } -static void * -create_frag_shader_video_buffer(struct vl_compositor *c) +static void +create_frag_shader_csc(struct ureg_program *shader, struct ureg_dst texel, + struct ureg_dst fragment) { - 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); - if (!shader) - return false; - - tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX, TGSI_INTERPOLATE_LINEAR); - for (i = 0; i < 3; ++i) { + for (i = 0; i < 3; ++i) csc[i] = ureg_DECL_constant(shader, i); - sampler[i] = ureg_DECL_sampler(shader, i); - } + + lumakey = ureg_DECL_constant(shader, 3); 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); - - /* - * texel.xyz = tex(tc, sampler[i]) - * fragment = csc * texel - */ - 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)); + 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_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)); @@ -178,6 +160,37 @@ create_frag_shader_video_buffer(struct vl_compositor *c) 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 sampler[3]; + struct ureg_dst texel; + struct ureg_dst fragment; + unsigned i; + + shader = ureg_create(PIPE_SHADER_FRAGMENT); + if (!shader) + return false; + + tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX, TGSI_INTERPOLATE_LINEAR); + for (i = 0; i < 3; ++i) + sampler[i] = ureg_DECL_sampler(shader, i); + + texel = ureg_DECL_temporary(shader); + fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0); + + /* + * texel.xyz = tex(tc, sampler[i]) + * fragment = csc * texel + */ + for (i = 0; i < 3; ++i) + ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), TGSI_TEXTURE_2D_ARRAY, tc, sampler[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]);