Turn AdapterBase into a wrapper class.
Change AdapterBase from an alias to PhysicalDeviceBase to a thin wrapper class holding a ref to a PhysicalDeviceBase. This way, mutiple AdapterBases can point at the same PhysicalDeviceBase. For now, InstanceBase wraps all PhysicalDeviceBases discovered by a backend in a single AdapterBase. In the future, this relationship will become many-to-one. Since Devices now maintain a ref on the AdapterBase wrapper (in order to query toggles, etc), PhysicalDeviceBase::CreateDeviceImpl() now takes the AdapterBase as an argument, so that the PhysicalDeviceBase knows which AdapterBase to vend a Device for. Note that the Toggles also still remain on the PhysicalDeviceBase, to be moved up to the AdapterBase in a future change. Bug: dawn:1774 Change-Id: Idef5d24fbd66d8552959230e246e453abddcc736 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131001 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
5eb3619d3e
commit
fed6b6b35b
|
@ -34,7 +34,8 @@ struct DeviceDescriptor;
|
|||
namespace dawn::native {
|
||||
|
||||
class InstanceBase;
|
||||
class PhysicalDeviceBase;
|
||||
class AdapterBase;
|
||||
|
||||
// An optional parameter of Adapter::CreateDevice() to send additional information when creating
|
||||
// a Device. For example, we can use it to enable a workaround, optimization or feature.
|
||||
struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor {
|
||||
|
@ -84,10 +85,8 @@ struct FeatureInfo {
|
|||
class DAWN_NATIVE_EXPORT Adapter {
|
||||
public:
|
||||
Adapter();
|
||||
// TODO(dawn:1774): all references to PhysicalDeviceBase in this class will go back to
|
||||
// using AdapterBase once the latter becomes a real class again.
|
||||
// NOLINTNEXTLINE(runtime/explicit)
|
||||
Adapter(PhysicalDeviceBase* impl);
|
||||
Adapter(AdapterBase* impl);
|
||||
~Adapter();
|
||||
|
||||
Adapter(const Adapter& other);
|
||||
|
@ -132,7 +131,7 @@ class DAWN_NATIVE_EXPORT Adapter {
|
|||
void ResetInternalDeviceForTesting();
|
||||
|
||||
private:
|
||||
PhysicalDeviceBase* mImpl = nullptr;
|
||||
AdapterBase* mImpl = nullptr;
|
||||
};
|
||||
|
||||
// Base class for options passed to Instance::DiscoverAdapters.
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright 2023 The Dawn Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "dawn/native/Adapter.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "dawn/native/PhysicalDevice.h"
|
||||
|
||||
namespace dawn::native {
|
||||
|
||||
AdapterBase::AdapterBase(const Ref<PhysicalDeviceBase>& physicalDevice)
|
||||
: mPhysicalDevice(std::move(physicalDevice)) {}
|
||||
|
||||
AdapterBase::~AdapterBase() = default;
|
||||
|
||||
PhysicalDeviceBase* AdapterBase::GetPhysicalDevice() {
|
||||
return mPhysicalDevice.Get();
|
||||
}
|
||||
|
||||
InstanceBase* AdapterBase::APIGetInstance() const {
|
||||
return mPhysicalDevice->APIGetInstance();
|
||||
}
|
||||
|
||||
bool AdapterBase::APIGetLimits(SupportedLimits* limits) const {
|
||||
return mPhysicalDevice->APIGetLimits(limits);
|
||||
}
|
||||
|
||||
void AdapterBase::APIGetProperties(AdapterProperties* properties) const {
|
||||
mPhysicalDevice->APIGetProperties(properties);
|
||||
}
|
||||
|
||||
bool AdapterBase::APIHasFeature(wgpu::FeatureName feature) const {
|
||||
return mPhysicalDevice->APIHasFeature(feature);
|
||||
}
|
||||
|
||||
size_t AdapterBase::APIEnumerateFeatures(wgpu::FeatureName* features) const {
|
||||
return mPhysicalDevice->APIEnumerateFeatures(features);
|
||||
}
|
||||
|
||||
DeviceBase* AdapterBase::APICreateDevice(const DeviceDescriptor* descriptor) {
|
||||
return mPhysicalDevice->CreateDevice(this, descriptor);
|
||||
}
|
||||
|
||||
void AdapterBase::APIRequestDevice(const DeviceDescriptor* descriptor,
|
||||
WGPURequestDeviceCallback callback,
|
||||
void* userdata) {
|
||||
return mPhysicalDevice->RequestDevice(this, descriptor, callback, userdata);
|
||||
}
|
||||
|
||||
const TogglesState& AdapterBase::GetTogglesState() const {
|
||||
return mPhysicalDevice->GetTogglesState();
|
||||
}
|
||||
|
||||
} // namespace dawn::native
|
|
@ -15,12 +15,43 @@
|
|||
#ifndef SRC_DAWN_NATIVE_ADAPTER_H_
|
||||
#define SRC_DAWN_NATIVE_ADAPTER_H_
|
||||
|
||||
#include "dawn/native/PhysicalDevice.h"
|
||||
#include "dawn/native/DawnNative.h"
|
||||
|
||||
#include "dawn/common/RefCounted.h"
|
||||
#include "dawn/native/dawn_platform.h"
|
||||
|
||||
namespace dawn::native {
|
||||
|
||||
using AdapterBase = PhysicalDeviceBase;
|
||||
class DeviceBase;
|
||||
class TogglesState;
|
||||
struct SupportedLimits;
|
||||
|
||||
}
|
||||
class AdapterBase : public RefCounted {
|
||||
public:
|
||||
explicit AdapterBase(const Ref<PhysicalDeviceBase>& physicalDevice);
|
||||
~AdapterBase() override;
|
||||
|
||||
// WebGPU API
|
||||
InstanceBase* APIGetInstance() const;
|
||||
bool APIGetLimits(SupportedLimits* limits) const;
|
||||
void APIGetProperties(AdapterProperties* properties) const;
|
||||
bool APIHasFeature(wgpu::FeatureName feature) const;
|
||||
size_t APIEnumerateFeatures(wgpu::FeatureName* features) const;
|
||||
void APIRequestDevice(const DeviceDescriptor* descriptor,
|
||||
WGPURequestDeviceCallback callback,
|
||||
void* userdata);
|
||||
DeviceBase* APICreateDevice(const DeviceDescriptor* descriptor = nullptr);
|
||||
|
||||
// Return the underlying PhysicalDevice.
|
||||
PhysicalDeviceBase* GetPhysicalDevice();
|
||||
|
||||
// Get the actual toggles state of the adapter.
|
||||
const TogglesState& GetTogglesState() const;
|
||||
|
||||
private:
|
||||
Ref<PhysicalDeviceBase> mPhysicalDevice;
|
||||
};
|
||||
|
||||
} // namespace dawn::native
|
||||
|
||||
#endif // SRC_DAWN_NATIVE_ADAPTER_H_
|
||||
|
|
|
@ -184,6 +184,7 @@ source_set("sources") {
|
|||
|
||||
sources = get_target_outputs(":utils_gen")
|
||||
sources += [
|
||||
"Adapter.cpp",
|
||||
"Adapter.h",
|
||||
"ApplyClearColorValueWithDrawHelper.cpp",
|
||||
"ApplyClearColorValueWithDrawHelper.h",
|
||||
|
|
|
@ -31,6 +31,7 @@ target_sources(dawn_native PRIVATE
|
|||
"${DAWN_INCLUDE_DIR}/dawn/native/dawn_native_export.h"
|
||||
${DAWN_NATIVE_UTILS_GEN_SOURCES}
|
||||
"Adapter.h"
|
||||
"Adapter.cpp"
|
||||
"ApplyClearColorValueWithDrawHelper.cpp"
|
||||
"ApplyClearColorValueWithDrawHelper.h"
|
||||
"AsyncTask.cpp"
|
||||
|
|
|
@ -79,7 +79,7 @@ MaybeError ValidateTimestampQuery(const DeviceBase* device,
|
|||
|
||||
DAWN_INVALID_IF(!device->HasFeature(requiredFeature),
|
||||
"Timestamp queries used without the %s feature enabled.",
|
||||
device->GetAdapter()
|
||||
device->GetPhysicalDevice()
|
||||
->GetInstance()
|
||||
->GetFeatureInfo(FeatureEnumToAPIFeature(requiredFeature))
|
||||
->name);
|
||||
|
|
|
@ -81,7 +81,7 @@ DawnDeviceDescriptor::~DawnDeviceDescriptor() = default;
|
|||
|
||||
Adapter::Adapter() = default;
|
||||
|
||||
Adapter::Adapter(PhysicalDeviceBase* impl) : mImpl(impl) {
|
||||
Adapter::Adapter(AdapterBase* impl) : mImpl(impl) {
|
||||
if (mImpl != nullptr) {
|
||||
mImpl->Reference();
|
||||
}
|
||||
|
@ -122,20 +122,20 @@ WGPUAdapter Adapter::Get() const {
|
|||
}
|
||||
|
||||
std::vector<const char*> Adapter::GetSupportedFeatures() const {
|
||||
FeaturesSet supportedFeaturesSet = mImpl->GetSupportedFeatures();
|
||||
FeaturesSet supportedFeaturesSet = mImpl->GetPhysicalDevice()->GetSupportedFeatures();
|
||||
return supportedFeaturesSet.GetEnabledFeatureNames();
|
||||
}
|
||||
|
||||
bool Adapter::GetLimits(WGPUSupportedLimits* limits) const {
|
||||
return mImpl->GetLimits(FromAPI(limits));
|
||||
return mImpl->GetPhysicalDevice()->GetLimits(FromAPI(limits));
|
||||
}
|
||||
|
||||
void Adapter::SetUseTieredLimits(bool useTieredLimits) {
|
||||
mImpl->SetUseTieredLimits(useTieredLimits);
|
||||
mImpl->GetPhysicalDevice()->SetUseTieredLimits(useTieredLimits);
|
||||
}
|
||||
|
||||
bool Adapter::SupportsExternalImages() const {
|
||||
return mImpl->SupportsExternalImages();
|
||||
return mImpl->GetPhysicalDevice()->SupportsExternalImages();
|
||||
}
|
||||
|
||||
Adapter::operator bool() const {
|
||||
|
@ -177,7 +177,7 @@ void Adapter::RequestDevice(const WGPUDeviceDescriptor* descriptor,
|
|||
}
|
||||
|
||||
void Adapter::ResetInternalDeviceForTesting() {
|
||||
mImpl->ResetInternalDeviceForTesting();
|
||||
mImpl->GetPhysicalDevice()->ResetInternalDeviceForTesting();
|
||||
}
|
||||
|
||||
// AdapterDiscoverOptionsBase
|
||||
|
@ -210,7 +210,7 @@ bool Instance::DiscoverAdapters(const AdapterDiscoveryOptionsBase* options) {
|
|||
std::vector<Adapter> Instance::GetAdapters() const {
|
||||
// Adapters are owned by mImpl so it is safe to return non RAII pointers to them
|
||||
std::vector<Adapter> adapters;
|
||||
for (const Ref<PhysicalDeviceBase>& adapter : mImpl->GetAdapters()) {
|
||||
for (const Ref<AdapterBase>& adapter : mImpl->GetAdapters()) {
|
||||
adapters.push_back(Adapter(adapter.Get()));
|
||||
}
|
||||
return adapters;
|
||||
|
|
|
@ -286,7 +286,7 @@ MaybeError DeviceBase::Initialize(Ref<QueueBase> defaultQueue) {
|
|||
// mAdapter is not set for mock test devices.
|
||||
// TODO(crbug.com/dawn/1702): using a mock adapter could avoid the null checking.
|
||||
if (mAdapter != nullptr) {
|
||||
mAdapter->GetInstance()->AddDevice(this);
|
||||
mAdapter->GetPhysicalDevice()->GetInstance()->AddDevice(this);
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -344,11 +344,12 @@ void DeviceBase::WillDropLastExternalRef() {
|
|||
// mAdapter is not set for mock test devices.
|
||||
// TODO(crbug.com/dawn/1702): using a mock adapter could avoid the null checking.
|
||||
if (mAdapter != nullptr) {
|
||||
mAdapter->GetInstance()->RemoveDevice(this);
|
||||
mAdapter->GetPhysicalDevice()->GetInstance()->RemoveDevice(this);
|
||||
|
||||
// Once last external ref dropped, all callbacks should be forwarded to Instance's callback
|
||||
// queue instead.
|
||||
mCallbackTaskManager = mAdapter->GetInstance()->GetCallbackTaskManager();
|
||||
mCallbackTaskManager =
|
||||
mAdapter->GetPhysicalDevice()->GetInstance()->GetCallbackTaskManager();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -659,9 +660,10 @@ BlobCache* DeviceBase::GetBlobCache() {
|
|||
// TODO(crbug.com/dawn/1481): Shader caching currently has a dependency on the WGSL writer to
|
||||
// generate cache keys. We can lift the dependency once we also cache frontend parsing,
|
||||
// transformations, and reflection.
|
||||
return mAdapter->GetInstance()->GetBlobCache(!IsToggleEnabled(Toggle::DisableBlobCache));
|
||||
return mAdapter->GetPhysicalDevice()->GetInstance()->GetBlobCache(
|
||||
!IsToggleEnabled(Toggle::DisableBlobCache));
|
||||
#else
|
||||
return mAdapter->GetInstance()->GetBlobCache(false);
|
||||
return mAdapter->GetPhysicalDevice()->GetInstance()->GetBlobCache(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -720,12 +722,11 @@ AdapterBase* DeviceBase::GetAdapter() const {
|
|||
}
|
||||
|
||||
PhysicalDeviceBase* DeviceBase::GetPhysicalDevice() const {
|
||||
return mAdapter
|
||||
.Get(); // TODO(dawn:1774): This will retrieve the PhysicalDevice from the AdapterBase.
|
||||
return mAdapter->GetPhysicalDevice();
|
||||
}
|
||||
|
||||
dawn::platform::Platform* DeviceBase::GetPlatform() const {
|
||||
return GetAdapter()->GetInstance()->GetPlatform();
|
||||
return GetPhysicalDevice()->GetInstance()->GetPlatform();
|
||||
}
|
||||
|
||||
ExecutionSerial DeviceBase::GetCompletedCommandSerial() const {
|
||||
|
@ -1346,7 +1347,7 @@ MaybeError DeviceBase::Tick() {
|
|||
return {};
|
||||
}
|
||||
|
||||
PhysicalDeviceBase* DeviceBase::APIGetAdapter() {
|
||||
AdapterBase* DeviceBase::APIGetAdapter() {
|
||||
mAdapter->Reference();
|
||||
return mAdapter.Get();
|
||||
}
|
||||
|
@ -1373,7 +1374,7 @@ ExternalTextureBase* DeviceBase::APICreateExternalTexture(
|
|||
|
||||
void DeviceBase::ApplyFeatures(const DeviceDescriptor* deviceDescriptor) {
|
||||
ASSERT(deviceDescriptor);
|
||||
ASSERT(GetAdapter()->SupportsAllRequiredFeatures(
|
||||
ASSERT(GetPhysicalDevice()->SupportsAllRequiredFeatures(
|
||||
{deviceDescriptor->requiredFeatures, deviceDescriptor->requiredFeaturesCount}));
|
||||
|
||||
for (uint32_t i = 0; i < deviceDescriptor->requiredFeaturesCount; ++i) {
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace dawn::native {
|
|||
|
||||
enum class ObjectType : uint32_t;
|
||||
|
||||
class AdapterBase;
|
||||
class BindGroupBase;
|
||||
class BindGroupLayoutBase;
|
||||
class BufferBase;
|
||||
|
@ -51,8 +52,6 @@ class SwapChainBase;
|
|||
class TextureBase;
|
||||
class TextureViewBase;
|
||||
|
||||
using AdapterBase = PhysicalDeviceBase;
|
||||
|
||||
class DeviceBase;
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -313,13 +313,13 @@ void InstanceBase::DiscoverDefaultAdapters() {
|
|||
TogglesState adapterToggles = TogglesState(ToggleStage::Adapter);
|
||||
adapterToggles.InheritFrom(mToggles);
|
||||
|
||||
std::vector<Ref<AdapterBase>> backendAdapters =
|
||||
std::vector<Ref<PhysicalDeviceBase>> physicalDevices =
|
||||
backend->DiscoverDefaultAdapters(adapterToggles);
|
||||
|
||||
for (Ref<AdapterBase>& adapter : backendAdapters) {
|
||||
ASSERT(adapter->GetBackendType() == backend->GetType());
|
||||
ASSERT(adapter->GetInstance() == this);
|
||||
mAdapters.push_back(std::move(adapter));
|
||||
for (Ref<PhysicalDeviceBase>& physicalDevice : physicalDevices) {
|
||||
ASSERT(physicalDevice->GetBackendType() == backend->GetType());
|
||||
ASSERT(physicalDevice->GetInstance() == this);
|
||||
mAdapters.push_back(AcquireRef(new AdapterBase(std::move(physicalDevice))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,13 +447,13 @@ MaybeError InstanceBase::DiscoverAdaptersInternal(const AdapterDiscoveryOptionsB
|
|||
TogglesState adapterToggles = TogglesState(ToggleStage::Adapter);
|
||||
adapterToggles.InheritFrom(mToggles);
|
||||
|
||||
std::vector<Ref<AdapterBase>> newAdapters;
|
||||
DAWN_TRY_ASSIGN(newAdapters, backend->DiscoverAdapters(options, adapterToggles));
|
||||
std::vector<Ref<PhysicalDeviceBase>> newPhysicalDevices;
|
||||
DAWN_TRY_ASSIGN(newPhysicalDevices, backend->DiscoverAdapters(options, adapterToggles));
|
||||
|
||||
for (Ref<AdapterBase>& adapter : newAdapters) {
|
||||
ASSERT(adapter->GetBackendType() == backend->GetType());
|
||||
ASSERT(adapter->GetInstance() == this);
|
||||
mAdapters.push_back(std::move(adapter));
|
||||
for (Ref<PhysicalDeviceBase>& physicalDevice : newPhysicalDevices) {
|
||||
ASSERT(physicalDevice->GetBackendType() == backend->GetType());
|
||||
ASSERT(physicalDevice->GetInstance() == this);
|
||||
mAdapters.push_back(AcquireRef(new AdapterBase(std::move(physicalDevice))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,12 +127,13 @@ size_t PhysicalDeviceBase::APIEnumerateFeatures(wgpu::FeatureName* features) con
|
|||
return mSupportedFeatures.EnumerateFeatures(features);
|
||||
}
|
||||
|
||||
DeviceBase* PhysicalDeviceBase::APICreateDevice(const DeviceDescriptor* descriptor) {
|
||||
DeviceBase* PhysicalDeviceBase::CreateDevice(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor) {
|
||||
DeviceDescriptor defaultDesc = {};
|
||||
if (descriptor == nullptr) {
|
||||
descriptor = &defaultDesc;
|
||||
}
|
||||
auto result = CreateDeviceInternal(descriptor);
|
||||
auto result = CreateDeviceInternal(adapter, descriptor);
|
||||
if (result.IsError()) {
|
||||
mInstance->ConsumedError(result.AcquireError());
|
||||
return nullptr;
|
||||
|
@ -140,14 +141,15 @@ DeviceBase* PhysicalDeviceBase::APICreateDevice(const DeviceDescriptor* descript
|
|||
return result.AcquireSuccess().Detach();
|
||||
}
|
||||
|
||||
void PhysicalDeviceBase::APIRequestDevice(const DeviceDescriptor* descriptor,
|
||||
WGPURequestDeviceCallback callback,
|
||||
void* userdata) {
|
||||
void PhysicalDeviceBase::RequestDevice(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
WGPURequestDeviceCallback callback,
|
||||
void* userdata) {
|
||||
static constexpr DeviceDescriptor kDefaultDescriptor = {};
|
||||
if (descriptor == nullptr) {
|
||||
descriptor = &kDefaultDescriptor;
|
||||
}
|
||||
auto result = CreateDeviceInternal(descriptor);
|
||||
auto result = CreateDeviceInternal(adapter, descriptor);
|
||||
|
||||
if (result.IsError()) {
|
||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||
|
@ -253,6 +255,7 @@ void PhysicalDeviceBase::SetSupportedFeaturesForTesting(
|
|||
}
|
||||
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDeviceBase::CreateDeviceInternal(
|
||||
AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor) {
|
||||
ASSERT(descriptor != nullptr);
|
||||
|
||||
|
@ -289,7 +292,7 @@ ResultOrError<Ref<DeviceBase>> PhysicalDeviceBase::CreateDeviceInternal(
|
|||
DAWN_INVALID_IF(descriptor->requiredLimits->nextInChain != nullptr,
|
||||
"nextInChain is not nullptr.");
|
||||
}
|
||||
return CreateDeviceImpl(descriptor, deviceToggles);
|
||||
return CreateDeviceImpl(adapter, descriptor, deviceToggles);
|
||||
}
|
||||
|
||||
void PhysicalDeviceBase::SetUseTieredLimits(bool useTieredLimits) {
|
||||
|
|
|
@ -48,10 +48,11 @@ class PhysicalDeviceBase : public RefCounted {
|
|||
void APIGetProperties(AdapterProperties* properties) const;
|
||||
bool APIHasFeature(wgpu::FeatureName feature) const;
|
||||
size_t APIEnumerateFeatures(wgpu::FeatureName* features) const;
|
||||
void APIRequestDevice(const DeviceDescriptor* descriptor,
|
||||
WGPURequestDeviceCallback callback,
|
||||
void* userdata);
|
||||
DeviceBase* APICreateDevice(const DeviceDescriptor* descriptor = nullptr);
|
||||
void RequestDevice(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
WGPURequestDeviceCallback callback,
|
||||
void* userdata);
|
||||
DeviceBase* CreateDevice(AdapterBase* adapter, const DeviceDescriptor* descriptor = nullptr);
|
||||
|
||||
uint32_t GetVendorId() const;
|
||||
uint32_t GetDeviceId() const;
|
||||
|
@ -101,7 +102,8 @@ class PhysicalDeviceBase : public RefCounted {
|
|||
// Backend-specific force-setting and defaulting device toggles
|
||||
virtual void SetupBackendDeviceToggles(TogglesState* deviceToggles) const = 0;
|
||||
|
||||
virtual ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
virtual ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) = 0;
|
||||
|
||||
virtual MaybeError InitializeImpl() = 0;
|
||||
|
@ -118,7 +120,8 @@ class PhysicalDeviceBase : public RefCounted {
|
|||
wgpu::FeatureName feature,
|
||||
const TogglesState& toggles) const = 0;
|
||||
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceInternal(const DeviceDescriptor* descriptor);
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceInternal(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor);
|
||||
|
||||
virtual MaybeError ResetInternalDeviceForTestingImpl();
|
||||
Ref<InstanceBase> mInstance;
|
||||
|
|
|
@ -233,7 +233,7 @@ bool SwapChainBase::IsAttached() const {
|
|||
}
|
||||
|
||||
wgpu::BackendType SwapChainBase::GetBackendType() const {
|
||||
return GetDevice()->GetAdapter()->GetBackendType();
|
||||
return GetDevice()->GetPhysicalDevice()->GetBackendType();
|
||||
}
|
||||
|
||||
MaybeError SwapChainBase::ValidatePresent() const {
|
||||
|
|
|
@ -199,9 +199,10 @@ void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) cons
|
|||
deviceToggles->Default(Toggle::ApplyClearBigIntegerColorValueWithDraw, true);
|
||||
}
|
||||
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) {
|
||||
return Device::Create(this, descriptor, deviceToggles);
|
||||
return Device::Create(adapter, descriptor, deviceToggles);
|
||||
}
|
||||
|
||||
// Resets the backend device and creates a new one. If any D3D11 objects belonging to the
|
||||
|
|
|
@ -42,7 +42,8 @@ class PhysicalDevice : public d3d::PhysicalDevice {
|
|||
|
||||
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
|
||||
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) override;
|
||||
|
||||
MaybeError ResetInternalDeviceForTestingImpl() override;
|
||||
|
|
|
@ -579,9 +579,10 @@ void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) cons
|
|||
}
|
||||
}
|
||||
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) {
|
||||
return Device::Create(this, descriptor, deviceToggles);
|
||||
return Device::Create(adapter, descriptor, deviceToggles);
|
||||
}
|
||||
|
||||
// Resets the backend device and creates a new one. If any D3D12 objects belonging to the
|
||||
|
|
|
@ -44,7 +44,8 @@ class PhysicalDevice : public d3d::PhysicalDevice {
|
|||
|
||||
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
|
||||
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) override;
|
||||
|
||||
MaybeError ResetInternalDeviceForTestingImpl() override;
|
||||
|
|
|
@ -115,7 +115,7 @@ void ResidencyManager::UpdateVideoMemoryInfo() {
|
|||
void ResidencyManager::UpdateMemorySegmentInfo(MemorySegmentInfo* segmentInfo) {
|
||||
DXGI_QUERY_VIDEO_MEMORY_INFO queryVideoMemoryInfo;
|
||||
|
||||
ToBackend(mDevice->GetAdapter())
|
||||
ToBackend(mDevice->GetPhysicalDevice())
|
||||
->GetHardwareAdapter()
|
||||
->QueryVideoMemoryInfo(0, segmentInfo->dxgiSegment, &queryVideoMemoryInfo);
|
||||
|
||||
|
|
|
@ -89,10 +89,10 @@ ResultOrError<d3d::CompiledShader> ShaderModule::Compile(
|
|||
if (device->IsToggleEnabled(Toggle::UseDXC)) {
|
||||
// If UseDXC toggle are not forced to be disable, DXC should have been validated to be
|
||||
// available.
|
||||
ASSERT(ToBackend(device->GetAdapter())->GetBackend()->IsDXCAvailable());
|
||||
ASSERT(ToBackend(device->GetPhysicalDevice())->GetBackend()->IsDXCAvailable());
|
||||
// We can get the DXC version information since IsDXCAvailable() is true.
|
||||
d3d::DxcVersionInfo dxcVersionInfo =
|
||||
ToBackend(device->GetAdapter())->GetBackend()->GetDxcVersion();
|
||||
ToBackend(device->GetPhysicalDevice())->GetBackend()->GetDxcVersion();
|
||||
|
||||
req.bytecode.compiler = d3d::Compiler::DXC;
|
||||
req.bytecode.dxcLibrary = device->GetDxcLibrary().Get();
|
||||
|
|
|
@ -293,9 +293,10 @@ class PhysicalDevice : public PhysicalDeviceBase {
|
|||
}
|
||||
|
||||
private:
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) override {
|
||||
return Device::Create(this, mDevice, descriptor, deviceToggles);
|
||||
return Device::Create(adapter, mDevice, descriptor, deviceToggles);
|
||||
}
|
||||
|
||||
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override {
|
||||
|
|
|
@ -86,14 +86,14 @@ bool ComputePipeline::RequiresStorageBufferLength() const {
|
|||
void ComputePipeline::InitializeAsync(Ref<ComputePipelineBase> computePipeline,
|
||||
WGPUCreateComputePipelineAsyncCallback callback,
|
||||
void* userdata) {
|
||||
AdapterBase* adapter = computePipeline->GetDevice()->GetAdapter();
|
||||
PhysicalDeviceBase* physicalDevice = computePipeline->GetDevice()->GetPhysicalDevice();
|
||||
std::unique_ptr<CreateComputePipelineAsyncTask> asyncTask =
|
||||
std::make_unique<CreateComputePipelineAsyncTask>(std::move(computePipeline), callback,
|
||||
userdata);
|
||||
// Workaround a crash where the validation layers on AMD crash with partition alloc.
|
||||
// See crbug.com/dawn/1200.
|
||||
if (adapter->GetInstance()->IsBackendValidationEnabled() &&
|
||||
gpu_info::IsAMD(adapter->GetVendorId())) {
|
||||
if (physicalDevice->GetInstance()->IsBackendValidationEnabled() &&
|
||||
gpu_info::IsAMD(physicalDevice->GetVendorId())) {
|
||||
asyncTask->Run();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "dawn/common/GPUInfo.h"
|
||||
#include "dawn/common/Platform.h"
|
||||
#include "dawn/native/Adapter.h"
|
||||
#include "dawn/native/BackendConnection.h"
|
||||
#include "dawn/native/BindGroupLayout.h"
|
||||
#include "dawn/native/Commands.h"
|
||||
|
@ -155,7 +156,7 @@ MaybeError Device::Initialize(const DeviceDescriptor* descriptor) {
|
|||
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;
|
||||
mTimestampPeriod = gpu_info::IsIntel(GetPhysicalDevice()->GetVendorId()) ? 83.333f : 1.0f;
|
||||
|
||||
// Initialize kalman filter parameters
|
||||
mKalmanInfo = std::make_unique<KalmanInfo>();
|
||||
|
|
|
@ -513,14 +513,14 @@ NSRef<MTLVertexDescriptor> RenderPipeline::MakeVertexDesc() const {
|
|||
void RenderPipeline::InitializeAsync(Ref<RenderPipelineBase> renderPipeline,
|
||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||
void* userdata) {
|
||||
AdapterBase* adapter = renderPipeline->GetDevice()->GetAdapter();
|
||||
PhysicalDeviceBase* physicalDevice = renderPipeline->GetDevice()->GetPhysicalDevice();
|
||||
std::unique_ptr<CreateRenderPipelineAsyncTask> asyncTask =
|
||||
std::make_unique<CreateRenderPipelineAsyncTask>(std::move(renderPipeline), callback,
|
||||
userdata);
|
||||
// Workaround a crash where the validation layers on AMD crash with partition alloc.
|
||||
// See crbug.com/dawn/1200.
|
||||
if (adapter->GetInstance()->IsBackendValidationEnabled() &&
|
||||
gpu_info::IsAMD(adapter->GetVendorId())) {
|
||||
if (physicalDevice->GetInstance()->IsBackendValidationEnabled() &&
|
||||
gpu_info::IsAMD(physicalDevice->GetVendorId())) {
|
||||
asyncTask->Run();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -69,9 +69,10 @@ MaybeError PhysicalDevice::InitializeSupportedLimitsImpl(CombinedLimits* limits)
|
|||
|
||||
void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {}
|
||||
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) {
|
||||
return Device::Create(this, descriptor, deviceToggles);
|
||||
return Device::Create(adapter, descriptor, deviceToggles);
|
||||
}
|
||||
|
||||
MaybeError PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl(
|
||||
|
|
|
@ -193,7 +193,8 @@ class PhysicalDevice : public PhysicalDeviceBase {
|
|||
const TogglesState& toggles) const override;
|
||||
|
||||
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ MaybeError Device::Initialize(const DeviceDescriptor* descriptor) {
|
|||
// extensions
|
||||
bool hasDebugOutput = gl.IsAtLeastGL(4, 3) || gl.IsAtLeastGLES(3, 2);
|
||||
|
||||
if (GetAdapter()->GetInstance()->IsBackendValidationEnabled() && hasDebugOutput) {
|
||||
if (GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled() && hasDebugOutput) {
|
||||
gl.Enable(GL_DEBUG_OUTPUT);
|
||||
gl.Enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
|
||||
|
|
|
@ -38,13 +38,13 @@ class Texture;
|
|||
class TextureView;
|
||||
|
||||
struct OpenGLBackendTraits {
|
||||
using PhysicalDeviceType = PhysicalDevice;
|
||||
using BindGroupType = BindGroup;
|
||||
using BindGroupLayoutType = BindGroupLayout;
|
||||
using BufferType = Buffer;
|
||||
using CommandBufferType = CommandBuffer;
|
||||
using ComputePipelineType = ComputePipeline;
|
||||
using DeviceType = Device;
|
||||
using PhysicalDeviceType = PhysicalDevice;
|
||||
using PipelineLayoutType = PipelineLayout;
|
||||
using QuerySetType = QuerySet;
|
||||
using QueueType = Queue;
|
||||
|
|
|
@ -217,13 +217,14 @@ void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) cons
|
|||
gl.GetVersion().IsES());
|
||||
}
|
||||
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) {
|
||||
EGLenum api =
|
||||
GetBackendType() == wgpu::BackendType::OpenGL ? EGL_OPENGL_API : EGL_OPENGL_ES_API;
|
||||
std::unique_ptr<Device::Context> context;
|
||||
DAWN_TRY_ASSIGN(context, ContextEGL::Create(mEGLFunctions, api));
|
||||
return Device::Create(this, descriptor, mFunctions, std::move(context), deviceToggles);
|
||||
return Device::Create(adapter, descriptor, mFunctions, std::move(context), deviceToggles);
|
||||
}
|
||||
|
||||
MaybeError PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl(
|
||||
|
|
|
@ -43,7 +43,8 @@ class PhysicalDevice : public PhysicalDeviceBase {
|
|||
const TogglesState& toggles) const override;
|
||||
|
||||
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) override;
|
||||
|
||||
OpenGLFunctions mFunctions;
|
||||
|
|
|
@ -504,9 +504,10 @@ void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) cons
|
|||
deviceToggles->Default(Toggle::UsePlaceholderFragmentInVertexOnlyPipeline, true);
|
||||
}
|
||||
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) {
|
||||
return Device::Create(this, descriptor, deviceToggles);
|
||||
return Device::Create(adapter, descriptor, deviceToggles);
|
||||
}
|
||||
|
||||
MaybeError PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl(
|
||||
|
|
|
@ -54,7 +54,8 @@ class PhysicalDevice : public PhysicalDeviceBase {
|
|||
const TogglesState& toggles) const override;
|
||||
|
||||
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(AdapterBase* adapter,
|
||||
const DeviceDescriptor* descriptor,
|
||||
const TogglesState& deviceToggles) override;
|
||||
|
||||
VkPhysicalDevice mVkPhysicalDevice;
|
||||
|
|
|
@ -621,7 +621,8 @@ bool IsSampleCountSupported(const dawn::native::vulkan::Device* device,
|
|||
const VkImageCreateInfo& imageCreateInfo) {
|
||||
ASSERT(device);
|
||||
|
||||
VkPhysicalDevice vkPhysicalDevice = ToBackend(device->GetAdapter())->GetVkPhysicalDevice();
|
||||
VkPhysicalDevice vkPhysicalDevice =
|
||||
ToBackend(device->GetPhysicalDevice())->GetVkPhysicalDevice();
|
||||
VkImageFormatProperties properties;
|
||||
if (device->fn.GetPhysicalDeviceImageFormatProperties(
|
||||
vkPhysicalDevice, imageCreateInfo.format, imageCreateInfo.imageType,
|
||||
|
|
|
@ -153,7 +153,8 @@ class ServiceImplementationDmaBuf : public ServiceImplementation {
|
|||
static_cast<const ExternalImageDescriptorDmaBuf*>(descriptor);
|
||||
|
||||
// Verify plane count for the modifier.
|
||||
VkPhysicalDevice vkPhysicalDevice = ToBackend(mDevice->GetAdapter())->GetVkPhysicalDevice();
|
||||
VkPhysicalDevice vkPhysicalDevice =
|
||||
ToBackend(mDevice->GetPhysicalDevice())->GetVkPhysicalDevice();
|
||||
uint32_t planeCount = 0;
|
||||
if (mDevice->ConsumedError(GetModifierPlaneCount(mDevice->fn, vkPhysicalDevice, format,
|
||||
dmaBufDescriptor->drmModifier),
|
||||
|
@ -303,7 +304,8 @@ class ServiceImplementationDmaBuf : public ServiceImplementation {
|
|||
|
||||
const ExternalImageDescriptorDmaBuf* dmaBufDescriptor =
|
||||
static_cast<const ExternalImageDescriptorDmaBuf*>(descriptor);
|
||||
VkPhysicalDevice vkPhysicalDevice = ToBackend(mDevice->GetAdapter())->GetVkPhysicalDevice();
|
||||
VkPhysicalDevice vkPhysicalDevice =
|
||||
ToBackend(mDevice->GetPhysicalDevice())->GetVkPhysicalDevice();
|
||||
VkDevice device = mDevice->GetVkDevice();
|
||||
|
||||
uint32_t planeCount;
|
||||
|
|
|
@ -29,7 +29,7 @@ class ServiceImplementationZirconHandle : public ServiceImplementation {
|
|||
explicit ServiceImplementationZirconHandle(Device* device)
|
||||
: ServiceImplementation(device),
|
||||
mSupported(CheckSupport(device->GetDeviceInfo(),
|
||||
ToBackend(device->GetAdapter())->GetVkPhysicalDevice(),
|
||||
ToBackend(device->GetPhysicalDevice())->GetVkPhysicalDevice(),
|
||||
device->fn)) {}
|
||||
|
||||
~ServiceImplementationZirconHandle() override = default;
|
||||
|
|
|
@ -25,11 +25,13 @@ class FeatureTests : public testing::Test {
|
|||
FeatureTests()
|
||||
: testing::Test(),
|
||||
mInstanceBase(dawn::native::InstanceBase::Create()),
|
||||
mAdapterBase(mInstanceBase.Get()),
|
||||
mUnsafeAdapterBase(
|
||||
mPhysicalDevice(mInstanceBase.Get()),
|
||||
mUnsafePhysicalDevice(
|
||||
mInstanceBase.Get(),
|
||||
dawn::native::TogglesState(dawn::native::ToggleStage::Adapter)
|
||||
.SetForTesting(dawn::native::Toggle::DisallowUnsafeAPIs, false, false)) {}
|
||||
.SetForTesting(dawn::native::Toggle::DisallowUnsafeAPIs, false, false)),
|
||||
mAdapterBase(&mPhysicalDevice),
|
||||
mUnsafeAdapterBase(&mUnsafePhysicalDevice) {}
|
||||
|
||||
std::vector<wgpu::FeatureName> GetAllFeatureNames() {
|
||||
std::vector<wgpu::FeatureName> allFeatureNames(kTotalFeaturesCount);
|
||||
|
@ -45,11 +47,13 @@ class FeatureTests : public testing::Test {
|
|||
protected:
|
||||
// By default DisallowUnsafeAPIs is enabled in this instance.
|
||||
Ref<dawn::native::InstanceBase> mInstanceBase;
|
||||
dawn::native::null::PhysicalDevice mPhysicalDevice;
|
||||
dawn::native::null::PhysicalDevice mUnsafePhysicalDevice;
|
||||
// The adapter that inherit toggles states from the instance, also have DisallowUnsafeAPIs
|
||||
// enabled.
|
||||
dawn::native::null::PhysicalDevice mAdapterBase;
|
||||
dawn::native::AdapterBase mAdapterBase;
|
||||
// The adapter that override DisallowUnsafeAPIs to disabled in toggles state.
|
||||
dawn::native::null::PhysicalDevice mUnsafeAdapterBase;
|
||||
dawn::native::AdapterBase mUnsafeAdapterBase;
|
||||
};
|
||||
|
||||
// Test the creation of a device will fail if the requested feature is not supported on the
|
||||
|
@ -64,7 +68,7 @@ TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) {
|
|||
|
||||
// Test that the adapter with unsafe apis disallowed validate features as expected.
|
||||
{
|
||||
mAdapterBase.SetSupportedFeaturesForTesting(featureNamesWithoutOne);
|
||||
mPhysicalDevice.SetSupportedFeaturesForTesting(featureNamesWithoutOne);
|
||||
dawn::native::Adapter adapterWithoutFeature(&mAdapterBase);
|
||||
|
||||
wgpu::DeviceDescriptor deviceDescriptor;
|
||||
|
@ -79,7 +83,7 @@ TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) {
|
|||
|
||||
// Test that the adapter with unsafe apis allowed validate features as expected.
|
||||
{
|
||||
mUnsafeAdapterBase.SetSupportedFeaturesForTesting(featureNamesWithoutOne);
|
||||
mUnsafePhysicalDevice.SetSupportedFeaturesForTesting(featureNamesWithoutOne);
|
||||
dawn::native::Adapter adapterWithoutFeature(&mUnsafeAdapterBase);
|
||||
|
||||
wgpu::DeviceDescriptor deviceDescriptor;
|
||||
|
|
|
@ -56,13 +56,13 @@ class GetProcAddressTests : public testing::TestWithParam<DawnFlavor> {
|
|||
GetProcAddressTests()
|
||||
: testing::TestWithParam<DawnFlavor>(),
|
||||
mNativeInstance(dawn::native::InstanceBase::Create()),
|
||||
mNativeAdapter(mNativeInstance.Get()) {}
|
||||
mAdapterBase(AcquireRef(new dawn::native::null::PhysicalDevice(mNativeInstance.Get()))) {}
|
||||
|
||||
void SetUp() override {
|
||||
switch (GetParam()) {
|
||||
case DawnFlavor::Native: {
|
||||
mDevice = wgpu::Device::Acquire(
|
||||
reinterpret_cast<WGPUDevice>(mNativeAdapter.APICreateDevice()));
|
||||
reinterpret_cast<WGPUDevice>(mAdapterBase.APICreateDevice()));
|
||||
mProcs = dawn::native::GetProcs();
|
||||
break;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class GetProcAddressTests : public testing::TestWithParam<DawnFlavor> {
|
|||
|
||||
protected:
|
||||
Ref<dawn::native::InstanceBase> mNativeInstance;
|
||||
dawn::native::null::PhysicalDevice mNativeAdapter;
|
||||
dawn::native::AdapterBase mAdapterBase;
|
||||
|
||||
std::unique_ptr<utils::TerribleCommandBuffer> mC2sBuf;
|
||||
std::unique_ptr<dawn::wire::WireClient> mWireClient;
|
||||
|
|
|
@ -27,12 +27,12 @@ class PerThreadProcTests : public testing::Test {
|
|||
public:
|
||||
PerThreadProcTests()
|
||||
: mNativeInstance(dawn::native::InstanceBase::Create()),
|
||||
mNativeAdapter(mNativeInstance.Get()) {}
|
||||
mAdapterBase(AcquireRef(new dawn::native::null::PhysicalDevice(mNativeInstance.Get()))) {}
|
||||
~PerThreadProcTests() override = default;
|
||||
|
||||
protected:
|
||||
Ref<dawn::native::InstanceBase> mNativeInstance;
|
||||
dawn::native::null::PhysicalDevice mNativeAdapter;
|
||||
dawn::native::AdapterBase mAdapterBase;
|
||||
};
|
||||
|
||||
// Test that procs can be set per thread. This test overrides deviceCreateBuffer with a placeholder
|
||||
|
@ -57,10 +57,10 @@ TEST_F(PerThreadProcTests, DispatchesPerThread) {
|
|||
|
||||
// Note: Acquire doesn't call reference or release.
|
||||
wgpu::Device deviceA =
|
||||
wgpu::Device::Acquire(reinterpret_cast<WGPUDevice>(mNativeAdapter.APICreateDevice()));
|
||||
wgpu::Device::Acquire(reinterpret_cast<WGPUDevice>(mAdapterBase.APICreateDevice()));
|
||||
|
||||
wgpu::Device deviceB =
|
||||
wgpu::Device::Acquire(reinterpret_cast<WGPUDevice>(mNativeAdapter.APICreateDevice()));
|
||||
wgpu::Device::Acquire(reinterpret_cast<WGPUDevice>(mAdapterBase.APICreateDevice()));
|
||||
|
||||
std::thread threadA([&]() {
|
||||
DawnProcTable procs = dawn::native::GetProcs();
|
||||
|
|
|
@ -135,7 +135,7 @@ TEST_F(InstanceToggleTest, InstanceTogglesInheritToAdapterAndDevice) {
|
|||
// Get the adapter created by instance with default toggles.
|
||||
dawn::native::AdapterBase* nullAdapter = nullptr;
|
||||
for (auto& adapter : instance->GetAdapters()) {
|
||||
if (adapter->GetBackendType() == wgpu::BackendType::Null) {
|
||||
if (adapter->GetPhysicalDevice()->GetBackendType() == wgpu::BackendType::Null) {
|
||||
nullAdapter = adapter.Get();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include <utility>
|
||||
|
||||
#include "dawn/common/Math.h"
|
||||
#include "dawn/native/Adapter.h"
|
||||
#include "dawn/native/vulkan/DeviceVk.h"
|
||||
#include "dawn/native/vulkan/PhysicalDeviceVk.h"
|
||||
#include "dawn/tests/DawnTest.h"
|
||||
#include "dawn/tests/white_box/VulkanImageWrappingTests.h"
|
||||
#include "dawn/utils/ComboRenderPipelineDescriptor.h"
|
||||
|
|
Loading…
Reference in New Issue