tu: C++-proofing: ease access to global bo struct
authorDanylo Piliaiev <dpiliaiev@igalia.com>
Tue, 14 Mar 2023 18:16:59 +0000 (19:16 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 24 Mar 2023 15:49:25 +0000 (15:49 +0000)
Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21931>

src/freedreno/vulkan/tu_autotune.c
src/freedreno/vulkan/tu_clear_blit.c
src/freedreno/vulkan/tu_cmd_buffer.c
src/freedreno/vulkan/tu_cs_breadcrumbs.c
src/freedreno/vulkan/tu_device.c
src/freedreno/vulkan/tu_device.h
src/freedreno/vulkan/tu_dynamic_rendering.c
src/freedreno/vulkan/tu_util.c

index 3db26dd..378bbb0 100644 (file)
@@ -92,8 +92,7 @@ fence_before(uint32_t a, uint32_t b)
 static uint32_t
 get_autotune_fence(struct tu_autotune *at)
 {
-   const struct tu6_global *global = at->device->global_bo->map;
-   return global->autotune_fence;
+   return at->device->global_bo_map->autotune_fence;
 }
 
 static struct tu_submission_data *
index f8d620b..fe463a1 100644 (file)
@@ -720,19 +720,20 @@ compile_shader(struct tu_device *dev, struct nir_shader *nir,
 
    ir3_finalize_nir(dev->compiler, nir);
 
+   const struct ir3_shader_options options = {
+      .reserved_user_consts = align(consts, 4),
+      .api_wavesize = IR3_SINGLE_OR_DOUBLE,
+      .real_wavesize = IR3_SINGLE_OR_DOUBLE,
+   };
    struct ir3_shader *sh =
-      ir3_shader_from_nir(dev->compiler, nir, &(struct ir3_shader_options) {
-                              .reserved_user_consts = align(consts, 4),
-                              .api_wavesize = IR3_SINGLE_OR_DOUBLE,
-                              .real_wavesize = IR3_SINGLE_OR_DOUBLE,
-                          }, NULL);
+      ir3_shader_from_nir(dev->compiler, nir, &options, NULL);
 
    struct ir3_shader_key key = {};
    bool created;
    struct ir3_shader_variant *so =
       ir3_shader_get_variant(sh, &key, false, false, &created);
 
-   struct tu6_global *global = dev->global_bo->map;
+   struct tu6_global *global = dev->global_bo_map;
 
    assert(*offset + so->info.sizedwords <= ARRAY_SIZE(global->shaders));
    dev->global_shaders[idx] = sh;
index a42ded1..3533531 100644 (file)
@@ -97,7 +97,7 @@ tu6_lazy_emit_vsc(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
     */
    mtx_lock(&dev->mutex);
 
-   struct tu6_global *global = dev->global_bo->map;
+   struct tu6_global *global = dev->global_bo_map;
 
    uint32_t vsc_draw_overflow = global->vsc_draw_overflow;
    uint32_t vsc_prim_overflow = global->vsc_prim_overflow;
index 4689dc4..2f1c39f 100644 (file)
@@ -43,8 +43,7 @@ static void *
 sync_gpu_with_cpu(void *_job)
 {
    struct breadcrumbs_context *ctx = (struct breadcrumbs_context *) _job;
-   struct tu6_global *global =
-      (struct tu6_global *) ctx->device->global_bo->map;
+   struct tu6_global *global = ctx->device->global_bo_map;
    uint32_t last_breadcrumb = 0;
    uint32_t breakpoint_hits = 0;
 
@@ -135,7 +134,7 @@ tu_breadcrumbs_init(struct tu_device *device)
 
    device->breadcrumbs_ctx = ctx;
 
-   struct tu6_global *global = device->global_bo->map;
+   struct tu6_global *global = device->global_bo_map;
    global->breadcrumb_cpu_sync_seqno = 0;
    global->breadcrumb_gpu_sync_seqno = 0;
 
index 7222498..219313b 100644 (file)
@@ -2246,7 +2246,9 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
    }
 
    global = (struct tu6_global *)device->global_bo->map;
+   device->global_bo_map = global;
    tu_init_clear_blit_shaders(device);
+
    global->predicate = 0;
    global->vtx_stats_query_not_running = 1;
    global->dbg_one = (uint32_t)-1;
@@ -3102,9 +3104,8 @@ tu_init_sampler(struct tu_device *device,
       }
 
       tu6_pack_border_color(
-         device->global_bo->map +
-            offsetof_arr(struct tu6_global, bcolor, border_color),
-         &color, pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT);
+         &device->global_bo_map->bcolor[border_color], &color,
+         pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT);
       border_color += TU_BORDER_COLOR_BUILTIN;
    }
 
index e0a568e..96224a0 100644 (file)
@@ -247,6 +247,7 @@ struct tu_device
    } fiber_pvtmem_bo, wave_pvtmem_bo;
 
    struct tu_bo *global_bo;
+   struct tu6_global *global_bo_map;
 
    uint32_t implicit_sync_bo_count;
 
index e65b60c..a5f36d2 100644 (file)
@@ -31,7 +31,7 @@ struct dynamic_rendering_entry {
 static VkResult
 get_cmd_buffer(struct tu_device *dev, struct tu_cmd_buffer **cmd_buffer_out)
 {
-   struct tu6_global *global = dev->global_bo->map;
+   struct tu6_global *global = dev->global_bo_map;
 
    /* Note: because QueueSubmit is serialized, we don't need any locks here.
     */
index b3cd3fb..54e10b3 100644 (file)
@@ -351,7 +351,7 @@ tu_dbg_log_gmem_load_store_skips(struct tu_device *device)
       return;
    }
 
-   struct tu6_global *global = device->global_bo->map;
+   struct tu6_global *global = device->global_bo_map;
 
    uint32_t current_taken_loads = global->dbg_gmem_taken_loads;
    uint32_t current_taken_stores = global->dbg_gmem_taken_stores;