Commit 25cbec5c authored by Natasha Lee's avatar Natasha Lee Committed by Chromium LUCI CQ

Have Chromium give Dawn the current IDXGIAdapter

This helps Dawn create a dawn adapter using the given IDXGIAdapter
instead of loading every single backend and adapter available.

Bug: chromium:1036711
Change-Id: I67ef16b64393aa3521bbf188af7d9f5121480e7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2296011
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: default avatarRafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Reviewed-by: default avatarKai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832612}
parent c5a972ef
...@@ -30,6 +30,11 @@ ...@@ -30,6 +30,11 @@
#include "gpu/config/gpu_preferences.h" #include "gpu/config/gpu_preferences.h"
#include "ipc/ipc_channel.h" #include "ipc/ipc_channel.h"
#if defined(OS_WIN)
#include <dawn_native/D3D12Backend.h>
#include "ui/gl/gl_angle_util_win.h"
#endif
namespace gpu { namespace gpu {
namespace webgpu { namespace webgpu {
...@@ -698,26 +703,29 @@ error::Error WebGPUDecoderImpl::InitDawnDeviceAndSetWireServer( ...@@ -698,26 +703,29 @@ error::Error WebGPUDecoderImpl::InitDawnDeviceAndSetWireServer(
} }
void WebGPUDecoderImpl::DiscoverAdapters() { void WebGPUDecoderImpl::DiscoverAdapters() {
#if defined(OS_WIN)
Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device =
gl::QueryD3D11DeviceObjectFromANGLE();
if (!d3d11_device) {
// In the case where the d3d11 device is nullptr, we want to return a null
// adapter
return;
}
Microsoft::WRL::ComPtr<IDXGIDevice> dxgi_device;
d3d11_device.As(&dxgi_device);
Microsoft::WRL::ComPtr<IDXGIAdapter> dxgi_adapter;
dxgi_device->GetAdapter(&dxgi_adapter);
dawn_native::d3d12::AdapterDiscoveryOptions options(std::move(dxgi_adapter));
dawn_instance_->DiscoverAdapters(&options);
#else
dawn_instance_->DiscoverDefaultAdapters(); dawn_instance_->DiscoverDefaultAdapters();
#endif
std::vector<dawn_native::Adapter> adapters = dawn_instance_->GetAdapters(); std::vector<dawn_native::Adapter> adapters = dawn_instance_->GetAdapters();
for (const dawn_native::Adapter& adapter : adapters) { for (const dawn_native::Adapter& adapter : adapters) {
#if defined(OS_WIN)
// On Windows 10, we pick D3D12 backend because the rest of Chromium renders
// with D3D11. By the same token, we pick the first adapter because ANGLE
// also picks the first adapter. Later, we'll need to centralize adapter
// picking such that Dawn and ANGLE are told which adapter to use by
// Chromium. If we decide to handle multiple adapters, code on the Chromium
// side will need to change to do appropriate cross adapter copying to make
// this happen, either manually or by using DirectComposition.
if (adapter.GetBackendType() == dawn_native::BackendType::D3D12) {
#else
if (adapter.GetBackendType() != dawn_native::BackendType::Null && if (adapter.GetBackendType() != dawn_native::BackendType::Null &&
adapter.GetBackendType() != dawn_native::BackendType::OpenGL) { adapter.GetBackendType() != dawn_native::BackendType::OpenGL) {
#endif
dawn_adapters_.push_back(adapter); dawn_adapters_.push_back(adapter);
#if defined(OS_WIN)
break;
#endif
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment