turnip: move descriptor set BO tracking to CmdBindDescriptorSets
authorJonathan Marek <jonathan@marek.ca>
Sun, 14 Jun 2020 14:17:28 +0000 (10:17 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 17 Jun 2020 15:32:30 +0000 (15:32 +0000)
This avoids the duplicated code.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5446>

src/freedreno/vulkan/tu_cmd_buffer.c

index 04765a3d8968460fe9b81b5ba415f24311c56dcf..b258ccf01b7da2a565398cf2bdba2da8d63485d3 100644 (file)
@@ -1906,12 +1906,12 @@ tu_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
                          uint32_t dynamicOffsetCount,
                          const uint32_t *pDynamicOffsets)
 {
-   TU_FROM_HANDLE(tu_cmd_buffer, cmd_buffer, commandBuffer);
+   TU_FROM_HANDLE(tu_cmd_buffer, cmd, commandBuffer);
    TU_FROM_HANDLE(tu_pipeline_layout, layout, _layout);
    unsigned dyn_idx = 0;
 
    struct tu_descriptor_state *descriptors_state =
-      tu_get_descriptors_state(cmd_buffer, pipelineBindPoint);
+      tu_get_descriptors_state(cmd, pipelineBindPoint);
 
    for (unsigned i = 0; i < descriptorSetCount; ++i) {
       unsigned idx = i + firstSet;
@@ -1970,12 +1970,24 @@ tu_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
             dst[5] = va >> 32;
          }
       }
+
+      for (unsigned j = 0; j < set->layout->buffer_count; ++j) {
+         if (set->buffers[j]) {
+            tu_bo_list_add(&cmd->bo_list, set->buffers[j],
+                           MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_WRITE);
+         }
+      }
+
+      if (set->size > 0) {
+         tu_bo_list_add(&cmd->bo_list, &set->pool->bo,
+                        MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_DUMP);
+      }
    }
 
    if (pipelineBindPoint == VK_PIPELINE_BIND_POINT_COMPUTE)
-      cmd_buffer->state.dirty |= TU_CMD_DIRTY_COMPUTE_DESCRIPTOR_SETS;
+      cmd->state.dirty |= TU_CMD_DIRTY_COMPUTE_DESCRIPTOR_SETS;
    else
-      cmd_buffer->state.dirty |= TU_CMD_DIRTY_DESCRIPTOR_SETS;
+      cmd->state.dirty |= TU_CMD_DIRTY_DESCRIPTOR_SETS;
 }
 
 void tu_CmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
@@ -3477,22 +3489,6 @@ tu6_bind_draw_states(struct tu_cmd_buffer *cmd,
    tu_cs_sanity_check(cs);
 
    /* track BOs */
-   if (cmd->state.dirty & TU_CMD_DIRTY_DESCRIPTOR_SETS) {
-      unsigned i;
-      for_each_bit(i, descriptors_state->valid) {
-         struct tu_descriptor_set *set = descriptors_state->sets[i];
-         for (unsigned j = 0; j < set->layout->buffer_count; ++j) {
-            if (set->buffers[j]) {
-               tu_bo_list_add(&cmd->bo_list, set->buffers[j],
-                              MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_WRITE);
-            }
-         }
-         if (set->size > 0) {
-            tu_bo_list_add(&cmd->bo_list, &set->pool->bo,
-                           MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_DUMP);
-         }
-      }
-   }
    if (cmd->state.dirty & TU_CMD_DIRTY_STREAMOUT_BUFFERS) {
       for (unsigned i = 0; i < IR3_MAX_SO_BUFFERS; i++) {
          const struct tu_buffer *buf = cmd->state.streamout_buf.buffers[i];
@@ -3842,23 +3838,6 @@ tu_dispatch(struct tu_cmd_buffer *cmd,
          cmd->record_result = result;
          return;
       }
-
-      /* track BOs */
-      unsigned i;
-      for_each_bit(i, descriptors_state->valid) {
-         struct tu_descriptor_set *set = descriptors_state->sets[i];
-         for (unsigned j = 0; j < set->layout->buffer_count; ++j) {
-            if (set->buffers[j]) {
-               tu_bo_list_add(&cmd->bo_list, set->buffers[j],
-                              MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_WRITE);
-            }
-         }
-
-         if (set->size > 0) {
-            tu_bo_list_add(&cmd->bo_list, &set->pool->bo,
-                           MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_DUMP);
-         }
-      }
    }
 
    if (ib.size)