zink: directly use resource count from pool instead of accumulating every time
this is a surprisingly impactful speedup Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9348>
This commit is contained in:
parent
201cd1a8c0
commit
4a3b344b23
|
@ -216,7 +216,7 @@ allocate_desc_set(struct zink_screen *screen, struct zink_program *pg, enum zink
|
||||||
|
|
||||||
struct zink_descriptor_set *alloc = ralloc_array(pool, struct zink_descriptor_set, bucket_size);
|
struct zink_descriptor_set *alloc = ralloc_array(pool, struct zink_descriptor_set, bucket_size);
|
||||||
assert(alloc);
|
assert(alloc);
|
||||||
unsigned num_resources = zink_program_num_bindings_typed(pg, type, is_compute);
|
unsigned num_resources = pool->num_resources;
|
||||||
struct zink_resource **resources = rzalloc_array(pool, struct zink_resource*, num_resources * bucket_size);
|
struct zink_resource **resources = rzalloc_array(pool, struct zink_resource*, num_resources * bucket_size);
|
||||||
assert(resources);
|
assert(resources);
|
||||||
void **samplers = NULL;
|
void **samplers = NULL;
|
||||||
|
|
|
@ -344,14 +344,12 @@ write_descriptors(struct zink_context *ctx, struct zink_descriptor_set *zds, uns
|
||||||
bool is_compute, bool cache_hit)
|
bool is_compute, bool cache_hit)
|
||||||
{
|
{
|
||||||
bool need_flush = false;
|
bool need_flush = false;
|
||||||
struct zink_program *pg = is_compute ? (struct zink_program *)ctx->curr_compute : (struct zink_program *)ctx->curr_program;
|
|
||||||
struct zink_batch *batch = is_compute ? &ctx->compute_batch : zink_curr_batch(ctx);
|
struct zink_batch *batch = is_compute ? &ctx->compute_batch : zink_curr_batch(ctx);
|
||||||
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||||
assert(zds->desc_set);
|
assert(zds->desc_set);
|
||||||
unsigned check_flush_id = is_compute ? 0 : ZINK_COMPUTE_BATCH_ID;
|
unsigned check_flush_id = is_compute ? 0 : ZINK_COMPUTE_BATCH_ID;
|
||||||
for (int i = 0; i < num_resources; ++i) {
|
for (int i = 0; i < num_resources; ++i) {
|
||||||
assert(num_resources <= zink_program_num_bindings_typed(pg, zds->pool->type, is_compute));
|
assert(num_resources <= zds->pool->num_resources);
|
||||||
assert(num_resources <= zds->num_resources);
|
|
||||||
|
|
||||||
struct zink_resource *res = resources[i].res;
|
struct zink_resource *res = resources[i].res;
|
||||||
if (res) {
|
if (res) {
|
||||||
|
@ -390,7 +388,7 @@ update_ubo_descriptors(struct zink_context *ctx, struct zink_descriptor_set *zds
|
||||||
struct zink_program *pg = is_compute ? (struct zink_program *)ctx->curr_compute : (struct zink_program *)ctx->curr_program;
|
struct zink_program *pg = is_compute ? (struct zink_program *)ctx->curr_compute : (struct zink_program *)ctx->curr_program;
|
||||||
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||||
unsigned num_descriptors = pg->pool[zds->pool->type]->key.num_descriptors;
|
unsigned num_descriptors = pg->pool[zds->pool->type]->key.num_descriptors;
|
||||||
unsigned num_bindings = zink_program_num_bindings_typed(pg, zds->pool->type, is_compute);
|
unsigned num_bindings = zds->pool->num_resources;
|
||||||
VkWriteDescriptorSet wds[num_descriptors];
|
VkWriteDescriptorSet wds[num_descriptors];
|
||||||
struct zink_descriptor_resource resources[num_bindings];
|
struct zink_descriptor_resource resources[num_bindings];
|
||||||
VkDescriptorBufferInfo buffer_infos[num_bindings];
|
VkDescriptorBufferInfo buffer_infos[num_bindings];
|
||||||
|
@ -474,7 +472,7 @@ update_ssbo_descriptors(struct zink_context *ctx, struct zink_descriptor_set *zd
|
||||||
struct zink_program *pg = is_compute ? (struct zink_program *)ctx->curr_compute : (struct zink_program *)ctx->curr_program;
|
struct zink_program *pg = is_compute ? (struct zink_program *)ctx->curr_compute : (struct zink_program *)ctx->curr_program;
|
||||||
ASSERTED struct zink_screen *screen = zink_screen(ctx->base.screen);
|
ASSERTED struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||||
unsigned num_descriptors = pg->pool[zds->pool->type]->key.num_descriptors;
|
unsigned num_descriptors = pg->pool[zds->pool->type]->key.num_descriptors;
|
||||||
unsigned num_bindings = zink_program_num_bindings_typed(pg, zds->pool->type, is_compute);
|
unsigned num_bindings = zds->pool->num_resources;
|
||||||
VkWriteDescriptorSet wds[num_descriptors];
|
VkWriteDescriptorSet wds[num_descriptors];
|
||||||
struct zink_descriptor_resource resources[num_bindings];
|
struct zink_descriptor_resource resources[num_bindings];
|
||||||
VkDescriptorBufferInfo buffer_infos[num_bindings];
|
VkDescriptorBufferInfo buffer_infos[num_bindings];
|
||||||
|
@ -580,7 +578,7 @@ update_sampler_descriptors(struct zink_context *ctx, struct zink_descriptor_set
|
||||||
struct zink_program *pg = is_compute ? (struct zink_program *)ctx->curr_compute : (struct zink_program *)ctx->curr_program;
|
struct zink_program *pg = is_compute ? (struct zink_program *)ctx->curr_compute : (struct zink_program *)ctx->curr_program;
|
||||||
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||||
unsigned num_descriptors = pg->pool[zds->pool->type]->key.num_descriptors;
|
unsigned num_descriptors = pg->pool[zds->pool->type]->key.num_descriptors;
|
||||||
unsigned num_bindings = zink_program_num_bindings(pg, is_compute);
|
unsigned num_bindings = zds->pool->num_resources;
|
||||||
VkWriteDescriptorSet wds[num_descriptors];
|
VkWriteDescriptorSet wds[num_descriptors];
|
||||||
struct zink_descriptor_resource resources[num_bindings];
|
struct zink_descriptor_resource resources[num_bindings];
|
||||||
VkDescriptorImageInfo image_infos[num_bindings];
|
VkDescriptorImageInfo image_infos[num_bindings];
|
||||||
|
@ -656,7 +654,7 @@ update_image_descriptors(struct zink_context *ctx, struct zink_descriptor_set *z
|
||||||
struct zink_program *pg = is_compute ? (struct zink_program *)ctx->curr_compute : (struct zink_program *)ctx->curr_program;
|
struct zink_program *pg = is_compute ? (struct zink_program *)ctx->curr_compute : (struct zink_program *)ctx->curr_program;
|
||||||
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||||
unsigned num_descriptors = pg->pool[zds->pool->type]->key.num_descriptors;
|
unsigned num_descriptors = pg->pool[zds->pool->type]->key.num_descriptors;
|
||||||
unsigned num_bindings = zink_program_num_bindings(pg, is_compute);
|
unsigned num_bindings = zds->pool->num_resources;
|
||||||
VkWriteDescriptorSet wds[num_descriptors];
|
VkWriteDescriptorSet wds[num_descriptors];
|
||||||
struct zink_descriptor_resource resources[num_bindings];
|
struct zink_descriptor_resource resources[num_bindings];
|
||||||
VkDescriptorImageInfo image_infos[num_bindings];
|
VkDescriptorImageInfo image_infos[num_bindings];
|
||||||
|
|
Loading…
Reference in New Issue