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 <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8977>
This commit is contained in:
Erik Faye-Lund 2021-02-10 18:50:32 +01:00 committed by Marge Bot
parent d906c007d6
commit b65093c0cf

View file

@ -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