From 2e48f011b085cdbd0acafdef7045dc6fc0583aa6 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Fri, 17 Sep 2021 17:24:44 +0000 Subject: [PATCH] Add an option for the Adapter to use tiered limits Does nothing right now since Dawn always exposes the default limits. In the future, setting useTieredLimits to true will bucket the exposed adapter limits to minimize fingerprinting surface. Disabled by default for native applications, but Chrome will always enable it. Bug: dawn:685 Change-Id: I0ecfefc93f7a554f8f8be7906cef9fa8d4745ac2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64524 Reviewed-by: Corentin Wallez Commit-Queue: Austin Eng --- src/dawn_native/Adapter.cpp | 13 ++++++++++++- src/dawn_native/Adapter.h | 3 +++ src/dawn_native/DawnNative.cpp | 4 ++++ src/include/dawn_native/DawnNative.h | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/dawn_native/Adapter.cpp b/src/dawn_native/Adapter.cpp index 5c0d87364c..7cdd1f2e98 100644 --- a/src/dawn_native/Adapter.cpp +++ b/src/dawn_native/Adapter.cpp @@ -82,7 +82,14 @@ namespace dawn_native { if (limits->nextInChain != nullptr) { return false; } - limits->limits = mLimits.v1; + if (mUseTieredLimits) { + // TODO(crbug.com/dawn/685): Apply limit tiers. + // For now, set all limits to the defaults until tiers are + // defined. + GetDefaultLimits(&limits->limits); + } else { + limits->limits = mLimits.v1; + } return true; } @@ -136,6 +143,10 @@ namespace dawn_native { return {}; } + void AdapterBase::SetUseTieredLimits(bool useTieredLimits) { + mUseTieredLimits = useTieredLimits; + } + void AdapterBase::ResetInternalDeviceForTesting() { mInstance->ConsumedError(ResetInternalDeviceForTestingImpl()); } diff --git a/src/dawn_native/Adapter.h b/src/dawn_native/Adapter.h index 32cdd719ee..b8ba82a4a3 100644 --- a/src/dawn_native/Adapter.h +++ b/src/dawn_native/Adapter.h @@ -54,6 +54,8 @@ namespace dawn_native { bool GetLimits(SupportedLimits* limits) const; + void SetUseTieredLimits(bool useTieredLimits); + virtual bool SupportsExternalImages() const = 0; protected: @@ -71,6 +73,7 @@ namespace dawn_native { InstanceBase* mInstance = nullptr; wgpu::BackendType mBackend; CombinedLimits mLimits; + bool mUseTieredLimits = false; }; } // namespace dawn_native diff --git a/src/dawn_native/DawnNative.cpp b/src/dawn_native/DawnNative.cpp index 8cbda6fe02..73d238e4ca 100644 --- a/src/dawn_native/DawnNative.cpp +++ b/src/dawn_native/DawnNative.cpp @@ -110,6 +110,10 @@ namespace dawn_native { return mImpl->GetLimits(reinterpret_cast(limits)); } + void Adapter::SetUseTieredLimits(bool useTieredLimits) { + mImpl->SetUseTieredLimits(useTieredLimits); + } + bool Adapter::SupportsExternalImages() const { return mImpl->SupportsExternalImages(); } diff --git a/src/include/dawn_native/DawnNative.h b/src/include/dawn_native/DawnNative.h index b0700301c0..2d8968774e 100644 --- a/src/include/dawn_native/DawnNative.h +++ b/src/include/dawn_native/DawnNative.h @@ -112,6 +112,8 @@ namespace dawn_native { WGPUDeviceProperties GetAdapterProperties() const; bool GetLimits(WGPUSupportedLimits* limits) const; + void SetUseTieredLimits(bool useTieredLimits); + // Check that the Adapter is able to support importing external images. This is necessary // to implement the swapchain and interop APIs in Chromium. bool SupportsExternalImages() const;