From b65093c0cfbc614e88bb333fd99e4f578ddccdb7 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 10 Feb 2021 18:50:32 +0100 Subject: [PATCH] zink: correctly handle 64 valid timestamp bits We can't shift up 1ull by more than 63 without triggering undefined behavior here. But in that case, doing nothing is perfectly fine. While we're at it, remove some needless parens. This fixes the spec@ext_timer_query@time-elapsed piglit test on top of Lavapipe. Reviewed-by: Hoe Hao Cheng Part-of: --- src/gallium/drivers/zink/zink_query.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c index 89ec037be9c..f4652432428 100644 --- a/src/gallium/drivers/zink/zink_query.c +++ b/src/gallium/drivers/zink/zink_query.c @@ -49,7 +49,9 @@ timestamp_to_nanoseconds(struct zink_screen *screen, uint64_t *timestamp) * the VkQueueFamilyProperties::timestampValidBits property of the queue on which the timestamp is written. * - 17.5. Timestamp Queries */ - *timestamp &= ((1ull << screen->timestamp_valid_bits) - 1); + if (screen->timestamp_valid_bits < 64) + *timestamp &= (1ull << screen->timestamp_valid_bits) - 1; + /* The number of nanoseconds it takes for a timestamp value to be incremented by 1 * can be obtained from VkPhysicalDeviceLimits::timestampPeriod * - 17.5. Timestamp Queries