gallium/vl: add 4:2:2 support
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2363 Reviewed-by: Marek Olšák <marek.olsak@amd.com> Acked-by: Leo Liu <leo.liu@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3738>
This commit is contained in:
@@ -813,7 +813,7 @@ 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) + 6*sizeof(float) + 6*sizeof(int)
|
||||
sizeof(csc_matrix) + 6*sizeof(float) + 10*sizeof(int)
|
||||
);
|
||||
|
||||
if (!s->shader_params)
|
||||
|
||||
@@ -51,7 +51,7 @@ const char *compute_shader_video_buffer =
|
||||
"DCL SV[0], THREAD_ID\n"
|
||||
"DCL SV[1], BLOCK_ID\n"
|
||||
|
||||
"DCL CONST[0..5]\n"
|
||||
"DCL CONST[0..6]\n"
|
||||
"DCL SVIEW[0..2], RECT, FLOAT\n"
|
||||
"DCL SAMP[0..2]\n"
|
||||
|
||||
@@ -59,7 +59,7 @@ const char *compute_shader_video_buffer =
|
||||
"DCL TEMP[0..7]\n"
|
||||
|
||||
"IMM[0] UINT32 { 8, 8, 1, 0}\n"
|
||||
"IMM[1] FLT32 { 1.0, 2.0, 0.0, 0.0}\n"
|
||||
"IMM[1] FLT32 { 1.0, 0.0, 0.0, 0.0}\n"
|
||||
|
||||
"UMAD TEMP[0].xy, SV[1].xyyy, IMM[0].xyyy, SV[0].xyyy\n"
|
||||
|
||||
@@ -74,7 +74,7 @@ const char *compute_shader_video_buffer =
|
||||
/* Translate */
|
||||
"UADD TEMP[2].xy, TEMP[0].xyyy, -CONST[5].xyxy\n"
|
||||
"U2F TEMP[2].xy, TEMP[2].xyyy\n"
|
||||
"DIV TEMP[3].xy, TEMP[2].xyyy, IMM[1].yyyy\n"
|
||||
"MUL TEMP[3].xy, TEMP[2].xyyy, CONST[6].xyyy\n"
|
||||
|
||||
/* Scale */
|
||||
"DIV TEMP[2].xy, TEMP[2].xyyy, CONST[3].zwww\n"
|
||||
@@ -646,7 +646,8 @@ calc_drawn_area(struct vl_compositor_state *s,
|
||||
|
||||
static bool
|
||||
set_viewport(struct vl_compositor_state *s,
|
||||
struct cs_viewport *drawn)
|
||||
struct cs_viewport *drawn,
|
||||
struct pipe_sampler_view **samplers)
|
||||
{
|
||||
struct pipe_transfer *buf_transfer;
|
||||
|
||||
@@ -674,7 +675,19 @@ set_viewport(struct vl_compositor_state *s,
|
||||
|
||||
ptr_float = (float *)ptr_int;
|
||||
*ptr_float++ = drawn->sampler0_w;
|
||||
*ptr_float = drawn->sampler0_h;
|
||||
*ptr_float++ = drawn->sampler0_h;
|
||||
|
||||
/* compute_shader_video_buffer uses pixel coordinates based on the
|
||||
* Y sampler dimensions. If U/V are using separate planes and are
|
||||
* subsampled, we need to scale the coordinates */
|
||||
if (samplers[1]) {
|
||||
float h_ratio = samplers[1]->texture->width0 /
|
||||
(float) samplers[0]->texture->width0;
|
||||
*ptr_float++ = h_ratio;
|
||||
float v_ratio = samplers[1]->texture->height0 /
|
||||
(float) samplers[0]->texture->height0;
|
||||
*ptr_float++ = v_ratio;
|
||||
}
|
||||
pipe_buffer_unmap(s->pipe, buf_transfer);
|
||||
|
||||
return true;
|
||||
@@ -704,7 +717,7 @@ draw_layers(struct vl_compositor *c,
|
||||
drawn.translate_y = (int)layer->viewport.translate[1];
|
||||
drawn.sampler0_w = (float)layer->sampler_views[0]->texture->width0;
|
||||
drawn.sampler0_h = (float)layer->sampler_views[0]->texture->height0;
|
||||
set_viewport(s, &drawn);
|
||||
set_viewport(s, &drawn, samplers);
|
||||
|
||||
c->pipe->bind_sampler_states(c->pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
num_sampler_views, layer->samplers);
|
||||
|
||||
Reference in New Issue
Block a user