Fix timestamp period for timestamp-query-inside-passes on Metal

Still a missing condition to enable timestamp period calculation at
device initialization on Metal.

Refactor GPUTimestampCalibrationTests.cpp to check timestamp query
correctness on both D3D12 and Metal backends.

Bug: dawn:1193
Change-Id: I69feeaea0df309e15c008647d76b11899dcdc727
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119320
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Li Hao
2023-02-11 09:30:38 +00:00
committed by Dawn LUCI CQ
parent f5cee3fadf
commit 9ee3c7afcc
7 changed files with 198 additions and 21 deletions

View File

@@ -160,6 +160,7 @@ class Device final : public DeviceBase {
MTLTimestamp mGpuTimestamp API_AVAILABLE(macos(10.15), ios(14.0)) = 0;
// The parameters for kalman filter
std::unique_ptr<KalmanInfo> mKalmanInfo;
bool mIsTimestampQueryEnabled = false;
// Support counter sampling between blit commands, dispatches and draw calls
bool mCounterSamplingAtCommandBoundary;

View File

@@ -131,6 +131,9 @@ Device::Device(AdapterBase* adapter,
mCounterSamplingAtCommandBoundary = true;
mCounterSamplingAtStageBoundary = false;
}
mIsTimestampQueryEnabled =
HasFeature(Feature::TimestampQuery) || HasFeature(Feature::TimestampQueryInsidePasses);
}
Device::~Device() {
@@ -149,8 +152,7 @@ MaybeError Device::Initialize(const DeviceDescriptor* descriptor) {
DAWN_TRY(mCommandContext.PrepareNextCommandBuffer(*mCommandQueue));
if (HasFeature(Feature::TimestampQuery) &&
!IsToggleEnabled(Toggle::DisableTimestampQueryConversion)) {
if (mIsTimestampQueryEnabled && !IsToggleEnabled(Toggle::DisableTimestampQueryConversion)) {
// Make a best guess of timestamp period based on device vendor info, and converge it to
// an accurate value by the following calculations.
mTimestampPeriod = gpu_info::IsIntel(GetAdapter()->GetVendorId()) ? 83.333f : 1.0f;
@@ -266,8 +268,7 @@ MaybeError Device::TickImpl() {
// Just run timestamp period calculation when timestamp feature is enabled and timestamp
// conversion is not disabled.
if ((HasFeature(Feature::TimestampQuery) || HasFeature(Feature::TimestampQueryInsidePasses)) &&
!IsToggleEnabled(Toggle::DisableTimestampQueryConversion)) {
if (mIsTimestampQueryEnabled && !IsToggleEnabled(Toggle::DisableTimestampQueryConversion)) {
if (@available(macos 10.15, iOS 14.0, *)) {
UpdateTimestampPeriod(GetMTLDevice(), mKalmanInfo.get(), &mCpuTimestamp, &mGpuTimestamp,
&mTimestampPeriod);