gallium/vl: Fix creating buffers with auxiliary planes

Buffers with compression enabled (eg. DCC) have auxiliary planes that
needs to be all imported, but should not be used to create sampler views
and surfaces.
Only use main planes and ignore the remaining planes.
Also remove vl_video_buffer::num_planes as it's now unused.

Cc: mesa-stable
Acked-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32893>
This commit is contained in:
David Rosca 2025-01-06 12:20:50 +01:00 committed by Marge Bot
parent cf87ed60e2
commit 986f545744
2 changed files with 12 additions and 8 deletions

View file

@ -291,7 +291,7 @@ vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer)
struct pipe_context *pipe;
enum pipe_format sampler_format[VL_NUM_COMPONENTS];
const unsigned *plane_order;
unsigned i, j, component;
unsigned i, j, component, num_planes;
assert(buf);
@ -299,8 +299,9 @@ vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer)
vl_get_video_buffer_formats(pipe->screen, buf->base.buffer_format, sampler_format);
plane_order = vl_video_buffer_plane_order(buf->base.buffer_format);
num_planes = util_format_get_num_planes(buf->base.buffer_format);
for (component = 0, i = 0; i < buf->num_planes; ++i ) {
for (component = 0, i = 0; i < num_planes; ++i) {
struct pipe_resource *res = buf->resources[plane_order[i]];
const struct util_format_description *desc = util_format_description(res->format);
unsigned nr_components = util_format_get_nr_components(res->format);
@ -478,12 +479,14 @@ vl_video_buffer_create_ex2(struct pipe_context *pipe,
struct pipe_resource *resources[VL_NUM_COMPONENTS])
{
struct vl_video_buffer *buffer;
unsigned i;
unsigned i, num_planes;
buffer = CALLOC_STRUCT(vl_video_buffer);
if (!buffer)
return NULL;
num_planes = util_format_get_num_planes(tmpl->buffer_format);
buffer->base = *tmpl;
buffer->base.context = pipe;
buffer->base.destroy = vl_video_buffer_destroy;
@ -491,12 +494,14 @@ vl_video_buffer_create_ex2(struct pipe_context *pipe,
buffer->base.get_sampler_view_planes = vl_video_buffer_sampler_view_planes;
buffer->base.get_sampler_view_components = vl_video_buffer_sampler_view_components;
buffer->base.get_surfaces = vl_video_buffer_surfaces;
buffer->num_planes = 0;
for (i = 0; i < VL_NUM_COMPONENTS; ++i) {
for (i = 0; i < num_planes; ++i)
buffer->resources[i] = resources[i];
if (resources[i])
buffer->num_planes++;
/* Ignore auxiliary planes. */
for (; i < VL_NUM_COMPONENTS; ++i) {
struct pipe_resource *res = resources[i];
pipe_resource_reference(&res, NULL);
}
return &buffer->base;

View file

@ -41,7 +41,6 @@
struct vl_video_buffer
{
struct pipe_video_buffer base;
unsigned num_planes;
struct pipe_resource *resources[VL_NUM_COMPONENTS];
struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS];
struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS];