gallium: Set and count all extra samplers

After the commit mentioned below the `extra` variable only holds the
last added extra sampler. For 3-plane formats this results in one extra
sampler being leaked.

Add the bits for each extra sampler instead.

Fixes: abcd02a07d (gallium: Properly handle non-contiguous used sampler view indexes)
Signed-off-by: Robert Mader <robert.mader@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Matthias Reichl <hias@horus.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36870>
(cherry picked from commit 25fe82630a)
This commit is contained in:
Robert Mader 2025-08-20 10:18:13 +02:00 committed by Eric Engestrom
parent dc7228101e
commit 29c6a25747
2 changed files with 10 additions and 4 deletions

View file

@ -2524,7 +2524,7 @@
"description": "gallium: Set and count all extra samplers",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "abcd02a07db11b8cb56ca5de754efa3355eeb2cb",
"notes": null

View file

@ -187,6 +187,7 @@ st_get_sampler_views(struct st_context *st,
extra = u_bit_scan(&free_slots);
sampler_views[extra] =
pipe->create_sampler_view(pipe, stObj->pt->next, &tmpl);
(*extra_sampler_views) |= 1 << extra;
break;
case PIPE_FORMAT_NV12:
if (stObj->pt->format == PIPE_FORMAT_R8_G8B8_420_UNORM)
@ -199,6 +200,7 @@ st_get_sampler_views(struct st_context *st,
extra = u_bit_scan(&free_slots);
sampler_views[extra] =
pipe->create_sampler_view(pipe, stObj->pt->next, &tmpl);
(*extra_sampler_views) |= 1 << extra;
break;
case PIPE_FORMAT_NV21:
if (stObj->pt->format == PIPE_FORMAT_R8_B8G8_420_UNORM)
@ -211,6 +213,7 @@ st_get_sampler_views(struct st_context *st,
extra = u_bit_scan(&free_slots);
sampler_views[extra] =
pipe->create_sampler_view(pipe, stObj->pt->next, &tmpl);
(*extra_sampler_views) |= 1 << extra;
break;
case PIPE_FORMAT_P010:
case PIPE_FORMAT_P012:
@ -222,6 +225,7 @@ st_get_sampler_views(struct st_context *st,
extra = u_bit_scan(&free_slots);
sampler_views[extra] =
pipe->create_sampler_view(pipe, stObj->pt->next, &tmpl);
(*extra_sampler_views) |= 1 << extra;
break;
case PIPE_FORMAT_IYUV:
if (stObj->pt->format == PIPE_FORMAT_R8_G8_B8_420_UNORM ||
@ -234,9 +238,11 @@ st_get_sampler_views(struct st_context *st,
extra = u_bit_scan(&free_slots);
sampler_views[extra] =
pipe->create_sampler_view(pipe, stObj->pt->next, &tmpl);
(*extra_sampler_views) |= 1 << extra;
extra = u_bit_scan(&free_slots);
sampler_views[extra] =
pipe->create_sampler_view(pipe, stObj->pt->next->next, &tmpl);
(*extra_sampler_views) |= 1 << extra;
break;
case PIPE_FORMAT_YUYV:
case PIPE_FORMAT_YVYU:
@ -252,6 +258,7 @@ st_get_sampler_views(struct st_context *st,
extra = u_bit_scan(&free_slots);
sampler_views[extra] =
pipe->create_sampler_view(pipe, stObj->pt->next, &tmpl);
(*extra_sampler_views) |= 1 << extra;
break;
case PIPE_FORMAT_UYVY:
case PIPE_FORMAT_VYUY:
@ -267,6 +274,7 @@ st_get_sampler_views(struct st_context *st,
extra = u_bit_scan(&free_slots);
sampler_views[extra] =
pipe->create_sampler_view(pipe, stObj->pt->next, &tmpl);
(*extra_sampler_views) |= 1 << extra;
break;
case PIPE_FORMAT_Y210:
case PIPE_FORMAT_Y212:
@ -278,14 +286,12 @@ st_get_sampler_views(struct st_context *st,
extra = u_bit_scan(&free_slots);
sampler_views[extra] =
pipe->create_sampler_view(pipe, stObj->pt->next, &tmpl);
(*extra_sampler_views) |= 1 << extra;
break;
default:
break;
}
if (extra)
(*extra_sampler_views) |= 1 << extra;
num_textures = MAX2(num_textures, extra + 1);
}