-
Notifications
You must be signed in to change notification settings - Fork 755
Open
Description
I see two issues with timestamp example:
- Support for timestamps is detected by comparing
VkPhysicalDeviceLimits::timestampPeriod
to zero. If it is zero, the device is considered to not support timestamps. I was trying to find support for this idea in Vulkan specification, but found none. The only base for the timestamp support in the spec is based ontimestampComputeAndGraphics
andtimestampValidBits
in the spec. There is no word aboutVkPhysicalDeviceLimits::timestampPeriod
value if timestamps are not supported. - In the part "Interpreting the results", following equation is used
float delta_in_ms = float(time_stamps[1] - time_stamps[0]) * device_limits.timestampPeriod / 1000000.0f;
. The equation does not handle timestamp overflows correctly, in my opinion. Timestamp precision is between 36..64 bits. And returned timestamps contain zeros on the place of bits outside of the valid bits range. So, if time_stamps[1] already wraps over to value zero and time_stamps[0] contains maximum value of 36 bits of precision, we have 0x0000'0000'0000'0000 - 0x0000'000f'ffff'ffff = 0xffff'fff0'0000'0001. In other words, the result of subtraction is now not 1 but extremely high number. I guess that correct computation shall use the maskuint64_t timestampValidBitMask = (timestampValidBits >= 64) ? ~uint64_t(0) : (uint64_t(1) << timestampValidBits) - 1;
. And the fixed equation would be
float delta_in_ms = float((time_stamps[1] - time_stamps[0]) & timestampValidBitMask) * device_limits.timestampPeriod / 1000000.0f;
. - The text uses both "timestamp" and "time stamp". The spec uses only "timestamp". I am inclined to suggest to be consistent with the spec.
If I am mistaken, especially on point 1 and 2, please correct me.
Edit: Corrected computation of timestampValidBitMask.
Metadata
Metadata
Assignees
Labels
No labels