Commit 5904ee3f by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Fix timestamp query units

Vulkan returns timestamps in cycles, which needs to be converted to nanoseconds (by multiplying by limits.timestampPeriod) for GLES. On NVidia, this multiplier seems to be 1 for a majority of their hardware, while the timer has less and more varying granularity on AMD, Intel and others. Bug: angleproject:2885 Change-Id: I34e08ad386e06619170975039385ce35cab025a5 Reviewed-on: https://chromium-review.googlesource.com/c/1436835Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 59d756e5
...@@ -143,6 +143,8 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait) ...@@ -143,6 +143,8 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait)
} }
ANGLE_VK_TRY(contextVk, result); ANGLE_VK_TRY(contextVk, result);
double timestampPeriod = renderer->getPhysicalDeviceProperties().limits.timestampPeriod;
// Fix up the results to what OpenGL expects. // Fix up the results to what OpenGL expects.
switch (getType()) switch (getType())
{ {
...@@ -152,6 +154,7 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait) ...@@ -152,6 +154,7 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait)
mCachedResult = !!mCachedResult; mCachedResult = !!mCachedResult;
break; break;
case gl::QueryType::Timestamp: case gl::QueryType::Timestamp:
mCachedResult = static_cast<uint64_t>(mCachedResult * timestampPeriod);
break; break;
case gl::QueryType::TimeElapsed: case gl::QueryType::TimeElapsed:
{ {
...@@ -166,6 +169,8 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait) ...@@ -166,6 +169,8 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait)
ANGLE_VK_TRY(contextVk, result); ANGLE_VK_TRY(contextVk, result);
mCachedResult = timeElapsedEnd - mCachedResult; mCachedResult = timeElapsedEnd - mCachedResult;
mCachedResult = static_cast<uint64_t>(mCachedResult * timestampPeriod);
break; break;
} }
default: default:
......
...@@ -1636,6 +1636,10 @@ angle::Result RendererVk::getTimestamp(vk::Context *context, uint64_t *timestamp ...@@ -1636,6 +1636,10 @@ angle::Result RendererVk::getTimestamp(vk::Context *context, uint64_t *timestamp
timestampQueryPool.get().freeQuery(context, &timestampQuery); timestampQueryPool.get().freeQuery(context, &timestampQuery);
// Convert results to nanoseconds.
*timestampOut = static_cast<uint64_t>(
*timestampOut * static_cast<double>(mPhysicalDeviceProperties.limits.timestampPeriod));
return angle::Result::Continue; return angle::Result::Continue;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment