~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/gallium/drivers/zink/zink_batch.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
         /* prune all existing views */
59
59
         obj->view_prune_count = util_dynarray_num_elements(&obj->views, VkBufferView);
60
60
         /* prune them when the views will definitely not be in use */
61
 
         obj->view_prune_timeline = MAX2(obj->bo->reads ? obj->bo->reads->usage : 0,
62
 
                                         obj->bo->writes ? obj->bo->writes->usage : 0);
 
61
         obj->view_prune_timeline = MAX2(obj->bo->reads.u ? obj->bo->reads.u->usage : 0,
 
62
                                         obj->bo->writes.u ? obj->bo->writes.u->usage : 0);
63
63
      }
64
64
      simple_mtx_unlock(&obj->view_lock);
65
65
   }
111
111
   /* queries must only be destroyed once they are inactive */
112
112
   set_foreach_remove(&bs->active_queries, entry) {
113
113
      struct zink_query *query = (void*)entry->key;
114
 
      zink_prune_query(screen, bs, query);
 
114
      zink_prune_query(bs, query);
115
115
   }
116
116
   util_dynarray_foreach(&bs->dead_querypools, VkQueryPool, pool)
117
117
      VKSCR(DestroyQueryPool)(screen->dev, *pool, NULL);
118
118
   util_dynarray_clear(&bs->dead_querypools);
119
119
 
 
120
   util_dynarray_foreach(&bs->dgc.pipelines, VkPipeline, pipeline)
 
121
      VKSCR(DestroyPipeline)(screen->dev, *pipeline, NULL);
 
122
   util_dynarray_clear(&bs->dgc.pipelines);
 
123
   util_dynarray_foreach(&bs->dgc.layouts, VkIndirectCommandsLayoutNV, iclayout)
 
124
      VKSCR(DestroyIndirectCommandsLayoutNV)(screen->dev, *iclayout, NULL);
 
125
   util_dynarray_clear(&bs->dgc.layouts);
 
126
 
120
127
   /* framebuffers are appended to the batch state in which they are destroyed
121
128
    * to ensure deferred deletion without destroying in-use objects
122
129
    */
160
167
   bs->unordered_write_access = 0;
161
168
   bs->unordered_write_stages = 0;
162
169
 
 
170
   /* only increment batch generation if previously in-use to avoid false detection of batch completion */
 
171
   if (bs->fence.submitted)
 
172
      bs->usage.submit_count++;
163
173
   /* only reset submitted here so that tc fence desync can pick up the 'completed' flag
164
174
    * before the state is reused
165
175
    */
167
177
   bs->has_barriers = false;
168
178
   if (bs->fence.batch_id)
169
179
      zink_screen_update_last_finished(screen, bs->fence.batch_id);
170
 
   bs->submit_count++;
171
180
   bs->fence.batch_id = 0;
172
181
   bs->usage.usage = 0;
173
182
   bs->next = NULL;
272
281
   free(bs->slab_objs.objs);
273
282
   free(bs->sparse_objs.objs);
274
283
   util_dynarray_fini(&bs->dead_querypools);
 
284
   util_dynarray_fini(&bs->dgc.pipelines);
 
285
   util_dynarray_fini(&bs->dgc.layouts);
275
286
   util_dynarray_fini(&bs->swapchain_obj);
276
287
   util_dynarray_fini(&bs->zombie_samplers);
277
288
   util_dynarray_fini(&bs->dead_framebuffers);
333
344
   SET_CREATE_OR_FAIL(&bs->active_queries);
334
345
   util_dynarray_init(&bs->wait_semaphores, NULL);
335
346
   util_dynarray_init(&bs->dead_querypools, NULL);
 
347
   util_dynarray_init(&bs->dgc.pipelines, NULL);
 
348
   util_dynarray_init(&bs->dgc.layouts, NULL);
336
349
   util_dynarray_init(&bs->wait_semaphore_stages, NULL);
337
350
   util_dynarray_init(&bs->zombie_samplers, NULL);
338
351
   util_dynarray_init(&bs->dead_framebuffers, NULL);
450
463
void
451
464
zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
452
465
{
 
466
   struct zink_screen *screen = zink_screen(ctx->base.screen);
453
467
   zink_reset_batch(ctx, batch);
454
468
 
455
469
   batch->state->usage.unflushed = true;
473
487
   }
474
488
 
475
489
#ifdef HAVE_RENDERDOC_APP_H
476
 
   struct zink_screen *screen = zink_screen(ctx->base.screen);
477
490
   if (VKCTX(CmdInsertDebugUtilsLabelEXT) && screen->renderdoc_api) {
478
491
      VkDebugUtilsLabelEXT capture_label;
479
492
      /* Magic fallback which lets us bridge the Wine barrier over to Linux RenderDoc. */
496
509
   /* descriptor buffers must always be bound at the start of a batch */
497
510
   if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB && !(ctx->flags & ZINK_CONTEXT_COPY_ONLY))
498
511
      zink_batch_bind_db(ctx);
 
512
   /* zero init for unordered blits */
 
513
   if (screen->info.have_EXT_attachment_feedback_loop_dynamic_state)
 
514
      VKCTX(CmdSetAttachmentFeedbackLoopEnableEXT)(ctx->batch.state->barrier_cmdbuf, 0);
499
515
}
500
516
 
501
517
/* common operations to run post submit; split out for clarity */
514
530
      screen->device_lost = true;
515
531
   } else if (bs->ctx->batch_states_count > 5000) {
516
532
      /* throttle in case something crazy is happening */
517
 
      zink_screen_timeline_wait(screen, bs->fence.batch_id - 2500, PIPE_TIMEOUT_INFINITE);
 
533
      zink_screen_timeline_wait(screen, bs->fence.batch_id - 2500, OS_TIMEOUT_INFINITE);
518
534
   }
519
535
   /* this resets the buffer hashlist for the state's next use */
520
536
   memset(&bs->buffer_indices_hashlist, -1, sizeof(bs->buffer_indices_hashlist));
608
624
      bs->is_device_lost = true;
609
625
   }
610
626
   simple_mtx_unlock(&screen->queue_lock);
611
 
   bs->submit_count++;
 
627
   bs->usage.submit_count++;
612
628
end:
613
629
   cnd_broadcast(&bs->usage.flush);
614
630