zink: store valid timestamp bits onto zink_screen
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 10 Jul 2020 18:40:01 +0000 (14:40 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 3 Aug 2020 14:22:39 +0000 (14:22 +0000)
we need this for converting timestamp ticks to nonoseconds

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5913>

src/gallium/drivers/zink/zink_screen.c
src/gallium/drivers/zink/zink_screen.h

index 64ea007..6df0127 100644 (file)
@@ -662,24 +662,25 @@ choose_pdev(const VkInstance instance)
    return pdev;
 }
 
-static uint32_t
-find_gfx_queue(const VkPhysicalDevice pdev)
+static void
+update_queue_props(struct zink_screen *screen)
 {
    uint32_t num_queues;
-   vkGetPhysicalDeviceQueueFamilyProperties(pdev, &num_queues, NULL);
+   vkGetPhysicalDeviceQueueFamilyProperties(screen->pdev, &num_queues, NULL);
    assert(num_queues > 0);
 
    VkQueueFamilyProperties *props = malloc(sizeof(*props) * num_queues);
-   vkGetPhysicalDeviceQueueFamilyProperties(pdev, &num_queues, props);
+   vkGetPhysicalDeviceQueueFamilyProperties(screen->pdev, &num_queues, props);
 
    for (uint32_t i = 0; i < num_queues; i++) {
       if (props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
-         free(props);
-         return i;
+         screen->gfx_queue = i;
+         screen->timestamp_valid_bits = props[i].timestampValidBits;
+         assert(screen->timestamp_valid_bits);
+         break;
       }
    }
-
-   return UINT32_MAX;
+   free(props);
 }
 
 static void
@@ -768,7 +769,7 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
 
    screen->instance = create_instance();
    screen->pdev = choose_pdev(screen->instance);
-   screen->gfx_queue = find_gfx_queue(screen->pdev);
+   update_queue_props(screen);
 
    vkGetPhysicalDeviceMemoryProperties(screen->pdev, &screen->mem_props);
 
index a4fae65..0b6e62e 100644 (file)
@@ -66,6 +66,7 @@ struct zink_screen {
    bool have_D24_UNORM_S8_UINT;
 
    uint32_t gfx_queue;
+   uint32_t timestamp_valid_bits;
    VkDevice dev;
 
    PFN_vkGetMemoryFdKHR vk_GetMemoryFdKHR;