Mesa (master): anv: disable VK_EXT_calibrated_timestamps when the timestamp register is unreadable

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 20 22:03:08 UTC 2020


Module: Mesa
Branch: master
Commit: f68db81cbb3c8f2b901fc5dcac02d01d3e698cc3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f68db81cbb3c8f2b901fc5dcac02d01d3e698cc3

Author: Eric Engestrom <eric.engestrom at intel.com>
Date:   Wed May 15 11:30:36 2019 +0100

anv: disable VK_EXT_calibrated_timestamps when the timestamp register is unreadable

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 at intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2797>

---

 src/intel/vulkan/anv_device.c      | 10 ++++++++--
 src/intel/vulkan/anv_extensions.py |  2 +-
 src/intel/vulkan/anv_private.h     |  7 +++++++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index fe87c233d15..8178a128089 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -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,
diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py
index dabe675971c..251ca0f3495 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -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),
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 3994b21b962..4bee161227d 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -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



More information about the mesa-commit mailing list