diff options
author | Leo Liu <[email protected]> | 2016-07-04 15:59:00 -0400 |
---|---|---|
committer | Leo Liu <[email protected]> | 2016-07-12 09:27:53 -0400 |
commit | 2e18c2c6f86342e7ea77b0f1a1f731f879db0ed3 (patch) | |
tree | 856294845a414bf6a72e13aeea0c4fd5f8567936 /src/gallium | |
parent | ead7736821633bbbd8ae743a49d2ee87ebef0763 (diff) |
vl/compositor: move weave shader out from rgb weaving
We'll use weave shader in the later patch.
Signed-off-by: Leo Liu <[email protected]>
Acked-by: Christian König <[email protected]>
Tested-by: Julien Isorce <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/vl/vl_compositor.c | 157 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_compositor.h | 2 |
2 files changed, 83 insertions, 76 deletions
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index 77fc92ecd66..275022bd349 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -126,6 +126,77 @@ create_vert_shader(struct vl_compositor *c) } 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) { @@ -199,86 +270,22 @@ create_frag_shader_video_buffer(struct vl_compositor *c) } 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); @@ -378,8 +385,8 @@ init_shaders(struct vl_compositor *c) 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; } @@ -411,7 +418,7 @@ static void cleanup_shaders(struct vl_compositor *c) 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); @@ -971,7 +978,7 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s, 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: diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h index 12976fc95a1..3f81bc91176 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.h +++ b/src/gallium/auxiliary/vl/vl_compositor.h @@ -113,7 +113,7 @@ struct vl_compositor void *vs; void *fs_video_buffer; - void *fs_weave; + void *fs_weave_rgb; void *fs_rgba; struct { |