Don't map the buffer in vl_compositor_set_csc_matrix.
This avoids mapping the buffer twice with compute shaders.
Acked-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Thong Thai <thong.thai@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25258>
vl_csc_matrix const *matrix,
float luma_min, float luma_max)
{
- struct pipe_transfer *buf_transfer;
-
assert(s);
- float *ptr = pipe_buffer_map(s->pipe, s->shader_params,
- PIPE_MAP_WRITE | PIPE_MAP_DISCARD_RANGE,
- &buf_transfer);
-
- if (!ptr)
- return false;
-
- 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);
+ memcpy(&s->csc_matrix, matrix, sizeof(vl_csc_matrix));
+ s->luma_min = luma_min;
+ s->luma_max = luma_max;
return true;
}
struct vl_compositor_layer layers[VL_COMPOSITOR_MAX_LAYERS];
bool interlaced;
unsigned chroma_location;
+
+ vl_csc_matrix csc_matrix;
+ float luma_min, luma_max;
};
struct vl_compositor
assert(s && drawn);
- void *ptr = pipe_buffer_map_range(s->pipe, s->shader_params,
- sizeof(vl_csc_matrix) + sizeof(float) * 2,
- sizeof(float) * 12 + sizeof(int) * 8,
- PIPE_MAP_WRITE | PIPE_MAP_DISCARD_RANGE,
- &buf_transfer);
+ void *ptr = pipe_buffer_map(s->pipe, s->shader_params,
+ PIPE_MAP_WRITE | PIPE_MAP_DISCARD_WHOLE_RESOURCE,
+ &buf_transfer);
if (!ptr)
return false;
+ memcpy(ptr, &s->csc_matrix, sizeof(vl_csc_matrix));
+
float *ptr_float = (float *)ptr;
+ ptr_float += sizeof(vl_csc_matrix) / sizeof(float);
+ *ptr_float++ = s->luma_min;
+ *ptr_float++ = s->luma_max;
*ptr_float++ = drawn->scale_x;
*ptr_float++ = drawn->scale_y;
}
static void
+set_csc_matrix(struct vl_compositor_state *s)
+{
+ struct pipe_transfer *buf_transfer;
+
+ float *ptr = pipe_buffer_map(s->pipe, s->shader_params,
+ PIPE_MAP_WRITE | PIPE_MAP_DISCARD_WHOLE_RESOURCE,
+ &buf_transfer);
+
+ if (!ptr)
+ return;
+
+ memcpy(ptr, &s->csc_matrix, sizeof(vl_csc_matrix));
+
+ ptr += sizeof(vl_csc_matrix) / sizeof(float);
+ *ptr++ = s->luma_min;
+ *ptr++ = s->luma_max;
+
+ pipe_buffer_unmap(s->pipe, buf_transfer);
+}
+
+static void
draw_layers(struct vl_compositor *c, struct vl_compositor_state *s, struct u_rect *dirty)
{
unsigned vb_index, i;
c->pipe->set_scissor_states(c->pipe, 0, 1, &s->scissor);
gen_vertex_data(c, s, dirty_area);
+ set_csc_matrix(s);
if (clear_dirty && dirty_area &&
(dirty_area->x0 < dirty_area->x1 || dirty_area->y0 < dirty_area->y1)) {