d3d12: Add GetD3D12Device for querying ID3D12Device from WGPUDevice.

Chrome will needs to get a ID3D12Device for decoder/DComp. Currently Chrome's D3D11 decoder fetch the device from ANGLE/Dawn, while for D3D12 it creates the device by itself maybe using different setup(feature levels, etc) from ANGLE/Dawn. Though the device is per-adapter, the behavior of the creation with different setup is unclear.
To make sure decoder and renderer are always consistent on the device settings, we better share the device from ANGLE/Dawn if possible.

Bug: dawn:2210
Change-Id: I4c700bab7c1e176e23f18fce9ed18703e3670984
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/159480
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/include/dawn/native/D3D12Backend.h b/include/dawn/native/D3D12Backend.h
index bc6117d..935adc9 100644
--- a/include/dawn/native/D3D12Backend.h
+++ b/include/dawn/native/D3D12Backend.h
@@ -47,6 +47,8 @@
     NonLocal,
 };
 
+DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D12Device> GetD3D12Device(WGPUDevice device);
+
 DAWN_NATIVE_EXPORT uint64_t SetExternalMemoryReservation(WGPUDevice device,
                                                          uint64_t requestedReservationSize,
                                                          MemorySegment memorySegment);
diff --git a/src/dawn/native/d3d12/D3D12Backend.cpp b/src/dawn/native/d3d12/D3D12Backend.cpp
index 5b96b4c..30f7e79 100644
--- a/src/dawn/native/d3d12/D3D12Backend.cpp
+++ b/src/dawn/native/d3d12/D3D12Backend.cpp
@@ -41,6 +41,10 @@
 
 namespace dawn::native::d3d12 {
 
+Microsoft::WRL::ComPtr<ID3D12Device> GetD3D12Device(WGPUDevice device) {
+    return ToBackend(FromAPI(device))->GetD3D12Device();
+}
+
 uint64_t SetExternalMemoryReservation(WGPUDevice device,
                                       uint64_t requestedReservationSize,
                                       MemorySegment memorySegment) {