More code clean-ups after creating DeviceMock with Adapter This patch does more code clean-ups in Device.cpp after we update the creation of DeviceMock with Adapter: 1. Remove the `virtual` qualifier on the member functions `GetInstance()` and `GetPlatform()` of class `DeviceBase` after the removal of these overloads in the Mock tests. 2. Remove the check on the nullability of `mAdapter` in `DeviceBase`. Bug: chromium:42240655 Test: dawn_unittests Change-Id: I11ba819d2724ed32300131fbdc773299e465c72e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/202497 Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp index 84e96ed..e58623f 100644 --- a/src/dawn/native/Device.cpp +++ b/src/dawn/native/Device.cpp
@@ -1869,12 +1869,8 @@ } // Language features are enabled instance-wide. - // mAdapter is not set for mock test devices. - // TODO(crbug.com/dawn/1702): using a mock adapter and instance could avoid the null checking. - if (mAdapter != nullptr) { - const auto& allowedFeatures = GetInstance()->GetAllowedWGSLLanguageFeatures(); - mWGSLAllowedFeatures.features = {allowedFeatures.begin(), allowedFeatures.end()}; - } + const auto& allowedFeatures = GetInstance()->GetAllowedWGSLLanguageFeatures(); + mWGSLAllowedFeatures.features = {allowedFeatures.begin(), allowedFeatures.end()}; } const tint::wgsl::AllowedFeatures& DeviceBase::GetWGSLAllowedFeatures() const {
diff --git a/src/dawn/native/Device.h b/src/dawn/native/Device.h index cea3471..3dc04ec 100644 --- a/src/dawn/native/Device.h +++ b/src/dawn/native/Device.h
@@ -127,12 +127,10 @@ MaybeError ValidateObject(const ApiObjectBase* object) const; - // TODO(dawn:1702) Remove virtual when we mock the adapter. - virtual InstanceBase* GetInstance() const; - + InstanceBase* GetInstance() const; AdapterBase* GetAdapter() const; PhysicalDeviceBase* GetPhysicalDevice() const; - virtual dawn::platform::Platform* GetPlatform() const; + dawn::platform::Platform* GetPlatform() const; // Returns the Format corresponding to the wgpu::TextureFormat or an error if the format // isn't a valid wgpu::TextureFormat or isn't supported by this device.