radv: move ac_perfcounters to physical_device.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sat, 21 May 2022 13:09:15 +0000 (15:09 +0200)
committerMarge Bot <emma+marge@anholt.net>
Sat, 9 Jul 2022 12:29:05 +0000 (12:29 +0000)
Going to need it there for vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16879>

src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_private.h
src/amd/vulkan/radv_spm.c

index 66af2ef..745bccb 100644 (file)
@@ -805,7 +805,7 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm
          result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
                             "failed to stat DRM primary node %s",
                             drm_device->nodes[DRM_NODE_PRIMARY]);
-         goto fail_disk_cache;
+         goto fail_perfcounters;
       }
       device->primary_devid = primary_stat.st_rdev;
 
@@ -814,7 +814,7 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm
          result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
                             "failed to stat DRM render node %s",
                             drm_device->nodes[DRM_NODE_RENDER]);
-         goto fail_disk_cache;
+         goto fail_perfcounters;
       }
       device->render_devid = render_stat.st_rdev;
    }
@@ -825,6 +825,9 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm
 
    radv_physical_device_init_queue_table(device);
 
+   /* We don't check the error code, but later check if it is initialized. */
+   ac_init_perfcounters(&device->rad_info, false, false, &device->ac_perfcounters);
+
    /* The WSI is structured as a layer on top of the driver, so this has
     * to be the last part of initialization (at least until we get other
     * semi-layers).
@@ -832,7 +835,7 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm
    result = radv_init_wsi(device);
    if (result != VK_SUCCESS) {
       vk_error(instance, result);
-      goto fail_disk_cache;
+      goto fail_perfcounters;
    }
 
    device->gs_table_depth =
@@ -845,7 +848,8 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm
 
    return VK_SUCCESS;
 
-fail_disk_cache:
+fail_perfcounters:
+   ac_destroy_perfcounters(&device->ac_perfcounters);
    disk_cache_destroy(device->disk_cache);
 #ifdef ENABLE_SHADER_CACHE
 fail_wsi:
@@ -867,6 +871,7 @@ static void
 radv_physical_device_destroy(struct radv_physical_device *device)
 {
    radv_finish_wsi(device);
+   ac_destroy_perfcounters(&device->ac_perfcounters);
    device->ws->destroy(device->ws);
    disk_cache_destroy(device->disk_cache);
    if (device->local_fd != -1)
index b681087..9ef009e 100644 (file)
@@ -333,6 +333,9 @@ struct radv_physical_device {
 
    struct ac_hs_info hs;
    struct ac_task_info task_info;
+
+   /* Performance counters. */
+   struct ac_perfcounters ac_perfcounters;
 };
 
 struct radv_instance {
@@ -868,9 +871,6 @@ struct radv_device {
    /* SPM. */
    struct ac_spm_trace_data spm_trace;
 
-   /* Performance counters. */
-   struct ac_perfcounters perfcounters;
-
    /* Trap handler. */
    struct radv_trap_handler_shader *trap_handler_shader;
    struct radeon_winsys_bo *tma_bo; /* Trap Memory Address */
index a0c0347..8ef3daf 100644 (file)
@@ -187,7 +187,7 @@ bool
 radv_spm_init(struct radv_device *device)
 {
    const struct radeon_info *info = &device->physical_device->rad_info;
-   struct ac_perfcounters *pc = &device->perfcounters;
+   struct ac_perfcounters *pc = &device->physical_device->ac_perfcounters;
    struct ac_spm_counter_create_info spm_counters[] = {
       {TCP, 0, 0x9},    /* Number of L2 requests. */
       {TCP, 0, 0x12},   /* Number of L2 misses. */
@@ -203,7 +203,8 @@ radv_spm_init(struct radv_device *device)
       {GL2C, 0, info->gfx_level >= GFX10_3 ? 0x2b : 0x23},  /* Number of GL2C misses. */
    };
 
-   if (!ac_init_perfcounters(info, false, false, pc))
+   /* We failed to initialize the performance counters. */
+   if (!pc->blocks)
       return false;
 
    if (!ac_init_spm(info, pc, ARRAY_SIZE(spm_counters), spm_counters, &device->spm_trace))
@@ -226,5 +227,4 @@ radv_spm_finish(struct radv_device *device)
    }
 
    ac_destroy_spm(&device->spm_trace);
-   ac_destroy_perfcounters(&device->perfcounters);
 }