summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/vl
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2017-08-26 16:59:42 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2017-08-26 16:59:42 +0000
commit81ece42815e80818f160cdd85fab57d65b56ad15 (patch)
tree1059ff094da1aa50334115952fcb1cfcbda3acc6 /lib/mesa/src/gallium/auxiliary/vl
parentb0244145d5bb49623d58f6b5cab8143ada692b60 (diff)
Revert to Mesa 13.0.6 to hopefully address rendering issues a handful of
people have reported with xpdf/fvwm on ivy bridge with modesetting driver.
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/vl')
-rw-r--r--lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c273
-rw-r--r--lib/mesa/src/gallium/auxiliary/vl/vl_compositor.h23
-rw-r--r--lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c84
-rw-r--r--lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c6
-rw-r--r--lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c11
-rw-r--r--lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c36
-rw-r--r--lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h40
-rw-r--r--lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c116
-rw-r--r--lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c18
-rw-r--r--lib/mesa/src/gallium/auxiliary/vl/vl_zscan.h1
10 files changed, 405 insertions, 203 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c b/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c
index afe53063b..03a0a6453 100644
--- a/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c
@@ -62,7 +62,7 @@ create_vert_shader(struct vl_compositor *c)
struct ureg_dst o_vpos, o_vtex, o_color;
struct ureg_dst o_vtop, o_vbottom;
- shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+ shader = ureg_create(PIPE_SHADER_VERTEX);
if (!shader)
return false;
@@ -125,78 +125,25 @@ 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)
-{
- struct ureg_program *shader;
- struct ureg_src tc;
- struct ureg_src csc[3];
- struct ureg_src sampler[3];
- struct ureg_dst texel;
- struct ureg_dst fragment;
- unsigned i;
-
- shader = ureg_create(TGSI_PROCESSOR_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) {
- csc[i] = ureg_DECL_constant(shader, 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]);
-
- 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(fragment, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f));
-
- ureg_release_temporary(shader, texel);
- ureg_END(shader);
-
- return ureg_create_shader_and_destroy(shader, c->pipe);
-}
-
-static void *
-create_frag_shader_weave(struct vl_compositor *c)
+static void
+create_frag_shader_weave(struct ureg_program *shader, struct ureg_dst fragment)
{
- 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];
- struct ureg_dst o_fragment;
unsigned i, j;
- shader = ureg_create(TGSI_PROCESSOR_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) {
- 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);
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
@@ -239,23 +186,135 @@ create_frag_shader_weave(struct vl_compositor *c)
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]),
+ 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]));
- /* and finally do colour space transformation
+ 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)
+{
+ 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 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
*/
- 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_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), TGSI_TEXTURE_2D_ARRAY, tc, sampler[i]);
- ureg_MOV(shader, ureg_writemask(o_fragment, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f));
+ 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 ureg_create_shader_and_destroy(shader, c->pipe);
+}
+
+static void *
+create_frag_shader_weave_rgb(struct vl_compositor *c)
+{
+ struct ureg_program *shader;
+ struct ureg_dst texel, fragment;
+
+ shader = ureg_create(PIPE_SHADER_FRAGMENT);
+ if (!shader)
+ return false;
+
+ texel = ureg_DECL_temporary(shader);
+ fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
+
+ create_frag_shader_weave(shader, texel);
+ create_frag_shader_csc(shader, texel, fragment);
+
+ ureg_release_temporary(shader, texel);
+
+ ureg_END(shader);
+
+ return ureg_create_shader_and_destroy(shader, c->pipe);
+}
+
+static void *
+create_frag_shader_weave_yuv(struct vl_compositor *c, bool y)
+{
+ struct ureg_program *shader;
+ struct ureg_dst texel, fragment;
+
+ shader = ureg_create(PIPE_SHADER_FRAGMENT);
+ if (!shader)
+ return false;
+
+ texel = ureg_DECL_temporary(shader);
+ fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
+
+ create_frag_shader_weave(shader, texel);
+
+ if (y)
+ ureg_MOV(shader, ureg_writemask(fragment, TGSI_WRITEMASK_X), ureg_src(texel));
+ else
+ ureg_MOV(shader, ureg_writemask(fragment, TGSI_WRITEMASK_XY),
+ ureg_swizzle(ureg_src(texel), TGSI_SWIZZLE_Y,
+ TGSI_SWIZZLE_Z, TGSI_SWIZZLE_W, TGSI_SWIZZLE_W));
+
+ ureg_release_temporary(shader, texel);
ureg_END(shader);
@@ -274,7 +333,7 @@ create_frag_shader_palette(struct vl_compositor *c, bool include_cc)
struct ureg_dst fragment;
unsigned i;
- shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+ shader = ureg_create(PIPE_SHADER_FRAGMENT);
if (!shader)
return false;
@@ -318,7 +377,7 @@ create_frag_shader_rgba(struct vl_compositor *c)
struct ureg_src tc, color, sampler;
struct ureg_dst texel, fragment;
- shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+ shader = ureg_create(PIPE_SHADER_FRAGMENT);
if (!shader)
return false;
@@ -355,12 +414,19 @@ 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;
}
+ c->fs_weave_yuv.y = create_frag_shader_weave_yuv(c, true);
+ c->fs_weave_yuv.uv = create_frag_shader_weave_yuv(c, false);
+ if (!c->fs_weave_yuv.y || !c->fs_weave_yuv.uv) {
+ debug_printf("Unable to create YCbCr i-to-YCbCr p weave fragment shader.\n");
+ return false;
+ }
+
c->fs_palette.yuv = create_frag_shader_palette(c, true);
if (!c->fs_palette.yuv) {
debug_printf("Unable to create YUV-Palette-to-RGB fragment shader.\n");
@@ -388,7 +454,9 @@ 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_weave_yuv.y);
+ c->pipe->delete_fs_state(c->pipe, c->fs_weave_yuv.uv);
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);
@@ -716,6 +784,7 @@ gen_vertex_data(struct vl_compositor *c, struct vl_compositor_state *s, struct u
/* Allocate new memory for vertices. */
u_upload_alloc(c->upload, 0,
c->vertex_buf.stride * VL_COMPOSITOR_MAX_LAYERS * 4, /* size */
+ 4, /* alignment */
&c->vertex_buf.buffer_offset, &c->vertex_buf.buffer,
(void**)&vb);
@@ -851,20 +920,23 @@ vl_compositor_cleanup(struct vl_compositor *c)
}
void
-vl_compositor_set_csc_matrix(struct vl_compositor_state *s, vl_csc_matrix const *matrix)
+vl_compositor_set_csc_matrix(struct vl_compositor_state *s,
+ vl_csc_matrix const *matrix,
+ float luma_min, float luma_max)
{
struct pipe_transfer *buf_transfer;
assert(s);
- memcpy
- (
- pipe_buffer_map(s->pipe, s->csc_matrix,
- PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- &buf_transfer),
- matrix,
- sizeof(vl_csc_matrix)
- );
+ float *ptr = pipe_buffer_map(s->pipe, s->csc_matrix,
+ PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
+ &buf_transfer);
+
+ memcpy(ptr, matrix, sizeof(vl_csc_matrix));
+
+ ptr += sizeof(vl_csc_matrix)/sizeof(float);
+ ptr[0] = luma_min;
+ ptr[1] = luma_max;
pipe_buffer_unmap(s->pipe, buf_transfer);
}
@@ -944,7 +1016,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:
@@ -1039,6 +1111,36 @@ vl_compositor_set_layer_rotation(struct vl_compositor_state *s,
}
void
+vl_compositor_set_yuv_layer(struct vl_compositor_state *s,
+ struct vl_compositor *c,
+ unsigned layer,
+ struct pipe_video_buffer *buffer,
+ struct u_rect *src_rect,
+ struct u_rect *dst_rect,
+ bool y)
+{
+ struct pipe_sampler_view **sampler_views;
+ unsigned i;
+
+ assert(s && c && buffer);
+
+ assert(layer < VL_COMPOSITOR_MAX_LAYERS);
+
+ s->used_layers |= 1 << layer;
+ sampler_views = buffer->get_sampler_view_components(buffer);
+ for (i = 0; i < 3; ++i) {
+ s->layers[layer].samplers[i] = c->sampler_linear;
+ pipe_sampler_view_reference(&s->layers[layer].sampler_views[i], sampler_views[i]);
+ }
+
+ calc_src_and_dst(&s->layers[layer], buffer->width, buffer->height,
+ src_rect ? *src_rect : default_rect(&s->layers[layer]),
+ dst_rect ? *dst_rect : default_rect(&s->layers[layer]));
+
+ s->layers[layer].fs = (y) ? c->fs_weave_yuv.y : c->fs_weave_yuv.uv;
+}
+
+void
vl_compositor_render(struct vl_compositor_state *s,
struct vl_compositor *c,
struct pipe_surface *dst_surface,
@@ -1066,7 +1168,7 @@ vl_compositor_render(struct vl_compositor_state *s,
(dirty_area->x0 < dirty_area->x1 || dirty_area->y0 < dirty_area->y1)) {
c->pipe->clear_render_target(c->pipe, dst_surface, &s->clear_color,
- 0, 0, dst_surface->width, dst_surface->height);
+ 0, 0, dst_surface->width, dst_surface->height, false);
dirty_area->x0 = dirty_area->y0 = MAX_DIRTY;
dirty_area->x1 = dirty_area->y1 = MIN_DIRTY;
}
@@ -1090,7 +1192,8 @@ vl_compositor_init(struct vl_compositor *c, struct pipe_context *pipe)
c->pipe = pipe;
- c->upload = u_upload_create(pipe, 128 * 1024, 4, PIPE_BIND_VERTEX_BUFFER);
+ c->upload = u_upload_create(pipe, 128 * 1024, PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STREAM);
if (!c->upload)
return false;
@@ -1140,13 +1243,13 @@ vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pip
pipe->screen,
PIPE_BIND_CONSTANT_BUFFER,
PIPE_USAGE_DEFAULT,
- sizeof(csc_matrix)
+ sizeof(csc_matrix) + 2*sizeof(float)
);
vl_compositor_clear_layers(s);
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, &csc_matrix);
- vl_compositor_set_csc_matrix(s, (const vl_csc_matrix *)&csc_matrix);
+ vl_compositor_set_csc_matrix(s, (const vl_csc_matrix *)&csc_matrix, 1.0f, 0.0f);
return true;
}
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.h b/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.h
index 934b634b3..ceab5e004 100644
--- a/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.h
+++ b/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.h
@@ -113,10 +113,15 @@ struct vl_compositor
void *vs;
void *fs_video_buffer;
- void *fs_weave;
+ void *fs_weave_rgb;
void *fs_rgba;
struct {
+ void *y;
+ void *uv;
+ } fs_weave_yuv;
+
+ struct {
void *rgb;
void *yuv;
} fs_palette;
@@ -138,7 +143,9 @@ vl_compositor_init_state(struct vl_compositor_state *state, struct pipe_context
* set yuv -> rgba conversion matrix
*/
void
-vl_compositor_set_csc_matrix(struct vl_compositor_state *settings, const vl_csc_matrix *matrix);
+vl_compositor_set_csc_matrix(struct vl_compositor_state *settings,
+ const vl_csc_matrix *matrix,
+ float luma_min, float luma_max);
/**
* reset dirty area, so it's cleared with the clear colour
@@ -234,6 +241,18 @@ vl_compositor_set_layer_rotation(struct vl_compositor_state *state,
unsigned layer,
enum vl_compositor_rotation rotate);
+/**
+ * set a layer of y or uv to render
+ */
+void
+vl_compositor_set_yuv_layer(struct vl_compositor_state *s,
+ struct vl_compositor *c,
+ unsigned layer,
+ struct pipe_video_buffer *buffer,
+ struct u_rect *src_rect,
+ struct u_rect *dst_rect,
+ bool y);
+
/*@}*/
/**
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c b/lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c
index 8fa70e84c..3ca3b4954 100644
--- a/lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c
+++ b/lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c
@@ -47,6 +47,7 @@
#include "util/u_draw.h"
#include "util/u_memory.h"
#include "util/u_math.h"
+#include "util/u_format.h"
#include "vl_types.h"
#include "vl_video_buffer.h"
@@ -66,7 +67,7 @@ create_vert_shader(struct vl_deint_filter *filter)
struct ureg_src i_vpos;
struct ureg_dst o_vpos, o_vtex;
- shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+ shader = ureg_create(PIPE_SHADER_VERTEX);
if (!shader)
return NULL;
@@ -91,7 +92,7 @@ create_copy_frag_shader(struct vl_deint_filter *filter, unsigned field)
struct ureg_dst o_fragment;
struct ureg_dst t_tex;
- shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+ shader = ureg_create(PIPE_SHADER_FRAGMENT);
if (!shader) {
return NULL;
}
@@ -135,7 +136,7 @@ create_deint_frag_shader(struct vl_deint_filter *filter, unsigned field,
struct ureg_dst t_a, t_b;
struct ureg_dst t_weave, t_linear;
- shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+ shader = ureg_create(PIPE_SHADER_FRAGMENT);
if (!shader) {
return NULL;
}
@@ -214,8 +215,9 @@ create_deint_frag_shader(struct vl_deint_filter *filter, unsigned field,
ureg_imm4f(shader, -0.02353f, 0, 0, 0));
ureg_MUL(shader, ureg_saturate(ureg_writemask(t_diff, TGSI_WRITEMASK_X)),
ureg_src(t_diff), ureg_imm4f(shader, 31.8750f, 0, 0, 0));
- ureg_LRP(shader, ureg_writemask(o_fragment, TGSI_WRITEMASK_X), ureg_src(t_diff),
+ ureg_LRP(shader, ureg_writemask(t_tex, TGSI_WRITEMASK_X), ureg_src(t_diff),
ureg_src(t_linear), ureg_src(t_weave));
+ ureg_MOV(shader, o_fragment, ureg_scalar(ureg_src(t_tex), TGSI_SWIZZLE_X));
ureg_release_temporary(shader, t_tex);
ureg_release_temporary(shader, t_comp_top);
@@ -253,7 +255,13 @@ vl_deint_filter_init(struct vl_deint_filter *filter, struct pipe_context *pipe,
/* TODO: handle other than 4:2:0 subsampling */
memset(&templ, 0, sizeof(templ));
- templ.buffer_format = PIPE_FORMAT_YV12;
+ templ.buffer_format = pipe->screen->get_video_param
+ (
+ pipe->screen,
+ PIPE_VIDEO_PROFILE_UNKNOWN,
+ PIPE_VIDEO_ENTRYPOINT_UNKNOWN,
+ PIPE_VIDEO_CAP_PREFERED_FORMAT
+ );
templ.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
templ.width = video_width;
templ.height = video_height;
@@ -271,10 +279,20 @@ vl_deint_filter_init(struct vl_deint_filter *filter, struct pipe_context *pipe,
goto error_rs_state;
memset(&blend, 0, sizeof blend);
- blend.rt[0].colormask = PIPE_MASK_RGBA;
- filter->blend = pipe->create_blend_state(pipe, &blend);
- if (!filter->blend)
- goto error_blend;
+ blend.rt[0].colormask = PIPE_MASK_R;
+ filter->blend[0] = pipe->create_blend_state(pipe, &blend);
+ if (!filter->blend[0])
+ goto error_blendR;
+
+ blend.rt[0].colormask = PIPE_MASK_G;
+ filter->blend[1] = pipe->create_blend_state(pipe, &blend);
+ if (!filter->blend[1])
+ goto error_blendG;
+
+ blend.rt[0].colormask = PIPE_MASK_B;
+ filter->blend[2] = pipe->create_blend_state(pipe, &blend);
+ if (!filter->blend[2])
+ goto error_blendB;
memset(&sampler, 0, sizeof(sampler));
sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
@@ -349,9 +367,15 @@ error_quad:
pipe->delete_sampler_state(pipe, filter->sampler);
error_sampler:
- pipe->delete_blend_state(pipe, filter->blend);
+ pipe->delete_blend_state(pipe, filter->blend[2]);
+
+error_blendB:
+ pipe->delete_blend_state(pipe, filter->blend[1]);
+
+error_blendG:
+ pipe->delete_blend_state(pipe, filter->blend[0]);
-error_blend:
+error_blendR:
pipe->delete_rasterizer_state(pipe, filter->rs_state);
error_rs_state:
@@ -367,7 +391,9 @@ vl_deint_filter_cleanup(struct vl_deint_filter *filter)
assert(filter);
filter->pipe->delete_sampler_state(filter->pipe, filter->sampler[0]);
- filter->pipe->delete_blend_state(filter->pipe, filter->blend);
+ filter->pipe->delete_blend_state(filter->pipe, filter->blend[0]);
+ filter->pipe->delete_blend_state(filter->pipe, filter->blend[1]);
+ filter->pipe->delete_blend_state(filter->pipe, filter->blend[2]);
filter->pipe->delete_rasterizer_state(filter->pipe, filter->rs_state);
filter->pipe->delete_vertex_elements_state(filter->pipe, filter->ves);
pipe_resource_reference(&filter->quad.buffer, NULL);
@@ -420,12 +446,15 @@ vl_deint_filter_render(struct vl_deint_filter *filter,
struct pipe_sampler_view **next_sv;
struct pipe_sampler_view *sampler_views[4];
struct pipe_surface **dst_surfaces;
- int j;
+ const unsigned *plane_order;
+ int i;
+ unsigned j;
assert(filter && prevprev && prev && cur && next && field <= 1);
/* set up destination and source */
dst_surfaces = filter->video_buffer->get_surfaces(filter->video_buffer);
+ plane_order = vl_video_buffer_plane_order(filter->video_buffer->buffer_format);
cur_sv = cur->get_sampler_view_components(cur);
prevprev_sv = prevprev->get_sampler_view_components(prevprev);
prev_sv = prev->get_sampler_view_components(prev);
@@ -433,7 +462,6 @@ vl_deint_filter_render(struct vl_deint_filter *filter,
/* set up pipe state */
filter->pipe->bind_rasterizer_state(filter->pipe, filter->rs_state);
- filter->pipe->bind_blend_state(filter->pipe, filter->blend);
filter->pipe->set_vertex_buffers(filter->pipe, 0, 1, &filter->quad);
filter->pipe->bind_vertex_elements_state(filter->pipe, filter->ves);
filter->pipe->bind_vs_state(filter->pipe, filter->vs);
@@ -449,12 +477,13 @@ vl_deint_filter_render(struct vl_deint_filter *filter,
fb_state.nr_cbufs = 1;
/* process each plane separately */
- for (j = 0; j < 3; j++) {
- /* select correct YV12 surfaces */
- int k = j == 1 ? 2 :
- j == 2 ? 1 : 0;
- struct pipe_surface *blit_surf = dst_surfaces[2 * k + field];
- struct pipe_surface *dst_surf = dst_surfaces[2 * k + 1 - field];
+ for (i = 0, j = 0; i < VL_NUM_COMPONENTS; ++i) {
+ struct pipe_surface *blit_surf = dst_surfaces[field];
+ struct pipe_surface *dst_surf = dst_surfaces[1 - field];
+ int k = plane_order[i];
+
+ /* bind blend state for this component in the plane */
+ filter->pipe->bind_blend_state(filter->pipe, filter->blend[j]);
/* update render target state */
viewport.scale[0] = blit_surf->texture->width0;
@@ -463,10 +492,10 @@ vl_deint_filter_render(struct vl_deint_filter *filter,
fb_state.height = blit_surf->texture->height0;
/* update sampler view sources */
- sampler_views[0] = prevprev_sv[j];
- sampler_views[1] = prev_sv[j];
- sampler_views[2] = cur_sv[j];
- sampler_views[3] = next_sv[j];
+ sampler_views[0] = prevprev_sv[k];
+ sampler_views[1] = prev_sv[k];
+ sampler_views[2] = cur_sv[k];
+ sampler_views[3] = next_sv[k];
filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT, 0, 4, sampler_views);
/* blit current field */
@@ -479,11 +508,16 @@ vl_deint_filter_render(struct vl_deint_filter *filter,
/* blit or interpolate other field */
fb_state.cbufs[0] = dst_surf;
filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
- if (j > 0 && filter->skip_chroma) {
+ if (i > 0 && filter->skip_chroma) {
util_draw_arrays(filter->pipe, PIPE_PRIM_QUADS, 0, 4);
} else {
filter->pipe->bind_fs_state(filter->pipe, field ? filter->fs_deint_top : filter->fs_deint_bottom);
util_draw_arrays(filter->pipe, PIPE_PRIM_QUADS, 0, 4);
}
+
+ if (++j >= util_format_get_nr_components(dst_surf->format)) {
+ dst_surfaces += 2;
+ j = 0;
+ }
}
}
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c b/lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c
index 52ce45401..e331cb758 100644
--- a/lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c
+++ b/lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c
@@ -52,7 +52,7 @@ create_vert_shader(struct vl_matrix_filter *filter)
struct ureg_src i_vpos;
struct ureg_dst o_vpos, o_vtex;
- shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+ shader = ureg_create(PIPE_SHADER_VERTEX);
if (!shader)
return NULL;
@@ -85,9 +85,9 @@ create_frag_shader(struct vl_matrix_filter *filter, unsigned num_offsets,
struct ureg_dst t_sum;
struct ureg_dst o_fragment;
bool first;
- int i;
+ unsigned i;
- shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+ shader = ureg_create(PIPE_SHADER_FRAGMENT);
if (!shader) {
FREE(t_array);
return NULL;
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c b/lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c
index aa9a6b264..f7477b757 100644
--- a/lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c
+++ b/lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c
@@ -50,7 +50,7 @@ create_vert_shader(struct vl_median_filter *filter)
struct ureg_src i_vpos;
struct ureg_dst o_vpos, o_vtex;
- shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+ shader = ureg_create(PIPE_SHADER_VERTEX);
if (!shader)
return NULL;
@@ -84,7 +84,7 @@ create_frag_shader(struct vl_median_filter *filter,
struct ureg_dst *t_array = MALLOC(sizeof(struct ureg_dst) * num_offsets);
struct ureg_dst o_fragment;
const unsigned median = num_offsets >> 1;
- int i, j;
+ unsigned i, j;
assert(num_offsets & 1); /* we need an odd number of offsets */
if (!(num_offsets & 1)) { /* yeah, we REALLY need an odd number of offsets!!! */
@@ -93,13 +93,13 @@ create_frag_shader(struct vl_median_filter *filter,
}
if (num_offsets > screen->get_shader_param(
- screen, TGSI_PROCESSOR_FRAGMENT, PIPE_SHADER_CAP_MAX_TEMPS)) {
+ screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_TEMPS)) {
FREE(t_array);
return NULL;
}
- shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+ shader = ureg_create(PIPE_SHADER_FRAGMENT);
if (!shader) {
FREE(t_array);
return NULL;
@@ -158,7 +158,8 @@ static void
generate_offsets(enum vl_median_filter_shape shape, unsigned size,
struct vertex2f **offsets, unsigned *num_offsets)
{
- int i = 0, half_size;
+ unsigned i = 0;
+ int half_size;
struct vertex2f v;
assert(offsets && num_offsets);
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c b/lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c
index 5e0ae0ecb..fdc9598f8 100644
--- a/lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c
+++ b/lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c
@@ -62,6 +62,18 @@ const enum pipe_format const_resource_formats_VUYA[3] = {
PIPE_FORMAT_NONE
};
+const enum pipe_format const_resource_formats_YUVX[3] = {
+ PIPE_FORMAT_R8G8B8X8_UNORM,
+ PIPE_FORMAT_NONE,
+ PIPE_FORMAT_NONE
+};
+
+const enum pipe_format const_resource_formats_VUYX[3] = {
+ PIPE_FORMAT_B8G8R8X8_UNORM,
+ PIPE_FORMAT_NONE,
+ PIPE_FORMAT_NONE
+};
+
const enum pipe_format const_resource_formats_YUYV[3] = {
PIPE_FORMAT_R8G8_R8B8_UNORM,
PIPE_FORMAT_NONE,
@@ -102,6 +114,12 @@ vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format)
case PIPE_FORMAT_B8G8R8A8_UNORM:
return const_resource_formats_VUYA;
+ case PIPE_FORMAT_R8G8B8X8_UNORM:
+ return const_resource_formats_YUVX;
+
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ return const_resource_formats_VUYX;
+
case PIPE_FORMAT_YUYV:
return const_resource_formats_YUYV;
@@ -232,17 +250,11 @@ vl_video_buffer_template(struct pipe_resource *templ,
templ->height0 = tmpl->height;
templ->depth0 = depth;
templ->array_size = array_size;
- templ->bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+ templ->bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET | tmpl->bind;
templ->usage = usage;
- if (plane > 0) {
- if (tmpl->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
- templ->width0 /= 2;
- templ->height0 /= 2;
- } else if (tmpl->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
- templ->width0 /= 2;
- }
- }
+ vl_video_buffer_adjust_size(&templ->width0, &templ->height0, plane,
+ tmpl->chroma_format, false);
}
static void
@@ -285,7 +297,7 @@ vl_video_buffer_sampler_view_planes(struct pipe_video_buffer *buffer)
u_sampler_view_default_template(&sv_templ, buf->resources[i], buf->resources[i]->format);
if (util_format_get_nr_components(buf->resources[i]->format) == 1)
- sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = sv_templ.swizzle_a = PIPE_SWIZZLE_RED;
+ sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = sv_templ.swizzle_a = PIPE_SWIZZLE_X;
buf->sampler_view_planes[i] = pipe->create_sampler_view(pipe, buf->resources[i], &sv_templ);
if (!buf->sampler_view_planes[i])
@@ -332,8 +344,8 @@ vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer)
memset(&sv_templ, 0, sizeof(sv_templ));
u_sampler_view_default_template(&sv_templ, res, sampler_format[plane_order[i]]);
- sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = PIPE_SWIZZLE_RED + j;
- sv_templ.swizzle_a = PIPE_SWIZZLE_ONE;
+ sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = PIPE_SWIZZLE_X + j;
+ sv_templ.swizzle_a = PIPE_SWIZZLE_1;
buf->sampler_view_components[component] = pipe->create_sampler_view(pipe, res, &sv_templ);
if (!buf->sampler_view_components[component])
goto error;
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h
index f6b47c964..26db9f263 100644
--- a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h
+++ b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h
@@ -42,28 +42,36 @@ struct pipe_loader_device;
struct vl_screen
{
- struct pipe_screen *pscreen;
- struct pipe_loader_device *dev;
-};
+ void (*destroy)(struct vl_screen *vscreen);
-struct vl_screen*
-vl_screen_create(Display *display, int screen);
+ struct pipe_resource *
+ (*texture_from_drawable)(struct vl_screen *vscreen, void *drawable);
-void vl_screen_destroy(struct vl_screen *vscreen);
+ struct u_rect *
+ (*get_dirty_area)(struct vl_screen *vscreen);
-struct pipe_resource*
-vl_screen_texture_from_drawable(struct vl_screen *vscreen, Drawable drawable);
+ uint64_t
+ (*get_timestamp)(struct vl_screen *vscreen, void *drawable);
-struct u_rect *
-vl_screen_get_dirty_area(struct vl_screen *vscreen);
+ void
+ (*set_next_timestamp)(struct vl_screen *vscreen, uint64_t stamp);
-uint64_t
-vl_screen_get_timestamp(struct vl_screen *vscreen, Drawable drawable);
+ void *
+ (*get_private)(struct vl_screen *vscreen);
-void
-vl_screen_set_next_timestamp(struct vl_screen *vscreen, uint64_t stamp);
+ struct pipe_screen *pscreen;
+ struct pipe_loader_device *dev;
+};
+
+struct vl_screen *
+vl_dri2_screen_create(Display *display, int screen);
-void*
-vl_screen_get_private(struct vl_screen *vscreen);
+struct vl_screen *
+vl_drm_screen_create(int fd);
+
+#if defined(HAVE_DRI3)
+struct vl_screen *
+vl_dri3_screen_create(Display *display, int screen);
+#endif
#endif
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 3b1b87f95..9ecc216b9 100644
--- a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -73,24 +73,27 @@ struct vl_dri_screen
int64_t last_ust, ns_frame, last_msc, next_msc;
};
-static const unsigned int attachments[1] = { XCB_DRI2_ATTACHMENT_BUFFER_BACK_LEFT };
+static const unsigned attachments[1] = { XCB_DRI2_ATTACHMENT_BUFFER_BACK_LEFT };
+
+static void vl_dri2_screen_destroy(struct vl_screen *vscreen);
static void
-vl_dri2_handle_stamps(struct vl_dri_screen* scrn,
+vl_dri2_handle_stamps(struct vl_dri_screen *scrn,
uint32_t ust_hi, uint32_t ust_lo,
uint32_t msc_hi, uint32_t msc_lo)
{
int64_t ust = ((((uint64_t)ust_hi) << 32) | ust_lo) * 1000;
int64_t msc = (((uint64_t)msc_hi) << 32) | msc_lo;
- if (scrn->last_ust && scrn->last_msc && (ust > scrn->last_ust) && (msc > scrn->last_msc))
+ if (scrn->last_ust && (ust > scrn->last_ust) &&
+ scrn->last_msc && (msc > scrn->last_msc))
scrn->ns_frame = (ust - scrn->last_ust) / (msc - scrn->last_msc);
scrn->last_ust = ust;
scrn->last_msc = msc;
}
-static xcb_dri2_get_buffers_reply_t*
+static xcb_dri2_get_buffers_reply_t *
vl_dri2_get_flush_reply(struct vl_dri_screen *scrn)
{
xcb_dri2_wait_sbc_reply_t *wait_sbc_reply;
@@ -120,7 +123,7 @@ vl_dri2_flush_frontbuffer(struct pipe_screen *screen,
unsigned level, unsigned layer,
void *context_private, struct pipe_box *sub_box)
{
- struct vl_dri_screen *scrn = (struct vl_dri_screen*)context_private;
+ struct vl_dri_screen *scrn = (struct vl_dri_screen *)context_private;
uint32_t msc_hi, msc_lo;
assert(screen);
@@ -132,9 +135,11 @@ vl_dri2_flush_frontbuffer(struct pipe_screen *screen,
msc_hi = scrn->next_msc >> 32;
msc_lo = scrn->next_msc & 0xFFFFFFFF;
- scrn->swap_cookie = xcb_dri2_swap_buffers_unchecked(scrn->conn, scrn->drawable, msc_hi, msc_lo, 0, 0, 0, 0);
+ scrn->swap_cookie = xcb_dri2_swap_buffers_unchecked(scrn->conn, scrn->drawable,
+ msc_hi, msc_lo, 0, 0, 0, 0);
scrn->wait_cookie = xcb_dri2_wait_sbc_unchecked(scrn->conn, scrn->drawable, 0, 0);
- scrn->buffers_cookie = xcb_dri2_get_buffers_unchecked(scrn->conn, scrn->drawable, 1, 1, attachments);
+ scrn->buffers_cookie = xcb_dri2_get_buffers_unchecked(scrn->conn, scrn->drawable,
+ 1, 1, attachments);
scrn->flushed = true;
scrn->current_buffer = !scrn->current_buffer;
@@ -170,10 +175,10 @@ vl_dri2_set_drawable(struct vl_dri_screen *scrn, Drawable drawable)
scrn->drawable = drawable;
}
-struct pipe_resource*
-vl_screen_texture_from_drawable(struct vl_screen *vscreen, Drawable drawable)
+static struct pipe_resource *
+vl_dri2_screen_texture_from_drawable(struct vl_screen *vscreen, void *drawable)
{
- struct vl_dri_screen *scrn = (struct vl_dri_screen*)vscreen;
+ struct vl_dri_screen *scrn = (struct vl_dri_screen *)vscreen;
struct winsys_handle dri2_handle;
struct pipe_resource template, *tex;
@@ -185,11 +190,12 @@ vl_screen_texture_from_drawable(struct vl_screen *vscreen, Drawable drawable)
assert(scrn);
- vl_dri2_set_drawable(scrn, drawable);
+ vl_dri2_set_drawable(scrn, (Drawable)drawable);
reply = vl_dri2_get_flush_reply(scrn);
if (!reply) {
xcb_dri2_get_buffers_cookie_t cookie;
- cookie = xcb_dri2_get_buffers_unchecked(scrn->conn, drawable, 1, 1, attachments);
+ cookie = xcb_dri2_get_buffers_unchecked(scrn->conn, (Drawable)drawable,
+ 1, 1, attachments);
reply = xcb_dri2_get_buffers_reply(scrn->conn, cookie, NULL);
}
if (!reply)
@@ -241,32 +247,34 @@ vl_screen_texture_from_drawable(struct vl_screen *vscreen, Drawable drawable)
template.bind = PIPE_BIND_RENDER_TARGET;
template.flags = 0;
- tex = scrn->base.pscreen->resource_from_handle(scrn->base.pscreen, &template, &dri2_handle);
+ tex = scrn->base.pscreen->resource_from_handle(scrn->base.pscreen, &template,
+ &dri2_handle,
+ PIPE_HANDLE_USAGE_READ_WRITE);
free(reply);
return tex;
}
-struct u_rect *
-vl_screen_get_dirty_area(struct vl_screen *vscreen)
+static struct u_rect *
+vl_dri2_screen_get_dirty_area(struct vl_screen *vscreen)
{
- struct vl_dri_screen *scrn = (struct vl_dri_screen*)vscreen;
+ struct vl_dri_screen *scrn = (struct vl_dri_screen *)vscreen;
assert(scrn);
return &scrn->dirty_areas[scrn->current_buffer];
}
-uint64_t
-vl_screen_get_timestamp(struct vl_screen *vscreen, Drawable drawable)
+static uint64_t
+vl_dri2_screen_get_timestamp(struct vl_screen *vscreen, void *drawable)
{
- struct vl_dri_screen *scrn = (struct vl_dri_screen*)vscreen;
+ struct vl_dri_screen *scrn = (struct vl_dri_screen *)vscreen;
xcb_dri2_get_msc_cookie_t cookie;
xcb_dri2_get_msc_reply_t *reply;
assert(scrn);
- vl_dri2_set_drawable(scrn, drawable);
+ vl_dri2_set_drawable(scrn, (Drawable)drawable);
if (!scrn->last_ust) {
- cookie = xcb_dri2_get_msc_unchecked(scrn->conn, drawable);
+ cookie = xcb_dri2_get_msc_unchecked(scrn->conn, (Drawable)drawable);
reply = xcb_dri2_get_msc_reply(scrn->conn, cookie, NULL);
if (reply) {
@@ -278,19 +286,20 @@ vl_screen_get_timestamp(struct vl_screen *vscreen, Drawable drawable)
return scrn->last_ust;
}
-void
-vl_screen_set_next_timestamp(struct vl_screen *vscreen, uint64_t stamp)
+static void
+vl_dri2_screen_set_next_timestamp(struct vl_screen *vscreen, uint64_t stamp)
{
- struct vl_dri_screen *scrn = (struct vl_dri_screen*)vscreen;
+ struct vl_dri_screen *scrn = (struct vl_dri_screen *)vscreen;
assert(scrn);
if (stamp && scrn->last_ust && scrn->ns_frame && scrn->last_msc)
- scrn->next_msc = ((int64_t)stamp - scrn->last_ust + scrn->ns_frame/2) / scrn->ns_frame + scrn->last_msc;
+ scrn->next_msc = ((int64_t)stamp - scrn->last_ust + scrn->ns_frame/2) /
+ scrn->ns_frame + scrn->last_msc;
else
scrn->next_msc = 0;
}
-void*
-vl_screen_get_private(struct vl_screen *vscreen)
+static void *
+vl_dri2_screen_get_private(struct vl_screen *vscreen)
{
return vscreen;
}
@@ -305,8 +314,8 @@ get_xcb_screen(xcb_screen_iterator_t iter, int screen)
return NULL;
}
-struct vl_screen*
-vl_screen_create(Display *display, int screen)
+struct vl_screen *
+vl_dri2_screen_create(Display *display, int screen)
{
struct vl_dri_screen *scrn;
const xcb_query_extension_reply_t *extension;
@@ -320,7 +329,7 @@ vl_screen_create(Display *display, int screen)
xcb_generic_error_t *error = NULL;
char *device_name;
int fd, device_name_length;
- unsigned int driverType;
+ unsigned driverType;
drm_magic_t magic;
@@ -340,7 +349,9 @@ vl_screen_create(Display *display, int screen)
if (!(extension && extension->present))
goto free_screen;
- dri2_query_cookie = xcb_dri2_query_version (scrn->conn, XCB_DRI2_MAJOR_VERSION, XCB_DRI2_MINOR_VERSION);
+ dri2_query_cookie = xcb_dri2_query_version (scrn->conn,
+ XCB_DRI2_MAJOR_VERSION,
+ XCB_DRI2_MINOR_VERSION);
dri2_query = xcb_dri2_query_version_reply (scrn->conn, dri2_query_cookie, &error);
if (dri2_query == NULL || error != NULL || dri2_query->minor_version < 2)
goto free_query;
@@ -352,7 +363,7 @@ vl_screen_create(Display *display, int screen)
{
char *prime = getenv("DRI_PRIME");
if (prime) {
- unsigned int primeid;
+ unsigned primeid;
errno = 0;
primeid = strtoul(prime, NULL, 0);
if (errno == 0)
@@ -362,9 +373,12 @@ vl_screen_create(Display *display, int screen)
}
#endif
- connect_cookie = xcb_dri2_connect_unchecked(scrn->conn, get_xcb_screen(s, screen)->root, driverType);
+ connect_cookie = xcb_dri2_connect_unchecked(scrn->conn,
+ get_xcb_screen(s, screen)->root,
+ driverType);
connect = xcb_dri2_connect_reply(scrn->conn, connect_cookie, NULL);
- if (connect == NULL || connect->driver_name_length + connect->device_name_length == 0)
+ if (connect == NULL ||
+ connect->driver_name_length + connect->device_name_length == 0)
goto free_connect;
device_name_length = xcb_dri2_connect_device_name_length(connect);
@@ -379,24 +393,28 @@ vl_screen_create(Display *display, int screen)
goto free_connect;
if (drmGetMagic(fd, &magic))
- goto free_connect;
+ goto close_fd;
- authenticate_cookie = xcb_dri2_authenticate_unchecked(scrn->conn, get_xcb_screen(s, screen)->root, magic);
+ authenticate_cookie = xcb_dri2_authenticate_unchecked(scrn->conn,
+ get_xcb_screen(s, screen)->root,
+ magic);
authenticate = xcb_dri2_authenticate_reply(scrn->conn, authenticate_cookie, NULL);
if (authenticate == NULL || !authenticate->authenticated)
goto free_authenticate;
-#if GALLIUM_STATIC_TARGETS
- scrn->base.pscreen = dd_create_screen(fd);
-#else
if (pipe_loader_drm_probe_fd(&scrn->base.dev, fd))
- scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev, PIPE_SEARCH_DIR);
-#endif // GALLIUM_STATIC_TARGETS
+ scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev);
if (!scrn->base.pscreen)
goto release_pipe;
+ scrn->base.destroy = vl_dri2_screen_destroy;
+ scrn->base.texture_from_drawable = vl_dri2_screen_texture_from_drawable;
+ scrn->base.get_dirty_area = vl_dri2_screen_get_dirty_area;
+ scrn->base.get_timestamp = vl_dri2_screen_get_timestamp;
+ scrn->base.set_next_timestamp = vl_dri2_screen_set_next_timestamp;
+ scrn->base.get_private = vl_dri2_screen_get_private;
scrn->base.pscreen->flush_frontbuffer = vl_dri2_flush_frontbuffer;
vl_compositor_reset_dirty_area(&scrn->dirty_areas[0]);
vl_compositor_reset_dirty_area(&scrn->dirty_areas[1]);
@@ -409,12 +427,15 @@ vl_screen_create(Display *display, int screen)
return &scrn->base;
release_pipe:
-#if !GALLIUM_STATIC_TARGETS
- if (scrn->base.dev)
+ if (scrn->base.dev) {
pipe_loader_release(&scrn->base.dev, 1);
-#endif // !GALLIUM_STATIC_TARGETS
+ fd = -1;
+ }
free_authenticate:
free(authenticate);
+close_fd:
+ if (fd != -1)
+ close(fd);
free_connect:
free(connect);
free_query:
@@ -426,9 +447,10 @@ free_screen:
return NULL;
}
-void vl_screen_destroy(struct vl_screen *vscreen)
+static void
+vl_dri2_screen_destroy(struct vl_screen *vscreen)
{
- struct vl_dri_screen *scrn = (struct vl_dri_screen*)vscreen;
+ struct vl_dri_screen *scrn = (struct vl_dri_screen *)vscreen;
assert(vscreen);
@@ -440,8 +462,6 @@ void vl_screen_destroy(struct vl_screen *vscreen)
vl_dri2_destroy_drawable(scrn);
scrn->base.pscreen->destroy(scrn->base.pscreen);
-#if !GALLIUM_STATIC_TARGETS
pipe_loader_release(&scrn->base.dev, 1);
-#endif // !GALLIUM_STATIC_TARGETS
FREE(scrn);
}
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c b/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c
index 1c6cdd4f2..24d64525b 100644
--- a/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c
+++ b/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c
@@ -49,6 +49,13 @@ enum VS_OUTPUT
VS_O_VTEX = 0
};
+const int vl_zscan_normal_16[] =
+{
+ /* Zig-Zag scan pattern */
+ 0, 1, 4, 8, 5, 2, 3, 6,
+ 9,12,13,10, 7,11,14,15
+};
+
const int vl_zscan_linear[] =
{
/* Linear scan pattern */
@@ -92,17 +99,14 @@ static void *
create_vert_shader(struct vl_zscan *zscan)
{
struct ureg_program *shader;
-
struct ureg_src scale;
struct ureg_src vrect, vpos, block_num;
-
struct ureg_dst tmp;
struct ureg_dst o_vpos;
struct ureg_dst *o_vtex;
+ unsigned i;
- signed i;
-
- shader = ureg_create(TGSI_PROCESSOR_VERTEX);
+ shader = ureg_create(PIPE_SHADER_VERTEX);
if (!shader)
return NULL;
@@ -148,7 +152,7 @@ create_vert_shader(struct vl_zscan *zscan)
for (i = 0; i < zscan->num_channels; ++i) {
ureg_ADD(shader, ureg_writemask(tmp, TGSI_WRITEMASK_X), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Y),
ureg_imm1f(shader, 1.0f / (zscan->blocks_per_line * VL_BLOCK_WIDTH)
- * (i - (signed)zscan->num_channels / 2)));
+ * ((signed)i - (signed)zscan->num_channels / 2)));
ureg_MAD(shader, ureg_writemask(o_vtex[i], TGSI_WRITEMASK_X), vrect,
ureg_imm1f(shader, 1.0f / zscan->blocks_per_line), ureg_src(tmp));
@@ -179,7 +183,7 @@ create_frag_shader(struct vl_zscan *zscan)
unsigned i;
- shader = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+ shader = ureg_create(PIPE_SHADER_FRAGMENT);
if (!shader)
return NULL;
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.h b/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.h
index eacee2db6..268cf0a6e 100644
--- a/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.h
+++ b/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.h
@@ -64,6 +64,7 @@ struct vl_zscan_buffer
struct pipe_surface *dst;
};
+extern const int vl_zscan_normal_16[];
extern const int vl_zscan_linear[];
extern const int vl_zscan_normal[];
extern const int vl_zscan_alternate[];