gallium/vl: Init shaders on first use

It takes significant amount of time at va context creation, and most
of the time the postproc pipelines are not used anyway.
This reduces total time it takes to run all libva-utils tests on my machine
from 38s to 28s.

Reviewed-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29936>
This commit is contained in:
David Rosca
2024-06-27 13:18:43 +02:00
committed by Marge Bot
parent 6f1dd9a2aa
commit a3f35964ba
2 changed files with 25 additions and 5 deletions

View File

@@ -35,6 +35,9 @@ init_shaders(struct vl_compositor *c)
{
assert(c);
if (c->shaders_initialized)
return true;
if (c->pipe_cs_composit_supported) {
if (!vl_compositor_cs_init_shaders(c))
return false;
@@ -96,6 +99,8 @@ init_shaders(struct vl_compositor *c)
}
}
c->shaders_initialized = true;
return true;
}
@@ -103,6 +108,9 @@ static void cleanup_shaders(struct vl_compositor *c)
{
assert(c);
if (!c->shaders_initialized)
return;
if (c->pipe_cs_composit_supported) {
vl_compositor_cs_cleanup_shaders(c);
} else if (c->pipe_gfx_supported) {
@@ -332,6 +340,9 @@ set_yuv_layer(struct vl_compositor_state *s, struct vl_compositor *c,
assert(layer < VL_COMPOSITOR_MAX_LAYERS);
if (!init_shaders(c))
return;
s->used_layers |= 1 << layer;
sampler_views = buffer->get_sampler_view_components(buffer);
for (i = 0; i < 3; ++i) {
@@ -391,6 +402,9 @@ set_rgb_to_yuv_layer(struct vl_compositor_state *s, struct vl_compositor *c,
assert(layer < VL_COMPOSITOR_MAX_LAYERS);
if (!init_shaders(c))
return;
s->used_layers |= 1 << layer;
if (c->pipe_cs_composit_supported)
@@ -550,6 +564,9 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
assert(layer < VL_COMPOSITOR_MAX_LAYERS);
if (!init_shaders(c))
return;
s->used_layers |= 1 << layer;
sampler_views = buffer->get_sampler_view_components(buffer);
for (i = 0; i < 3; ++i) {
@@ -616,6 +633,9 @@ vl_compositor_set_palette_layer(struct vl_compositor_state *s,
assert(layer < VL_COMPOSITOR_MAX_LAYERS);
if (!init_shaders(c))
return;
s->used_layers |= 1 << layer;
s->layers[layer].fs = include_color_conversion ?
@@ -647,6 +667,9 @@ vl_compositor_set_rgba_layer(struct vl_compositor_state *s,
assert(layer < VL_COMPOSITOR_MAX_LAYERS);
if (!init_shaders(c))
return;
s->used_layers |= 1 << layer;
s->layers[layer].fs = c->fs_rgba;
s->layers[layer].samplers[0] = c->sampler_linear;
@@ -782,11 +805,6 @@ vl_compositor_init(struct vl_compositor *c, struct pipe_context *pipe)
return false;
}
if (!init_shaders(c)) {
cleanup_pipe_state(c);
return false;
}
if (!init_buffers(c)) {
cleanup_shaders(c);
cleanup_pipe_state(c);

View File

@@ -182,6 +182,8 @@ struct vl_compositor
void *y;
void *uv;
} cs_rgb_yuv;
bool shaders_initialized;
};
/**