mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 15:38:09 +02:00
zink: add batch usage flags for sampler views/states and desc sets
this massively cuts down cpu time for hashing and lookups, resulting in a noticeable performance increase the sampler_state batch usage for now is just being set for future use when it will be leveraged to permit immediate deletion Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9567>
This commit is contained in:
parent
013aa05edb
commit
839d609b8c
5 changed files with 22 additions and 4 deletions
|
|
@ -36,6 +36,8 @@ zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch)
|
|||
/* unref all used sampler-views */
|
||||
set_foreach(batch->sampler_views, entry) {
|
||||
struct pipe_sampler_view *pres = (struct pipe_sampler_view *)entry->key;
|
||||
struct zink_sampler_view *sampler_view = zink_sampler_view(pres);
|
||||
sampler_view->batch_uses &= ~BITFIELD_BIT(batch->batch_id);
|
||||
pipe_sampler_view_reference(&pres, NULL);
|
||||
_mesa_set_remove(batch->sampler_views, entry);
|
||||
}
|
||||
|
|
@ -54,6 +56,7 @@ zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch)
|
|||
|
||||
set_foreach(batch->desc_sets, entry) {
|
||||
struct zink_descriptor_set *zds = (void*)entry->key;
|
||||
zds->batch_uses &= ~BITFIELD_BIT(batch->batch_id);
|
||||
/* reset descriptor pools when no batch is using this program to avoid
|
||||
* having some inactive program hogging a billion descriptors
|
||||
*/
|
||||
|
|
@ -226,9 +229,13 @@ zink_batch_reference_sampler_view(struct zink_batch *batch,
|
|||
struct zink_sampler_view *sv)
|
||||
{
|
||||
bool found = false;
|
||||
uint32_t bit = BITFIELD_BIT(batch->batch_id);
|
||||
if (sv->batch_uses & bit)
|
||||
return;
|
||||
_mesa_set_search_and_add(batch->sampler_views, sv, &found);
|
||||
if (!found)
|
||||
pipe_reference(NULL, &sv->base.reference);
|
||||
assert(!found);
|
||||
sv->batch_uses |= bit;
|
||||
pipe_reference(NULL, &sv->base.reference);
|
||||
batch->has_work = true;
|
||||
}
|
||||
|
||||
|
|
@ -257,9 +264,13 @@ bool
|
|||
zink_batch_add_desc_set(struct zink_batch *batch, struct zink_descriptor_set *zds)
|
||||
{
|
||||
bool found = false;
|
||||
uint32_t bit = BITFIELD_BIT(batch->batch_id);
|
||||
if (zds->batch_uses & bit)
|
||||
return false;
|
||||
_mesa_set_search_and_add(batch->desc_sets, zds, &found);
|
||||
if (!found)
|
||||
pipe_reference(NULL, &zds->reference);
|
||||
assert(!found);
|
||||
zds->batch_uses |= bit;
|
||||
pipe_reference(NULL, &zds->reference);
|
||||
return !found;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ struct zink_sampler_state {
|
|||
VkSampler sampler;
|
||||
uint32_t hash;
|
||||
struct zink_descriptor_refs desc_set_refs;
|
||||
uint32_t batch_uses;
|
||||
bool custom_border_color;
|
||||
};
|
||||
|
||||
|
|
@ -82,6 +83,7 @@ struct zink_sampler_view {
|
|||
VkBufferView buffer_view;
|
||||
};
|
||||
uint32_t hash;
|
||||
uint32_t batch_uses;
|
||||
};
|
||||
|
||||
struct zink_image_view {
|
||||
|
|
|
|||
|
|
@ -232,6 +232,7 @@ allocate_desc_set(struct zink_screen *screen, struct zink_program *pg, enum zink
|
|||
pipe_reference_init(&zds->reference, 1);
|
||||
zds->pool = pool;
|
||||
zds->hash = 0;
|
||||
zds->batch_uses = 0;
|
||||
zds->invalid = true;
|
||||
zds->recycled = false;
|
||||
if (num_resources) {
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ struct zink_descriptor_set {
|
|||
bool recycled;
|
||||
struct zink_descriptor_state_key key;
|
||||
struct util_dynarray barriers;
|
||||
uint32_t batch_uses;
|
||||
#ifndef NDEBUG
|
||||
/* for extra debug asserts */
|
||||
unsigned num_resources;
|
||||
|
|
|
|||
|
|
@ -625,6 +625,9 @@ update_sampler_descriptors(struct zink_context *ctx, struct zink_descriptor_set
|
|||
struct zink_batch *batch = is_compute ? &ctx->compute_batch : zink_curr_batch(ctx);
|
||||
if (sampler_view)
|
||||
zink_batch_reference_sampler_view(batch, sampler_view);
|
||||
if (sampler)
|
||||
/* this only tracks the most recent usage for now */
|
||||
sampler->batch_uses = BITFIELD_BIT(batch->batch_id);
|
||||
}
|
||||
assert(num_wds < num_descriptors);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue