From 456852b4c2f59f7b9b33729ce0b54e73929dc9dd Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Fri, 3 Nov 2023 15:01:00 -0700 Subject: [PATCH] Merge pull request #14 from fdwr/npu-enabled For NPU, use D3D feature level core, switch to command list type COMPUTE, and re-enable DXCore over DXGI --- content/browser/ml/webnn/dml/adapter_dml.cc | 2 +- content/browser/ml/webnn/dml/command_queue.cc | 2 +- content/browser/ml/webnn/dml/command_recorder.cc | 4 ++-- content/browser/ml/webnn/dml/webnn_service_dml_impl.cc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/content/browser/ml/webnn/dml/adapter_dml.cc b/content/browser/ml/webnn/dml/adapter_dml.cc index a82a17d53e79ef..dea25385b02335 100644 --- a/content/browser/ml/webnn/dml/adapter_dml.cc +++ b/content/browser/ml/webnn/dml/adapter_dml.cc @@ -23,7 +23,7 @@ HRESULT AdapterDML::Initialize() { IUnknown* dxgi_adapter = hardware_adapter_.Get(); IUnknown* adapter = dxcore_adapter ? dxcore_adapter : dxgi_adapter; HRESULT hr = - D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0, + D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_1_0_CORE, IID_PPV_ARGS(&d3d12_device_)); if (FAILED(hr)) { return hr; diff --git a/content/browser/ml/webnn/dml/command_queue.cc b/content/browser/ml/webnn/dml/command_queue.cc index d62aeed0b04dea..430ca1e04dea55 100644 --- a/content/browser/ml/webnn/dml/command_queue.cc +++ b/content/browser/ml/webnn/dml/command_queue.cc @@ -15,7 +15,7 @@ CommandQueue::~CommandQueue() = default; HRESULT CommandQueue::Initialize(ID3D12Device* d3d12_device) { D3D12_COMMAND_QUEUE_DESC command_queue_desc = {}; - command_queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; + command_queue_desc.Type = D3D12_COMMAND_LIST_TYPE_COMPUTE; command_queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; HRESULT hr = d3d12_device->CreateCommandQueue(&command_queue_desc, IID_PPV_ARGS(&command_queue_)); diff --git a/content/browser/ml/webnn/dml/command_recorder.cc b/content/browser/ml/webnn/dml/command_recorder.cc index c59cf54070190a..8f9d8e2c768ba8 100644 --- a/content/browser/ml/webnn/dml/command_recorder.cc +++ b/content/browser/ml/webnn/dml/command_recorder.cc @@ -37,13 +37,13 @@ HRESULT CommandRecorder::Initialize() { return hr; } - hr = d3d12_device_->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, + hr = d3d12_device_->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_COMPUTE, IID_PPV_ARGS(&command_allocator_)); if (FAILED(hr)) { return hr; } - hr = d3d12_device_->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, + hr = d3d12_device_->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_COMPUTE, command_allocator_.Get(), nullptr, IID_PPV_ARGS(&command_list_)); if (FAILED(hr)) { diff --git a/content/browser/ml/webnn/dml/webnn_service_dml_impl.cc b/content/browser/ml/webnn/dml/webnn_service_dml_impl.cc index 6b01cc0b35895a..a114774127045a 100644 --- a/content/browser/ml/webnn/dml/webnn_service_dml_impl.cc +++ b/content/browser/ml/webnn/dml/webnn_service_dml_impl.cc @@ -26,7 +26,7 @@ std::map> EnumerateAdapters(base::ScopedN // DXCore is optional as it was missing in older Windows 10 versions. // It's needed for MDCM devices (NPU's) which are not enumerable via DXGI. - if (((false) && dxcore_library.is_valid())) { + if (dxcore_library.is_valid()) { // Disambiguate primary function from the templated overload. using DXCoreCreateAdapterFactoryProc = decltype(static_cast(