Skip to content

Commit

Permalink
Merge pull request #14 from fdwr/npu-enabled
Browse files Browse the repository at this point in the history
For NPU, use D3D feature level core, switch to command list type COMPUTE, and re-enable DXCore over DXGI
  • Loading branch information
fdwr committed Nov 6, 2023
1 parent a0fe3a5 commit 456852b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion content/browser/ml/webnn/dml/adapter_dml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion content/browser/ml/webnn/dml/command_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_));
Expand Down
4 changes: 2 additions & 2 deletions content/browser/ml/webnn/dml/command_recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion content/browser/ml/webnn/dml/webnn_service_dml_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ std::map<AdapterType, scoped_refptr<AdapterDML>> 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<STDMETHODIMP (*)(REFIID, void**)>(
Expand Down

0 comments on commit 456852b

Please sign in to comment.