panfrost: Optimise recalculation of max sampler view

Previously we always searched through 128 sampler views for set
sampler views, now we never look above the maximum updated view.

Fixes: 304851422a ("panfrost: Fix set_sampler_views for big GL")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15366>
(cherry picked from commit d5870c45ae)
This commit is contained in:
Icecream95 2021-10-14 16:39:59 +13:00 committed by Eric Engestrom
parent 9552166f27
commit ce4b620e39
2 changed files with 18 additions and 6 deletions

View file

@ -2101,7 +2101,7 @@
"description": "panfrost: Optimise recalculation of max sampler view",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "304851422a4610170e870a5315fefaa5ec42917f"
},

View file

@ -628,12 +628,16 @@ panfrost_set_sampler_views(
struct panfrost_context *ctx = pan_context(pctx);
ctx->dirty_shader[shader] |= PAN_DIRTY_STAGE_TEXTURE;
unsigned new_nr = 0;
unsigned i;
for (i = 0; i < num_views; ++i) {
struct pipe_sampler_view *view = views ? views[i] : NULL;
unsigned p = i + start_slot;
if (view)
new_nr = p + 1;
if (take_ownership) {
pipe_sampler_view_reference((struct pipe_sampler_view **)&ctx->sampler_views[shader][p],
NULL);
@ -650,13 +654,21 @@ panfrost_set_sampler_views(
NULL);
}
/* Recalculate sampler view count */
ctx->sampler_view_count[shader] = 0;
/* If the sampler view count is higher than the greatest sampler view
* we touch, it can't change */
if (ctx->sampler_view_count[shader] > start_slot + num_views + unbind_num_trailing_slots)
return;
for (i = 0; i < ARRAY_SIZE(ctx->sampler_views[shader]); ++i) {
if (ctx->sampler_views[shader][i])
ctx->sampler_view_count[shader] = i + 1;
/* If we haven't set any sampler views here, search lower numbers for
* set sampler views */
if (new_nr == 0) {
for (i = 0; i < start_slot; ++i) {
if (ctx->sampler_views[shader][i])
new_nr = i + 1;
}
}
ctx->sampler_view_count[shader] = new_nr;
}
static void