Rename AdapterD3D* -> PhysicalDeviceD3D*.

Bug: dawn:1774

Change-Id: I9eca75c75c1ec162112915af3bd8371e808c2d60
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130421
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Stephen White 2023-05-01 23:10:47 +00:00 committed by Dawn LUCI CQ
parent 5c2f1678be
commit 9091b46278
32 changed files with 166 additions and 156 deletions

View File

@ -398,8 +398,6 @@ source_set("sources") {
if (dawn_enable_d3d11 || dawn_enable_d3d12) { if (dawn_enable_d3d11 || dawn_enable_d3d12) {
sources += [ sources += [
"d3d/AdapterD3D.cpp",
"d3d/AdapterD3D.h",
"d3d/BackendD3D.cpp", "d3d/BackendD3D.cpp",
"d3d/BackendD3D.h", "d3d/BackendD3D.h",
"d3d/BlobD3D.cpp", "d3d/BlobD3D.cpp",
@ -412,6 +410,8 @@ source_set("sources") {
"d3d/ExternalImageDXGIImpl.cpp", "d3d/ExternalImageDXGIImpl.cpp",
"d3d/ExternalImageDXGIImpl.h", "d3d/ExternalImageDXGIImpl.h",
"d3d/Forward.h", "d3d/Forward.h",
"d3d/PhysicalDeviceD3D.cpp",
"d3d/PhysicalDeviceD3D.h",
"d3d/PlatformFunctions.cpp", "d3d/PlatformFunctions.cpp",
"d3d/PlatformFunctions.h", "d3d/PlatformFunctions.h",
"d3d/ShaderUtils.cpp", "d3d/ShaderUtils.cpp",
@ -427,8 +427,6 @@ source_set("sources") {
if (dawn_enable_d3d11) { if (dawn_enable_d3d11) {
libs += [ "dxguid.lib" ] libs += [ "dxguid.lib" ]
sources += [ sources += [
"d3d11/AdapterD3D11.cpp",
"d3d11/AdapterD3D11.h",
"d3d11/BackendD3D11.cpp", "d3d11/BackendD3D11.cpp",
"d3d11/BackendD3D11.h", "d3d11/BackendD3D11.h",
"d3d11/BindGroupD3D11.cpp", "d3d11/BindGroupD3D11.cpp",
@ -448,6 +446,8 @@ source_set("sources") {
"d3d11/DeviceInfoD3D11.cpp", "d3d11/DeviceInfoD3D11.cpp",
"d3d11/DeviceInfoD3D11.h", "d3d11/DeviceInfoD3D11.h",
"d3d11/Forward.h", "d3d11/Forward.h",
"d3d11/PhysicalDeviceD3D11.cpp",
"d3d11/PhysicalDeviceD3D11.h",
"d3d11/PipelineLayoutD3D11.cpp", "d3d11/PipelineLayoutD3D11.cpp",
"d3d11/PipelineLayoutD3D11.h", "d3d11/PipelineLayoutD3D11.h",
"d3d11/PlatformFunctionsD3D11.cpp", "d3d11/PlatformFunctionsD3D11.cpp",
@ -472,8 +472,6 @@ source_set("sources") {
if (dawn_enable_d3d12) { if (dawn_enable_d3d12) {
libs += [ "dxguid.lib" ] libs += [ "dxguid.lib" ]
sources += [ sources += [
"d3d12/AdapterD3D12.cpp",
"d3d12/AdapterD3D12.h",
"d3d12/BackendD3D12.cpp", "d3d12/BackendD3D12.cpp",
"d3d12/BackendD3D12.h", "d3d12/BackendD3D12.h",
"d3d12/BindGroupD3D12.cpp", "d3d12/BindGroupD3D12.cpp",
@ -510,6 +508,8 @@ source_set("sources") {
"d3d12/IntegerTypes.h", "d3d12/IntegerTypes.h",
"d3d12/PageableD3D12.cpp", "d3d12/PageableD3D12.cpp",
"d3d12/PageableD3D12.h", "d3d12/PageableD3D12.h",
"d3d12/PhysicalDeviceD3D12.cpp",
"d3d12/PhysicalDeviceD3D12.h",
"d3d12/PipelineLayoutD3D12.cpp", "d3d12/PipelineLayoutD3D12.cpp",
"d3d12/PipelineLayoutD3D12.h", "d3d12/PipelineLayoutD3D12.h",
"d3d12/PlatformFunctionsD3D12.cpp", "d3d12/PlatformFunctionsD3D12.cpp",

View File

@ -255,8 +255,6 @@ endif()
if (DAWN_ENABLE_D3D11 OR DAWN_ENABLE_D3D12) if (DAWN_ENABLE_D3D11 OR DAWN_ENABLE_D3D12)
target_sources(dawn_native PRIVATE target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn/native/D3DBackend.h" "${DAWN_INCLUDE_DIR}/dawn/native/D3DBackend.h"
"d3d/AdapterD3D.cpp"
"d3d/AdapterD3D.h"
"d3d/BackendD3D.cpp" "d3d/BackendD3D.cpp"
"d3d/BackendD3D.h" "d3d/BackendD3D.h"
"d3d/BlobD3D.cpp" "d3d/BlobD3D.cpp"
@ -269,6 +267,8 @@ if (DAWN_ENABLE_D3D11 OR DAWN_ENABLE_D3D12)
"d3d/ExternalImageDXGIImpl.cpp" "d3d/ExternalImageDXGIImpl.cpp"
"d3d/ExternalImageDXGIImpl.h" "d3d/ExternalImageDXGIImpl.h"
"d3d/Forward.h" "d3d/Forward.h"
"d3d/PhysicalDeviceD3D.cpp"
"d3d/PhysicalDeviceD3D.h"
"d3d/PlatformFunctions.cpp" "d3d/PlatformFunctions.cpp"
"d3d/PlatformFunctions.h" "d3d/PlatformFunctions.h"
"d3d/ShaderUtils.cpp" "d3d/ShaderUtils.cpp"
@ -284,8 +284,6 @@ endif()
if (DAWN_ENABLE_D3D11) if (DAWN_ENABLE_D3D11)
target_sources(dawn_native PRIVATE target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn/native/D3D11Backend.h" "${DAWN_INCLUDE_DIR}/dawn/native/D3D11Backend.h"
"d3d11/AdapterD3D11.cpp"
"d3d11/AdapterD3D11.h"
"d3d11/BackendD3D11.cpp" "d3d11/BackendD3D11.cpp"
"d3d11/BackendD3D11.h" "d3d11/BackendD3D11.h"
"d3d11/BindGroupD3D11.cpp" "d3d11/BindGroupD3D11.cpp"
@ -305,6 +303,8 @@ if (DAWN_ENABLE_D3D11)
"d3d11/DeviceInfoD3D11.cpp" "d3d11/DeviceInfoD3D11.cpp"
"d3d11/DeviceInfoD3D11.h" "d3d11/DeviceInfoD3D11.h"
"d3d11/Forward.h" "d3d11/Forward.h"
"d3d11/PhysicalDeviceD3D11.cpp"
"d3d11/PhysicalDeviceD3D11.h"
"d3d11/PipelineLayoutD3D11.cpp" "d3d11/PipelineLayoutD3D11.cpp"
"d3d11/PipelineLayoutD3D11.h" "d3d11/PipelineLayoutD3D11.h"
"d3d11/PlatformFunctionsD3D11.cpp" "d3d11/PlatformFunctionsD3D11.cpp"
@ -329,8 +329,6 @@ endif()
if (DAWN_ENABLE_D3D12) if (DAWN_ENABLE_D3D12)
target_sources(dawn_native PRIVATE target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn/native/D3D12Backend.h" "${DAWN_INCLUDE_DIR}/dawn/native/D3D12Backend.h"
"d3d12/AdapterD3D12.cpp"
"d3d12/AdapterD3D12.h"
"d3d12/BackendD3D12.cpp" "d3d12/BackendD3D12.cpp"
"d3d12/BackendD3D12.h" "d3d12/BackendD3D12.h"
"d3d12/BindGroupD3D12.cpp" "d3d12/BindGroupD3D12.cpp"
@ -367,6 +365,8 @@ if (DAWN_ENABLE_D3D12)
"d3d12/IntegerTypes.h" "d3d12/IntegerTypes.h"
"d3d12/PageableD3D12.cpp" "d3d12/PageableD3D12.cpp"
"d3d12/PageableD3D12.h" "d3d12/PageableD3D12.h"
"d3d12/PhysicalDeviceD3D12.cpp"
"d3d12/PhysicalDeviceD3D12.h"
"d3d12/PipelineLayoutD3D12.cpp" "d3d12/PipelineLayoutD3D12.cpp"
"d3d12/PipelineLayoutD3D12.h" "d3d12/PipelineLayoutD3D12.h"
"d3d12/PlatformFunctionsD3D12.cpp" "d3d12/PlatformFunctionsD3D12.cpp"

View File

@ -715,10 +715,15 @@ ApiObjectList* DeviceBase::GetObjectTrackingList(ObjectType type) {
return &mObjectLists[type]; return &mObjectLists[type];
} }
PhysicalDeviceBase* DeviceBase::GetAdapter() const { AdapterBase* DeviceBase::GetAdapter() const {
return mAdapter.Get(); 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 { dawn::platform::Platform* DeviceBase::GetPlatform() const {
return GetAdapter()->GetInstance()->GetPlatform(); return GetAdapter()->GetInstance()->GetPlatform();
} }

View File

@ -155,6 +155,7 @@ class DeviceBase : public RefCountedWithExternalCount {
MaybeError ValidateObject(const ApiObjectBase* object) const; MaybeError ValidateObject(const ApiObjectBase* object) const;
AdapterBase* GetAdapter() const; AdapterBase* GetAdapter() const;
PhysicalDeviceBase* GetPhysicalDevice() const;
virtual dawn::platform::Platform* GetPlatform() const; virtual dawn::platform::Platform* GetPlatform() const;
// Returns the Format corresponding to the wgpu::TextureFormat or an error if the format // Returns the Format corresponding to the wgpu::TextureFormat or an error if the format

View File

@ -25,7 +25,7 @@ struct ToBackendTraits;
template <typename BackendTraits> template <typename BackendTraits>
struct ToBackendTraits<PhysicalDeviceBase, BackendTraits> { struct ToBackendTraits<PhysicalDeviceBase, BackendTraits> {
using BackendType = typename BackendTraits::AdapterType; using BackendType = typename BackendTraits::PhysicalDeviceType;
}; };
template <typename BackendTraits> template <typename BackendTraits>

View File

@ -260,7 +260,7 @@ ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters(
// |dxgiAdapter| was provided. Discover just that adapter. // |dxgiAdapter| was provided. Discover just that adapter.
Ref<PhysicalDeviceBase> adapter; Ref<PhysicalDeviceBase> adapter;
DAWN_TRY_ASSIGN(adapter, DAWN_TRY_ASSIGN(adapter,
CreateAdapterFromIDXGIAdapter(options->dxgiAdapter, adapterToggles)); CreatePhysicalDeviceFromIDXGIAdapter(options->dxgiAdapter, adapterToggles));
adapters.push_back(std::move(adapter)); adapters.push_back(std::move(adapter));
return std::move(adapters); return std::move(adapters);
} }
@ -274,8 +274,8 @@ ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters(
ASSERT(dxgiAdapter != nullptr); ASSERT(dxgiAdapter != nullptr);
Ref<PhysicalDeviceBase> adapter; Ref<PhysicalDeviceBase> adapter;
if (GetInstance()->ConsumedError(CreateAdapterFromIDXGIAdapter(dxgiAdapter, adapterToggles), if (GetInstance()->ConsumedError(
&adapter)) { CreatePhysicalDeviceFromIDXGIAdapter(dxgiAdapter, adapterToggles), &adapter)) {
continue; continue;
} }

View File

@ -82,7 +82,7 @@ class Backend : public BackendConnection {
const TogglesState& adapterToggles) override; const TogglesState& adapterToggles) override;
protected: protected:
virtual ResultOrError<Ref<PhysicalDeviceBase>> CreateAdapterFromIDXGIAdapter( virtual ResultOrError<Ref<PhysicalDeviceBase>> CreatePhysicalDeviceFromIDXGIAdapter(
ComPtr<IDXGIAdapter> dxgiAdapter, ComPtr<IDXGIAdapter> dxgiAdapter,
const TogglesState& adapterToggles) = 0; const TogglesState& adapterToggles) = 0;

View File

@ -14,9 +14,9 @@
#include "dawn/native/d3d/DeviceD3D.h" #include "dawn/native/d3d/DeviceD3D.h"
#include "dawn/native/d3d/AdapterD3D.h"
#include "dawn/native/d3d/BackendD3D.h" #include "dawn/native/d3d/BackendD3D.h"
#include "dawn/native/d3d/Forward.h" #include "dawn/native/d3d/Forward.h"
#include "dawn/native/d3d/PhysicalDeviceD3D.h"
namespace dawn::native::d3d { namespace dawn::native::d3d {
@ -35,23 +35,23 @@ ResultOrError<wgpu::TextureUsage> Device::GetSupportedSurfaceUsageImpl(
} }
const PlatformFunctions* Device::GetFunctions() const { const PlatformFunctions* Device::GetFunctions() const {
return ToBackend(GetAdapter())->GetBackend()->GetFunctions(); return ToBackend(GetPhysicalDevice())->GetBackend()->GetFunctions();
} }
ComPtr<IDXGIFactory4> Device::GetFactory() const { ComPtr<IDXGIFactory4> Device::GetFactory() const {
return ToBackend(GetAdapter())->GetBackend()->GetFactory(); return ToBackend(GetPhysicalDevice())->GetBackend()->GetFactory();
} }
ComPtr<IDxcLibrary> Device::GetDxcLibrary() const { ComPtr<IDxcLibrary> Device::GetDxcLibrary() const {
return ToBackend(GetAdapter())->GetBackend()->GetDxcLibrary(); return ToBackend(GetPhysicalDevice())->GetBackend()->GetDxcLibrary();
} }
ComPtr<IDxcCompiler> Device::GetDxcCompiler() const { ComPtr<IDxcCompiler> Device::GetDxcCompiler() const {
return ToBackend(GetAdapter())->GetBackend()->GetDxcCompiler(); return ToBackend(GetPhysicalDevice())->GetBackend()->GetDxcCompiler();
} }
ComPtr<IDxcValidator> Device::GetDxcValidator() const { ComPtr<IDxcValidator> Device::GetDxcValidator() const {
return ToBackend(GetAdapter())->GetBackend()->GetDxcValidator(); return ToBackend(GetPhysicalDevice())->GetBackend()->GetDxcValidator();
} }
} // namespace dawn::native::d3d } // namespace dawn::native::d3d

View File

@ -19,13 +19,13 @@
namespace dawn::native::d3d { namespace dawn::native::d3d {
class Adapter; class PhysicalDevice;
class Device; class Device;
class SwapChain; class SwapChain;
struct D3DBackendTraits { struct D3DBackendTraits {
using AdapterType = Adapter;
using DeviceType = Device; using DeviceType = Device;
using PhysicalDeviceType = PhysicalDevice;
using SwapChainType = SwapChain; using SwapChainType = SwapChain;
}; };

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "dawn/native/d3d/AdapterD3D.h" #include "dawn/native/d3d/PhysicalDeviceD3D.h"
#include <string> #include <string>
#include <utility> #include <utility>
@ -22,25 +22,25 @@
namespace dawn::native::d3d { namespace dawn::native::d3d {
Adapter::Adapter(Backend* backend, PhysicalDevice::PhysicalDevice(Backend* backend,
ComPtr<IDXGIAdapter3> hardwareAdapter, ComPtr<IDXGIAdapter3> hardwareAdapter,
wgpu::BackendType backendType, wgpu::BackendType backendType,
const TogglesState& adapterToggles) const TogglesState& adapterToggles)
: PhysicalDeviceBase(backend->GetInstance(), backendType, adapterToggles), : PhysicalDeviceBase(backend->GetInstance(), backendType, adapterToggles),
mHardwareAdapter(std::move(hardwareAdapter)), mHardwareAdapter(std::move(hardwareAdapter)),
mBackend(backend) {} mBackend(backend) {}
Adapter::~Adapter() = default; PhysicalDevice::~PhysicalDevice() = default;
IDXGIAdapter3* Adapter::GetHardwareAdapter() const { IDXGIAdapter3* PhysicalDevice::GetHardwareAdapter() const {
return mHardwareAdapter.Get(); return mHardwareAdapter.Get();
} }
Backend* Adapter::GetBackend() const { Backend* PhysicalDevice::GetBackend() const {
return mBackend; return mBackend;
} }
MaybeError Adapter::InitializeImpl() { MaybeError PhysicalDevice::InitializeImpl() {
DXGI_ADAPTER_DESC1 adapterDesc; DXGI_ADAPTER_DESC1 adapterDesc;
GetHardwareAdapter()->GetDesc1(&adapterDesc); GetHardwareAdapter()->GetDesc1(&adapterDesc);

View File

@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_DAWN_NATIVE_D3D_ADAPTERD3D_H_ #ifndef SRC_DAWN_NATIVE_D3D_PHYSICALDEVICED3D_H_
#define SRC_DAWN_NATIVE_D3D_ADAPTERD3D_H_ #define SRC_DAWN_NATIVE_D3D_PHYSICALDEVICED3D_H_
#include "dawn/native/PhysicalDevice.h" #include "dawn/native/PhysicalDevice.h"
@ -23,13 +23,13 @@ namespace dawn::native::d3d {
class Backend; class Backend;
class Adapter : public PhysicalDeviceBase { class PhysicalDevice : public PhysicalDeviceBase {
public: public:
Adapter(Backend* backend, PhysicalDevice(Backend* backend,
ComPtr<IDXGIAdapter3> hardwareAdapter, ComPtr<IDXGIAdapter3> hardwareAdapter,
wgpu::BackendType backendType, wgpu::BackendType backendType,
const TogglesState& adapterToggles); const TogglesState& adapterToggles);
~Adapter() override; ~PhysicalDevice() override;
IDXGIAdapter3* GetHardwareAdapter() const; IDXGIAdapter3* GetHardwareAdapter() const;
Backend* GetBackend() const; Backend* GetBackend() const;
@ -44,4 +44,4 @@ class Adapter : public PhysicalDeviceBase {
} // namespace dawn::native::d3d } // namespace dawn::native::d3d
#endif // SRC_DAWN_NATIVE_D3D_ADAPTERD3D_H_ #endif // SRC_DAWN_NATIVE_D3D_PHYSICALDEVICED3D_H_

View File

@ -21,7 +21,7 @@
#include "dawn/native/D3D11Backend.h" #include "dawn/native/D3D11Backend.h"
#include "dawn/native/Instance.h" #include "dawn/native/Instance.h"
#include "dawn/native/d3d/D3DError.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" #include "dawn/native/d3d11/PlatformFunctionsD3D11.h"
namespace dawn::native::d3d11 { namespace dawn::native::d3d11 {
@ -41,15 +41,16 @@ const PlatformFunctions* Backend::GetFunctions() const {
return static_cast<const PlatformFunctions*>(Base::GetFunctions()); return static_cast<const PlatformFunctions*>(Base::GetFunctions());
} }
ResultOrError<Ref<PhysicalDeviceBase>> Backend::CreateAdapterFromIDXGIAdapter( ResultOrError<Ref<PhysicalDeviceBase>> Backend::CreatePhysicalDeviceFromIDXGIAdapter(
ComPtr<IDXGIAdapter> dxgiAdapter, ComPtr<IDXGIAdapter> dxgiAdapter,
const TogglesState& adapterToggles) { const TogglesState& adapterToggles) {
ComPtr<IDXGIAdapter3> dxgiAdapter3; ComPtr<IDXGIAdapter3> dxgiAdapter3;
DAWN_TRY(CheckHRESULT(dxgiAdapter.As(&dxgiAdapter3), "DXGIAdapter retrieval")); DAWN_TRY(CheckHRESULT(dxgiAdapter.As(&dxgiAdapter3), "DXGIAdapter retrieval"));
Ref<Adapter> adapter = AcquireRef(new Adapter(this, std::move(dxgiAdapter3), adapterToggles)); Ref<PhysicalDevice> physicalDevice =
DAWN_TRY(adapter->Initialize()); AcquireRef(new PhysicalDevice(this, std::move(dxgiAdapter3), adapterToggles));
DAWN_TRY(physicalDevice->Initialize());
return {std::move(adapter)}; return {std::move(physicalDevice)};
} }
BackendConnection* Connect(InstanceBase* instance) { BackendConnection* Connect(InstanceBase* instance) {

View File

@ -31,7 +31,7 @@ class Backend : public d3d::Backend {
const PlatformFunctions* GetFunctions() const; const PlatformFunctions* GetFunctions() const;
protected: protected:
ResultOrError<Ref<PhysicalDeviceBase>> CreateAdapterFromIDXGIAdapter( ResultOrError<Ref<PhysicalDeviceBase>> CreatePhysicalDeviceFromIDXGIAdapter(
ComPtr<IDXGIAdapter> dxgiAdapter, ComPtr<IDXGIAdapter> dxgiAdapter,
const TogglesState& adapterToggles) override; const TogglesState& adapterToggles) override;

View File

@ -25,13 +25,13 @@
#include "dawn/native/Instance.h" #include "dawn/native/Instance.h"
#include "dawn/native/d3d/D3DError.h" #include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d/ExternalImageDXGIImpl.h" #include "dawn/native/d3d/ExternalImageDXGIImpl.h"
#include "dawn/native/d3d11/AdapterD3D11.h"
#include "dawn/native/d3d11/BackendD3D11.h" #include "dawn/native/d3d11/BackendD3D11.h"
#include "dawn/native/d3d11/BindGroupD3D11.h" #include "dawn/native/d3d11/BindGroupD3D11.h"
#include "dawn/native/d3d11/BindGroupLayoutD3D11.h" #include "dawn/native/d3d11/BindGroupLayoutD3D11.h"
#include "dawn/native/d3d11/BufferD3D11.h" #include "dawn/native/d3d11/BufferD3D11.h"
#include "dawn/native/d3d11/CommandBufferD3D11.h" #include "dawn/native/d3d11/CommandBufferD3D11.h"
#include "dawn/native/d3d11/ComputePipelineD3D11.h" #include "dawn/native/d3d11/ComputePipelineD3D11.h"
#include "dawn/native/d3d11/PhysicalDeviceD3D11.h"
#include "dawn/native/d3d11/PipelineLayoutD3D11.h" #include "dawn/native/d3d11/PipelineLayoutD3D11.h"
#include "dawn/native/d3d11/PlatformFunctionsD3D11.h" #include "dawn/native/d3d11/PlatformFunctionsD3D11.h"
#include "dawn/native/d3d11/QueueD3D11.h" #include "dawn/native/d3d11/QueueD3D11.h"
@ -90,7 +90,7 @@ void AppendDebugLayerMessagesToError(ID3D11InfoQueue* infoQueue,
} // namespace } // namespace
// static // static
ResultOrError<Ref<Device>> Device::Create(Adapter* adapter, ResultOrError<Ref<Device>> Device::Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor, const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) { const TogglesState& deviceToggles) {
Ref<Device> device = AcquireRef(new Device(adapter, descriptor, deviceToggles)); Ref<Device> device = AcquireRef(new Device(adapter, descriptor, deviceToggles));
@ -99,7 +99,7 @@ ResultOrError<Ref<Device>> Device::Create(Adapter* adapter,
} }
MaybeError Device::Initialize(const DeviceDescriptor* descriptor) { MaybeError Device::Initialize(const DeviceDescriptor* descriptor) {
DAWN_TRY_ASSIGN(mD3d11Device, ToBackend(GetAdapter())->CreateD3D11Device()); DAWN_TRY_ASSIGN(mD3d11Device, ToBackend(GetPhysicalDevice())->CreateD3D11Device());
ASSERT(mD3d11Device != nullptr); ASSERT(mD3d11Device != nullptr);
DAWN_TRY(DeviceBase::Initialize(Queue::Create(this, &descriptor->defaultQueue))); DAWN_TRY(DeviceBase::Initialize(Queue::Create(this, &descriptor->defaultQueue)));
@ -334,7 +334,7 @@ MaybeError Device::CopyFromStagingToTextureImpl(const BufferBase* source,
} }
const DeviceInfo& Device::GetDeviceInfo() const { const DeviceInfo& Device::GetDeviceInfo() const {
return ToBackend(GetAdapter())->GetDeviceInfo(); return ToBackend(GetPhysicalDevice())->GetDeviceInfo();
} }
MaybeError Device::WaitForIdleForDestruction() { MaybeError Device::WaitForIdleForDestruction() {
@ -346,7 +346,7 @@ MaybeError Device::WaitForIdleForDestruction() {
} }
MaybeError Device::CheckDebugLayerAndGenerateErrors() { MaybeError Device::CheckDebugLayerAndGenerateErrors() {
if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled()) { if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled()) {
return {}; return {};
} }
@ -370,7 +370,7 @@ MaybeError Device::CheckDebugLayerAndGenerateErrors() {
} }
void Device::AppendDebugLayerMessages(ErrorData* error) { void Device::AppendDebugLayerMessages(ErrorData* error) {
if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled()) { if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled()) {
return; return;
} }

View File

@ -31,7 +31,7 @@ class Fence;
// Definition of backend types // Definition of backend types
class Device final : public d3d::Device { class Device final : public d3d::Device {
public: public:
static ResultOrError<Ref<Device>> Create(Adapter* adapter, static ResultOrError<Ref<Device>> Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor, const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles); const TogglesState& deviceToggles);
~Device() override; ~Device() override;

View File

@ -21,7 +21,7 @@
namespace dawn::native::d3d11 { namespace dawn::native::d3d11 {
class Adapter; class PhysicalDevice;
struct DeviceInfo { struct DeviceInfo {
bool isUMA; bool isUMA;

View File

@ -19,7 +19,6 @@
namespace dawn::native::d3d11 { namespace dawn::native::d3d11 {
class Adapter;
class BindGroup; class BindGroup;
class BindGroupLayout; class BindGroupLayout;
class Buffer; class Buffer;
@ -27,6 +26,7 @@ class CommandBuffer;
class ComputePipeline; class ComputePipeline;
class Device; class Device;
class Heap; class Heap;
class PhysicalDevice;
class PipelineCache; class PipelineCache;
class PipelineLayout; class PipelineLayout;
class QuerySet; class QuerySet;
@ -39,13 +39,13 @@ class Texture;
class TextureView; class TextureView;
struct D3D11BackendTraits { struct D3D11BackendTraits {
using AdapterType = Adapter;
using BindGroupType = BindGroup; using BindGroupType = BindGroup;
using BindGroupLayoutType = BindGroupLayout; using BindGroupLayoutType = BindGroupLayout;
using BufferType = Buffer; using BufferType = Buffer;
using CommandBufferType = CommandBuffer; using CommandBufferType = CommandBuffer;
using ComputePipelineType = ComputePipeline; using ComputePipelineType = ComputePipeline;
using DeviceType = Device; using DeviceType = Device;
using PhysicalDeviceType = PhysicalDevice;
using PipelineCacheType = PipelineCache; using PipelineCacheType = PipelineCache;
using PipelineLayoutType = PipelineLayout; using PipelineLayoutType = PipelineLayout;
using QuerySetType = QuerySet; using QuerySetType = QuerySet;

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "dawn/native/d3d11/AdapterD3D11.h" #include "dawn/native/d3d11/PhysicalDeviceD3D11.h"
#include <string> #include <string>
#include <utility> #include <utility>
@ -61,23 +61,23 @@ MaybeError InitializeDebugLayerFilters(ComPtr<ID3D11Device> d3d11Device) {
} // namespace } // namespace
Adapter::Adapter(Backend* backend, PhysicalDevice::PhysicalDevice(Backend* backend,
ComPtr<IDXGIAdapter3> hardwareAdapter, ComPtr<IDXGIAdapter3> hardwareAdapter,
const TogglesState& adapterToggles) const TogglesState& adapterToggles)
: Base(backend, std::move(hardwareAdapter), wgpu::BackendType::D3D11, 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. // TODO(dawn:1724): Implement external images on D3D11.
return false; return false;
} }
const DeviceInfo& Adapter::GetDeviceInfo() const { const DeviceInfo& PhysicalDevice::GetDeviceInfo() const {
return mDeviceInfo; return mDeviceInfo;
} }
ResultOrError<ComPtr<ID3D11Device>> Adapter::CreateD3D11Device() { ResultOrError<ComPtr<ID3D11Device>> PhysicalDevice::CreateD3D11Device() {
ComPtr<ID3D11Device> device = std::move(mD3d11Device); ComPtr<ID3D11Device> device = std::move(mD3d11Device);
if (!device) { if (!device) {
const PlatformFunctions* functions = static_cast<Backend*>(GetBackend())->GetFunctions(); const PlatformFunctions* functions = static_cast<Backend*>(GetBackend())->GetFunctions();
@ -102,7 +102,7 @@ ResultOrError<ComPtr<ID3D11Device>> Adapter::CreateD3D11Device() {
return device; return device;
} }
MaybeError Adapter::InitializeImpl() { MaybeError PhysicalDevice::InitializeImpl() {
DAWN_TRY(Base::InitializeImpl()); DAWN_TRY(Base::InitializeImpl());
// D3D11 cannot check for feature support without a device. // D3D11 cannot check for feature support without a device.
// Create the device to populate the adapter properties then reuse it when needed for actual // Create the device to populate the adapter properties then reuse it when needed for actual
@ -121,12 +121,12 @@ MaybeError Adapter::InitializeImpl() {
return {}; return {};
} }
void Adapter::InitializeSupportedFeaturesImpl() { void PhysicalDevice::InitializeSupportedFeaturesImpl() {
EnableFeature(Feature::TextureCompressionBC); EnableFeature(Feature::TextureCompressionBC);
EnableFeature(Feature::SurfaceCapabilities); EnableFeature(Feature::SurfaceCapabilities);
} }
MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) { MaybeError PhysicalDevice::InitializeSupportedLimitsImpl(CombinedLimits* limits) {
GetDefaultLimits(&limits->v1); GetDefaultLimits(&limits->v1);
// // https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels // // https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels
@ -188,18 +188,19 @@ MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) {
return {}; return {};
} }
MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature, MaybeError PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl(
const TogglesState& toggles) const { wgpu::FeatureName feature,
const TogglesState& toggles) const {
return {}; return {};
} }
void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const { void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {
// D3D11 can only clear RTV with float values. // D3D11 can only clear RTV with float values.
deviceToggles->Default(Toggle::ApplyClearBigIntegerColorValueWithDraw, true); deviceToggles->Default(Toggle::ApplyClearBigIntegerColorValueWithDraw, true);
} }
ResultOrError<Ref<DeviceBase>> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor, ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) { const TogglesState& deviceToggles) {
return Device::Create(this, descriptor, deviceToggles); return Device::Create(this, descriptor, deviceToggles);
} }
@ -207,7 +208,7 @@ ResultOrError<Ref<DeviceBase>> Adapter::CreateDeviceImpl(const DeviceDescriptor*
// current ID3D11Device have not been destroyed, a non-zero value will be returned upon Reset() // 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 // and the subequent call to CreateDevice will return a handle the existing device instead of
// creating a new one. // creating a new one.
MaybeError Adapter::ResetInternalDeviceForTestingImpl() { MaybeError PhysicalDevice::ResetInternalDeviceForTestingImpl() {
[[maybe_unused]] auto refCount = mD3d11Device.Reset(); [[maybe_unused]] auto refCount = mD3d11Device.Reset();
ASSERT(refCount == 0); ASSERT(refCount == 0);
DAWN_TRY(Initialize()); DAWN_TRY(Initialize());

View File

@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_DAWN_NATIVE_D3D11_ADAPTERD3D11_H_ #ifndef SRC_DAWN_NATIVE_D3D11_PHYSICALDEVICED3D11_H_
#define SRC_DAWN_NATIVE_D3D11_ADAPTERD3D11_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/d3d/d3d_platform.h"
#include "dawn/native/d3d11/DeviceInfoD3D11.h" #include "dawn/native/d3d11/DeviceInfoD3D11.h"
@ -24,12 +24,12 @@ namespace dawn::native::d3d11 {
class Backend; class Backend;
class Adapter : public d3d::Adapter { class PhysicalDevice : public d3d::PhysicalDevice {
public: public:
Adapter(Backend* backend, PhysicalDevice(Backend* backend,
ComPtr<IDXGIAdapter3> hardwareAdapter, ComPtr<IDXGIAdapter3> hardwareAdapter,
const TogglesState& adapterToggles); const TogglesState& adapterToggles);
~Adapter() override; ~PhysicalDevice() override;
// PhysicalDeviceBase Implementation // PhysicalDeviceBase Implementation
bool SupportsExternalImages() const override; bool SupportsExternalImages() const override;
@ -38,7 +38,7 @@ class Adapter : public d3d::Adapter {
ResultOrError<ComPtr<ID3D11Device>> CreateD3D11Device(); ResultOrError<ComPtr<ID3D11Device>> CreateD3D11Device();
private: private:
using Base = d3d::Adapter; using Base = d3d::PhysicalDevice;
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override; void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
@ -60,4 +60,4 @@ class Adapter : public d3d::Adapter {
} // namespace dawn::native::d3d11 } // namespace dawn::native::d3d11
#endif // SRC_DAWN_NATIVE_D3D11_ADAPTERD3D11_H_ #endif // SRC_DAWN_NATIVE_D3D11_PHYSICALDEVICED3D11_H_

View File

@ -24,10 +24,10 @@
#include "dawn/native/TintUtils.h" #include "dawn/native/TintUtils.h"
#include "dawn/native/d3d/D3DCompilationRequest.h" #include "dawn/native/d3d/D3DCompilationRequest.h"
#include "dawn/native/d3d/D3DError.h" #include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d11/AdapterD3D11.h"
#include "dawn/native/d3d11/BackendD3D11.h" #include "dawn/native/d3d11/BackendD3D11.h"
#include "dawn/native/d3d11/BindGroupLayoutD3D11.h" #include "dawn/native/d3d11/BindGroupLayoutD3D11.h"
#include "dawn/native/d3d11/DeviceD3D11.h" #include "dawn/native/d3d11/DeviceD3D11.h"
#include "dawn/native/d3d11/PhysicalDeviceD3D11.h"
#include "dawn/native/d3d11/PipelineLayoutD3D11.h" #include "dawn/native/d3d11/PipelineLayoutD3D11.h"
#include "dawn/native/d3d11/PlatformFunctionsD3D11.h" #include "dawn/native/d3d11/PlatformFunctionsD3D11.h"
#include "dawn/native/d3d11/UtilsD3D11.h" #include "dawn/native/d3d11/UtilsD3D11.h"

View File

@ -21,7 +21,7 @@
#include "dawn/native/D3D12Backend.h" #include "dawn/native/D3D12Backend.h"
#include "dawn/native/Instance.h" #include "dawn/native/Instance.h"
#include "dawn/native/d3d/D3DError.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/PlatformFunctionsD3D12.h"
#include "dawn/native/d3d12/UtilsD3D12.h" #include "dawn/native/d3d12/UtilsD3D12.h"
@ -63,15 +63,16 @@ const PlatformFunctions* Backend::GetFunctions() const {
return static_cast<const PlatformFunctions*>(Base::GetFunctions()); return static_cast<const PlatformFunctions*>(Base::GetFunctions());
} }
ResultOrError<Ref<PhysicalDeviceBase>> Backend::CreateAdapterFromIDXGIAdapter( ResultOrError<Ref<PhysicalDeviceBase>> Backend::CreatePhysicalDeviceFromIDXGIAdapter(
ComPtr<IDXGIAdapter> dxgiAdapter, ComPtr<IDXGIAdapter> dxgiAdapter,
const TogglesState& adapterToggles) { const TogglesState& adapterToggles) {
ComPtr<IDXGIAdapter3> dxgiAdapter3; ComPtr<IDXGIAdapter3> dxgiAdapter3;
DAWN_TRY(CheckHRESULT(dxgiAdapter.As(&dxgiAdapter3), "DXGIAdapter retrieval")); DAWN_TRY(CheckHRESULT(dxgiAdapter.As(&dxgiAdapter3), "DXGIAdapter retrieval"));
Ref<Adapter> adapter = AcquireRef(new Adapter(this, std::move(dxgiAdapter3), adapterToggles)); Ref<PhysicalDevice> physicalDevice =
DAWN_TRY(adapter->Initialize()); AcquireRef(new PhysicalDevice(this, std::move(dxgiAdapter3), adapterToggles));
DAWN_TRY(physicalDevice->Initialize());
return {std::move(adapter)}; return {std::move(physicalDevice)};
} }
BackendConnection* Connect(InstanceBase* instance) { BackendConnection* Connect(InstanceBase* instance) {

View File

@ -35,7 +35,7 @@ class Backend final : public d3d::Backend {
const PlatformFunctions* GetFunctions() const; const PlatformFunctions* GetFunctions() const;
protected: protected:
ResultOrError<Ref<PhysicalDeviceBase>> CreateAdapterFromIDXGIAdapter( ResultOrError<Ref<PhysicalDeviceBase>> CreatePhysicalDeviceFromIDXGIAdapter(
ComPtr<IDXGIAdapter> dxgiAdapter, ComPtr<IDXGIAdapter> dxgiAdapter,
const TogglesState& adapterToggles) override; const TogglesState& adapterToggles) override;

View File

@ -18,13 +18,13 @@
#include "dawn/common/GPUInfo.h" #include "dawn/common/GPUInfo.h"
#include "dawn/native/d3d/D3DError.h" #include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/AdapterD3D12.h"
#include "dawn/native/d3d12/BackendD3D12.h" #include "dawn/native/d3d12/BackendD3D12.h"
#include "dawn/native/d3d12/PhysicalDeviceD3D12.h"
#include "dawn/native/d3d12/PlatformFunctionsD3D12.h" #include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
namespace dawn::native::d3d12 { namespace dawn::native::d3d12 {
ResultOrError<D3D12DeviceInfo> GatherDeviceInfo(const Adapter& adapter) { ResultOrError<D3D12DeviceInfo> GatherDeviceInfo(const PhysicalDevice& physicalDevice) {
D3D12DeviceInfo info = {}; D3D12DeviceInfo info = {};
// Newer builds replace D3D_FEATURE_DATA_ARCHITECTURE with // Newer builds replace D3D_FEATURE_DATA_ARCHITECTURE with
@ -32,26 +32,26 @@ ResultOrError<D3D12DeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
// for backwards compat. // for backwards compat.
// https://docs.microsoft.com/en-us/windows/desktop/api/d3d12/ne-d3d12-d3d12_feature // https://docs.microsoft.com/en-us/windows/desktop/api/d3d12/ne-d3d12-d3d12_feature
D3D12_FEATURE_DATA_ARCHITECTURE arch = {}; D3D12_FEATURE_DATA_ARCHITECTURE arch = {};
DAWN_TRY(CheckHRESULT( DAWN_TRY(CheckHRESULT(physicalDevice.GetDevice()->CheckFeatureSupport(
adapter.GetDevice()->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &arch, sizeof(arch)), D3D12_FEATURE_ARCHITECTURE, &arch, sizeof(arch)),
"ID3D12Device::CheckFeatureSupport")); "ID3D12Device::CheckFeatureSupport"));
info.isUMA = arch.UMA; info.isUMA = arch.UMA;
D3D12_FEATURE_DATA_D3D12_OPTIONS featureOptions = {}; 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)), D3D12_FEATURE_D3D12_OPTIONS, &featureOptions, sizeof(featureOptions)),
"ID3D12Device::CheckFeatureSupport")); "ID3D12Device::CheckFeatureSupport"));
info.resourceHeapTier = featureOptions.ResourceHeapTier; info.resourceHeapTier = featureOptions.ResourceHeapTier;
D3D12_FEATURE_DATA_D3D12_OPTIONS2 featureOptions2 = {}; D3D12_FEATURE_DATA_D3D12_OPTIONS2 featureOptions2 = {};
if (SUCCEEDED(adapter.GetDevice()->CheckFeatureSupport( if (SUCCEEDED(physicalDevice.GetDevice()->CheckFeatureSupport(
D3D12_FEATURE_D3D12_OPTIONS2, &featureOptions2, sizeof(featureOptions2)))) { D3D12_FEATURE_D3D12_OPTIONS2, &featureOptions2, sizeof(featureOptions2)))) {
info.programmableSamplePositionsTier = featureOptions2.ProgrammableSamplePositionsTier; info.programmableSamplePositionsTier = featureOptions2.ProgrammableSamplePositionsTier;
} }
D3D12_FEATURE_DATA_D3D12_OPTIONS3 featureOptions3 = {}; D3D12_FEATURE_DATA_D3D12_OPTIONS3 featureOptions3 = {};
if (SUCCEEDED(adapter.GetDevice()->CheckFeatureSupport( if (SUCCEEDED(physicalDevice.GetDevice()->CheckFeatureSupport(
D3D12_FEATURE_D3D12_OPTIONS3, &featureOptions3, sizeof(featureOptions3)))) { D3D12_FEATURE_D3D12_OPTIONS3, &featureOptions3, sizeof(featureOptions3)))) {
info.supportsCastingFullyTypedFormat = featureOptions3.CastingFullyTypedFormatSupported; info.supportsCastingFullyTypedFormat = featureOptions3.CastingFullyTypedFormatSupported;
} }
@ -60,7 +60,7 @@ ResultOrError<D3D12DeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
// D3D12_FEATURE_D3D12_OPTIONS4 successfully, then we can use cross-API sharing. // D3D12_FEATURE_D3D12_OPTIONS4 successfully, then we can use cross-API sharing.
info.supportsSharedResourceCapabilityTier1 = false; info.supportsSharedResourceCapabilityTier1 = false;
D3D12_FEATURE_DATA_D3D12_OPTIONS4 featureOptions4 = {}; D3D12_FEATURE_DATA_D3D12_OPTIONS4 featureOptions4 = {};
if (SUCCEEDED(adapter.GetDevice()->CheckFeatureSupport( if (SUCCEEDED(physicalDevice.GetDevice()->CheckFeatureSupport(
D3D12_FEATURE_D3D12_OPTIONS4, &featureOptions4, sizeof(featureOptions4)))) { D3D12_FEATURE_D3D12_OPTIONS4, &featureOptions4, sizeof(featureOptions4)))) {
// Tier 1 support additionally enables the NV12 format. Since only the NV12 format // Tier 1 support additionally enables the NV12 format. Since only the NV12 format
// is used by Dawn, check for Tier 1. // is used by Dawn, check for Tier 1.
@ -75,13 +75,13 @@ ResultOrError<D3D12DeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
// the render pass API. // the render pass API.
info.supportsRenderPass = false; info.supportsRenderPass = false;
D3D12_FEATURE_DATA_D3D12_OPTIONS5 featureOptions5 = {}; D3D12_FEATURE_DATA_D3D12_OPTIONS5 featureOptions5 = {};
if (SUCCEEDED(adapter.GetDevice()->CheckFeatureSupport( if (SUCCEEDED(physicalDevice.GetDevice()->CheckFeatureSupport(
D3D12_FEATURE_D3D12_OPTIONS5, &featureOptions5, sizeof(featureOptions5)))) { D3D12_FEATURE_D3D12_OPTIONS5, &featureOptions5, sizeof(featureOptions5)))) {
// Performance regressions been observed when using a render pass on Intel graphics // 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 // with RENDER_PASS_TIER_1 available, so fall back to a software emulated render
// pass on these platforms. // pass on these platforms.
if (featureOptions5.RenderPassesTier < D3D12_RENDER_PASS_TIER_1 || if (featureOptions5.RenderPassesTier < D3D12_RENDER_PASS_TIER_1 ||
!gpu_info::IsIntel(adapter.GetVendorId())) { !gpu_info::IsIntel(physicalDevice.GetVendorId())) {
info.supportsRenderPass = true; info.supportsRenderPass = true;
} }
} }
@ -91,7 +91,7 @@ ResultOrError<D3D12DeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
{D3D_SHADER_MODEL_6_1}, {D3D_SHADER_MODEL_6_0}, {D3D_SHADER_MODEL_5_1}}; {D3D_SHADER_MODEL_6_1}, {D3D_SHADER_MODEL_6_0}, {D3D_SHADER_MODEL_5_1}};
uint32_t driverShaderModel = 0; uint32_t driverShaderModel = 0;
for (D3D12_FEATURE_DATA_SHADER_MODEL shaderModel : knownShaderModels) { 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)))) { D3D12_FEATURE_SHADER_MODEL, &shaderModel, sizeof(shaderModel)))) {
driverShaderModel = shaderModel.HighestShaderModel; driverShaderModel = shaderModel.HighestShaderModel;
break; break;

View File

@ -21,7 +21,7 @@
namespace dawn::native::d3d12 { namespace dawn::native::d3d12 {
class Adapter; class PhysicalDevice;
struct D3D12DeviceInfo { struct D3D12DeviceInfo {
bool isUMA; bool isUMA;
@ -38,7 +38,7 @@ struct D3D12DeviceInfo {
uint32_t programmableSamplePositionsTier; uint32_t programmableSamplePositionsTier;
}; };
ResultOrError<D3D12DeviceInfo> GatherDeviceInfo(const Adapter& adapter); ResultOrError<D3D12DeviceInfo> GatherDeviceInfo(const PhysicalDevice& physicalDevice);
} // namespace dawn::native::d3d12 } // namespace dawn::native::d3d12
#endif // SRC_DAWN_NATIVE_D3D12_D3D12INFO_H_ #endif // SRC_DAWN_NATIVE_D3D12_D3D12INFO_H_

View File

@ -24,7 +24,6 @@
#include "dawn/native/DynamicUploader.h" #include "dawn/native/DynamicUploader.h"
#include "dawn/native/Instance.h" #include "dawn/native/Instance.h"
#include "dawn/native/d3d/D3DError.h" #include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/AdapterD3D12.h"
#include "dawn/native/d3d12/BackendD3D12.h" #include "dawn/native/d3d12/BackendD3D12.h"
#include "dawn/native/d3d12/BindGroupD3D12.h" #include "dawn/native/d3d12/BindGroupD3D12.h"
#include "dawn/native/d3d12/BindGroupLayoutD3D12.h" #include "dawn/native/d3d12/BindGroupLayoutD3D12.h"
@ -32,6 +31,7 @@
#include "dawn/native/d3d12/CommandBufferD3D12.h" #include "dawn/native/d3d12/CommandBufferD3D12.h"
#include "dawn/native/d3d12/ComputePipelineD3D12.h" #include "dawn/native/d3d12/ComputePipelineD3D12.h"
#include "dawn/native/d3d12/ExternalImageDXGIImplD3D12.h" #include "dawn/native/d3d12/ExternalImageDXGIImplD3D12.h"
#include "dawn/native/d3d12/PhysicalDeviceD3D12.h"
#include "dawn/native/d3d12/PipelineLayoutD3D12.h" #include "dawn/native/d3d12/PipelineLayoutD3D12.h"
#include "dawn/native/d3d12/PlatformFunctionsD3D12.h" #include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
#include "dawn/native/d3d12/QuerySetD3D12.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 constexpr uint64_t kMaxDebugMessagesToPrint = 5;
// static // static
ResultOrError<Ref<Device>> Device::Create(Adapter* adapter, ResultOrError<Ref<Device>> Device::Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor, const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) { const TogglesState& deviceToggles) {
Ref<Device> device = AcquireRef(new Device(adapter, descriptor, deviceToggles)); Ref<Device> device = AcquireRef(new Device(adapter, descriptor, deviceToggles));
@ -70,7 +70,7 @@ ResultOrError<Ref<Device>> Device::Create(Adapter* adapter,
} }
MaybeError Device::Initialize(const DeviceDescriptor* descriptor) { MaybeError Device::Initialize(const DeviceDescriptor* descriptor) {
mD3d12Device = ToBackend(GetAdapter())->GetDevice(); mD3d12Device = ToBackend(GetPhysicalDevice())->GetDevice();
ASSERT(mD3d12Device != nullptr); ASSERT(mD3d12Device != nullptr);
@ -233,17 +233,17 @@ ComPtr<ID3D12CommandSignature> Device::GetDrawIndexedIndirectSignature() const {
// Ensure DXC if use_dxc toggles are set and validated. // Ensure DXC if use_dxc toggles are set and validated.
MaybeError Device::EnsureDXCIfRequired() { MaybeError Device::EnsureDXCIfRequired() {
if (IsToggleEnabled(Toggle::UseDXC)) { if (IsToggleEnabled(Toggle::UseDXC)) {
ASSERT(ToBackend(GetAdapter())->GetBackend()->IsDXCAvailable()); ASSERT(ToBackend(GetPhysicalDevice())->GetBackend()->IsDXCAvailable());
DAWN_TRY(ToBackend(GetAdapter())->GetBackend()->EnsureDxcCompiler()); DAWN_TRY(ToBackend(GetPhysicalDevice())->GetBackend()->EnsureDxcCompiler());
DAWN_TRY(ToBackend(GetAdapter())->GetBackend()->EnsureDxcLibrary()); DAWN_TRY(ToBackend(GetPhysicalDevice())->GetBackend()->EnsureDxcLibrary());
DAWN_TRY(ToBackend(GetAdapter())->GetBackend()->EnsureDxcValidator()); DAWN_TRY(ToBackend(GetPhysicalDevice())->GetBackend()->EnsureDxcValidator());
} }
return {}; return {};
} }
const PlatformFunctions* Device::GetFunctions() const { const PlatformFunctions* Device::GetFunctions() const {
return ToBackend(GetAdapter())->GetBackend()->GetFunctions(); return ToBackend(GetPhysicalDevice())->GetBackend()->GetFunctions();
} }
CommandAllocatorManager* Device::GetCommandAllocatorManager() const { CommandAllocatorManager* Device::GetCommandAllocatorManager() const {
@ -608,7 +608,7 @@ Ref<TextureBase> Device::CreateD3D12ExternalTexture(const TextureDescriptor* des
} }
const D3D12DeviceInfo& Device::GetDeviceInfo() const { const D3D12DeviceInfo& Device::GetDeviceInfo() const {
return ToBackend(GetAdapter())->GetDeviceInfo(); return ToBackend(GetPhysicalDevice())->GetDeviceInfo();
} }
MaybeError Device::WaitForIdleForDestruction() { MaybeError Device::WaitForIdleForDestruction() {
@ -662,7 +662,7 @@ void AppendDebugLayerMessagesToError(ID3D12InfoQueue* infoQueue,
} }
MaybeError Device::CheckDebugLayerAndGenerateErrors() { MaybeError Device::CheckDebugLayerAndGenerateErrors() {
if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled()) { if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled()) {
return {}; return {};
} }
@ -686,7 +686,7 @@ MaybeError Device::CheckDebugLayerAndGenerateErrors() {
} }
void Device::AppendDebugLayerMessages(ErrorData* error) { void Device::AppendDebugLayerMessages(ErrorData* error) {
if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled()) { if (!GetPhysicalDevice()->GetInstance()->IsBackendValidationEnabled()) {
return; return;
} }

View File

@ -49,7 +49,7 @@ class StagingDescriptorAllocator;
// Definition of backend types // Definition of backend types
class Device final : public d3d::Device { class Device final : public d3d::Device {
public: public:
static ResultOrError<Ref<Device>> Create(Adapter* adapter, static ResultOrError<Ref<Device>> Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor, const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles); const TogglesState& deviceToggles);
~Device() override; ~Device() override;

View File

@ -19,7 +19,6 @@
namespace dawn::native::d3d12 { namespace dawn::native::d3d12 {
class Adapter;
class BindGroup; class BindGroup;
class BindGroupLayout; class BindGroupLayout;
class Buffer; class Buffer;
@ -27,6 +26,7 @@ class CommandBuffer;
class ComputePipeline; class ComputePipeline;
class Device; class Device;
class Heap; class Heap;
class PhysicalDevice;
class PipelineCache; class PipelineCache;
class PipelineLayout; class PipelineLayout;
class QuerySet; class QuerySet;
@ -39,13 +39,13 @@ class Texture;
class TextureView; class TextureView;
struct D3D12BackendTraits { struct D3D12BackendTraits {
using AdapterType = Adapter;
using BindGroupType = BindGroup; using BindGroupType = BindGroup;
using BindGroupLayoutType = BindGroupLayout; using BindGroupLayoutType = BindGroupLayout;
using BufferType = Buffer; using BufferType = Buffer;
using CommandBufferType = CommandBuffer; using CommandBufferType = CommandBuffer;
using ComputePipelineType = ComputePipeline; using ComputePipelineType = ComputePipeline;
using DeviceType = Device; using DeviceType = Device;
using PhysicalDeviceType = PhysicalDevice;
using PipelineCacheType = PipelineCache; using PipelineCacheType = PipelineCache;
using PipelineLayoutType = PipelineLayout; using PipelineLayoutType = PipelineLayout;
using QuerySetType = QuerySet; using QuerySetType = QuerySet;

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "dawn/native/d3d12/AdapterD3D12.h" #include "dawn/native/d3d12/PhysicalDeviceD3D12.h"
#include <string> #include <string>
#include <utility> #include <utility>
@ -29,33 +29,33 @@
namespace dawn::native::d3d12 { namespace dawn::native::d3d12 {
Adapter::Adapter(Backend* backend, PhysicalDevice::PhysicalDevice(Backend* backend,
ComPtr<IDXGIAdapter3> hardwareAdapter, ComPtr<IDXGIAdapter3> hardwareAdapter,
const TogglesState& adapterToggles) const TogglesState& adapterToggles)
: Base(backend, std::move(hardwareAdapter), wgpu::BackendType::D3D12, adapterToggles) {} : Base(backend, std::move(hardwareAdapter), wgpu::BackendType::D3D12, adapterToggles) {}
Adapter::~Adapter() { PhysicalDevice::~PhysicalDevice() {
CleanUpDebugLayerFilters(); CleanUpDebugLayerFilters();
} }
bool Adapter::SupportsExternalImages() const { bool PhysicalDevice::SupportsExternalImages() const {
// Via dawn::native::d3d12::ExternalImageDXGI::Create // Via dawn::native::d3d12::ExternalImageDXGI::Create
return true; return true;
} }
const D3D12DeviceInfo& Adapter::GetDeviceInfo() const { const D3D12DeviceInfo& PhysicalDevice::GetDeviceInfo() const {
return mDeviceInfo; return mDeviceInfo;
} }
Backend* Adapter::GetBackend() const { Backend* PhysicalDevice::GetBackend() const {
return static_cast<Backend*>(Base::GetBackend()); return static_cast<Backend*>(Base::GetBackend());
} }
ComPtr<ID3D12Device> Adapter::GetDevice() const { ComPtr<ID3D12Device> PhysicalDevice::GetDevice() const {
return mD3d12Device; return mD3d12Device;
} }
MaybeError Adapter::InitializeImpl() { MaybeError PhysicalDevice::InitializeImpl() {
DAWN_TRY(Base::InitializeImpl()); DAWN_TRY(Base::InitializeImpl());
// D3D12 cannot check for feature support without a device. // D3D12 cannot check for feature support without a device.
// Create the device to populate the adapter properties then reuse it when needed for actual // Create the device to populate the adapter properties then reuse it when needed for actual
@ -93,7 +93,7 @@ MaybeError Adapter::InitializeImpl() {
return {}; return {};
} }
bool Adapter::AreTimestampQueriesSupported() const { bool PhysicalDevice::AreTimestampQueriesSupported() const {
D3D12_COMMAND_QUEUE_DESC queueDesc = {}; D3D12_COMMAND_QUEUE_DESC queueDesc = {};
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
@ -114,7 +114,7 @@ bool Adapter::AreTimestampQueriesSupported() const {
return true; return true;
} }
void Adapter::InitializeSupportedFeaturesImpl() { void PhysicalDevice::InitializeSupportedFeaturesImpl() {
EnableFeature(Feature::TextureCompressionBC); EnableFeature(Feature::TextureCompressionBC);
EnableFeature(Feature::MultiPlanarFormats); EnableFeature(Feature::MultiPlanarFormats);
EnableFeature(Feature::Depth32FloatStencil8); 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 = {}; D3D12_FEATURE_DATA_D3D12_OPTIONS featureData = {};
DAWN_TRY(CheckHRESULT(mD3d12Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, DAWN_TRY(CheckHRESULT(mD3d12Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS,
@ -320,8 +320,9 @@ MaybeError Adapter::InitializeSupportedLimitsImpl(CombinedLimits* limits) {
return {}; return {};
} }
MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName feature, MaybeError PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl(
const TogglesState& toggles) const { wgpu::FeatureName feature,
const TogglesState& toggles) const {
// shader-f16 feature and chromium-experimental-dp4a feature require DXC 1.4 or higher for // shader-f16 feature and chromium-experimental-dp4a feature require DXC 1.4 or higher for
// D3D12. Note that DXC version is checked in InitializeSupportedFeaturesImpl. // D3D12. Note that DXC version is checked in InitializeSupportedFeaturesImpl.
if (feature == wgpu::FeatureName::ShaderF16 || if (feature == wgpu::FeatureName::ShaderF16 ||
@ -332,7 +333,7 @@ MaybeError Adapter::ValidateFeatureSupportedWithTogglesImpl(wgpu::FeatureName fe
return {}; return {};
} }
MaybeError Adapter::InitializeDebugLayerFilters() { MaybeError PhysicalDevice::InitializeDebugLayerFilters() {
if (!GetInstance()->IsBackendValidationEnabled()) { if (!GetInstance()->IsBackendValidationEnabled()) {
return {}; return {};
} }
@ -423,7 +424,7 @@ MaybeError Adapter::InitializeDebugLayerFilters() {
return {}; return {};
} }
void Adapter::CleanUpDebugLayerFilters() { void PhysicalDevice::CleanUpDebugLayerFilters() {
if (!GetInstance()->IsBackendValidationEnabled()) { if (!GetInstance()->IsBackendValidationEnabled()) {
return; return;
} }
@ -443,7 +444,7 @@ void Adapter::CleanUpDebugLayerFilters() {
infoQueue->PopStorageFilter(); infoQueue->PopStorageFilter();
} }
void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const { void PhysicalDevice::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {
const bool useResourceHeapTier2 = (GetDeviceInfo().resourceHeapTier >= 2); const bool useResourceHeapTier2 = (GetDeviceInfo().resourceHeapTier >= 2);
deviceToggles->Default(Toggle::UseD3D12ResourceHeapTier2, useResourceHeapTier2); deviceToggles->Default(Toggle::UseD3D12ResourceHeapTier2, useResourceHeapTier2);
deviceToggles->Default(Toggle::UseD3D12RenderPass, GetDeviceInfo().supportsRenderPass); deviceToggles->Default(Toggle::UseD3D12RenderPass, GetDeviceInfo().supportsRenderPass);
@ -578,8 +579,8 @@ void Adapter::SetupBackendDeviceToggles(TogglesState* deviceToggles) const {
} }
} }
ResultOrError<Ref<DeviceBase>> Adapter::CreateDeviceImpl(const DeviceDescriptor* descriptor, ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) { const TogglesState& deviceToggles) {
return Device::Create(this, descriptor, deviceToggles); return Device::Create(this, descriptor, deviceToggles);
} }
@ -587,7 +588,7 @@ ResultOrError<Ref<DeviceBase>> Adapter::CreateDeviceImpl(const DeviceDescriptor*
// current ID3D12Device have not been destroyed, a non-zero value will be returned upon Reset() // 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 // and the subequent call to CreateDevice will return a handle the existing device instead of
// creating a new one. // creating a new one.
MaybeError Adapter::ResetInternalDeviceForTestingImpl() { MaybeError PhysicalDevice::ResetInternalDeviceForTestingImpl() {
[[maybe_unused]] auto refCount = mD3d12Device.Reset(); [[maybe_unused]] auto refCount = mD3d12Device.Reset();
ASSERT(refCount == 0); ASSERT(refCount == 0);
DAWN_TRY(Initialize()); DAWN_TRY(Initialize());

View File

@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_DAWN_NATIVE_D3D12_ADAPTERD3D12_H_ #ifndef SRC_DAWN_NATIVE_D3D12_PHYSICALDEVICED3D12_H_
#define SRC_DAWN_NATIVE_D3D12_ADAPTERD3D12_H_ #define SRC_DAWN_NATIVE_D3D12_PHYSICALDEVICED3D12_H_
#include "dawn/native/PhysicalDevice.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/D3D12Info.h"
#include "dawn/native/d3d12/d3d12_platform.h" #include "dawn/native/d3d12/d3d12_platform.h"
@ -25,12 +25,12 @@ namespace dawn::native::d3d12 {
class Backend; class Backend;
class Adapter : public d3d::Adapter { class PhysicalDevice : public d3d::PhysicalDevice {
public: public:
Adapter(Backend* backend, PhysicalDevice(Backend* backend,
ComPtr<IDXGIAdapter3> hardwareAdapter, ComPtr<IDXGIAdapter3> hardwareAdapter,
const TogglesState& adapterToggles); const TogglesState& adapterToggles);
~Adapter() override; ~PhysicalDevice() override;
// PhysicalDeviceBase Implementation // PhysicalDeviceBase Implementation
bool SupportsExternalImages() const override; bool SupportsExternalImages() const override;
@ -40,7 +40,7 @@ class Adapter : public d3d::Adapter {
ComPtr<ID3D12Device> GetDevice() const; ComPtr<ID3D12Device> GetDevice() const;
private: private:
using Base = d3d::Adapter; using Base = d3d::PhysicalDevice;
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override; void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
@ -68,4 +68,4 @@ class Adapter : public d3d::Adapter {
} // namespace dawn::native::d3d12 } // namespace dawn::native::d3d12
#endif // SRC_DAWN_NATIVE_D3D12_ADAPTERD3D12_H_ #endif // SRC_DAWN_NATIVE_D3D12_PHYSICALDEVICED3D12_H_

View File

@ -18,10 +18,10 @@
#include <vector> #include <vector>
#include "dawn/native/d3d/D3DError.h" #include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/AdapterD3D12.h"
#include "dawn/native/d3d12/DeviceD3D12.h" #include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/Forward.h" #include "dawn/native/d3d12/Forward.h"
#include "dawn/native/d3d12/HeapD3D12.h" #include "dawn/native/d3d12/HeapD3D12.h"
#include "dawn/native/d3d12/PhysicalDeviceD3D12.h"
namespace dawn::native::d3d12 { namespace dawn::native::d3d12 {

View File

@ -24,10 +24,10 @@
#include "dawn/native/TintUtils.h" #include "dawn/native/TintUtils.h"
#include "dawn/native/d3d/D3DCompilationRequest.h" #include "dawn/native/d3d/D3DCompilationRequest.h"
#include "dawn/native/d3d/D3DError.h" #include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/AdapterD3D12.h"
#include "dawn/native/d3d12/BackendD3D12.h" #include "dawn/native/d3d12/BackendD3D12.h"
#include "dawn/native/d3d12/BindGroupLayoutD3D12.h" #include "dawn/native/d3d12/BindGroupLayoutD3D12.h"
#include "dawn/native/d3d12/DeviceD3D12.h" #include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/PhysicalDeviceD3D12.h"
#include "dawn/native/d3d12/PipelineLayoutD3D12.h" #include "dawn/native/d3d12/PipelineLayoutD3D12.h"
#include "dawn/native/d3d12/PlatformFunctionsD3D12.h" #include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
#include "dawn/native/d3d12/UtilsD3D12.h" #include "dawn/native/d3d12/UtilsD3D12.h"

View File

@ -39,13 +39,13 @@ class Texture;
class TextureView; class TextureView;
struct VulkanBackendTraits { struct VulkanBackendTraits {
using AdapterType = Adapter;
using BindGroupType = BindGroup; using BindGroupType = BindGroup;
using BindGroupLayoutType = BindGroupLayout; using BindGroupLayoutType = BindGroupLayout;
using BufferType = Buffer; using BufferType = Buffer;
using CommandBufferType = CommandBuffer; using CommandBufferType = CommandBuffer;
using ComputePipelineType = ComputePipeline; using ComputePipelineType = ComputePipeline;
using DeviceType = Device; using DeviceType = Device;
using PhysicalDeviceType = Adapter;
using PipelineCacheType = PipelineCache; using PipelineCacheType = PipelineCache;
using PipelineLayoutType = PipelineLayout; using PipelineLayoutType = PipelineLayout;
using QuerySetType = QuerySet; using QuerySetType = QuerySet;