diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn index ee6812bc82..537b0ba583 100644 --- a/src/dawn/native/BUILD.gn +++ b/src/dawn/native/BUILD.gn @@ -398,8 +398,6 @@ source_set("sources") { if (dawn_enable_d3d11 || dawn_enable_d3d12) { sources += [ - "d3d/AdapterD3D.cpp", - "d3d/AdapterD3D.h", "d3d/BackendD3D.cpp", "d3d/BackendD3D.h", "d3d/BlobD3D.cpp", @@ -412,6 +410,8 @@ source_set("sources") { "d3d/ExternalImageDXGIImpl.cpp", "d3d/ExternalImageDXGIImpl.h", "d3d/Forward.h", + "d3d/PhysicalDeviceD3D.cpp", + "d3d/PhysicalDeviceD3D.h", "d3d/PlatformFunctions.cpp", "d3d/PlatformFunctions.h", "d3d/ShaderUtils.cpp", @@ -427,8 +427,6 @@ source_set("sources") { if (dawn_enable_d3d11) { libs += [ "dxguid.lib" ] sources += [ - "d3d11/AdapterD3D11.cpp", - "d3d11/AdapterD3D11.h", "d3d11/BackendD3D11.cpp", "d3d11/BackendD3D11.h", "d3d11/BindGroupD3D11.cpp", @@ -448,6 +446,8 @@ source_set("sources") { "d3d11/DeviceInfoD3D11.cpp", "d3d11/DeviceInfoD3D11.h", "d3d11/Forward.h", + "d3d11/PhysicalDeviceD3D11.cpp", + "d3d11/PhysicalDeviceD3D11.h", "d3d11/PipelineLayoutD3D11.cpp", "d3d11/PipelineLayoutD3D11.h", "d3d11/PlatformFunctionsD3D11.cpp", @@ -472,8 +472,6 @@ source_set("sources") { if (dawn_enable_d3d12) { libs += [ "dxguid.lib" ] sources += [ - "d3d12/AdapterD3D12.cpp", - "d3d12/AdapterD3D12.h", "d3d12/BackendD3D12.cpp", "d3d12/BackendD3D12.h", "d3d12/BindGroupD3D12.cpp", @@ -510,6 +508,8 @@ source_set("sources") { "d3d12/IntegerTypes.h", "d3d12/PageableD3D12.cpp", "d3d12/PageableD3D12.h", + "d3d12/PhysicalDeviceD3D12.cpp", + "d3d12/PhysicalDeviceD3D12.h", "d3d12/PipelineLayoutD3D12.cpp", "d3d12/PipelineLayoutD3D12.h", "d3d12/PlatformFunctionsD3D12.cpp", diff --git a/src/dawn/native/CMakeLists.txt b/src/dawn/native/CMakeLists.txt index d370757261..1b143df8b8 100644 --- a/src/dawn/native/CMakeLists.txt +++ b/src/dawn/native/CMakeLists.txt @@ -255,8 +255,6 @@ endif() if (DAWN_ENABLE_D3D11 OR DAWN_ENABLE_D3D12) target_sources(dawn_native PRIVATE "${DAWN_INCLUDE_DIR}/dawn/native/D3DBackend.h" - "d3d/AdapterD3D.cpp" - "d3d/AdapterD3D.h" "d3d/BackendD3D.cpp" "d3d/BackendD3D.h" "d3d/BlobD3D.cpp" @@ -269,6 +267,8 @@ if (DAWN_ENABLE_D3D11 OR DAWN_ENABLE_D3D12) "d3d/ExternalImageDXGIImpl.cpp" "d3d/ExternalImageDXGIImpl.h" "d3d/Forward.h" + "d3d/PhysicalDeviceD3D.cpp" + "d3d/PhysicalDeviceD3D.h" "d3d/PlatformFunctions.cpp" "d3d/PlatformFunctions.h" "d3d/ShaderUtils.cpp" @@ -284,8 +284,6 @@ endif() if (DAWN_ENABLE_D3D11) target_sources(dawn_native PRIVATE "${DAWN_INCLUDE_DIR}/dawn/native/D3D11Backend.h" - "d3d11/AdapterD3D11.cpp" - "d3d11/AdapterD3D11.h" "d3d11/BackendD3D11.cpp" "d3d11/BackendD3D11.h" "d3d11/BindGroupD3D11.cpp" @@ -305,6 +303,8 @@ if (DAWN_ENABLE_D3D11) "d3d11/DeviceInfoD3D11.cpp" "d3d11/DeviceInfoD3D11.h" "d3d11/Forward.h" + "d3d11/PhysicalDeviceD3D11.cpp" + "d3d11/PhysicalDeviceD3D11.h" "d3d11/PipelineLayoutD3D11.cpp" "d3d11/PipelineLayoutD3D11.h" "d3d11/PlatformFunctionsD3D11.cpp" @@ -329,8 +329,6 @@ endif() if (DAWN_ENABLE_D3D12) target_sources(dawn_native PRIVATE "${DAWN_INCLUDE_DIR}/dawn/native/D3D12Backend.h" - "d3d12/AdapterD3D12.cpp" - "d3d12/AdapterD3D12.h" "d3d12/BackendD3D12.cpp" "d3d12/BackendD3D12.h" "d3d12/BindGroupD3D12.cpp" @@ -367,6 +365,8 @@ if (DAWN_ENABLE_D3D12) "d3d12/IntegerTypes.h" "d3d12/PageableD3D12.cpp" "d3d12/PageableD3D12.h" + "d3d12/PhysicalDeviceD3D12.cpp" + "d3d12/PhysicalDeviceD3D12.h" "d3d12/PipelineLayoutD3D12.cpp" "d3d12/PipelineLayoutD3D12.h" "d3d12/PlatformFunctionsD3D12.cpp" diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp index 80623b87a0..e40dd5d744 100644 --- a/src/dawn/native/Device.cpp +++ b/src/dawn/native/Device.cpp @@ -715,10 +715,15 @@ ApiObjectList* DeviceBase::GetObjectTrackingList(ObjectType type) { return &mObjectLists[type]; } -PhysicalDeviceBase* DeviceBase::GetAdapter() const { +AdapterBase* DeviceBase::GetAdapter() const { return mAdapter.Get(); } +PhysicalDeviceBase* DeviceBase::GetPhysicalDevice() const { + return mAdapter + .Get(); // TODO(dawn:1774): This will retrieve the PhysicalDevice from the AdapterBase. +} + dawn::platform::Platform* DeviceBase::GetPlatform() const { return GetAdapter()->GetInstance()->GetPlatform(); } diff --git a/src/dawn/native/Device.h b/src/dawn/native/Device.h index 6d19badef9..364786ffb6 100644 --- a/src/dawn/native/Device.h +++ b/src/dawn/native/Device.h @@ -155,6 +155,7 @@ class DeviceBase : public RefCountedWithExternalCount { MaybeError ValidateObject(const ApiObjectBase* object) const; AdapterBase* GetAdapter() const; + PhysicalDeviceBase* GetPhysicalDevice() const; virtual dawn::platform::Platform* GetPlatform() const; // Returns the Format corresponding to the wgpu::TextureFormat or an error if the format diff --git a/src/dawn/native/ToBackend.h b/src/dawn/native/ToBackend.h index a4758e27ca..ffc507b8f2 100644 --- a/src/dawn/native/ToBackend.h +++ b/src/dawn/native/ToBackend.h @@ -25,7 +25,7 @@ struct ToBackendTraits; template struct ToBackendTraits { - using BackendType = typename BackendTraits::AdapterType; + using BackendType = typename BackendTraits::PhysicalDeviceType; }; template diff --git a/src/dawn/native/d3d/BackendD3D.cpp b/src/dawn/native/d3d/BackendD3D.cpp index 3c36033d07..bda0dab2f6 100644 --- a/src/dawn/native/d3d/BackendD3D.cpp +++ b/src/dawn/native/d3d/BackendD3D.cpp @@ -260,7 +260,7 @@ ResultOrError>> Backend::DiscoverAdapters( // |dxgiAdapter| was provided. Discover just that adapter. Ref adapter; DAWN_TRY_ASSIGN(adapter, - CreateAdapterFromIDXGIAdapter(options->dxgiAdapter, adapterToggles)); + CreatePhysicalDeviceFromIDXGIAdapter(options->dxgiAdapter, adapterToggles)); adapters.push_back(std::move(adapter)); return std::move(adapters); } @@ -274,8 +274,8 @@ ResultOrError>> Backend::DiscoverAdapters( ASSERT(dxgiAdapter != nullptr); Ref adapter; - if (GetInstance()->ConsumedError(CreateAdapterFromIDXGIAdapter(dxgiAdapter, adapterToggles), - &adapter)) { + if (GetInstance()->ConsumedError( + CreatePhysicalDeviceFromIDXGIAdapter(dxgiAdapter, adapterToggles), &adapter)) { continue; } diff --git a/src/dawn/native/d3d/BackendD3D.h b/src/dawn/native/d3d/BackendD3D.h index a4137130f0..53a0edfbf3 100644 --- a/src/dawn/native/d3d/BackendD3D.h +++ b/src/dawn/native/d3d/BackendD3D.h @@ -82,7 +82,7 @@ class Backend : public BackendConnection { const TogglesState& adapterToggles) override; protected: - virtual ResultOrError> CreateAdapterFromIDXGIAdapter( + virtual ResultOrError> CreatePhysicalDeviceFromIDXGIAdapter( ComPtr dxgiAdapter, const TogglesState& adapterToggles) = 0; diff --git a/src/dawn/native/d3d/DeviceD3D.cpp b/src/dawn/native/d3d/DeviceD3D.cpp index 1dc884f187..df1c6ead89 100644 --- a/src/dawn/native/d3d/DeviceD3D.cpp +++ b/src/dawn/native/d3d/DeviceD3D.cpp @@ -14,9 +14,9 @@ #include "dawn/native/d3d/DeviceD3D.h" -#include "dawn/native/d3d/AdapterD3D.h" #include "dawn/native/d3d/BackendD3D.h" #include "dawn/native/d3d/Forward.h" +#include "dawn/native/d3d/PhysicalDeviceD3D.h" namespace dawn::native::d3d { @@ -35,23 +35,23 @@ ResultOrError Device::GetSupportedSurfaceUsageImpl( } const PlatformFunctions* Device::GetFunctions() const { - return ToBackend(GetAdapter())->GetBackend()->GetFunctions(); + return ToBackend(GetPhysicalDevice())->GetBackend()->GetFunctions(); } ComPtr Device::GetFactory() const { - return ToBackend(GetAdapter())->GetBackend()->GetFactory(); + return ToBackend(GetPhysicalDevice())->GetBackend()->GetFactory(); } ComPtr Device::GetDxcLibrary() const { - return ToBackend(GetAdapter())->GetBackend()->GetDxcLibrary(); + return ToBackend(GetPhysicalDevice())->GetBackend()->GetDxcLibrary(); } ComPtr Device::GetDxcCompiler() const { - return ToBackend(GetAdapter())->GetBackend()->GetDxcCompiler(); + return ToBackend(GetPhysicalDevice())->GetBackend()->GetDxcCompiler(); } ComPtr Device::GetDxcValidator() const { - return ToBackend(GetAdapter())->GetBackend()->GetDxcValidator(); + return ToBackend(GetPhysicalDevice())->GetBackend()->GetDxcValidator(); } } // namespace dawn::native::d3d diff --git a/src/dawn/native/d3d/Forward.h b/src/dawn/native/d3d/Forward.h index 361241707f..e1d4db33ac 100644 --- a/src/dawn/native/d3d/Forward.h +++ b/src/dawn/native/d3d/Forward.h @@ -19,13 +19,13 @@ namespace dawn::native::d3d { -class Adapter; +class PhysicalDevice; class Device; class SwapChain; struct D3DBackendTraits { - using AdapterType = Adapter; using DeviceType = Device; + using PhysicalDeviceType = PhysicalDevice; using SwapChainType = SwapChain; }; diff --git a/src/dawn/native/d3d/AdapterD3D.cpp b/src/dawn/native/d3d/PhysicalDeviceD3D.cpp similarity index 82% rename from src/dawn/native/d3d/AdapterD3D.cpp rename to src/dawn/native/d3d/PhysicalDeviceD3D.cpp index 34dd1592e2..a747ba02f5 100644 --- a/src/dawn/native/d3d/AdapterD3D.cpp +++ b/src/dawn/native/d3d/PhysicalDeviceD3D.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "dawn/native/d3d/AdapterD3D.h" +#include "dawn/native/d3d/PhysicalDeviceD3D.h" #include #include @@ -22,25 +22,25 @@ namespace dawn::native::d3d { -Adapter::Adapter(Backend* backend, - ComPtr hardwareAdapter, - wgpu::BackendType backendType, - const TogglesState& adapterToggles) +PhysicalDevice::PhysicalDevice(Backend* backend, + ComPtr hardwareAdapter, + wgpu::BackendType backendType, + const TogglesState& adapterToggles) : PhysicalDeviceBase(backend->GetInstance(), backendType, adapterToggles), mHardwareAdapter(std::move(hardwareAdapter)), mBackend(backend) {} -Adapter::~Adapter() = default; +PhysicalDevice::~PhysicalDevice() = default; -IDXGIAdapter3* Adapter::GetHardwareAdapter() const { +IDXGIAdapter3* PhysicalDevice::GetHardwareAdapter() const { return mHardwareAdapter.Get(); } -Backend* Adapter::GetBackend() const { +Backend* PhysicalDevice::GetBackend() const { return mBackend; } -MaybeError Adapter::InitializeImpl() { +MaybeError PhysicalDevice::InitializeImpl() { DXGI_ADAPTER_DESC1 adapterDesc; GetHardwareAdapter()->GetDesc1(&adapterDesc); diff --git a/src/dawn/native/d3d/AdapterD3D.h b/src/dawn/native/d3d/PhysicalDeviceD3D.h similarity index 69% rename from src/dawn/native/d3d/AdapterD3D.h rename to src/dawn/native/d3d/PhysicalDeviceD3D.h index 86ada890dc..57209b8edd 100644 --- a/src/dawn/native/d3d/AdapterD3D.h +++ b/src/dawn/native/d3d/PhysicalDeviceD3D.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_DAWN_NATIVE_D3D_ADAPTERD3D_H_ -#define SRC_DAWN_NATIVE_D3D_ADAPTERD3D_H_ +#ifndef SRC_DAWN_NATIVE_D3D_PHYSICALDEVICED3D_H_ +#define SRC_DAWN_NATIVE_D3D_PHYSICALDEVICED3D_H_ #include "dawn/native/PhysicalDevice.h" @@ -23,13 +23,13 @@ namespace dawn::native::d3d { class Backend; -class Adapter : public PhysicalDeviceBase { +class PhysicalDevice : public PhysicalDeviceBase { public: - Adapter(Backend* backend, - ComPtr hardwareAdapter, - wgpu::BackendType backendType, - const TogglesState& adapterToggles); - ~Adapter() override; + PhysicalDevice(Backend* backend, + ComPtr hardwareAdapter, + wgpu::BackendType backendType, + const TogglesState& adapterToggles); + ~PhysicalDevice() override; IDXGIAdapter3* GetHardwareAdapter() const; Backend* GetBackend() const; @@ -44,4 +44,4 @@ class Adapter : public PhysicalDeviceBase { } // namespace dawn::native::d3d -#endif // SRC_DAWN_NATIVE_D3D_ADAPTERD3D_H_ +#endif // SRC_DAWN_NATIVE_D3D_PHYSICALDEVICED3D_H_ diff --git a/src/dawn/native/d3d11/BackendD3D11.cpp b/src/dawn/native/d3d11/BackendD3D11.cpp index 6bdf1e73fb..9b9946bc9f 100644 --- a/src/dawn/native/d3d11/BackendD3D11.cpp +++ b/src/dawn/native/d3d11/BackendD3D11.cpp @@ -21,7 +21,7 @@ #include "dawn/native/D3D11Backend.h" #include "dawn/native/Instance.h" #include "dawn/native/d3d/D3DError.h" -#include "dawn/native/d3d11/AdapterD3D11.h" +#include "dawn/native/d3d11/PhysicalDeviceD3D11.h" #include "dawn/native/d3d11/PlatformFunctionsD3D11.h" namespace dawn::native::d3d11 { @@ -41,15 +41,16 @@ const PlatformFunctions* Backend::GetFunctions() const { return static_cast(Base::GetFunctions()); } -ResultOrError> Backend::CreateAdapterFromIDXGIAdapter( +ResultOrError> Backend::CreatePhysicalDeviceFromIDXGIAdapter( ComPtr dxgiAdapter, const TogglesState& adapterToggles) { ComPtr dxgiAdapter3; DAWN_TRY(CheckHRESULT(dxgiAdapter.As(&dxgiAdapter3), "DXGIAdapter retrieval")); - Ref adapter = AcquireRef(new Adapter(this, std::move(dxgiAdapter3), adapterToggles)); - DAWN_TRY(adapter->Initialize()); + Ref physicalDevice = + AcquireRef(new PhysicalDevice(this, std::move(dxgiAdapter3), adapterToggles)); + DAWN_TRY(physicalDevice->Initialize()); - return {std::move(adapter)}; + return {std::move(physicalDevice)}; } BackendConnection* Connect(InstanceBase* instance) { diff --git a/src/dawn/native/d3d11/BackendD3D11.h b/src/dawn/native/d3d11/BackendD3D11.h index 8e3cbb7df0..3ee7480e36 100644 --- a/src/dawn/native/d3d11/BackendD3D11.h +++ b/src/dawn/native/d3d11/BackendD3D11.h @@ -31,7 +31,7 @@ class Backend : public d3d::Backend { const PlatformFunctions* GetFunctions() const; protected: - ResultOrError> CreateAdapterFromIDXGIAdapter( + ResultOrError> CreatePhysicalDeviceFromIDXGIAdapter( ComPtr dxgiAdapter, const TogglesState& adapterToggles) override; diff --git a/src/dawn/native/d3d11/DeviceD3D11.cpp b/src/dawn/native/d3d11/DeviceD3D11.cpp index 33de82f1f5..2fd6f3bd1b 100644 --- a/src/dawn/native/d3d11/DeviceD3D11.cpp +++ b/src/dawn/native/d3d11/DeviceD3D11.cpp @@ -25,13 +25,13 @@ #include "dawn/native/Instance.h" #include "dawn/native/d3d/D3DError.h" #include "dawn/native/d3d/ExternalImageDXGIImpl.h" -#include "dawn/native/d3d11/AdapterD3D11.h" #include "dawn/native/d3d11/BackendD3D11.h" #include "dawn/native/d3d11/BindGroupD3D11.h" #include "dawn/native/d3d11/BindGroupLayoutD3D11.h" #include "dawn/native/d3d11/BufferD3D11.h" #include "dawn/native/d3d11/CommandBufferD3D11.h" #include "dawn/native/d3d11/ComputePipelineD3D11.h" +#include "dawn/native/d3d11/PhysicalDeviceD3D11.h" #include "dawn/native/d3d11/PipelineLayoutD3D11.h" #include "dawn/native/d3d11/PlatformFunctionsD3D11.h" #include "dawn/native/d3d11/QueueD3D11.h" @@ -90,7 +90,7 @@ void AppendDebugLayerMessagesToError(ID3D11InfoQueue* infoQueue, } // namespace // static -ResultOrError> Device::Create(Adapter* adapter, +ResultOrError> Device::Create(AdapterBase* adapter, const DeviceDescriptor* descriptor, const TogglesState& deviceToggles) { Ref device = AcquireRef(new Device(adapter, descriptor, deviceToggles)); @@ -99,7 +99,7 @@ ResultOrError> Device::Create(Adapter* adapter, } MaybeError Device::Initialize(const DeviceDescriptor* descriptor) { - DAWN_TRY_ASSIGN(mD3d11Device, ToBackend(GetAdapter())->CreateD3D11Device()); + DAWN_TRY_ASSIGN(mD3d11Device, ToBackend(GetPhysicalDevice())->CreateD3D11Device()); ASSERT(mD3d11Device != nullptr); DAWN_TRY(DeviceBase::Initialize(Queue::Create(this, &descriptor->defaultQueue))); @@ -334,7 +334,7 @@ MaybeError Device::CopyFromStagingToTextureImpl(const BufferBase* source, } const DeviceInfo& Device::GetDeviceInfo() const { - return ToBackend(GetAdapter())->GetDeviceInfo(); + return ToBackend(GetPhysicalDevice())->GetDeviceInfo(); } MaybeError Device::WaitForIdleForDestruction() { @@ -346,7 +346,7 @@ MaybeError Device::WaitForIdleForDestruction() { } MaybeError Device::CheckDebugLayerAndGenerateErrors() { - if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled()) { + if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled()) { return {}; } @@ -370,7 +370,7 @@ MaybeError Device::CheckDebugLayerAndGenerateErrors() { } void Device::AppendDebugLayerMessages(ErrorData* error) { - if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled()) { + if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled()) { return; } diff --git a/src/dawn/native/d3d11/DeviceD3D11.h b/src/dawn/native/d3d11/DeviceD3D11.h index 99cf3f5529..1b1774d201 100644 --- a/src/dawn/native/d3d11/DeviceD3D11.h +++ b/src/dawn/native/d3d11/DeviceD3D11.h @@ -31,7 +31,7 @@ class Fence; // Definition of backend types class Device final : public d3d::Device { public: - static ResultOrError> Create(Adapter* adapter, + static ResultOrError> Create(AdapterBase* adapter, const DeviceDescriptor* descriptor, const TogglesState& deviceToggles); ~Device() override; diff --git a/src/dawn/native/d3d11/DeviceInfoD3D11.h b/src/dawn/native/d3d11/DeviceInfoD3D11.h index 0f5992571c..71192f7606 100644 --- a/src/dawn/native/d3d11/DeviceInfoD3D11.h +++ b/src/dawn/native/d3d11/DeviceInfoD3D11.h @@ -21,7 +21,7 @@ namespace dawn::native::d3d11 { -class Adapter; +class PhysicalDevice; struct DeviceInfo { bool isUMA; diff --git a/src/dawn/native/d3d11/Forward.h b/src/dawn/native/d3d11/Forward.h index 398bdd2b05..d57589cc3b 100644 --- a/src/dawn/native/d3d11/Forward.h +++ b/src/dawn/native/d3d11/Forward.h @@ -19,7 +19,6 @@ namespace dawn::native::d3d11 { -class Adapter; class BindGroup; class BindGroupLayout; class Buffer; @@ -27,6 +26,7 @@ class CommandBuffer; class ComputePipeline; class Device; class Heap; +class PhysicalDevice; class PipelineCache; class PipelineLayout; class QuerySet; @@ -39,13 +39,13 @@ class Texture; class TextureView; struct D3D11BackendTraits { - using AdapterType = Adapter; using BindGroupType = BindGroup; using BindGroupLayoutType = BindGroupLayout; using BufferType = Buffer; using CommandBufferType = CommandBuffer; using ComputePipelineType = ComputePipeline; using DeviceType = Device; + using PhysicalDeviceType = PhysicalDevice; using PipelineCacheType = PipelineCache; using PipelineLayoutType = PipelineLayout; using QuerySetType = QuerySet; diff --git a/src/dawn/native/d3d11/AdapterD3D11.cpp b/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp similarity index 88% rename from src/dawn/native/d3d11/AdapterD3D11.cpp rename to src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp index b2744b65bb..c39d47f580 100644 --- a/src/dawn/native/d3d11/AdapterD3D11.cpp +++ b/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "dawn/native/d3d11/AdapterD3D11.h" +#include "dawn/native/d3d11/PhysicalDeviceD3D11.h" #include #include @@ -61,23 +61,23 @@ MaybeError InitializeDebugLayerFilters(ComPtr d3d11Device) { } // namespace -Adapter::Adapter(Backend* backend, - ComPtr hardwareAdapter, - const TogglesState& adapterToggles) +PhysicalDevice::PhysicalDevice(Backend* backend, + ComPtr hardwareAdapter, + const TogglesState& adapterToggles) : Base(backend, std::move(hardwareAdapter), wgpu::BackendType::D3D11, adapterToggles) {} -Adapter::~Adapter() = default; +PhysicalDevice::~PhysicalDevice() = default; -bool Adapter::SupportsExternalImages() const { +bool PhysicalDevice::SupportsExternalImages() const { // TODO(dawn:1724): Implement external images on D3D11. return false; } -const DeviceInfo& Adapter::GetDeviceInfo() const { +const DeviceInfo& PhysicalDevice::GetDeviceInfo() const { return mDeviceInfo; } -ResultOrError> Adapter::CreateD3D11Device() { +ResultOrError> PhysicalDevice::CreateD3D11Device() { ComPtr device = std::move(mD3d11Device); if (!device) { const PlatformFunctions* functions = static_cast(GetBackend())->GetFunctions(); @@ -102,7 +102,7 @@ ResultOrError> Adapter::CreateD3D11Device() { return device; } -MaybeError Adapter::InitializeImpl() { +MaybeError PhysicalDevice::InitializeImpl() { DAWN_TRY(Base::InitializeImpl()); // D3D11 cannot check for feature support without a device. // Create the device to populate the adapter properties then reuse it when needed for actual @@ -121,12 +121,12 @@ MaybeError Adapter::InitializeImpl() { return {}; } -void Adapter::InitializeSupportedFeaturesImpl() { +void PhysicalDevice::InitializeSupportedFeaturesImpl() { EnableFeature(Feature::TextureCompressionBC); EnableFeature(Feature::SurfaceCapabilities); } -MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) { +MaybeError PhysicalDevice::InitializeSupportedLimitsImpl(CombinedLimits* limits) { GetDefaultLimits(&limits->v1); // // https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels @@ -188,18 +188,19 @@ MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) { return {}; } -MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature, - const TogglesState& toggles) const { +MaybeError PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl( + wgpu::FeatureName feature, + const TogglesState& toggles) const { return {}; } -void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const { +void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) const { // D3D11 can only clear RTV with float values. deviceToggles->Default(Toggle::ApplyClearBigIntegerColorValueWithDraw, true); } -ResultOrError> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor, - const TogglesState& deviceToggles) { +ResultOrError> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor, + const TogglesState& deviceToggles) { return Device::Create(this, descriptor, deviceToggles); } @@ -207,7 +208,7 @@ ResultOrError> Adapter::CreateDeviceImpl(const DeviceDescriptor* // current ID3D11Device have not been destroyed, a non-zero value will be returned upon Reset() // and the subequent call to CreateDevice will return a handle the existing device instead of // creating a new one. -MaybeError Adapter::ResetInternalDeviceForTestingImpl() { +MaybeError PhysicalDevice::ResetInternalDeviceForTestingImpl() { [[maybe_unused]] auto refCount = mD3d11Device.Reset(); ASSERT(refCount == 0); DAWN_TRY(Initialize()); diff --git a/src/dawn/native/d3d11/AdapterD3D11.h b/src/dawn/native/d3d11/PhysicalDeviceD3D11.h similarity index 78% rename from src/dawn/native/d3d11/AdapterD3D11.h rename to src/dawn/native/d3d11/PhysicalDeviceD3D11.h index 41c281b38e..9c3a7458a0 100644 --- a/src/dawn/native/d3d11/AdapterD3D11.h +++ b/src/dawn/native/d3d11/PhysicalDeviceD3D11.h @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_DAWN_NATIVE_D3D11_ADAPTERD3D11_H_ -#define SRC_DAWN_NATIVE_D3D11_ADAPTERD3D11_H_ +#ifndef SRC_DAWN_NATIVE_D3D11_PHYSICALDEVICED3D11_H_ +#define SRC_DAWN_NATIVE_D3D11_PHYSICALDEVICED3D11_H_ -#include "dawn/native/d3d/AdapterD3D.h" +#include "dawn/native/d3d/PhysicalDeviceD3D.h" #include "dawn/native/d3d/d3d_platform.h" #include "dawn/native/d3d11/DeviceInfoD3D11.h" @@ -24,12 +24,12 @@ namespace dawn::native::d3d11 { class Backend; -class Adapter : public d3d::Adapter { +class PhysicalDevice : public d3d::PhysicalDevice { public: - Adapter(Backend* backend, - ComPtr hardwareAdapter, - const TogglesState& adapterToggles); - ~Adapter() override; + PhysicalDevice(Backend* backend, + ComPtr hardwareAdapter, + const TogglesState& adapterToggles); + ~PhysicalDevice() override; // PhysicalDeviceBase Implementation bool SupportsExternalImages() const override; @@ -38,7 +38,7 @@ class Adapter : public d3d::Adapter { ResultOrError> CreateD3D11Device(); private: - using Base = d3d::Adapter; + using Base = d3d::PhysicalDevice; void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override; @@ -60,4 +60,4 @@ class Adapter : public d3d::Adapter { } // namespace dawn::native::d3d11 -#endif // SRC_DAWN_NATIVE_D3D11_ADAPTERD3D11_H_ +#endif // SRC_DAWN_NATIVE_D3D11_PHYSICALDEVICED3D11_H_ diff --git a/src/dawn/native/d3d11/ShaderModuleD3D11.cpp b/src/dawn/native/d3d11/ShaderModuleD3D11.cpp index 6ccbe3eba2..23fd202645 100644 --- a/src/dawn/native/d3d11/ShaderModuleD3D11.cpp +++ b/src/dawn/native/d3d11/ShaderModuleD3D11.cpp @@ -24,10 +24,10 @@ #include "dawn/native/TintUtils.h" #include "dawn/native/d3d/D3DCompilationRequest.h" #include "dawn/native/d3d/D3DError.h" -#include "dawn/native/d3d11/AdapterD3D11.h" #include "dawn/native/d3d11/BackendD3D11.h" #include "dawn/native/d3d11/BindGroupLayoutD3D11.h" #include "dawn/native/d3d11/DeviceD3D11.h" +#include "dawn/native/d3d11/PhysicalDeviceD3D11.h" #include "dawn/native/d3d11/PipelineLayoutD3D11.h" #include "dawn/native/d3d11/PlatformFunctionsD3D11.h" #include "dawn/native/d3d11/UtilsD3D11.h" diff --git a/src/dawn/native/d3d12/BackendD3D12.cpp b/src/dawn/native/d3d12/BackendD3D12.cpp index 5cece4a60b..696bd3df25 100644 --- a/src/dawn/native/d3d12/BackendD3D12.cpp +++ b/src/dawn/native/d3d12/BackendD3D12.cpp @@ -21,7 +21,7 @@ #include "dawn/native/D3D12Backend.h" #include "dawn/native/Instance.h" #include "dawn/native/d3d/D3DError.h" -#include "dawn/native/d3d12/AdapterD3D12.h" +#include "dawn/native/d3d12/PhysicalDeviceD3D12.h" #include "dawn/native/d3d12/PlatformFunctionsD3D12.h" #include "dawn/native/d3d12/UtilsD3D12.h" @@ -63,15 +63,16 @@ const PlatformFunctions* Backend::GetFunctions() const { return static_cast(Base::GetFunctions()); } -ResultOrError> Backend::CreateAdapterFromIDXGIAdapter( +ResultOrError> Backend::CreatePhysicalDeviceFromIDXGIAdapter( ComPtr dxgiAdapter, const TogglesState& adapterToggles) { ComPtr dxgiAdapter3; DAWN_TRY(CheckHRESULT(dxgiAdapter.As(&dxgiAdapter3), "DXGIAdapter retrieval")); - Ref adapter = AcquireRef(new Adapter(this, std::move(dxgiAdapter3), adapterToggles)); - DAWN_TRY(adapter->Initialize()); + Ref physicalDevice = + AcquireRef(new PhysicalDevice(this, std::move(dxgiAdapter3), adapterToggles)); + DAWN_TRY(physicalDevice->Initialize()); - return {std::move(adapter)}; + return {std::move(physicalDevice)}; } BackendConnection* Connect(InstanceBase* instance) { diff --git a/src/dawn/native/d3d12/BackendD3D12.h b/src/dawn/native/d3d12/BackendD3D12.h index 6170bc0f71..06c5436ef6 100644 --- a/src/dawn/native/d3d12/BackendD3D12.h +++ b/src/dawn/native/d3d12/BackendD3D12.h @@ -35,7 +35,7 @@ class Backend final : public d3d::Backend { const PlatformFunctions* GetFunctions() const; protected: - ResultOrError> CreateAdapterFromIDXGIAdapter( + ResultOrError> CreatePhysicalDeviceFromIDXGIAdapter( ComPtr dxgiAdapter, const TogglesState& adapterToggles) override; diff --git a/src/dawn/native/d3d12/D3D12Info.cpp b/src/dawn/native/d3d12/D3D12Info.cpp index ee927ef36b..b9811b1c5f 100644 --- a/src/dawn/native/d3d12/D3D12Info.cpp +++ b/src/dawn/native/d3d12/D3D12Info.cpp @@ -18,13 +18,13 @@ #include "dawn/common/GPUInfo.h" #include "dawn/native/d3d/D3DError.h" -#include "dawn/native/d3d12/AdapterD3D12.h" #include "dawn/native/d3d12/BackendD3D12.h" +#include "dawn/native/d3d12/PhysicalDeviceD3D12.h" #include "dawn/native/d3d12/PlatformFunctionsD3D12.h" namespace dawn::native::d3d12 { -ResultOrError GatherDeviceInfo(const Adapter& adapter) { +ResultOrError GatherDeviceInfo(const PhysicalDevice& physicalDevice) { D3D12DeviceInfo info = {}; // Newer builds replace D3D_FEATURE_DATA_ARCHITECTURE with @@ -32,26 +32,26 @@ ResultOrError GatherDeviceInfo(const Adapter& adapter) { // for backwards compat. // https://docs.microsoft.com/en-us/windows/desktop/api/d3d12/ne-d3d12-d3d12_feature D3D12_FEATURE_DATA_ARCHITECTURE arch = {}; - DAWN_TRY(CheckHRESULT( - adapter.GetDevice()->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &arch, sizeof(arch)), - "ID3D12Device::CheckFeatureSupport")); + DAWN_TRY(CheckHRESULT(physicalDevice.GetDevice()->CheckFeatureSupport( + D3D12_FEATURE_ARCHITECTURE, &arch, sizeof(arch)), + "ID3D12Device::CheckFeatureSupport")); info.isUMA = arch.UMA; D3D12_FEATURE_DATA_D3D12_OPTIONS featureOptions = {}; - DAWN_TRY(CheckHRESULT(adapter.GetDevice()->CheckFeatureSupport( + DAWN_TRY(CheckHRESULT(physicalDevice.GetDevice()->CheckFeatureSupport( D3D12_FEATURE_D3D12_OPTIONS, &featureOptions, sizeof(featureOptions)), "ID3D12Device::CheckFeatureSupport")); info.resourceHeapTier = featureOptions.ResourceHeapTier; D3D12_FEATURE_DATA_D3D12_OPTIONS2 featureOptions2 = {}; - if (SUCCEEDED(adapter.GetDevice()->CheckFeatureSupport( + if (SUCCEEDED(physicalDevice.GetDevice()->CheckFeatureSupport( D3D12_FEATURE_D3D12_OPTIONS2, &featureOptions2, sizeof(featureOptions2)))) { info.programmableSamplePositionsTier = featureOptions2.ProgrammableSamplePositionsTier; } D3D12_FEATURE_DATA_D3D12_OPTIONS3 featureOptions3 = {}; - if (SUCCEEDED(adapter.GetDevice()->CheckFeatureSupport( + if (SUCCEEDED(physicalDevice.GetDevice()->CheckFeatureSupport( D3D12_FEATURE_D3D12_OPTIONS3, &featureOptions3, sizeof(featureOptions3)))) { info.supportsCastingFullyTypedFormat = featureOptions3.CastingFullyTypedFormatSupported; } @@ -60,7 +60,7 @@ ResultOrError GatherDeviceInfo(const Adapter& adapter) { // D3D12_FEATURE_D3D12_OPTIONS4 successfully, then we can use cross-API sharing. info.supportsSharedResourceCapabilityTier1 = false; D3D12_FEATURE_DATA_D3D12_OPTIONS4 featureOptions4 = {}; - if (SUCCEEDED(adapter.GetDevice()->CheckFeatureSupport( + if (SUCCEEDED(physicalDevice.GetDevice()->CheckFeatureSupport( D3D12_FEATURE_D3D12_OPTIONS4, &featureOptions4, sizeof(featureOptions4)))) { // Tier 1 support additionally enables the NV12 format. Since only the NV12 format // is used by Dawn, check for Tier 1. @@ -75,13 +75,13 @@ ResultOrError GatherDeviceInfo(const Adapter& adapter) { // the render pass API. info.supportsRenderPass = false; D3D12_FEATURE_DATA_D3D12_OPTIONS5 featureOptions5 = {}; - if (SUCCEEDED(adapter.GetDevice()->CheckFeatureSupport( + if (SUCCEEDED(physicalDevice.GetDevice()->CheckFeatureSupport( D3D12_FEATURE_D3D12_OPTIONS5, &featureOptions5, sizeof(featureOptions5)))) { // Performance regressions been observed when using a render pass on Intel graphics // with RENDER_PASS_TIER_1 available, so fall back to a software emulated render // pass on these platforms. if (featureOptions5.RenderPassesTier < D3D12_RENDER_PASS_TIER_1 || - !gpu_info::IsIntel(adapter.GetVendorId())) { + !gpu_info::IsIntel(physicalDevice.GetVendorId())) { info.supportsRenderPass = true; } } @@ -91,7 +91,7 @@ ResultOrError GatherDeviceInfo(const Adapter& adapter) { {D3D_SHADER_MODEL_6_1}, {D3D_SHADER_MODEL_6_0}, {D3D_SHADER_MODEL_5_1}}; uint32_t driverShaderModel = 0; for (D3D12_FEATURE_DATA_SHADER_MODEL shaderModel : knownShaderModels) { - if (SUCCEEDED(adapter.GetDevice()->CheckFeatureSupport( + if (SUCCEEDED(physicalDevice.GetDevice()->CheckFeatureSupport( D3D12_FEATURE_SHADER_MODEL, &shaderModel, sizeof(shaderModel)))) { driverShaderModel = shaderModel.HighestShaderModel; break; diff --git a/src/dawn/native/d3d12/D3D12Info.h b/src/dawn/native/d3d12/D3D12Info.h index af0b6331c9..8c0a0476ab 100644 --- a/src/dawn/native/d3d12/D3D12Info.h +++ b/src/dawn/native/d3d12/D3D12Info.h @@ -21,7 +21,7 @@ namespace dawn::native::d3d12 { -class Adapter; +class PhysicalDevice; struct D3D12DeviceInfo { bool isUMA; @@ -38,7 +38,7 @@ struct D3D12DeviceInfo { uint32_t programmableSamplePositionsTier; }; -ResultOrError GatherDeviceInfo(const Adapter& adapter); +ResultOrError GatherDeviceInfo(const PhysicalDevice& physicalDevice); } // namespace dawn::native::d3d12 #endif // SRC_DAWN_NATIVE_D3D12_D3D12INFO_H_ diff --git a/src/dawn/native/d3d12/DeviceD3D12.cpp b/src/dawn/native/d3d12/DeviceD3D12.cpp index 309dd879aa..a799379cd2 100644 --- a/src/dawn/native/d3d12/DeviceD3D12.cpp +++ b/src/dawn/native/d3d12/DeviceD3D12.cpp @@ -24,7 +24,6 @@ #include "dawn/native/DynamicUploader.h" #include "dawn/native/Instance.h" #include "dawn/native/d3d/D3DError.h" -#include "dawn/native/d3d12/AdapterD3D12.h" #include "dawn/native/d3d12/BackendD3D12.h" #include "dawn/native/d3d12/BindGroupD3D12.h" #include "dawn/native/d3d12/BindGroupLayoutD3D12.h" @@ -32,6 +31,7 @@ #include "dawn/native/d3d12/CommandBufferD3D12.h" #include "dawn/native/d3d12/ComputePipelineD3D12.h" #include "dawn/native/d3d12/ExternalImageDXGIImplD3D12.h" +#include "dawn/native/d3d12/PhysicalDeviceD3D12.h" #include "dawn/native/d3d12/PipelineLayoutD3D12.h" #include "dawn/native/d3d12/PlatformFunctionsD3D12.h" #include "dawn/native/d3d12/QuerySetD3D12.h" @@ -61,7 +61,7 @@ static constexpr uint64_t kZeroBufferSize = 1024 * 1024 * 4; // 4 Mb static constexpr uint64_t kMaxDebugMessagesToPrint = 5; // static -ResultOrError> Device::Create(Adapter* adapter, +ResultOrError> Device::Create(AdapterBase* adapter, const DeviceDescriptor* descriptor, const TogglesState& deviceToggles) { Ref device = AcquireRef(new Device(adapter, descriptor, deviceToggles)); @@ -70,7 +70,7 @@ ResultOrError> Device::Create(Adapter* adapter, } MaybeError Device::Initialize(const DeviceDescriptor* descriptor) { - mD3d12Device = ToBackend(GetAdapter())->GetDevice(); + mD3d12Device = ToBackend(GetPhysicalDevice())->GetDevice(); ASSERT(mD3d12Device != nullptr); @@ -233,17 +233,17 @@ ComPtr Device::GetDrawIndexedIndirectSignature() const { // Ensure DXC if use_dxc toggles are set and validated. MaybeError Device::EnsureDXCIfRequired() { if (IsToggleEnabled(Toggle::UseDXC)) { - ASSERT(ToBackend(GetAdapter())->GetBackend()->IsDXCAvailable()); - DAWN_TRY(ToBackend(GetAdapter())->GetBackend()->EnsureDxcCompiler()); - DAWN_TRY(ToBackend(GetAdapter())->GetBackend()->EnsureDxcLibrary()); - DAWN_TRY(ToBackend(GetAdapter())->GetBackend()->EnsureDxcValidator()); + ASSERT(ToBackend(GetPhysicalDevice())->GetBackend()->IsDXCAvailable()); + DAWN_TRY(ToBackend(GetPhysicalDevice())->GetBackend()->EnsureDxcCompiler()); + DAWN_TRY(ToBackend(GetPhysicalDevice())->GetBackend()->EnsureDxcLibrary()); + DAWN_TRY(ToBackend(GetPhysicalDevice())->GetBackend()->EnsureDxcValidator()); } return {}; } const PlatformFunctions* Device::GetFunctions() const { - return ToBackend(GetAdapter())->GetBackend()->GetFunctions(); + return ToBackend(GetPhysicalDevice())->GetBackend()->GetFunctions(); } CommandAllocatorManager* Device::GetCommandAllocatorManager() const { @@ -608,7 +608,7 @@ Ref Device::CreateD3D12ExternalTexture(const TextureDescriptor* des } const D3D12DeviceInfo& Device::GetDeviceInfo() const { - return ToBackend(GetAdapter())->GetDeviceInfo(); + return ToBackend(GetPhysicalDevice())->GetDeviceInfo(); } MaybeError Device::WaitForIdleForDestruction() { @@ -662,7 +662,7 @@ void AppendDebugLayerMessagesToError(ID3D12InfoQueue* infoQueue, } MaybeError Device::CheckDebugLayerAndGenerateErrors() { - if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled()) { + if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled()) { return {}; } @@ -686,7 +686,7 @@ MaybeError Device::CheckDebugLayerAndGenerateErrors() { } void Device::AppendDebugLayerMessages(ErrorData* error) { - if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled()) { + if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled()) { return; } diff --git a/src/dawn/native/d3d12/DeviceD3D12.h b/src/dawn/native/d3d12/DeviceD3D12.h index aa0c4e9852..a0281553d0 100644 --- a/src/dawn/native/d3d12/DeviceD3D12.h +++ b/src/dawn/native/d3d12/DeviceD3D12.h @@ -49,7 +49,7 @@ class StagingDescriptorAllocator; // Definition of backend types class Device final : public d3d::Device { public: - static ResultOrError> Create(Adapter* adapter, + static ResultOrError> Create(AdapterBase* adapter, const DeviceDescriptor* descriptor, const TogglesState& deviceToggles); ~Device() override; diff --git a/src/dawn/native/d3d12/Forward.h b/src/dawn/native/d3d12/Forward.h index a1bece44c4..f091825e78 100644 --- a/src/dawn/native/d3d12/Forward.h +++ b/src/dawn/native/d3d12/Forward.h @@ -19,7 +19,6 @@ namespace dawn::native::d3d12 { -class Adapter; class BindGroup; class BindGroupLayout; class Buffer; @@ -27,6 +26,7 @@ class CommandBuffer; class ComputePipeline; class Device; class Heap; +class PhysicalDevice; class PipelineCache; class PipelineLayout; class QuerySet; @@ -39,13 +39,13 @@ class Texture; class TextureView; struct D3D12BackendTraits { - using AdapterType = Adapter; using BindGroupType = BindGroup; using BindGroupLayoutType = BindGroupLayout; using BufferType = Buffer; using CommandBufferType = CommandBuffer; using ComputePipelineType = ComputePipeline; using DeviceType = Device; + using PhysicalDeviceType = PhysicalDevice; using PipelineCacheType = PipelineCache; using PipelineLayoutType = PipelineLayout; using QuerySetType = QuerySet; diff --git a/src/dawn/native/d3d12/AdapterD3D12.cpp b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp similarity index 95% rename from src/dawn/native/d3d12/AdapterD3D12.cpp rename to src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp index 337b8c8acb..3aa00da2aa 100644 --- a/src/dawn/native/d3d12/AdapterD3D12.cpp +++ b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "dawn/native/d3d12/AdapterD3D12.h" +#include "dawn/native/d3d12/PhysicalDeviceD3D12.h" #include #include @@ -29,33 +29,33 @@ namespace dawn::native::d3d12 { -Adapter::Adapter(Backend* backend, - ComPtr hardwareAdapter, - const TogglesState& adapterToggles) +PhysicalDevice::PhysicalDevice(Backend* backend, + ComPtr hardwareAdapter, + const TogglesState& adapterToggles) : Base(backend, std::move(hardwareAdapter), wgpu::BackendType::D3D12, adapterToggles) {} -Adapter::~Adapter() { +PhysicalDevice::~PhysicalDevice() { CleanUpDebugLayerFilters(); } -bool Adapter::SupportsExternalImages() const { +bool PhysicalDevice::SupportsExternalImages() const { // Via dawn::native::d3d12::ExternalImageDXGI::Create return true; } -const D3D12DeviceInfo& Adapter::GetDeviceInfo() const { +const D3D12DeviceInfo& PhysicalDevice::GetDeviceInfo() const { return mDeviceInfo; } -Backend* Adapter::GetBackend() const { +Backend* PhysicalDevice::GetBackend() const { return static_cast(Base::GetBackend()); } -ComPtr Adapter::GetDevice() const { +ComPtr PhysicalDevice::GetDevice() const { return mD3d12Device; } -MaybeError Adapter::InitializeImpl() { +MaybeError PhysicalDevice::InitializeImpl() { DAWN_TRY(Base::InitializeImpl()); // D3D12 cannot check for feature support without a device. // Create the device to populate the adapter properties then reuse it when needed for actual @@ -93,7 +93,7 @@ MaybeError Adapter::InitializeImpl() { return {}; } -bool Adapter::AreTimestampQueriesSupported() const { +bool PhysicalDevice::AreTimestampQueriesSupported() const { D3D12_COMMAND_QUEUE_DESC queueDesc = {}; queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; @@ -114,7 +114,7 @@ bool Adapter::AreTimestampQueriesSupported() const { return true; } -void Adapter::InitializeSupportedFeaturesImpl() { +void PhysicalDevice::InitializeSupportedFeaturesImpl() { EnableFeature(Feature::TextureCompressionBC); EnableFeature(Feature::MultiPlanarFormats); EnableFeature(Feature::Depth32FloatStencil8); @@ -149,7 +149,7 @@ void Adapter::InitializeSupportedFeaturesImpl() { } } -MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) { +MaybeError PhysicalDevice::InitializeSupportedLimitsImpl(CombinedLimits* limits) { D3D12_FEATURE_DATA_D3D12_OPTIONS featureData = {}; DAWN_TRY(CheckHRESULT(mD3d12Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, @@ -320,8 +320,9 @@ MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) { return {}; } -MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature, - const TogglesState& toggles) const { +MaybeError PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl( + wgpu::FeatureName feature, + const TogglesState& toggles) const { // shader-f16 feature and chromium-experimental-dp4a feature require DXC 1.4 or higher for // D3D12. Note that DXC version is checked in InitializeSupportedFeaturesImpl. if (feature == wgpu::FeatureName::ShaderF16 || @@ -332,7 +333,7 @@ MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName fe return {}; } -MaybeError Adapter::InitializeDebugLayerFilters() { +MaybeError PhysicalDevice::InitializeDebugLayerFilters() { if (!GetInstance()->IsBackendValidationEnabled()) { return {}; } @@ -423,7 +424,7 @@ MaybeError Adapter::InitializeDebugLayerFilters() { return {}; } -void Adapter::CleanUpDebugLayerFilters() { +void PhysicalDevice::CleanUpDebugLayerFilters() { if (!GetInstance()->IsBackendValidationEnabled()) { return; } @@ -443,7 +444,7 @@ void Adapter::CleanUpDebugLayerFilters() { infoQueue->PopStorageFilter(); } -void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const { +void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) const { const bool useResourceHeapTier2 = (GetDeviceInfo().resourceHeapTier >= 2); deviceToggles->Default(Toggle::UseD3D12ResourceHeapTier2, useResourceHeapTier2); deviceToggles->Default(Toggle::UseD3D12RenderPass, GetDeviceInfo().supportsRenderPass); @@ -578,8 +579,8 @@ void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const { } } -ResultOrError> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor, - const TogglesState& deviceToggles) { +ResultOrError> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor, + const TogglesState& deviceToggles) { return Device::Create(this, descriptor, deviceToggles); } @@ -587,7 +588,7 @@ ResultOrError> Adapter::CreateDeviceImpl(const DeviceDescriptor* // current ID3D12Device have not been destroyed, a non-zero value will be returned upon Reset() // and the subequent call to CreateDevice will return a handle the existing device instead of // creating a new one. -MaybeError Adapter::ResetInternalDeviceForTestingImpl() { +MaybeError PhysicalDevice::ResetInternalDeviceForTestingImpl() { [[maybe_unused]] auto refCount = mD3d12Device.Reset(); ASSERT(refCount == 0); DAWN_TRY(Initialize()); diff --git a/src/dawn/native/d3d12/AdapterD3D12.h b/src/dawn/native/d3d12/PhysicalDeviceD3D12.h similarity index 80% rename from src/dawn/native/d3d12/AdapterD3D12.h rename to src/dawn/native/d3d12/PhysicalDeviceD3D12.h index cbdd03f9bb..8fdf76f33b 100644 --- a/src/dawn/native/d3d12/AdapterD3D12.h +++ b/src/dawn/native/d3d12/PhysicalDeviceD3D12.h @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_DAWN_NATIVE_D3D12_ADAPTERD3D12_H_ -#define SRC_DAWN_NATIVE_D3D12_ADAPTERD3D12_H_ +#ifndef SRC_DAWN_NATIVE_D3D12_PHYSICALDEVICED3D12_H_ +#define SRC_DAWN_NATIVE_D3D12_PHYSICALDEVICED3D12_H_ #include "dawn/native/PhysicalDevice.h" -#include "dawn/native/d3d/AdapterD3D.h" +#include "dawn/native/d3d/PhysicalDeviceD3D.h" #include "dawn/native/d3d12/D3D12Info.h" #include "dawn/native/d3d12/d3d12_platform.h" @@ -25,12 +25,12 @@ namespace dawn::native::d3d12 { class Backend; -class Adapter : public d3d::Adapter { +class PhysicalDevice : public d3d::PhysicalDevice { public: - Adapter(Backend* backend, - ComPtr hardwareAdapter, - const TogglesState& adapterToggles); - ~Adapter() override; + PhysicalDevice(Backend* backend, + ComPtr hardwareAdapter, + const TogglesState& adapterToggles); + ~PhysicalDevice() override; // PhysicalDeviceBase Implementation bool SupportsExternalImages() const override; @@ -40,7 +40,7 @@ class Adapter : public d3d::Adapter { ComPtr GetDevice() const; private: - using Base = d3d::Adapter; + using Base = d3d::PhysicalDevice; void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override; @@ -68,4 +68,4 @@ class Adapter : public d3d::Adapter { } // namespace dawn::native::d3d12 -#endif // SRC_DAWN_NATIVE_D3D12_ADAPTERD3D12_H_ +#endif // SRC_DAWN_NATIVE_D3D12_PHYSICALDEVICED3D12_H_ diff --git a/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp b/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp index f6fb404076..97a062d2d9 100644 --- a/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp +++ b/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp @@ -18,10 +18,10 @@ #include #include "dawn/native/d3d/D3DError.h" -#include "dawn/native/d3d12/AdapterD3D12.h" #include "dawn/native/d3d12/DeviceD3D12.h" #include "dawn/native/d3d12/Forward.h" #include "dawn/native/d3d12/HeapD3D12.h" +#include "dawn/native/d3d12/PhysicalDeviceD3D12.h" namespace dawn::native::d3d12 { diff --git a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp index 7df96ca63a..851d420d83 100644 --- a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp @@ -24,10 +24,10 @@ #include "dawn/native/TintUtils.h" #include "dawn/native/d3d/D3DCompilationRequest.h" #include "dawn/native/d3d/D3DError.h" -#include "dawn/native/d3d12/AdapterD3D12.h" #include "dawn/native/d3d12/BackendD3D12.h" #include "dawn/native/d3d12/BindGroupLayoutD3D12.h" #include "dawn/native/d3d12/DeviceD3D12.h" +#include "dawn/native/d3d12/PhysicalDeviceD3D12.h" #include "dawn/native/d3d12/PipelineLayoutD3D12.h" #include "dawn/native/d3d12/PlatformFunctionsD3D12.h" #include "dawn/native/d3d12/UtilsD3D12.h" diff --git a/src/dawn/native/vulkan/Forward.h b/src/dawn/native/vulkan/Forward.h index 41c2721f38..ca1e443e9a 100644 --- a/src/dawn/native/vulkan/Forward.h +++ b/src/dawn/native/vulkan/Forward.h @@ -39,13 +39,13 @@ class Texture; class TextureView; struct VulkanBackendTraits { - using AdapterType = Adapter; using BindGroupType = BindGroup; using BindGroupLayoutType = BindGroupLayout; using BufferType = Buffer; using CommandBufferType = CommandBuffer; using ComputePipelineType = ComputePipeline; using DeviceType = Device; + using PhysicalDeviceType = Adapter; using PipelineCacheType = PipelineCache; using PipelineLayoutType = PipelineLayout; using QuerySetType = QuerySet;