anv: disable VK_EXT_calibrated_timestamps when the timestamp register is unreadable
authorEric Engestrom <eric.engestrom@intel.com>
Wed, 15 May 2019 10:30:36 +0000 (11:30 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 20 May 2020 21:49:10 +0000 (21:49 +0000)
When running in a virtual context, the timestamp register is unreadable
on Gen12+.
While we could work around this, that would result in very inaccurate
results for an extension where the whole point is accuracy, so let's
just disable the extension.

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2797>

src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_extensions.py
src/intel/vulkan/anv_private.h

index fe87c233d15747168b47ab165843b37cf0d3e95d..8178a12808903a5669ed59564399e245f978e9b2 100644 (file)
@@ -66,6 +66,9 @@ DRI_CONF_END;
  */
 #define MAX_DEBUG_MESSAGE_LENGTH    4096
 
+/* Render engine timestamp register */
+#define TIMESTAMP 0x2358
+
 static void
 compiler_debug_log(void *data, const char *fmt, ...)
 {
@@ -472,6 +475,11 @@ anv_physical_device_try_create(struct anv_instance *instance,
 
    device->has_implicit_ccs = device->info.has_aux_map;
 
+   /* Check if we can read the GPU timestamp register from the CPU */
+   uint64_t u64_ignore;
+   device->has_reg_timestamp = anv_gem_reg_read(fd, TIMESTAMP | I915_REG_READ_8B_WA,
+                                                &u64_ignore) == 0;
+
    device->has_mem_available = get_available_system_memory() != 0;
 
    device->always_flush_cache =
@@ -4427,8 +4435,6 @@ anv_clock_gettime(clockid_t clock_id)
    return (uint64_t) current.tv_sec * 1000000000ULL + current.tv_nsec;
 }
 
-#define TIMESTAMP 0x2358
-
 VkResult anv_GetCalibratedTimestampsEXT(
    VkDevice                                     _device,
    uint32_t                                     timestampCount,
index dabe675971cba168acd88cef59c1fe18fbdd6748..251ca0f3495b089bd72b57626371fd77b7de24fa 100644 (file)
@@ -117,7 +117,7 @@ EXTENSIONS = [
     Extension('VK_KHR_xlib_surface',                      6, 'VK_USE_PLATFORM_XLIB_KHR'),
     Extension('VK_EXT_acquire_xlib_display',              1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'),
     Extension('VK_EXT_buffer_device_address',             1, 'device->has_a64_buffer_access'),
-    Extension('VK_EXT_calibrated_timestamps',             1, True),
+    Extension('VK_EXT_calibrated_timestamps',             1, 'device->has_reg_timestamp'),
     Extension('VK_EXT_conditional_rendering',             1, 'device->info.gen >= 8 || device->info.is_haswell'),
     Extension('VK_EXT_custom_border_color',               12, 'device->info.gen >= 8'),
     Extension('VK_EXT_debug_report',                      8, True),
index 3994b21b962eedf6f60e386231c56c38a730d185..4bee161227d8fba4be30507c20d70cc6a1195893 100644 (file)
@@ -1092,6 +1092,13 @@ struct anv_physical_device {
     /** True if we can use bindless access for samplers */
     bool                                        has_bindless_samplers;
 
+    /** True if we can read the GPU timestamp register
+     *
+     * When running in a virtual context, the timestamp register is unreadable
+     * on Gen12+.
+     */
+    bool                                        has_reg_timestamp;
+
     /** True if this device has implicit AUX
      *
      * If true, CCS is handled as an implicit attachment to the BO rather than