diff options
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/vl')
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_bicubic_filter.c | 46 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c | 75 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_compositor.h | 3 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_csc.c | 92 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c | 14 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c | 69 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c | 11 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 8 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_vertex_buffers.c | 25 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c | 16 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h | 26 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c | 14 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri3.c | 132 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_winsys_drm.c | 12 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c | 21 | ||||
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/vl/vl_zscan.h | 2 |
16 files changed, 211 insertions, 355 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_bicubic_filter.c b/lib/mesa/src/gallium/auxiliary/vl/vl_bicubic_filter.c index a3dc6c8c5..0364d4326 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_bicubic_filter.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_bicubic_filter.c @@ -35,7 +35,6 @@ #include "util/u_memory.h" #include "util/u_math.h" #include "util/u_rect.h" -#include "util/u_upload_mgr.h" #include "vl_types.h" #include "vl_vertex_buffers.h" @@ -174,11 +173,6 @@ create_frag_shader(struct vl_bicubic_filter *filter, unsigned video_width, i_vtex = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX, TGSI_INTERPOLATE_LINEAR); sampler = ureg_DECL_sampler(shader, 0); - ureg_DECL_sampler_view(shader, 0, TGSI_TEXTURE_2D, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT); for (i = 0; i < 23; ++i) t_array[i] = ureg_DECL_temporary(shader); @@ -192,8 +186,8 @@ create_frag_shader(struct vl_bicubic_filter *filter, unsigned video_width, * t = frac(temp) * vtex = floor(i_vtex)/i_size */ - ureg_ADD(shader, ureg_writemask(t_array[21], TGSI_WRITEMASK_XY), - i_vtex, ureg_negate(half_pixel)); + ureg_SUB(shader, ureg_writemask(t_array[21], TGSI_WRITEMASK_XY), + i_vtex, half_pixel); ureg_MUL(shader, ureg_writemask(t_array[22], TGSI_WRITEMASK_XY), ureg_src(t_array[21]), ureg_imm2f(shader, video_width, video_height)); ureg_FRC(shader, ureg_writemask(t, TGSI_WRITEMASK_XY), @@ -295,7 +289,7 @@ vl_bicubic_filter_init(struct vl_bicubic_filter *filter, struct pipe_context *pi goto error_sampler; filter->quad = vl_vb_upload_quads(pipe); - if(!filter->quad.buffer.resource) + if(!filter->quad.buffer) goto error_quad; memset(&ve, 0, sizeof(ve)); @@ -349,7 +343,7 @@ error_vs: pipe->delete_vertex_elements_state(pipe, filter->ves); error_ves: - pipe_resource_reference(&filter->quad.buffer.resource, NULL); + pipe_resource_reference(&filter->quad.buffer, NULL); error_quad: pipe->delete_sampler_state(pipe, filter->sampler); @@ -373,7 +367,7 @@ vl_bicubic_filter_cleanup(struct vl_bicubic_filter *filter) filter->pipe->delete_blend_state(filter->pipe, filter->blend); 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.resource, NULL); + pipe_resource_reference(&filter->quad.buffer, NULL); filter->pipe->delete_vs_state(filter->pipe, filter->vs); filter->pipe->delete_fs_state(filter->pipe, filter->fs); @@ -390,7 +384,8 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, struct pipe_framebuffer_state fb_state; struct pipe_scissor_state scissor; union pipe_color_union clear_color; - + struct pipe_transfer *buf_transfer; + struct pipe_resource *surface_size; assert(filter && src && dst); if (dst_clip) { @@ -407,6 +402,14 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, clear_color.f[0] = clear_color.f[1] = 0.0f; clear_color.f[2] = clear_color.f[3] = 0.0f; + surface_size = pipe_buffer_create + ( + filter->pipe->screen, + PIPE_BIND_CONSTANT_BUFFER, + PIPE_USAGE_DEFAULT, + 2*sizeof(float) + ); + memset(&viewport, 0, sizeof(viewport)); if(dst_area){ @@ -420,18 +423,14 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, } viewport.scale[2] = 1; - struct pipe_constant_buffer cb = {}; - float *ptr = NULL; + float *ptr = pipe_buffer_map(filter->pipe, surface_size, + PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, + &buf_transfer); - u_upload_alloc(filter->pipe->const_uploader, 0, 2 * sizeof(float), 256, - &cb.buffer_offset, &cb.buffer, (void**)&ptr); - cb.buffer_size = 2 * sizeof(float); + ptr[0] = 0.5f/viewport.scale[0]; + ptr[1] = 0.5f/viewport.scale[1]; - if (ptr) { - ptr[0] = 0.5f/viewport.scale[0]; - ptr[1] = 0.5f/viewport.scale[1]; - } - u_upload_unmap(filter->pipe->const_uploader); + pipe_buffer_unmap(filter->pipe, buf_transfer); memset(&fb_state, 0, sizeof(fb_state)); fb_state.width = dst->width; @@ -442,8 +441,7 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, filter->pipe->set_scissor_states(filter->pipe, 0, 1, &scissor); filter->pipe->clear_render_target(filter->pipe, dst, &clear_color, 0, 0, dst->width, dst->height, false); - filter->pipe->set_constant_buffer(filter->pipe, PIPE_SHADER_FRAGMENT, - 0, &cb); + pipe_set_constant_buffer(filter->pipe, PIPE_SHADER_FRAGMENT, 0, surface_size); filter->pipe->bind_rasterizer_state(filter->pipe, filter->rs_state); filter->pipe->bind_blend_state(filter->pipe, filter->blend); filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT, diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c b/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c index a79bf1126..03a0a6453 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c @@ -137,15 +137,9 @@ create_frag_shader_weave(struct ureg_program *shader, struct ureg_dst fragment) 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) { + for (i = 0; i < 3; ++i) sampler[i] = ureg_DECL_sampler(shader, i); - ureg_DECL_sampler_view(shader, i, TGSI_TEXTURE_2D_ARRAY, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT); - } - + for (i = 0; i < 2; ++i) { t_tc[i] = ureg_DECL_temporary(shader); t_texel[i] = ureg_DECL_temporary(shader); @@ -157,8 +151,8 @@ create_frag_shader_weave(struct ureg_program *shader, struct ureg_dst fragment) */ for (i = 0; i < 2; ++i) { ureg_MOV(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_X), i_tc[i]); - ureg_ADD(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_YZ), - i_tc[i], ureg_imm1f(shader, -0.5f)); + 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)); @@ -254,15 +248,9 @@ create_frag_shader_video_buffer(struct vl_compositor *c) 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) sampler[i] = ureg_DECL_sampler(shader, i); - ureg_DECL_sampler_view(shader, i, TGSI_TEXTURE_2D_ARRAY, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT); - } - + texel = ureg_DECL_temporary(shader); fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0); @@ -354,18 +342,8 @@ create_frag_shader_palette(struct vl_compositor *c, bool include_cc) tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX, TGSI_INTERPOLATE_LINEAR); sampler = ureg_DECL_sampler(shader, 0); - ureg_DECL_sampler_view(shader, 0, TGSI_TEXTURE_2D, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT); palette = ureg_DECL_sampler(shader, 1); - ureg_DECL_sampler_view(shader, 1, TGSI_TEXTURE_1D, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT); - + texel = ureg_DECL_temporary(shader); fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0); @@ -406,11 +384,6 @@ create_frag_shader_rgba(struct vl_compositor *c) tc = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX, TGSI_INTERPOLATE_LINEAR); color = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_COLOR, VS_O_COLOR, TGSI_INTERPOLATE_LINEAR); sampler = ureg_DECL_sampler(shader, 0); - ureg_DECL_sampler_view(shader, 0, TGSI_TEXTURE_2D, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT); texel = ureg_DECL_temporary(shader); fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0); @@ -605,8 +578,7 @@ init_buffers(struct vl_compositor *c) */ c->vertex_buf.stride = sizeof(struct vertex2f) + sizeof(struct vertex4f) * 2; c->vertex_buf.buffer_offset = 0; - c->vertex_buf.buffer.resource = NULL; - c->vertex_buf.is_user_buffer = false; + c->vertex_buf.buffer = NULL; vertex_elems[0].src_offset = 0; vertex_elems[0].instance_divisor = 0; @@ -631,7 +603,7 @@ cleanup_buffers(struct vl_compositor *c) assert(c); c->pipe->delete_vertex_elements_state(c->pipe, c->vertex_elems_state); - pipe_resource_reference(&c->vertex_buf.buffer.resource, NULL); + pipe_resource_reference(&c->vertex_buf.buffer, NULL); } static inline struct u_rect @@ -810,10 +782,10 @@ gen_vertex_data(struct vl_compositor *c, struct vl_compositor_state *s, struct u assert(c); /* Allocate new memory for vertices. */ - u_upload_alloc(c->pipe->stream_uploader, 0, + 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.resource, + &c->vertex_buf.buffer_offset, &c->vertex_buf.buffer, (void**)&vb); for (i = 0; i < VL_COMPOSITOR_MAX_LAYERS; i++) { @@ -845,7 +817,7 @@ gen_vertex_data(struct vl_compositor *c, struct vl_compositor_state *s, struct u } } - u_upload_unmap(c->pipe->stream_uploader); + u_upload_unmap(c->upload); } static void @@ -941,12 +913,13 @@ vl_compositor_cleanup(struct vl_compositor *c) { assert(c); + u_upload_destroy(c->upload); cleanup_buffers(c); cleanup_shaders(c); cleanup_pipe_state(c); } -bool +void vl_compositor_set_csc_matrix(struct vl_compositor_state *s, vl_csc_matrix const *matrix, float luma_min, float luma_max) @@ -959,9 +932,6 @@ vl_compositor_set_csc_matrix(struct vl_compositor_state *s, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &buf_transfer); - if (!ptr) - return false; - memcpy(ptr, matrix, sizeof(vl_csc_matrix)); ptr += sizeof(vl_csc_matrix)/sizeof(float); @@ -969,8 +939,6 @@ vl_compositor_set_csc_matrix(struct vl_compositor_state *s, ptr[1] = luma_max; pipe_buffer_unmap(s->pipe, buf_transfer); - - return true; } void @@ -1224,16 +1192,25 @@ vl_compositor_init(struct vl_compositor *c, struct pipe_context *pipe) c->pipe = pipe; + c->upload = u_upload_create(pipe, 128 * 1024, PIPE_BIND_VERTEX_BUFFER, + PIPE_USAGE_STREAM); + + if (!c->upload) + return false; + if (!init_pipe_state(c)) { + u_upload_destroy(c->upload); return false; } if (!init_shaders(c)) { + u_upload_destroy(c->upload); cleanup_pipe_state(c); return false; } if (!init_buffers(c)) { + u_upload_destroy(c->upload); cleanup_shaders(c); cleanup_pipe_state(c); return false; @@ -1269,14 +1246,10 @@ vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pip sizeof(csc_matrix) + 2*sizeof(float) ); - if (!s->csc_matrix) - return false; - vl_compositor_clear_layers(s); vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, &csc_matrix); - if (!vl_compositor_set_csc_matrix(s, (const vl_csc_matrix *)&csc_matrix, 1.0f, 0.0f)) - return false; + 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 535abb75c..ceab5e004 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.h +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.h @@ -99,6 +99,7 @@ struct vl_compositor_state struct vl_compositor { struct pipe_context *pipe; + struct u_upload_mgr *upload; struct pipe_framebuffer_state fb_state; struct pipe_vertex_buffer vertex_buf; @@ -141,7 +142,7 @@ vl_compositor_init_state(struct vl_compositor_state *state, struct pipe_context /** * set yuv -> rgba conversion matrix */ -bool +void vl_compositor_set_csc_matrix(struct vl_compositor_state *settings, const vl_csc_matrix *matrix, float luma_min, float luma_max); diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_csc.c b/lib/mesa/src/gallium/auxiliary/vl/vl_csc.c index e4395d062..c8efe2867 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_csc.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_csc.c @@ -59,10 +59,10 @@ * [ 0, 0, 0, 1] * * brightness - * [ 1, 0, 0, b/c] - * [ 0, 1, 0, 0] - * [ 0, 0, 1, 0] - * [ 0, 0, 0, 1] + * [ 1, 0, 0, b] + * [ 0, 1, 0, 0] + * [ 0, 0, 1, 0] + * [ 0, 0, 0, 1] * * saturation * [ 1, 0, 0, 0] @@ -108,6 +108,18 @@ static const vl_csc_matrix bt_601 = }; /* + * Converts ITU-R BT.601 YCbCr pixels to RGB pixels where: + * Y is in [16,235], Cb and Cr are in [16,240] + * R, G, and B are in [0,255] + */ +static const vl_csc_matrix bt_601_full = +{ + { 1.164f, 0.0f, 1.596f, 0.0f, }, + { 1.164f, -0.391f, -0.813f, 0.0f, }, + { 1.164f, 2.018f, 0.0f, 0.0f, } +}; + +/* * Converts ITU-R BT.709 YCbCr pixels to RGB pixels where: * Y is in [16,235], Cb and Cr are in [16,240] * R, G, and B are in [16,235] @@ -120,15 +132,29 @@ static const vl_csc_matrix bt_709 = }; /* - * Converts SMPTE 240M YCbCr pixels to RGB pixels where: + * Converts ITU-R BT.709 YCbCr pixels to RGB pixels where: * Y is in [16,235], Cb and Cr are in [16,240] - * R, G, and B are in [16,235] + * R, G, and B are in [0,255] */ +static const vl_csc_matrix bt_709_full = +{ + { 1.164f, 0.0f, 1.793f, 0.0f, }, + { 1.164f, -0.213f, -0.534f, 0.0f, }, + { 1.164f, 2.115f, 0.0f, 0.0f, } +}; + static const vl_csc_matrix smpte240m = { - { 1.0f, 0.0f, 1.541f, 0.0f, }, - { 1.0f, -0.221f, -0.466f, 0.0f, }, - { 1.0f, 1.785f, 0.0f, 0.0f, } + { 1.0f, 0.0f, 1.582f, 0.0f, }, + { 1.0f, -0.228f, -0.478f, 0.0f, }, + { 1.0f, 1.833f, 0.0f, 0.0f, } +}; + +static const vl_csc_matrix smpte240m_full = +{ + { 1.164f, 0.0f, 1.794f, 0.0f, }, + { 1.164f, -0.258f, -0.543f, 0.0f, }, + { 1.164f, 2.079f, 0.0f, 0.0f, } }; static const vl_csc_matrix identity = @@ -150,6 +176,7 @@ void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs, bool full_range, vl_csc_matrix *matrix) { + float ybias = full_range ? -16.0f/255.0f : 0.0f; float cbbias = -128.0f/255.0f; float crbias = -128.0f/255.0f; @@ -158,31 +185,20 @@ void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs, float s = p->saturation; float b = p->brightness; float h = p->hue; - float x, y; const vl_csc_matrix *cstd; - if (full_range) { - c *= 1.164f; /* Adjust for the y range */ - b *= 1.164f; /* Adjust for the y range */ - b -= c * 16.0f / 255.0f; /* Adjust for the y bias */ - } - - /* Parameter substitutions */ - x = c * s * cosf(h); - y = c * s * sinf(h); - assert(matrix); switch (cs) { case VL_CSC_COLOR_STANDARD_BT_601: - cstd = &bt_601; + cstd = full_range ? &bt_601_full : &bt_601; break; case VL_CSC_COLOR_STANDARD_BT_709: - cstd = &bt_709; + cstd = full_range ? &bt_709_full : &bt_709; break; case VL_CSC_COLOR_STANDARD_SMPTE_240M: - cstd = &smpte240m; + cstd = full_range ? &smpte240m_full : &smpte240m; break; case VL_CSC_COLOR_STANDARD_IDENTITY: default: @@ -192,23 +208,23 @@ void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs, } (*matrix)[0][0] = c * (*cstd)[0][0]; - (*matrix)[0][1] = (*cstd)[0][1] * x - (*cstd)[0][2] * y; - (*matrix)[0][2] = (*cstd)[0][2] * x + (*cstd)[0][1] * y; - (*matrix)[0][3] = (*cstd)[0][3] + (*cstd)[0][0] * b + - (*cstd)[0][1] * (x * cbbias + y * crbias) + - (*cstd)[0][2] * (x * crbias - y * cbbias); + (*matrix)[0][1] = c * (*cstd)[0][1] * s * cosf(h) - c * (*cstd)[0][2] * s * sinf(h); + (*matrix)[0][2] = c * (*cstd)[0][2] * s * cosf(h) + c * (*cstd)[0][1] * s * sinf(h); + (*matrix)[0][3] = (*cstd)[0][3] + (*cstd)[0][0] * (b + c * ybias) + + (*cstd)[0][1] * (c * cbbias * s * cosf(h) + c * crbias * s * sinf(h)) + + (*cstd)[0][2] * (c * crbias * s * cosf(h) - c * cbbias * s * sinf(h)); (*matrix)[1][0] = c * (*cstd)[1][0]; - (*matrix)[1][1] = (*cstd)[1][1] * x - (*cstd)[1][2] * y; - (*matrix)[1][2] = (*cstd)[1][2] * x + (*cstd)[1][1] * y; - (*matrix)[1][3] = (*cstd)[1][3] + (*cstd)[1][0] * b + - (*cstd)[1][1] * (x * cbbias + y * crbias) + - (*cstd)[1][2] * (x * crbias - y * cbbias); + (*matrix)[1][1] = c * (*cstd)[1][1] * s * cosf(h) - c * (*cstd)[1][2] * s * sinf(h); + (*matrix)[1][2] = c * (*cstd)[1][2] * s * cosf(h) + c * (*cstd)[1][1] * s * sinf(h); + (*matrix)[1][3] = (*cstd)[1][3] + (*cstd)[1][0] * (b + c * ybias) + + (*cstd)[1][1] * (c * cbbias * s * cosf(h) + c * crbias * s * sinf(h)) + + (*cstd)[1][2] * (c * crbias * s * cosf(h) - c * cbbias * s * sinf(h)); (*matrix)[2][0] = c * (*cstd)[2][0]; - (*matrix)[2][1] = (*cstd)[2][1] * x - (*cstd)[2][2] * y; - (*matrix)[2][2] = (*cstd)[2][2] * x + (*cstd)[2][1] * y; - (*matrix)[2][3] = (*cstd)[2][3] + (*cstd)[2][0] * b + - (*cstd)[2][1] * (x * cbbias + y * crbias) + - (*cstd)[2][2] * (x * crbias - y * cbbias); + (*matrix)[2][1] = c * (*cstd)[2][1] * s * cosf(h) - c * (*cstd)[2][2] * s * sinf(h); + (*matrix)[2][2] = c * (*cstd)[2][2] * s * cosf(h) + c * (*cstd)[2][1] * s * sinf(h); + (*matrix)[2][3] = (*cstd)[2][3] + (*cstd)[2][0] * (b + c * ybias) + + (*cstd)[2][1] * (c * cbbias * s * cosf(h) + c * crbias * s * sinf(h)) + + (*cstd)[2][2] * (c * crbias * s * cosf(h) - c * cbbias * s * sinf(h)); } 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 d2c48bda7..3ca3b4954 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c @@ -173,21 +173,21 @@ create_deint_frag_shader(struct vl_deint_filter *filter, unsigned field, // cur vs prev2 ureg_TEX(shader, t_a, TGSI_TEXTURE_2D_ARRAY, ureg_src(t_comp_bot), sampler_cur); ureg_TEX(shader, t_b, TGSI_TEXTURE_2D_ARRAY, ureg_src(t_comp_bot), sampler_prevprev); - ureg_ADD(shader, ureg_writemask(t_diff, TGSI_WRITEMASK_X), ureg_src(t_a), ureg_negate(ureg_src(t_b))); + ureg_SUB(shader, ureg_writemask(t_diff, TGSI_WRITEMASK_X), ureg_src(t_a), ureg_src(t_b)); // prev vs next ureg_TEX(shader, t_a, TGSI_TEXTURE_2D_ARRAY, ureg_src(t_comp_top), sampler_prev); ureg_TEX(shader, t_b, TGSI_TEXTURE_2D_ARRAY, ureg_src(t_comp_top), sampler_next); - ureg_ADD(shader, ureg_writemask(t_diff, TGSI_WRITEMASK_Y), ureg_src(t_a), ureg_negate(ureg_src(t_b))); + ureg_SUB(shader, ureg_writemask(t_diff, TGSI_WRITEMASK_Y), ureg_src(t_a), ureg_src(t_b)); } else { /* interpolating bottom field -> current field is a top field */ // cur vs prev2 ureg_TEX(shader, t_a, TGSI_TEXTURE_2D_ARRAY, ureg_src(t_comp_top), sampler_cur); ureg_TEX(shader, t_b, TGSI_TEXTURE_2D_ARRAY, ureg_src(t_comp_top), sampler_prevprev); - ureg_ADD(shader, ureg_writemask(t_diff, TGSI_WRITEMASK_X), ureg_src(t_a), ureg_negate(ureg_src(t_b))); + ureg_SUB(shader, ureg_writemask(t_diff, TGSI_WRITEMASK_X), ureg_src(t_a), ureg_src(t_b)); // prev vs next ureg_TEX(shader, t_a, TGSI_TEXTURE_2D_ARRAY, ureg_src(t_comp_bot), sampler_prev); ureg_TEX(shader, t_b, TGSI_TEXTURE_2D_ARRAY, ureg_src(t_comp_bot), sampler_next); - ureg_ADD(shader, ureg_writemask(t_diff, TGSI_WRITEMASK_Y), ureg_src(t_a), ureg_negate(ureg_src(t_b))); + ureg_SUB(shader, ureg_writemask(t_diff, TGSI_WRITEMASK_Y), ureg_src(t_a), ureg_src(t_b)); } // absolute maximum of differences @@ -308,7 +308,7 @@ vl_deint_filter_init(struct vl_deint_filter *filter, struct pipe_context *pipe, goto error_sampler; filter->quad = vl_vb_upload_quads(pipe); - if(!filter->quad.buffer.resource) + if(!filter->quad.buffer) goto error_quad; memset(&ve, 0, sizeof(ve)); @@ -361,7 +361,7 @@ error_vs: pipe->delete_vertex_elements_state(pipe, filter->ves); error_ves: - pipe_resource_reference(&filter->quad.buffer.resource, NULL); + pipe_resource_reference(&filter->quad.buffer, NULL); error_quad: pipe->delete_sampler_state(pipe, filter->sampler); @@ -396,7 +396,7 @@ vl_deint_filter_cleanup(struct vl_deint_filter *filter) 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.resource, NULL); + pipe_resource_reference(&filter->quad.buffer, NULL); filter->pipe->delete_vs_state(filter->pipe, filter->vs); filter->pipe->delete_fs_state(filter->pipe, filter->fs_copy_top); 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 1dacc7c60..e331cb758 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c @@ -81,50 +81,69 @@ create_frag_shader(struct vl_matrix_filter *filter, unsigned num_offsets, struct ureg_program *shader; struct ureg_src i_vtex; struct ureg_src sampler; - struct ureg_dst tmp; + struct ureg_dst *t_array = MALLOC(sizeof(struct ureg_dst) * num_offsets); struct ureg_dst t_sum; struct ureg_dst o_fragment; + bool first; unsigned i; shader = ureg_create(PIPE_SHADER_FRAGMENT); if (!shader) { + FREE(t_array); return NULL; } i_vtex = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX, TGSI_INTERPOLATE_LINEAR); sampler = ureg_DECL_sampler(shader, 0); - ureg_DECL_sampler_view(shader, 0, TGSI_TEXTURE_2D, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT); - - tmp = ureg_DECL_temporary(shader); - t_sum = ureg_DECL_temporary(shader); + + for (i = 0; i < num_offsets; ++i) + if (matrix_values[i] != 0.0f) + t_array[i] = ureg_DECL_temporary(shader); + o_fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0); - ureg_MOV(shader, t_sum, ureg_imm1f(shader, 0.0f)); - for (i = 0; i < num_offsets; ++i) { - if (matrix_values[i] == 0.0f) - continue; + /* + * t_array[0..*] = vtex + offset[0..*] + * t_array[0..*] = tex(t_array[0..*], sampler) + * o_fragment = sum(t_array[0..*] * matrix_values[0..*]) + */ - if (!is_vec_zero(offsets[i])) { - ureg_ADD(shader, ureg_writemask(tmp, TGSI_WRITEMASK_XY), + for (i = 0; i < num_offsets; ++i) { + if (matrix_values[i] != 0.0f && !is_vec_zero(offsets[i])) { + ureg_ADD(shader, ureg_writemask(t_array[i], TGSI_WRITEMASK_XY), i_vtex, ureg_imm2f(shader, offsets[i].x, offsets[i].y)); - ureg_MOV(shader, ureg_writemask(tmp, TGSI_WRITEMASK_ZW), + ureg_MOV(shader, ureg_writemask(t_array[i], TGSI_WRITEMASK_ZW), ureg_imm1f(shader, 0.0f)); - ureg_TEX(shader, tmp, TGSI_TEXTURE_2D, ureg_src(tmp), sampler); - } else { - ureg_TEX(shader, tmp, TGSI_TEXTURE_2D, i_vtex, sampler); } - ureg_MAD(shader, t_sum, ureg_src(tmp), ureg_imm1f(shader, matrix_values[i]), - ureg_src(t_sum)); } - ureg_MOV(shader, o_fragment, ureg_src(t_sum)); + for (i = 0; i < num_offsets; ++i) { + if (matrix_values[i] != 0.0f) { + struct ureg_src src = is_vec_zero(offsets[i]) ? i_vtex : ureg_src(t_array[i]); + ureg_TEX(shader, t_array[i], TGSI_TEXTURE_2D, src, sampler); + } + } + + for (i = 0, first = true; i < num_offsets; ++i) { + if (matrix_values[i] != 0.0f) { + if (first) { + t_sum = t_array[i]; + ureg_MUL(shader, t_sum, ureg_src(t_array[i]), + ureg_imm1f(shader, matrix_values[i])); + first = false; + } else + ureg_MAD(shader, t_sum, ureg_src(t_array[i]), + ureg_imm1f(shader, matrix_values[i]), ureg_src(t_sum)); + } + } + if (first) + ureg_MOV(shader, o_fragment, ureg_imm1f(shader, 0.0f)); + else + ureg_MOV(shader, o_fragment, ureg_src(t_sum)); ureg_END(shader); + FREE(t_array); return ureg_create_shader_and_destroy(shader, filter->pipe); } @@ -184,7 +203,7 @@ vl_matrix_filter_init(struct vl_matrix_filter *filter, struct pipe_context *pipe goto error_sampler; filter->quad = vl_vb_upload_quads(pipe); - if(!filter->quad.buffer.resource) + if(!filter->quad.buffer) goto error_quad; memset(&ve, 0, sizeof(ve)); @@ -233,7 +252,7 @@ error_offsets: pipe->delete_vertex_elements_state(pipe, filter->ves); error_ves: - pipe_resource_reference(&filter->quad.buffer.resource, NULL); + pipe_resource_reference(&filter->quad.buffer, NULL); error_quad: pipe->delete_sampler_state(pipe, filter->sampler); @@ -257,7 +276,7 @@ vl_matrix_filter_cleanup(struct vl_matrix_filter *filter) filter->pipe->delete_blend_state(filter->pipe, filter->blend); 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.resource, NULL); + pipe_resource_reference(&filter->quad.buffer, NULL); filter->pipe->delete_vs_state(filter->pipe, filter->vs); filter->pipe->delete_fs_state(filter->pipe, filter->fs); 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 273afaf2f..f7477b757 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c @@ -107,11 +107,6 @@ create_frag_shader(struct vl_median_filter *filter, i_vtex = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTEX, TGSI_INTERPOLATE_LINEAR); sampler = ureg_DECL_sampler(shader, 0); - ureg_DECL_sampler_view(shader, 0, TGSI_TEXTURE_2D, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT, - TGSI_RETURN_TYPE_FLOAT); for (i = 0; i < num_offsets; ++i) t_array[i] = ureg_DECL_temporary(shader); @@ -295,7 +290,7 @@ vl_median_filter_init(struct vl_median_filter *filter, struct pipe_context *pipe goto error_sampler; filter->quad = vl_vb_upload_quads(pipe); - if(!filter->quad.buffer.resource) + if(!filter->quad.buffer) goto error_quad; memset(&ve, 0, sizeof(ve)); @@ -337,7 +332,7 @@ error_offsets: pipe->delete_vertex_elements_state(pipe, filter->ves); error_ves: - pipe_resource_reference(&filter->quad.buffer.resource, NULL); + pipe_resource_reference(&filter->quad.buffer, NULL); error_quad: pipe->delete_sampler_state(pipe, filter->sampler); @@ -361,7 +356,7 @@ vl_median_filter_cleanup(struct vl_median_filter *filter) filter->pipe->delete_blend_state(filter->pipe, filter->blend); 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.resource, NULL); + pipe_resource_reference(&filter->quad.buffer, NULL); filter->pipe->delete_vs_state(filter->pipe, filter->vs); filter->pipe->delete_fs_state(filter->pipe, filter->fs); diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/lib/mesa/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index b70098372..db62b44f5 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -189,7 +189,7 @@ init_zscan_buffer(struct vl_mpeg12_decoder *dec, struct vl_mpeg12_buffer *buffer memset(&sv_tmpl, 0, sizeof(sv_tmpl)); u_sampler_view_default_template(&sv_tmpl, res, res->format); - sv_tmpl.swizzle_r = sv_tmpl.swizzle_g = sv_tmpl.swizzle_b = sv_tmpl.swizzle_a = PIPE_SWIZZLE_RED; + sv_tmpl.swizzle_r = sv_tmpl.swizzle_g = sv_tmpl.swizzle_b = sv_tmpl.swizzle_a = PIPE_SWIZZLE_X; buffer->zscan_source = dec->context->create_sampler_view(dec->context, res, &sv_tmpl); pipe_resource_reference(&res, NULL); if (!buffer->zscan_source) @@ -542,7 +542,7 @@ vl_mpeg12_get_decode_buffer(struct vl_mpeg12_decoder *dec, struct pipe_video_buf return buffer; buffer = CALLOC_STRUCT(vl_mpeg12_buffer); - if (buffer == NULL) + if (!buffer) return NULL; if (!vl_vb_init(&buffer->vertex_stream, dec->context, @@ -792,7 +792,7 @@ vl_mpeg12_end_frame(struct pipe_video_codec *decoder, for (j = 0; j < VL_MAX_REF_FRAMES; ++j) { if (!ref_frames[j] || !ref_frames[j][i]) continue; - vb[2] = vl_vb_get_mv(&buf->vertex_stream, j);; + vb[2] = vl_vb_get_mv(&buf->vertex_stream, j); dec->context->set_vertex_buffers(dec->context, 0, 3, vb); vl_mc_render_ref(i ? &dec->mc_c : &dec->mc_y, &buf->mc[i], ref_frames[j][i]); @@ -1120,7 +1120,7 @@ vl_create_mpeg12_decoder(struct pipe_context *context, dec->base = *templat; dec->base.context = context; - dec->context = context->screen->context_create(context->screen, NULL); + dec->context = context->screen->context_create(context->screen, NULL, 0); dec->base.destroy = vl_mpeg12_destroy; dec->base.begin_frame = vl_mpeg12_begin_frame; diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_vertex_buffers.c b/lib/mesa/src/gallium/auxiliary/vl/vl_vertex_buffers.c index 45a9badce..13d3f8c30 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_vertex_buffers.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_vertex_buffers.c @@ -49,23 +49,23 @@ vl_vb_upload_quads(struct pipe_context *pipe) /* create buffer */ quad.stride = sizeof(struct vertex2f); quad.buffer_offset = 0; - quad.buffer.resource = pipe_buffer_create + quad.buffer = pipe_buffer_create ( pipe->screen, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_DEFAULT, sizeof(struct vertex2f) * 4 ); - quad.is_user_buffer = false; + quad.user_buffer = NULL; - if(!quad.buffer.resource) + if(!quad.buffer) return quad; /* and fill it */ v = pipe_buffer_map ( pipe, - quad.buffer.resource, + quad.buffer, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &buf_transfer ); @@ -94,23 +94,23 @@ vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height) /* create buffer */ pos.stride = sizeof(struct vertex2s); pos.buffer_offset = 0; - pos.buffer.resource = pipe_buffer_create + pos.buffer = pipe_buffer_create ( pipe->screen, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_DEFAULT, sizeof(struct vertex2s) * width * height ); - pos.is_user_buffer = false; + pos.user_buffer = NULL; - if(!pos.buffer.resource) + if(!pos.buffer) return pos; /* and fill it */ v = pipe_buffer_map ( pipe, - pos.buffer.resource, + pos.buffer, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &buf_transfer ); @@ -241,6 +241,7 @@ vl_vb_init(struct vl_vertex_buffer *buffer, struct pipe_context *pipe, goto error_mv; } + vl_vb_map(buffer, pipe); return true; error_mv: @@ -268,8 +269,8 @@ vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component) buf.stride = sizeof(struct vl_ycbcr_block); buf.buffer_offset = 0; - buf.buffer.resource = buffer->ycbcr[component].resource; - buf.is_user_buffer = false; + buf.buffer = buffer->ycbcr[component].resource; + buf.user_buffer = NULL; return buf; } @@ -283,8 +284,8 @@ vl_vb_get_mv(struct vl_vertex_buffer *buffer, int motionvector) buf.stride = sizeof(struct vl_motionvector); buf.buffer_offset = 0; - buf.buffer.resource = buffer->mv[motionvector].resource; - buf.is_user_buffer = false; + buf.buffer = buffer->mv[motionvector].resource; + buf.user_buffer = NULL; return buf; } 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 3b97ac81a..fdc9598f8 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -86,12 +86,6 @@ const enum pipe_format const_resource_formats_UYVY[3] = { PIPE_FORMAT_NONE }; -const enum pipe_format const_resource_formats_P016[3] = { - PIPE_FORMAT_R16_UNORM, - PIPE_FORMAT_R16G16_UNORM, - PIPE_FORMAT_NONE -}; - const unsigned const_resource_plane_order_YUV[3] = { 0, 1, @@ -132,9 +126,6 @@ vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format) case PIPE_FORMAT_UYVY: return const_resource_formats_UYVY; - case PIPE_FORMAT_P016: - return const_resource_formats_P016; - default: return NULL; } @@ -152,7 +143,6 @@ vl_video_buffer_plane_order(enum pipe_format format) case PIPE_FORMAT_B8G8R8A8_UNORM: case PIPE_FORMAT_YUYV: case PIPE_FORMAT_UYVY: - case PIPE_FORMAT_P016: return const_resource_plane_order_YUV; default: @@ -248,8 +238,6 @@ vl_video_buffer_template(struct pipe_resource *templ, unsigned depth, unsigned array_size, unsigned usage, unsigned plane) { - unsigned height = tmpl->height; - memset(templ, 0, sizeof(*templ)); if (depth > 1) templ->target = PIPE_TEXTURE_3D; @@ -259,14 +247,14 @@ vl_video_buffer_template(struct pipe_resource *templ, templ->target = PIPE_TEXTURE_2D; templ->format = resource_format; templ->width0 = tmpl->width; + templ->height0 = tmpl->height; templ->depth0 = depth; templ->array_size = array_size; templ->bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET | tmpl->bind; templ->usage = usage; - vl_video_buffer_adjust_size(&templ->width0, &height, plane, + vl_video_buffer_adjust_size(&templ->width0, &templ->height0, plane, tmpl->chroma_format, false); - templ->height0 = height; } static void diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h index 77277cefe..26db9f263 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h @@ -32,9 +32,7 @@ #ifndef vl_winsys_h #define vl_winsys_h -#ifdef HAVE_X11_PLATFORM #include <X11/Xlib.h> -#endif #include "pipe/p_defines.h" #include "pipe/p_format.h" @@ -61,37 +59,19 @@ struct vl_screen void * (*get_private)(struct vl_screen *vscreen); - void - (*set_back_texture_from_output)(struct vl_screen *vscreen, - struct pipe_resource *buffer, - uint32_t width, uint32_t height); - struct pipe_screen *pscreen; struct pipe_loader_device *dev; }; -#ifdef HAVE_X11_PLATFORM struct vl_screen * vl_dri2_screen_create(Display *display, int screen); -#else -static inline struct vl_screen * -vl_dri2_screen_create(void *display, int screen) { return NULL; }; -#endif -#if defined(HAVE_X11_PLATFORM) && defined(HAVE_DRI3) struct vl_screen * -vl_dri3_screen_create(Display *display, int screen); -#else -static inline struct vl_screen * -vl_dri3_screen_create(void *display, int screen) { return NULL; }; -#endif +vl_drm_screen_create(int fd); -#ifdef HAVE_DRM_PLATFORM +#if defined(HAVE_DRI3) struct vl_screen * -vl_drm_screen_create(int fd); -#else -static inline struct vl_screen * -vl_drm_screen_create(int fd) { return NULL; }; +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 043483b7f..9ecc216b9 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c @@ -46,7 +46,7 @@ #include "state_tracker/drm_driver.h" #include "util/u_memory.h" -#include "util/crc32.h" +#include "util/u_hash.h" #include "util/u_hash_table.h" #include "util/u_inlines.h" @@ -326,7 +326,6 @@ vl_dri2_screen_create(Display *display, int screen) xcb_dri2_authenticate_cookie_t authenticate_cookie; xcb_dri2_authenticate_reply_t *authenticate = NULL; xcb_screen_iterator_t s; - xcb_screen_t *xcb_screen; xcb_generic_error_t *error = NULL; char *device_name; int fd, device_name_length; @@ -358,11 +357,9 @@ vl_dri2_screen_create(Display *display, int screen) goto free_query; s = xcb_setup_roots_iterator(xcb_get_setup(scrn->conn)); - xcb_screen = get_xcb_screen(s, screen); - if (!xcb_screen) - goto free_query; driverType = XCB_DRI2_DRIVER_TYPE_DRI; +#ifdef DRI2DriverPrimeShift { char *prime = getenv("DRI_PRIME"); if (prime) { @@ -374,9 +371,10 @@ vl_dri2_screen_create(Display *display, int screen) ((primeid & DRI2DriverPrimeMask) << DRI2DriverPrimeShift); } } +#endif connect_cookie = xcb_dri2_connect_unchecked(scrn->conn, - xcb_screen->root, + get_xcb_screen(s, screen)->root, driverType); connect = xcb_dri2_connect_reply(scrn->conn, connect_cookie, NULL); if (connect == NULL || @@ -398,7 +396,7 @@ vl_dri2_screen_create(Display *display, int screen) goto close_fd; authenticate_cookie = xcb_dri2_authenticate_unchecked(scrn->conn, - xcb_screen->root, + get_xcb_screen(s, screen)->root, magic); authenticate = xcb_dri2_authenticate_reply(scrn->conn, authenticate_cookie, NULL); @@ -406,7 +404,7 @@ vl_dri2_screen_create(Display *display, int screen) goto free_authenticate; if (pipe_loader_drm_probe_fd(&scrn->base.dev, fd)) - scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev, 0); + scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev); if (!scrn->base.pscreen) goto release_pipe; diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri3.c index 68bac44d9..29299289f 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri3.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri3.c @@ -31,7 +31,6 @@ #include <X11/xshmfence.h> #include <xcb/dri3.h> #include <xcb/present.h> -#include <xcb/xfixes.h> #include "loader.h" @@ -72,12 +71,9 @@ struct vl_dri3_screen xcb_special_event_t *special_event; struct pipe_context *pipe; - struct pipe_resource *output_texture; - uint32_t clip_width, clip_height; struct vl_dri3_buffer *back_buffers[BACK_BUFFER_NUM]; int cur_back; - int next_back; struct u_rect dirty_areas[BACK_BUFFER_NUM]; @@ -89,7 +85,7 @@ struct vl_dri3_screen int64_t last_ust, ns_frame, last_msc, next_msc; bool flushed; - bool is_different_gpu; + int is_different_gpu; }; static void @@ -109,8 +105,7 @@ dri3_free_back_buffer(struct vl_dri3_screen *scrn, xcb_free_pixmap(scrn->conn, buffer->pixmap); xcb_sync_destroy_fence(scrn->conn, buffer->sync_fence); xshmfence_unmap_shm(buffer->shm_fence); - if (!scrn->output_texture) - pipe_resource_reference(&buffer->texture, NULL); + pipe_resource_reference(&buffer->texture, NULL); if (buffer->linear_texture) pipe_resource_reference(&buffer->linear_texture, NULL); FREE(buffer); @@ -241,31 +236,29 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn) templ.format = PIPE_FORMAT_B8G8R8X8_UNORM; templ.target = PIPE_TEXTURE_2D; templ.last_level = 0; - templ.width0 = (scrn->output_texture) ? - scrn->output_texture->width0 : scrn->width; - templ.height0 = (scrn->output_texture) ? - scrn->output_texture->height0 : scrn->height; + templ.width0 = scrn->width; + templ.height0 = scrn->height; templ.depth0 = 1; templ.array_size = 1; if (scrn->is_different_gpu) { - buffer->texture = (scrn->output_texture) ? scrn->output_texture : - scrn->base.pscreen->resource_create(scrn->base.pscreen, &templ); + buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen, + &templ); if (!buffer->texture) goto unmap_shm; templ.bind |= PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_LINEAR; - buffer->linear_texture = - scrn->base.pscreen->resource_create(scrn->base.pscreen, &templ); + buffer->linear_texture = scrn->base.pscreen->resource_create(scrn->base.pscreen, + &templ); pixmap_buffer_texture = buffer->linear_texture; if (!buffer->linear_texture) goto no_linear_texture; } else { templ.bind |= PIPE_BIND_SCANOUT | PIPE_BIND_SHARED; - buffer->texture = (scrn->output_texture) ? scrn->output_texture : - scrn->base.pscreen->resource_create(scrn->base.pscreen, &templ); + buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen, + &templ); if (!buffer->texture) goto unmap_shm; pixmap_buffer_texture = buffer->texture; @@ -278,14 +271,11 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn) usage); buffer_fd = whandle.handle; buffer->pitch = whandle.stride; - buffer->width = templ.width0; - buffer->height = templ.height0; - xcb_dri3_pixmap_from_buffer(scrn->conn, (pixmap = xcb_generate_id(scrn->conn)), scrn->drawable, 0, - buffer->width, buffer->height, buffer->pitch, + scrn->width, scrn->height, buffer->pitch, scrn->depth, 32, buffer_fd); xcb_dri3_fence_from_fd(scrn->conn, @@ -297,6 +287,8 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn) buffer->pixmap = pixmap; buffer->sync_fence = sync_fence; buffer->shm_fence = shm_fence; + buffer->width = scrn->width; + buffer->height = scrn->height; xshmfence_trigger(buffer->shm_fence); @@ -318,8 +310,6 @@ dri3_get_back_buffer(struct vl_dri3_screen *scrn) { struct vl_dri3_buffer *buffer; struct pipe_resource *texture = NULL; - bool allocate_new_buffer = false; - int b, id; assert(scrn); @@ -328,46 +318,8 @@ dri3_get_back_buffer(struct vl_dri3_screen *scrn) return NULL; buffer = scrn->back_buffers[scrn->cur_back]; - if (scrn->output_texture) { - if (!buffer || buffer->width < scrn->width || - buffer->height < scrn->height) - allocate_new_buffer = true; - else if (scrn->is_different_gpu) - /* In case of different gpu we can reuse the linear - * texture so we only need to set the external - * texture for copying - */ - buffer->texture = scrn->output_texture; - else { - /* In case of a single gpu we search if the texture is - * already present as buffer if not we get the - * handle and pixmap for the texture that is set - */ - for (b = 0; b < BACK_BUFFER_NUM; b++) { - id = (b + scrn->cur_back) % BACK_BUFFER_NUM; - buffer = scrn->back_buffers[id]; - if (buffer && !buffer->busy && - buffer->texture == scrn->output_texture) { - scrn->cur_back = id; - break; - } - } - - if (b == BACK_BUFFER_NUM) { - allocate_new_buffer = true; - scrn->cur_back = scrn->next_back; - scrn->next_back = (scrn->next_back + 1) % BACK_BUFFER_NUM; - buffer = scrn->back_buffers[scrn->cur_back]; - } - } - - } else { - if (!buffer || buffer->width != scrn->width || - buffer->height != scrn->height) - allocate_new_buffer = true; - } - - if (allocate_new_buffer) { + if (!buffer || buffer->width != scrn->width || + buffer->height != scrn->height) { struct vl_dri3_buffer *new_buffer; new_buffer = dri3_alloc_back_buffer(scrn); @@ -377,8 +329,7 @@ dri3_get_back_buffer(struct vl_dri3_screen *scrn) if (buffer) dri3_free_back_buffer(scrn, buffer); - if (!scrn->output_texture) - vl_compositor_reset_dirty_area(&scrn->dirty_areas[scrn->cur_back]); + vl_compositor_reset_dirty_area(&scrn->dirty_areas[scrn->cur_back]); buffer = new_buffer; scrn->back_buffers[scrn->cur_back] = buffer; } @@ -549,8 +500,6 @@ vl_dri3_flush_frontbuffer(struct pipe_screen *screen, uint32_t options = XCB_PRESENT_OPTION_NONE; struct vl_dri3_buffer *back; struct pipe_box src_box; - xcb_xfixes_region_t region; - xcb_rectangle_t rectangle; back = scrn->back_buffers[scrn->cur_back]; if (!back) @@ -562,16 +511,8 @@ vl_dri3_flush_frontbuffer(struct pipe_screen *screen, return; } - rectangle.x = 0; - rectangle.y = 0; - rectangle.width = (scrn->output_texture) ? scrn->clip_width : scrn->width; - rectangle.height = (scrn->output_texture) ? scrn->clip_height : scrn->height; - - region = xcb_generate_id(scrn->conn); - xcb_xfixes_create_region(scrn->conn, region, 2, &rectangle); - if (scrn->is_different_gpu) { - u_box_origin_2d(back->width, back->height, &src_box); + u_box_origin_2d(scrn->width, scrn->height, &src_box); scrn->pipe->resource_copy_region(scrn->pipe, back->linear_texture, 0, 0, 0, 0, @@ -587,7 +528,7 @@ vl_dri3_flush_frontbuffer(struct pipe_screen *screen, scrn->drawable, back->pixmap, (uint32_t)(++scrn->send_sbc), - 0, region, 0, 0, + 0, 0, 0, 0, None, None, back->sync_fence, options, @@ -686,20 +627,6 @@ vl_dri3_screen_get_private(struct vl_screen *vscreen) } static void -vl_dri3_screen_set_back_texture_from_output(struct vl_screen *vscreen, - struct pipe_resource *buffer, - uint32_t width, uint32_t height) -{ - struct vl_dri3_screen *scrn = (struct vl_dri3_screen *)vscreen; - - assert(scrn); - - scrn->output_texture = buffer; - scrn->clip_width = (width) ? width : scrn->width; - scrn->clip_height = (height) ? height : scrn->height; -} - -static void vl_dri3_screen_destroy(struct vl_screen *vscreen) { struct vl_dri3_screen *scrn = (struct vl_dri3_screen *)vscreen; @@ -748,9 +675,6 @@ vl_dri3_screen_create(Display *display, int screen) xcb_dri3_open_reply_t *open_reply; xcb_get_geometry_cookie_t geom_cookie; xcb_get_geometry_reply_t *geom_reply; - xcb_xfixes_query_version_cookie_t xfixes_cookie; - xcb_xfixes_query_version_reply_t *xfixes_reply; - xcb_generic_error_t *error; int fd; assert(display); @@ -765,26 +689,12 @@ vl_dri3_screen_create(Display *display, int screen) xcb_prefetch_extension_data(scrn->conn , &xcb_dri3_id); xcb_prefetch_extension_data(scrn->conn, &xcb_present_id); - xcb_prefetch_extension_data (scrn->conn, &xcb_xfixes_id); extension = xcb_get_extension_data(scrn->conn, &xcb_dri3_id); if (!(extension && extension->present)) goto free_screen; extension = xcb_get_extension_data(scrn->conn, &xcb_present_id); if (!(extension && extension->present)) goto free_screen; - extension = xcb_get_extension_data(scrn->conn, &xcb_xfixes_id); - if (!(extension && extension->present)) - goto free_screen; - - xfixes_cookie = xcb_xfixes_query_version(scrn->conn, XCB_XFIXES_MAJOR_VERSION, - XCB_XFIXES_MINOR_VERSION); - xfixes_reply = xcb_xfixes_query_version_reply(scrn->conn, xfixes_cookie, &error); - if (!xfixes_reply || error || xfixes_reply->major_version < 2) { - free(error); - free(xfixes_reply); - goto free_screen; - } - free(xfixes_reply); open_cookie = xcb_dri3_open(scrn->conn, RootWindow(display, screen), None); open_reply = xcb_dri3_open_reply(scrn->conn, open_cookie, NULL); @@ -817,13 +727,13 @@ vl_dri3_screen_create(Display *display, int screen) free(geom_reply); if (pipe_loader_drm_probe_fd(&scrn->base.dev, fd)) - scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev, 0); + scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev); if (!scrn->base.pscreen) goto release_pipe; scrn->pipe = scrn->base.pscreen->context_create(scrn->base.pscreen, - NULL, 0); + &scrn->base, 0); if (!scrn->pipe) goto no_context; @@ -834,9 +744,7 @@ vl_dri3_screen_create(Display *display, int screen) scrn->base.set_next_timestamp = vl_dri3_screen_set_next_timestamp; scrn->base.get_private = vl_dri3_screen_get_private; scrn->base.pscreen->flush_frontbuffer = vl_dri3_flush_frontbuffer; - scrn->base.set_back_texture_from_output = vl_dri3_screen_set_back_texture_from_output; - scrn->next_back = 1; return &scrn->base; no_context: diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_drm.c b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_drm.c index 6d9d94758..df8809c50 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_drm.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_drm.c @@ -26,6 +26,7 @@ **************************************************************************/ #include <assert.h> +#include <fcntl.h> #include "pipe/p_screen.h" #include "pipe-loader/pipe_loader.h" @@ -41,20 +42,20 @@ struct vl_screen * vl_drm_screen_create(int fd) { struct vl_screen *vscreen; - int new_fd = -1; + int new_fd; vscreen = CALLOC_STRUCT(vl_screen); if (!vscreen) return NULL; - if (fd < 0 || (new_fd = dup(fd)) < 0) - goto error; + if (fd < 0 || (new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) < 0) + goto free_screen; if (pipe_loader_drm_probe_fd(&vscreen->dev, new_fd)) vscreen->pscreen = pipe_loader_create_screen(vscreen->dev); if (!vscreen->pscreen) - goto error; + goto release_pipe; vscreen->destroy = vl_drm_screen_destroy; vscreen->texture_from_drawable = NULL; @@ -64,12 +65,13 @@ vl_drm_screen_create(int fd) vscreen->get_private = NULL; return vscreen; -error: +release_pipe: if (vscreen->dev) pipe_loader_release(&vscreen->dev, 1); else close(new_fd); +free_screen: FREE(vscreen); return NULL; } diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c b/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c index 75013c42b..24d64525b 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c @@ -95,27 +95,6 @@ const int vl_zscan_alternate[] = 38,46,54,62,39,47,55,63 }; -const int vl_zscan_h265_up_right_diagonal_16[] = -{ - /* Up-right diagonal scan order for 4x4 blocks - see H.265 section 6.5.3. */ - 0, 4, 1, 8, 5, 2, 12, 9, - 6, 3, 13, 10, 7, 14, 11, 15, -}; - -const int vl_zscan_h265_up_right_diagonal[] = -{ - /* Up-right diagonal scan order for 8x8 blocks - see H.265 section 6.5.3. */ - 0, 8, 1, 16, 9, 2, 24, 17, - 10, 3, 32, 25, 18, 11, 4, 40, - 33, 26, 19, 12, 5, 48, 41, 34, - 27, 20, 13, 6, 56, 49, 42, 35, - 28, 21, 14, 7, 57, 50, 43, 36, - 29, 22, 15, 58, 51, 44, 37, 30, - 23, 59, 52, 45, 38, 31, 60, 53, - 46, 39, 61, 54, 47, 62, 55, 63, -}; - - static void * create_vert_shader(struct vl_zscan *zscan) { diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.h b/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.h index 292152e87..268cf0a6e 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.h +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.h @@ -68,8 +68,6 @@ 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[]; -extern const int vl_zscan_h265_up_right_diagonal_16[]; -extern const int vl_zscan_h265_up_right_diagonal[]; struct pipe_sampler_view * vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks_per_line); |