Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_calibrated_timestamps should only return one value for maxDeviation #737

Closed
kanashimia opened this issue Apr 8, 2023 · 2 comments · Fixed by #738
Closed

get_calibrated_timestamps should only return one value for maxDeviation #737

kanashimia opened this issue Apr 8, 2023 · 2 comments · Fixed by #738

Comments

@kanashimia
Copy link
Contributor

It should return VkResult<(Vec<u64>, u64)> instead of VkResult<(Vec<u64>, Vec<u64>)> as per spec

Bug here:

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetCalibratedTimestampsEXT.html>
///
/// Returns a tuple containing `(timestamps, max_deviation)`
#[inline]
pub unsafe fn get_calibrated_timestamps(
    &self,
    device: vk::Device,
    info: &[vk::CalibratedTimestampInfoEXT],
) -> VkResult<(Vec<u64>, Vec<u64>)> {
    let mut timestamps = vec![0u64; info.len()];
    let mut max_deviation = vec![0u64; info.len()];
    (self.fp.get_calibrated_timestamps_ext)(
        device,
        info.len() as u32,
        info.as_ptr(),
        timestamps.as_mut_ptr(),
        max_deviation.as_mut_ptr(),
    )
    .result_with_success((timestamps, max_deviation))
}

Spec xml:

<command successcodes="VK_SUCCESS" errorcodes="VK_ERROR_OUT_OF_HOST_MEMORY,VK_ERROR_OUT_OF_DEVICE_MEMORY">
    <proto><type>VkResult</type> <name>vkGetCalibratedTimestampsEXT</name></proto>
    <param><type>VkDevice</type> <name>device</name></param>
    <param><type>uint32_t</type> <name>timestampCount</name></param>
    <param len="timestampCount">const <type>VkCalibratedTimestampInfoEXT</type>* <name>pTimestampInfos</name></param>
    <param len="timestampCount"><type>uint64_t</type>* <name>pTimestamps</name></param>
    <param><type>uint64_t</type>* <name>pMaxDeviation</name></param>
</command>

Spec: pMaxDeviation is a pointer to a 64-bit unsigned integer value in which the strictly positive maximum deviation, in nanoseconds, of the calibrated timestamp values is returned.
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetCalibratedTimestampsEXT.html

@Ralith
Copy link
Collaborator

Ralith commented Apr 8, 2023

Thanks; I confirm your analysis. This is not a soundness issue since we initialize the data regardless, but it is misleading. Want to make a PR with a fix?

@MarijnS95 MarijnS95 changed the title Bug in the get_calibrated_timestamps implementation get_calibrated_timestamps should only return one value for maxDeviation Apr 8, 2023
@MarijnS95
Copy link
Collaborator

Whoops, I agree. I probably misunderstood the last sentence of the quoted docs to say that there was one deviation per timestamp when implementing this, but the vk.xml spec makes it clear this is not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants