From 0befc259a649acad02937276b1008383d2f84c62 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 16 May 2022 08:58:37 -0400 Subject: [PATCH] zink: use copy context to eliminate dependency on EXT_calibrated_timestamps this is unsupported by a surprising number of drivers Reviewed-by: Adam Jackson Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_query.c | 24 ++++++++++++++++++------ src/gallium/drivers/zink/zink_screen.c | 3 +-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c index b3cc6caf788..7e2a1dbf91b 100644 --- a/src/gallium/drivers/zink/zink_query.c +++ b/src/gallium/drivers/zink/zink_query.c @@ -1298,12 +1298,24 @@ zink_get_timestamp(struct pipe_context *pctx) { struct zink_screen *screen = zink_screen(pctx->screen); uint64_t timestamp, deviation; - assert(screen->info.have_EXT_calibrated_timestamps); - VkCalibratedTimestampInfoEXT cti = {0}; - cti.sType = VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT; - cti.timeDomain = VK_TIME_DOMAIN_DEVICE_EXT; - if (VKSCR(GetCalibratedTimestampsEXT)(screen->dev, 1, &cti, ×tamp, &deviation) != VK_SUCCESS) { - mesa_loge("ZINK: vkGetCalibratedTimestampsEXT failed"); + if (screen->info.have_EXT_calibrated_timestamps) { + VkCalibratedTimestampInfoEXT cti = {0}; + cti.sType = VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT; + cti.timeDomain = VK_TIME_DOMAIN_DEVICE_EXT; + if (VKSCR(GetCalibratedTimestampsEXT)(screen->dev, 1, &cti, ×tamp, &deviation) != VK_SUCCESS) { + mesa_loge("ZINK: vkGetCalibratedTimestampsEXT failed"); + } + } else { + pctx = &screen->copy_context->base; + struct pipe_query *pquery = pctx->create_query(pctx, PIPE_QUERY_TIMESTAMP, 0); + if (!pquery) + return 0; + union pipe_query_result result = {0}; + pctx->begin_query(pctx, pquery); + pctx->end_query(pctx, pquery); + pctx->get_query_result(pctx, pquery, true, &result); + pctx->destroy_query(pctx, pquery); + timestamp = result.u64; } timestamp_to_nanoseconds(screen, ×tamp); return timestamp; diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 4ddb8c91e97..248abc7bd13 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -593,8 +593,7 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return screen->info.props.limits.minUniformBufferOffsetAlignment; case PIPE_CAP_QUERY_TIMESTAMP: - return screen->info.have_EXT_calibrated_timestamps && - screen->timestamp_valid_bits > 0; + return screen->timestamp_valid_bits > 0; case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: return 1 << MIN_SLAB_ORDER;