Mesa (master): zink: implement handling for VK_EXT_calibrated_timestamps
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 3 14:31:26 UTC 2020
Module: Mesa
Branch: master
Commit: cd1c21f8e5bfa1d682ef4123a3418fe64adb9f83
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd1c21f8e5bfa1d682ef4123a3418fe64adb9f83
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Fri Jul 10 14:42:08 2020 -0400
zink: implement handling for VK_EXT_calibrated_timestamps
just the extension setup; we need this to handle device timestamp
queries outside of batches
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5913>
---
src/gallium/drivers/zink/zink_screen.c | 42 ++++++++++++++++++++++++++++++++--
src/gallium/drivers/zink/zink_screen.h | 4 ++++
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 6df0127b243..921581d517d 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -735,6 +735,14 @@ load_device_extensions(struct zink_screen *screen)
if (!screen->vk_##x) \
return false; \
} while (0)
+
+#define GET_PROC_ADDR_INSTANCE(x) do { \
+ screen->vk_##x = (PFN_vk##x)vkGetInstanceProcAddr(screen->instance, "vk"#x); \
+ if (!screen->vk_##x) { \
+ debug_printf("GetInstanceProcAddr failed: vk"#x"\n"); \
+ return false; \
+ } \
+ } while (0)
if (screen->have_EXT_transform_feedback) {
GET_PROC_ADDR(CmdBindTransformFeedbackBuffersEXT);
GET_PROC_ADDR(CmdBeginTransformFeedbackEXT);
@@ -751,6 +759,29 @@ load_device_extensions(struct zink_screen *screen)
GET_PROC_ADDR(CmdEndConditionalRenderingEXT);
}
+ if (screen->have_EXT_calibrated_timestamps) {
+ GET_PROC_ADDR_INSTANCE(GetPhysicalDeviceCalibrateableTimeDomainsEXT);
+ GET_PROC_ADDR(GetCalibratedTimestampsEXT);
+
+ uint32_t num_domains = 0;
+ screen->vk_GetPhysicalDeviceCalibrateableTimeDomainsEXT(screen->pdev, &num_domains, NULL);
+ assert(num_domains > 0);
+
+ VkTimeDomainEXT *domains = malloc(sizeof(VkTimeDomainEXT) * num_domains);
+ screen->vk_GetPhysicalDeviceCalibrateableTimeDomainsEXT(screen->pdev, &num_domains, domains);
+
+ /* VK_TIME_DOMAIN_DEVICE_EXT is used for the ctx->get_timestamp hook and is the only one we really need */
+ bool have_device_time = false;
+ for (unsigned i = 0; i < num_domains; i++) {
+ if (domains[i] == VK_TIME_DOMAIN_DEVICE_EXT) {
+ have_device_time = true;
+ break;
+ }
+ }
+ assert(have_device_time);
+ free(domains);
+ }
+
#undef GET_PROC_ADDR
return true;
@@ -761,7 +792,8 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
{
struct zink_screen *screen = CALLOC_STRUCT(zink_screen);
bool have_tf_ext = false, have_cond_render_ext = false, have_EXT_index_type_uint8 = false,
- have_EXT_robustness2_features = false, have_EXT_vertex_attribute_divisor = false;
+ have_EXT_robustness2_features = false, have_EXT_vertex_attribute_divisor = false,
+ have_EXT_calibrated_timestamps = false;
if (!screen)
return NULL;
@@ -809,6 +841,9 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
if (!strcmp(extensions[i].extensionName,
VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME))
have_EXT_vertex_attribute_divisor = true;
+ if (!strcmp(extensions[i].extensionName,
+ VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME))
+ have_EXT_calibrated_timestamps = true;
}
FREE(extensions);
@@ -856,6 +891,7 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
screen->have_EXT_robustness2_features = have_EXT_robustness2_features;
if (have_EXT_vertex_attribute_divisor && screen->vdiv_feats.vertexAttributeInstanceRateDivisor)
screen->have_EXT_vertex_attribute_divisor = true;
+ screen->have_EXT_calibrated_timestamps = have_EXT_calibrated_timestamps;
VkPhysicalDeviceProperties2 props = {};
VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT vdiv_props = {};
@@ -899,7 +935,7 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
* this requires us to pass the whole VkPhysicalDeviceFeatures2 struct
*/
dci.pNext = &feats;
- const char *extensions[8] = {
+ const char *extensions[9] = {
VK_KHR_MAINTENANCE1_EXTENSION_NAME,
};
num_extensions = 1;
@@ -926,6 +962,8 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
extensions[num_extensions++] = VK_EXT_ROBUSTNESS_2_EXTENSION_NAME;
if (screen->have_EXT_vertex_attribute_divisor)
extensions[num_extensions++] = VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME;
+ if (screen->have_EXT_calibrated_timestamps)
+ extensions[num_extensions++] = VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME;
assert(num_extensions <= ARRAY_SIZE(extensions));
dci.ppEnabledExtensionNames = extensions;
diff --git a/src/gallium/drivers/zink/zink_screen.h b/src/gallium/drivers/zink/zink_screen.h
index 0b6e62ed569..a65a053c927 100644
--- a/src/gallium/drivers/zink/zink_screen.h
+++ b/src/gallium/drivers/zink/zink_screen.h
@@ -61,6 +61,7 @@ struct zink_screen {
bool have_EXT_index_type_uint8;
bool have_EXT_robustness2_features;
bool have_EXT_vertex_attribute_divisor;
+ bool have_EXT_calibrated_timestamps;
bool have_X8_D24_UNORM_PACK32;
bool have_D24_UNORM_S8_UINT;
@@ -79,6 +80,9 @@ struct zink_screen {
PFN_vkCmdBeginQueryIndexedEXT vk_CmdBeginQueryIndexedEXT;
PFN_vkCmdEndQueryIndexedEXT vk_CmdEndQueryIndexedEXT;
PFN_vkCmdDrawIndirectByteCountEXT vk_CmdDrawIndirectByteCountEXT;
+
+ PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT vk_GetPhysicalDeviceCalibrateableTimeDomainsEXT;
+ PFN_vkGetCalibratedTimestampsEXT vk_GetCalibratedTimestampsEXT;
};
static inline struct zink_screen *
More information about the mesa-commit
mailing list