mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user