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);
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);
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);
{
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];
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);
/* 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]);