panfrost: fix sampler_count and unbind samplers in bind_sampler_states

1. Old approach did not support unbind (set to NULL) samplers because
it only copied memory if sampler is not empty. New approach checks
if sampler is empty - it will set NULL.

2. Old approach just set sampler_count to 0 if sampler is empty.
That's wrong and we need to find highest non-null samplers[] entry.
It was done in new approach.

3. Gallium dosc says:
```
NOTE: at this time, start is always zero ...
This may change in the future.
```
It's better to take into consideration start parameter in new approach.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20285>
This commit is contained in:
Aleksey Komarov
2022-12-12 19:32:32 +03:00
committed by Marge Bot
parent a921486e2a
commit d51fc12af9
2 changed files with 11 additions and 5 deletions
+10 -5
View File
@@ -323,14 +323,19 @@ panfrost_bind_sampler_states(
unsigned start_slot, unsigned num_sampler,
void **sampler)
{
assert(start_slot == 0);
struct panfrost_context *ctx = pan_context(pctx);
ctx->dirty_shader[shader] |= PAN_DIRTY_STAGE_SAMPLER;
ctx->sampler_count[shader] = sampler ? num_sampler : 0;
if (sampler)
memcpy(ctx->samplers[shader], sampler, num_sampler * sizeof (void *));
for (unsigned i = 0; i < num_sampler; i++) {
unsigned p = start_slot + i;
ctx->samplers[shader][p] = sampler ? sampler[i] : NULL;
if (ctx->samplers[shader][p])
ctx->valid_samplers[shader] |= BITFIELD_BIT(p);
else
ctx->valid_samplers[shader] &= ~BITFIELD_BIT(p);
}
ctx->sampler_count[shader] = util_last_bit(ctx->valid_samplers[shader]);
}
static void
@@ -196,6 +196,7 @@ struct panfrost_context {
struct panfrost_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
unsigned sampler_count[PIPE_SHADER_TYPES];
uint32_t valid_samplers[PIPE_SHADER_TYPES];
struct panfrost_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
unsigned sampler_view_count[PIPE_SHADER_TYPES];