return ureg_create_shader_and_destroy(shader, c->pipe);
}
+static void
+create_frag_shader_weave(struct ureg_program *shader, struct ureg_dst fragment)
+{
+ struct ureg_src i_tc[2];
+ struct ureg_src sampler[3];
+ struct ureg_dst t_tc[2];
+ struct ureg_dst t_texel[2];
+ unsigned i, j;
+
+ 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)
+ sampler[i] = ureg_DECL_sampler(shader, i);
+
+ for (i = 0; i < 2; ++i) {
+ t_tc[i] = ureg_DECL_temporary(shader);
+ t_texel[i] = ureg_DECL_temporary(shader);
+ }
+
+ /* calculate the texture offsets
+ * t_tc.x = i_tc.x
+ * t_tc.y = (round(i_tc.y - 0.5) + 0.5) / height * 2
+ */
+ for (i = 0; i < 2; ++i) {
+ ureg_MOV(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_X), i_tc[i]);
+ ureg_SUB(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_YZ),
+ i_tc[i], ureg_imm1f(shader, 0.5f));
+ ureg_ROUND(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_YZ), ureg_src(t_tc[i]));
+ ureg_MOV(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_W),
+ ureg_imm1f(shader, i ? 1.0f : 0.0f));
+ ureg_ADD(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_YZ),
+ ureg_src(t_tc[i]), ureg_imm1f(shader, 0.5f));
+ ureg_MUL(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_Y),
+ ureg_src(t_tc[i]), ureg_scalar(i_tc[0], TGSI_SWIZZLE_W));
+ ureg_MUL(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_Z),
+ ureg_src(t_tc[i]), ureg_scalar(i_tc[1], TGSI_SWIZZLE_W));
+ }
+
+ /* fetch the texels
+ * texel[0..1].x = tex(t_tc[0..1][0])
+ * texel[0..1].y = tex(t_tc[0..1][1])
+ * texel[0..1].z = tex(t_tc[0..1][2])
+ */
+ for (i = 0; i < 2; ++i)
+ for (j = 0; j < 3; ++j) {
+ struct ureg_src src = ureg_swizzle(ureg_src(t_tc[i]),
+ TGSI_SWIZZLE_X, j ? TGSI_SWIZZLE_Z : TGSI_SWIZZLE_Y, TGSI_SWIZZLE_W, TGSI_SWIZZLE_W);
+
+ ureg_TEX(shader, ureg_writemask(t_texel[i], TGSI_WRITEMASK_X << j),
+ TGSI_TEXTURE_2D_ARRAY, src, sampler[j]);
+ }
+
+ /* calculate linear interpolation factor
+ * factor = |round(i_tc.y) - i_tc.y| * 2
+ */
+ ureg_ROUND(shader, ureg_writemask(t_tc[0], TGSI_WRITEMASK_YZ), i_tc[0]);
+ ureg_ADD(shader, ureg_writemask(t_tc[0], TGSI_WRITEMASK_YZ),
+ ureg_src(t_tc[0]), ureg_negate(i_tc[0]));
+ ureg_MUL(shader, ureg_writemask(t_tc[0], TGSI_WRITEMASK_YZ),
+ ureg_abs(ureg_src(t_tc[0])), ureg_imm1f(shader, 2.0f));
+ ureg_LRP(shader, fragment, ureg_swizzle(ureg_src(t_tc[0]),
+ TGSI_SWIZZLE_Y, TGSI_SWIZZLE_Z, TGSI_SWIZZLE_Z, TGSI_SWIZZLE_Z),
+ ureg_src(t_texel[0]), ureg_src(t_texel[1]));
+
+ for (i = 0; i < 2; ++i) {
+ ureg_release_temporary(shader, t_texel[i]);
+ ureg_release_temporary(shader, t_tc[i]);
+ }
+}
+
static void
create_frag_shader_csc(struct ureg_program *shader, struct ureg_dst texel,
struct ureg_dst fragment)
}
static void *
-create_frag_shader_weave(struct vl_compositor *c)
+create_frag_shader_weave_rgb(struct vl_compositor *c)
{
struct ureg_program *shader;
- struct ureg_src i_tc[2];
- struct ureg_src sampler[3];
- struct ureg_dst t_tc[2];
- struct ureg_dst t_texel[2];
- struct ureg_dst o_fragment;
- unsigned i, j;
+ struct ureg_dst texel, fragment;
shader = ureg_create(PIPE_SHADER_FRAGMENT);
if (!shader)
return false;
- 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)
- sampler[i] = ureg_DECL_sampler(shader, i);
-
- for (i = 0; i < 2; ++i) {
- t_tc[i] = ureg_DECL_temporary(shader);
- t_texel[i] = ureg_DECL_temporary(shader);
- }
- o_fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
-
- /* calculate the texture offsets
- * t_tc.x = i_tc.x
- * t_tc.y = (round(i_tc.y - 0.5) + 0.5) / height * 2
- */
- for (i = 0; i < 2; ++i) {
- ureg_MOV(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_X), i_tc[i]);
- ureg_SUB(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_YZ),
- i_tc[i], ureg_imm1f(shader, 0.5f));
- ureg_ROUND(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_YZ), ureg_src(t_tc[i]));
- ureg_MOV(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_W),
- ureg_imm1f(shader, i ? 1.0f : 0.0f));
- ureg_ADD(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_YZ),
- ureg_src(t_tc[i]), ureg_imm1f(shader, 0.5f));
- ureg_MUL(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_Y),
- ureg_src(t_tc[i]), ureg_scalar(i_tc[0], TGSI_SWIZZLE_W));
- ureg_MUL(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_Z),
- ureg_src(t_tc[i]), ureg_scalar(i_tc[1], TGSI_SWIZZLE_W));
- }
-
- /* fetch the texels
- * texel[0..1].x = tex(t_tc[0..1][0])
- * texel[0..1].y = tex(t_tc[0..1][1])
- * texel[0..1].z = tex(t_tc[0..1][2])
- */
- for (i = 0; i < 2; ++i)
- for (j = 0; j < 3; ++j) {
- struct ureg_src src = ureg_swizzle(ureg_src(t_tc[i]),
- TGSI_SWIZZLE_X, j ? TGSI_SWIZZLE_Z : TGSI_SWIZZLE_Y, TGSI_SWIZZLE_W, TGSI_SWIZZLE_W);
-
- ureg_TEX(shader, ureg_writemask(t_texel[i], TGSI_WRITEMASK_X << j),
- TGSI_TEXTURE_2D_ARRAY, src, sampler[j]);
- }
-
- /* calculate linear interpolation factor
- * factor = |round(i_tc.y) - i_tc.y| * 2
- */
- ureg_ROUND(shader, ureg_writemask(t_tc[0], TGSI_WRITEMASK_YZ), i_tc[0]);
- ureg_ADD(shader, ureg_writemask(t_tc[0], TGSI_WRITEMASK_YZ),
- ureg_src(t_tc[0]), ureg_negate(i_tc[0]));
- ureg_MUL(shader, ureg_writemask(t_tc[0], TGSI_WRITEMASK_YZ),
- ureg_abs(ureg_src(t_tc[0])), ureg_imm1f(shader, 2.0f));
- ureg_LRP(shader, t_texel[0], ureg_swizzle(ureg_src(t_tc[0]),
- TGSI_SWIZZLE_Y, TGSI_SWIZZLE_Z, TGSI_SWIZZLE_Z, TGSI_SWIZZLE_Z),
- ureg_src(t_texel[0]), ureg_src(t_texel[1]));
+ texel = ureg_DECL_temporary(shader);
+ fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
- /* and finally do colour space transformation
- * fragment = csc * texel
- */
- create_frag_shader_csc(shader, t_texel[0], o_fragment);
+ create_frag_shader_weave(shader, texel);
+ create_frag_shader_csc(shader, texel, fragment);
- for (i = 0; i < 2; ++i) {
- ureg_release_temporary(shader, t_texel[i]);
- ureg_release_temporary(shader, t_tc[i]);
- }
+ ureg_release_temporary(shader, texel);
ureg_END(shader);
return false;
}
- c->fs_weave = create_frag_shader_weave(c);
- if (!c->fs_weave) {
+ c->fs_weave_rgb = create_frag_shader_weave_rgb(c);
+ if (!c->fs_weave_rgb) {
debug_printf("Unable to create YCbCr-to-RGB weave fragment shader.\n");
return false;
}
c->pipe->delete_vs_state(c->pipe, c->vs);
c->pipe->delete_fs_state(c->pipe, c->fs_video_buffer);
- c->pipe->delete_fs_state(c->pipe, c->fs_weave);
+ c->pipe->delete_fs_state(c->pipe, c->fs_weave_rgb);
c->pipe->delete_fs_state(c->pipe, c->fs_palette.yuv);
c->pipe->delete_fs_state(c->pipe, c->fs_palette.rgb);
c->pipe->delete_fs_state(c->pipe, c->fs_rgba);
float half_a_line = 0.5f / s->layers[layer].zw.y;
switch(deinterlace) {
case VL_COMPOSITOR_WEAVE:
- s->layers[layer].fs = c->fs_weave;
+ s->layers[layer].fs = c->fs_weave_rgb;
break;
case VL_COMPOSITOR_BOB_TOP: