Move some files from d3d12 to d3d folder
Those files will be shared between d3d11 and d3d12 backends.
Change-Id: I0ec01365ccc465dfb0e9843a313d87ce649c940e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123740
Auto-Submit: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn
index 9f8f713..a7389f9 100644
--- a/src/dawn/native/BUILD.gn
+++ b/src/dawn/native/BUILD.gn
@@ -396,6 +396,18 @@
# WinPIX should be added as third party tools and linked statically
if (dawn_enable_d3d12) {
+ sources += [
+ "d3d/BlobD3D.cpp",
+ "d3d/BlobD3D.h",
+ "d3d/D3DError.cpp",
+ "d3d/D3DError.h",
+ "d3d/PlatformFunctions.cpp",
+ "d3d/PlatformFunctions.h",
+ "d3d/d3d_platform.h",
+ ]
+ }
+
+ if (dawn_enable_d3d12) {
libs += [ "dxguid.lib" ]
sources += [
"d3d12/AdapterD3D12.cpp",
@@ -406,8 +418,6 @@
"d3d12/BindGroupD3D12.h",
"d3d12/BindGroupLayoutD3D12.cpp",
"d3d12/BindGroupLayoutD3D12.h",
- "d3d12/BlobD3D12.cpp",
- "d3d12/BlobD3D12.h",
"d3d12/BufferD3D12.cpp",
"d3d12/BufferD3D12.h",
"d3d12/CPUDescriptorHeapAllocationD3D12.cpp",
@@ -422,8 +432,6 @@
"d3d12/ComputePipelineD3D12.h",
"d3d12/D3D11on12Util.cpp",
"d3d12/D3D11on12Util.h",
- "d3d12/D3D12Error.cpp",
- "d3d12/D3D12Error.h",
"d3d12/D3D12Info.cpp",
"d3d12/D3D12Info.h",
"d3d12/DeviceD3D12.cpp",
@@ -446,8 +454,8 @@
"d3d12/PageableD3D12.h",
"d3d12/PipelineLayoutD3D12.cpp",
"d3d12/PipelineLayoutD3D12.h",
- "d3d12/PlatformFunctions.cpp",
- "d3d12/PlatformFunctions.h",
+ "d3d12/PlatformFunctionsD3D12.cpp",
+ "d3d12/PlatformFunctionsD3D12.h",
"d3d12/QuerySetD3D12.cpp",
"d3d12/QuerySetD3D12.h",
"d3d12/QueueD3D12.cpp",
diff --git a/src/dawn/native/CMakeLists.txt b/src/dawn/native/CMakeLists.txt
index 7452b9e..e6d1ccf 100644
--- a/src/dawn/native/CMakeLists.txt
+++ b/src/dawn/native/CMakeLists.txt
@@ -253,6 +253,18 @@
if (DAWN_ENABLE_D3D12)
target_sources(dawn_native PRIVATE
+ "d3d/BlobD3D.cpp"
+ "d3d/BlobD3D.h"
+ "d3d/D3DError.cpp"
+ "d3d/D3DError.h"
+ "d3d/PlatformFunctions.cpp"
+ "d3d/PlatformFunctions.h"
+ "d3d/d3d_platform.h"
+ )
+endif()
+
+if (DAWN_ENABLE_D3D12)
+ target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn/native/D3D12Backend.h"
"d3d12/AdapterD3D12.cpp"
"d3d12/AdapterD3D12.h"
@@ -262,8 +274,6 @@
"d3d12/BindGroupD3D12.h"
"d3d12/BindGroupLayoutD3D12.cpp"
"d3d12/BindGroupLayoutD3D12.h"
- "d3d12/BlobD3D12.cpp"
- "d3d12/BlobD3D12.h"
"d3d12/BufferD3D12.cpp"
"d3d12/BufferD3D12.h"
"d3d12/CPUDescriptorHeapAllocationD3D12.cpp"
@@ -278,8 +288,6 @@
"d3d12/ComputePipelineD3D12.h"
"d3d12/D3D11on12Util.cpp"
"d3d12/D3D11on12Util.h"
- "d3d12/D3D12Error.cpp"
- "d3d12/D3D12Error.h"
"d3d12/D3D12Info.cpp"
"d3d12/D3D12Info.h"
"d3d12/DeviceD3D12.cpp"
@@ -302,8 +310,8 @@
"d3d12/PageableD3D12.h"
"d3d12/PipelineLayoutD3D12.cpp"
"d3d12/PipelineLayoutD3D12.h"
- "d3d12/PlatformFunctions.cpp"
- "d3d12/PlatformFunctions.h"
+ "d3d12/PlatformFunctionsD3D12.cpp"
+ "d3d12/PlatformFunctionsD3D12.h"
"d3d12/QuerySetD3D12.cpp"
"d3d12/QuerySetD3D12.h"
"d3d12/QueueD3D12.cpp"
diff --git a/src/dawn/native/Surface.h b/src/dawn/native/Surface.h
index 96da3c2..d0ea24b 100644
--- a/src/dawn/native/Surface.h
+++ b/src/dawn/native/Surface.h
@@ -24,7 +24,7 @@
#include "dawn/common/Platform.h"
#if DAWN_PLATFORM_IS(WINDOWS)
-#include "dawn/native/d3d12/d3d12_platform.h"
+#include "dawn/native/d3d/d3d_platform.h"
#endif // DAWN_PLATFORM_IS(WINDOWS)
// Forward declare IUnknown
diff --git a/src/dawn/native/d3d12/BlobD3D12.cpp b/src/dawn/native/d3d/BlobD3D.cpp
similarity index 97%
rename from src/dawn/native/d3d12/BlobD3D12.cpp
rename to src/dawn/native/d3d/BlobD3D.cpp
index 3b596575..b57690b 100644
--- a/src/dawn/native/d3d12/BlobD3D12.cpp
+++ b/src/dawn/native/d3d/BlobD3D.cpp
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "dawn/native/d3d12/BlobD3D12.h"
+#include "dawn/native/d3d/BlobD3D.h"
namespace dawn::native {
diff --git a/src/dawn/native/d3d12/BlobD3D12.h b/src/dawn/native/d3d/BlobD3D.h
similarity index 81%
rename from src/dawn/native/d3d12/BlobD3D12.h
rename to src/dawn/native/d3d/BlobD3D.h
index cc8c99c..e0befb6 100644
--- a/src/dawn/native/d3d12/BlobD3D12.h
+++ b/src/dawn/native/d3d/BlobD3D.h
@@ -12,8 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#ifndef SRC_DAWN_NATIVE_D3D_BLOBD3D_H_
+#define SRC_DAWN_NATIVE_D3D_BLOBD3D_H_
+
#include "dawn/native/Blob.h"
-#include "dawn/native/d3d12/d3d12_platform.h"
+#include "dawn/native/d3d/d3d_platform.h"
namespace dawn::native {
@@ -21,3 +24,5 @@
Blob CreateBlob(ComPtr<IDxcBlob> blob);
} // namespace dawn::native
+
+#endif // SRC_DAWN_NATIVE_D3D_BLOBD3D_H_
diff --git a/src/dawn/native/d3d12/D3D12Error.cpp b/src/dawn/native/d3d/D3DError.cpp
similarity index 92%
rename from src/dawn/native/d3d12/D3D12Error.cpp
rename to src/dawn/native/d3d/D3DError.cpp
index 0fda82b..9b03cef 100644
--- a/src/dawn/native/d3d12/D3D12Error.cpp
+++ b/src/dawn/native/d3d/D3DError.cpp
@@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include <iomanip>
#include <sstream>
#include <string>
-namespace dawn::native::d3d12 {
+namespace dawn::native::d3d {
const char* HRESULTAsString(HRESULT result) {
// There's a lot of possible HRESULTS, but these ones are the ones specifically listed as
- // being returned from D3D12, in addition to fake codes used internally for testing.
+ // being returned from D3D11 and D3D12, in addition to fake codes used internally for testing.
// https://docs.microsoft.com/en-us/windows/win32/direct3d12/d3d12-graphics-reference-returnvalues
switch (result) {
case S_OK:
@@ -83,4 +83,4 @@
return CheckHRESULTImpl(result, context);
}
-} // namespace dawn::native::d3d12
+} // namespace dawn::native::d3d
diff --git a/src/dawn/native/d3d12/D3D12Error.h b/src/dawn/native/d3d/D3DError.h
similarity index 62%
rename from src/dawn/native/d3d12/D3D12Error.h
rename to src/dawn/native/d3d/D3DError.h
index b058c7c..8cf2630 100644
--- a/src/dawn/native/d3d12/D3D12Error.h
+++ b/src/dawn/native/d3d/D3DError.h
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_DAWN_NATIVE_D3D12_D3D12ERROR_H_
-#define SRC_DAWN_NATIVE_D3D12_D3D12ERROR_H_
+#ifndef SRC_DAWN_NATIVE_D3D_D3DERROR_H_
+#define SRC_DAWN_NATIVE_D3D_D3DERROR_H_
-#include <d3d12.h>
+#include <winerror.h>
#include "dawn/native/Error.h"
#include "dawn/native/ErrorInjector.h"
-namespace dawn::native::d3d12 {
+namespace dawn::native::d3d {
constexpr HRESULT E_FAKE_ERROR_FOR_TESTING = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0xFF);
constexpr HRESULT E_FAKE_OUTOFMEMORY_ERROR_FOR_TESTING =
@@ -31,15 +31,15 @@
// Uses CheckRESULT but returns OOM specific error when recoverable.
MaybeError CheckOutOfMemoryHRESULTImpl(HRESULT result, const char* context);
-#define CheckHRESULT(resultIn, contextIn) \
- ::dawn::native::d3d12::CheckHRESULTImpl( \
- INJECT_ERROR_OR_RUN(resultIn, E_FAKE_ERROR_FOR_TESTING), contextIn)
-#define CheckOutOfMemoryHRESULT(resultIn, contextIn) \
- ::dawn::native::d3d12::CheckOutOfMemoryHRESULTImpl( \
- INJECT_ERROR_OR_RUN(resultIn, E_FAKE_OUTOFMEMORY_ERROR_FOR_TESTING, \
- E_FAKE_ERROR_FOR_TESTING), \
+#define CheckHRESULT(resultIn, contextIn) \
+ ::dawn::native::d3d::CheckHRESULTImpl( \
+ INJECT_ERROR_OR_RUN(resultIn, ::dawn::native::d3d::E_FAKE_ERROR_FOR_TESTING), contextIn)
+#define CheckOutOfMemoryHRESULT(resultIn, contextIn) \
+ ::dawn::native::d3d::CheckOutOfMemoryHRESULTImpl( \
+ INJECT_ERROR_OR_RUN(resultIn, ::dawn::native::d3d::E_FAKE_OUTOFMEMORY_ERROR_FOR_TESTING, \
+ ::dawn::native::d3d::E_FAKE_ERROR_FOR_TESTING), \
contextIn)
-} // namespace dawn::native::d3d12
+} // namespace dawn::native::d3d
-#endif // SRC_DAWN_NATIVE_D3D12_D3D12ERROR_H_
+#endif // SRC_DAWN_NATIVE_D3D_D3DERROR_H_
diff --git a/src/dawn/native/d3d12/PlatformFunctions.cpp b/src/dawn/native/d3d/PlatformFunctions.cpp
similarity index 69%
rename from src/dawn/native/d3d12/PlatformFunctions.cpp
rename to src/dawn/native/d3d/PlatformFunctions.cpp
index 1a3f3fe..52bfa0d 100644
--- a/src/dawn/native/d3d12/PlatformFunctions.cpp
+++ b/src/dawn/native/d3d/PlatformFunctions.cpp
@@ -1,4 +1,4 @@
-// Copyright 2018 The Dawn Authors
+// Copyright 2023 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "dawn/native/d3d12/PlatformFunctions.h"
+#include "dawn/native/d3d/PlatformFunctions.h"
#include <comdef.h>
@@ -23,7 +23,7 @@
#include "dawn/common/DynamicLib.h"
-namespace dawn::native::d3d12 {
+namespace dawn::native::d3d {
namespace {
// Extract Version from "10.0.{Version}.0" if possible, otherwise return 0.
uint32_t GetWindowsSDKVersionFromDirectoryName(const char* directoryName) {
@@ -101,53 +101,9 @@
PlatformFunctions::~PlatformFunctions() = default;
MaybeError PlatformFunctions::LoadFunctions() {
- DAWN_TRY(LoadD3D12());
DAWN_TRY(LoadDXGI());
LoadDXCLibraries();
DAWN_TRY(LoadFXCompiler());
- DAWN_TRY(LoadD3D11());
- LoadPIXRuntime();
- return {};
-}
-
-MaybeError PlatformFunctions::LoadD3D12() {
-#if DAWN_PLATFORM_IS(WINUWP)
- d3d12CreateDevice = &D3D12CreateDevice;
- d3d12GetDebugInterface = &D3D12GetDebugInterface;
- d3d12SerializeRootSignature = &D3D12SerializeRootSignature;
- d3d12CreateRootSignatureDeserializer = &D3D12CreateRootSignatureDeserializer;
- d3d12SerializeVersionedRootSignature = &D3D12SerializeVersionedRootSignature;
- d3d12CreateVersionedRootSignatureDeserializer = &D3D12CreateVersionedRootSignatureDeserializer;
-#else
- std::string error;
- if (!mD3D12Lib.Open("d3d12.dll", &error) ||
- !mD3D12Lib.GetProc(&d3d12CreateDevice, "D3D12CreateDevice", &error) ||
- !mD3D12Lib.GetProc(&d3d12GetDebugInterface, "D3D12GetDebugInterface", &error) ||
- !mD3D12Lib.GetProc(&d3d12SerializeRootSignature, "D3D12SerializeRootSignature", &error) ||
- !mD3D12Lib.GetProc(&d3d12CreateRootSignatureDeserializer,
- "D3D12CreateRootSignatureDeserializer", &error) ||
- !mD3D12Lib.GetProc(&d3d12SerializeVersionedRootSignature,
- "D3D12SerializeVersionedRootSignature", &error) ||
- !mD3D12Lib.GetProc(&d3d12CreateVersionedRootSignatureDeserializer,
- "D3D12CreateVersionedRootSignatureDeserializer", &error)) {
- return DAWN_INTERNAL_ERROR(error.c_str());
- }
-#endif
-
- return {};
-}
-
-MaybeError PlatformFunctions::LoadD3D11() {
-#if DAWN_PLATFORM_IS(WINUWP)
- d3d11on12CreateDevice = &D3D11On12CreateDevice;
-#else
- std::string error;
- if (!mD3D11Lib.Open("d3d11.dll", &error) ||
- !mD3D11Lib.GetProc(&d3d11on12CreateDevice, "D3D11On12CreateDevice", &error)) {
- return DAWN_INTERNAL_ERROR(error.c_str());
- }
-#endif
-
return {};
}
@@ -240,28 +196,10 @@
return {};
}
-bool PlatformFunctions::IsPIXEventRuntimeLoaded() const {
- return mPIXEventRuntimeLib.Valid();
-}
-
// Use Backend::IsDXCAvaliable if possible, which also check the DXC is no older than a given
// version
bool PlatformFunctions::IsDXCBinaryAvailable() const {
return mDXILLib.Valid() && mDXCompilerLib.Valid();
}
-void PlatformFunctions::LoadPIXRuntime() {
- // TODO(dawn:766):
- // In UWP PIX should be statically linked WinPixEventRuntime_UAP.lib
- // So maybe we should put WinPixEventRuntime as a third party package
- // Currently PIX is not going to be loaded in UWP since the following
- // mPIXEventRuntimeLib.Open will fail.
- if (!mPIXEventRuntimeLib.Open("WinPixEventRuntime.dll") ||
- !mPIXEventRuntimeLib.GetProc(&pixBeginEventOnCommandList, "PIXBeginEventOnCommandList") ||
- !mPIXEventRuntimeLib.GetProc(&pixEndEventOnCommandList, "PIXEndEventOnCommandList") ||
- !mPIXEventRuntimeLib.GetProc(&pixSetMarkerOnCommandList, "PIXSetMarkerOnCommandList")) {
- mPIXEventRuntimeLib.Close();
- }
-}
-
-} // namespace dawn::native::d3d12
+} // namespace dawn::native::d3d
diff --git a/src/dawn/native/d3d/PlatformFunctions.h b/src/dawn/native/d3d/PlatformFunctions.h
new file mode 100644
index 0000000..59fe910
--- /dev/null
+++ b/src/dawn/native/d3d/PlatformFunctions.h
@@ -0,0 +1,78 @@
+// Copyright 2023 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef SRC_DAWN_NATIVE_D3D_PLATFORMFUNCTIONS_H_
+#define SRC_DAWN_NATIVE_D3D_PLATFORMFUNCTIONS_H_
+
+#include <d3dcompiler.h>
+
+#include <string>
+
+#include "dawn/native/d3d/d3d_platform.h"
+
+#include "dawn/common/DynamicLib.h"
+#include "dawn/native/Error.h"
+
+namespace dawn::native::d3d {
+
+// Loads the functions required from the platform dynamically so that we don't need to rely on
+// them being present in the system. For example linking against d3d12.lib would prevent
+// dawn_native from loading on Windows 7 system where d3d12.dll doesn't exist.
+class PlatformFunctions {
+ public:
+ PlatformFunctions();
+ virtual ~PlatformFunctions();
+
+ MaybeError LoadFunctions();
+ bool IsPIXEventRuntimeLoaded() const;
+ bool IsDXCBinaryAvailable() const;
+
+ // Functions from dxgi.dll
+ using PFN_DXGI_GET_DEBUG_INTERFACE1 = HRESULT(WINAPI*)(UINT Flags,
+ REFIID riid,
+ _COM_Outptr_ void** pDebug);
+ PFN_DXGI_GET_DEBUG_INTERFACE1 dxgiGetDebugInterface1 = nullptr;
+
+ using PFN_CREATE_DXGI_FACTORY2 = HRESULT(WINAPI*)(UINT Flags,
+ REFIID riid,
+ _COM_Outptr_ void** ppFactory);
+ PFN_CREATE_DXGI_FACTORY2 createDxgiFactory2 = nullptr;
+
+ // Functions from dxcompiler.dll
+ using PFN_DXC_CREATE_INSTANCE = HRESULT(WINAPI*)(REFCLSID rclsid,
+ REFIID riid,
+ _COM_Outptr_ void** ppCompiler);
+ PFN_DXC_CREATE_INSTANCE dxcCreateInstance = nullptr;
+
+ // Functions from d3d3compiler.dll
+ pD3DCompile d3dCompile = nullptr;
+ pD3DDisassemble d3dDisassemble = nullptr;
+
+ private:
+ MaybeError LoadDXGI();
+ void LoadDXCLibraries();
+ void LoadDXIL(const std::string& baseWindowsSDKPath);
+ void LoadDXCompiler(const std::string& baseWindowsSDKPath);
+ MaybeError LoadFXCompiler();
+ void LoadPIXRuntime();
+
+ DynamicLib mDXGILib;
+ DynamicLib mDXILLib;
+ DynamicLib mDXCompilerLib;
+ DynamicLib mFXCompilerLib;
+};
+
+} // namespace dawn::native::d3d
+
+#endif // SRC_DAWN_NATIVE_D3D_PLATFORMFUNCTIONS_H_
diff --git a/src/dawn/native/d3d/d3d_platform.h b/src/dawn/native/d3d/d3d_platform.h
new file mode 100644
index 0000000..ac7b9d3
--- /dev/null
+++ b/src/dawn/native/d3d/d3d_platform.h
@@ -0,0 +1,36 @@
+// Copyright 2023 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef SRC_DAWN_NATIVE_D3D_D3D_PLATFORM_H_
+#define SRC_DAWN_NATIVE_D3D_D3D_PLATFORM_H_
+
+// Pre-emptively include windows.h but remove its macros so that they aren't set when declaring the
+// COM interfaces. Otherwise ID3D12InfoQueue::GetMessage would be either GetMessageA or GetMessageW
+// which causes compilation errors.
+// NOLINTNEXTLINE(build/include_order)
+#include "dawn/common/windows_with_undefs.h"
+
+#include <d3d11_2.h> // NOLINT(build/include_order)
+#include <dxcapi.h> // NOLINT(build/include_order)
+#include <dxgi1_4.h> // NOLINT(build/include_order)
+#include <wrl.h> // NOLINT(build/include_order)
+
+// DXProgrammableCapture.h takes a dependency on other platform header
+// files, so it must be defined after them.
+#include <DXProgrammableCapture.h> // NOLINT(build/include_order)
+#include <dxgidebug.h> // NOLINT(build/include_order)
+
+using Microsoft::WRL::ComPtr;
+
+#endif // SRC_DAWN_NATIVE_D3D_D3D_PLATFORM_H_
diff --git a/src/dawn/native/d3d12/AdapterD3D12.cpp b/src/dawn/native/d3d12/AdapterD3D12.cpp
index 2d39752..4859208 100644
--- a/src/dawn/native/d3d12/AdapterD3D12.cpp
+++ b/src/dawn/native/d3d12/AdapterD3D12.cpp
@@ -20,10 +20,10 @@
#include "dawn/common/Platform.h"
#include "dawn/common/WindowsUtils.h"
#include "dawn/native/Instance.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/BackendD3D12.h"
-#include "dawn/native/d3d12/D3D12Error.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
-#include "dawn/native/d3d12/PlatformFunctions.h"
+#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
#include "dawn/native/d3d12/UtilsD3D12.h"
namespace dawn::native::d3d12 {
diff --git a/src/dawn/native/d3d12/BackendD3D12.cpp b/src/dawn/native/d3d12/BackendD3D12.cpp
index 6e5fff5..1dca30b 100644
--- a/src/dawn/native/d3d12/BackendD3D12.cpp
+++ b/src/dawn/native/d3d12/BackendD3D12.cpp
@@ -19,9 +19,9 @@
#include "dawn/common/Log.h"
#include "dawn/native/D3D12Backend.h"
#include "dawn/native/Instance.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/AdapterD3D12.h"
-#include "dawn/native/d3d12/D3D12Error.h"
-#include "dawn/native/d3d12/PlatformFunctions.h"
+#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
#include "dawn/native/d3d12/UtilsD3D12.h"
namespace dawn::native::d3d12 {
diff --git a/src/dawn/native/d3d12/BufferD3D12.cpp b/src/dawn/native/d3d12/BufferD3D12.cpp
index 28a0ea9..82edbde 100644
--- a/src/dawn/native/d3d12/BufferD3D12.cpp
+++ b/src/dawn/native/d3d12/BufferD3D12.cpp
@@ -21,8 +21,8 @@
#include "dawn/common/Math.h"
#include "dawn/native/CommandBuffer.h"
#include "dawn/native/DynamicUploader.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/CommandRecordingContext.h"
-#include "dawn/native/d3d12/D3D12Error.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/HeapD3D12.h"
#include "dawn/native/d3d12/ResidencyManagerD3D12.h"
diff --git a/src/dawn/native/d3d12/CommandAllocatorManager.cpp b/src/dawn/native/d3d12/CommandAllocatorManager.cpp
index 892cc32..03bf3af 100644
--- a/src/dawn/native/d3d12/CommandAllocatorManager.cpp
+++ b/src/dawn/native/d3d12/CommandAllocatorManager.cpp
@@ -14,7 +14,7 @@
#include "dawn/native/d3d12/CommandAllocatorManager.h"
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/common/Assert.h"
diff --git a/src/dawn/native/d3d12/CommandBufferD3D12.cpp b/src/dawn/native/d3d12/CommandBufferD3D12.cpp
index 53aa856..8ebdc73 100644
--- a/src/dawn/native/d3d12/CommandBufferD3D12.cpp
+++ b/src/dawn/native/d3d12/CommandBufferD3D12.cpp
@@ -28,7 +28,7 @@
#include "dawn/native/d3d12/ComputePipelineD3D12.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/PipelineLayoutD3D12.h"
-#include "dawn/native/d3d12/PlatformFunctions.h"
+#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
#include "dawn/native/d3d12/QuerySetD3D12.h"
#include "dawn/native/d3d12/RenderPassBuilderD3D12.h"
#include "dawn/native/d3d12/RenderPipelineD3D12.h"
diff --git a/src/dawn/native/d3d12/CommandRecordingContext.cpp b/src/dawn/native/d3d12/CommandRecordingContext.cpp
index 6a368a0..72f29b4 100644
--- a/src/dawn/native/d3d12/CommandRecordingContext.cpp
+++ b/src/dawn/native/d3d12/CommandRecordingContext.cpp
@@ -20,8 +20,8 @@
#include <string>
#include <utility>
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/CommandAllocatorManager.h"
-#include "dawn/native/d3d12/D3D12Error.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/HeapD3D12.h"
#include "dawn/native/d3d12/ResidencyManagerD3D12.h"
diff --git a/src/dawn/native/d3d12/ComputePipelineD3D12.cpp b/src/dawn/native/d3d12/ComputePipelineD3D12.cpp
index 8dc05fc..e781f0f 100644
--- a/src/dawn/native/d3d12/ComputePipelineD3D12.cpp
+++ b/src/dawn/native/d3d12/ComputePipelineD3D12.cpp
@@ -18,11 +18,11 @@
#include <utility>
#include "dawn/native/CreatePipelineAsyncTask.h"
-#include "dawn/native/d3d12/BlobD3D12.h"
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/BlobD3D.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/PipelineLayoutD3D12.h"
-#include "dawn/native/d3d12/PlatformFunctions.h"
+#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
#include "dawn/native/d3d12/ShaderModuleD3D12.h"
#include "dawn/native/d3d12/UtilsD3D12.h"
diff --git a/src/dawn/native/d3d12/D3D11on12Util.cpp b/src/dawn/native/d3d12/D3D11on12Util.cpp
index 0d165a5..83747f1 100644
--- a/src/dawn/native/d3d12/D3D11on12Util.cpp
+++ b/src/dawn/native/d3d12/D3D11on12Util.cpp
@@ -22,7 +22,7 @@
#include "dawn/common/HashUtils.h"
#include "dawn/common/Log.h"
#include "dawn/native/D3D12Backend.h"
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
namespace dawn::native::d3d12 {
diff --git a/src/dawn/native/d3d12/D3D12Info.cpp b/src/dawn/native/d3d12/D3D12Info.cpp
index d6d8dde..ee927ef 100644
--- a/src/dawn/native/d3d12/D3D12Info.cpp
+++ b/src/dawn/native/d3d12/D3D12Info.cpp
@@ -17,10 +17,10 @@
#include <utility>
#include "dawn/common/GPUInfo.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/AdapterD3D12.h"
#include "dawn/native/d3d12/BackendD3D12.h"
-#include "dawn/native/d3d12/D3D12Error.h"
-#include "dawn/native/d3d12/PlatformFunctions.h"
+#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
namespace dawn::native::d3d12 {
diff --git a/src/dawn/native/d3d12/DeviceD3D12.cpp b/src/dawn/native/d3d12/DeviceD3D12.cpp
index 43fa4cf..0e0862a 100644
--- a/src/dawn/native/d3d12/DeviceD3D12.cpp
+++ b/src/dawn/native/d3d12/DeviceD3D12.cpp
@@ -23,6 +23,7 @@
#include "dawn/native/D3D12Backend.h"
#include "dawn/native/DynamicUploader.h"
#include "dawn/native/Instance.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/AdapterD3D12.h"
#include "dawn/native/d3d12/BackendD3D12.h"
#include "dawn/native/d3d12/BindGroupD3D12.h"
@@ -31,10 +32,9 @@
#include "dawn/native/d3d12/CommandBufferD3D12.h"
#include "dawn/native/d3d12/ComputePipelineD3D12.h"
#include "dawn/native/d3d12/D3D11on12Util.h"
-#include "dawn/native/d3d12/D3D12Error.h"
#include "dawn/native/d3d12/ExternalImageDXGIImpl.h"
#include "dawn/native/d3d12/PipelineLayoutD3D12.h"
-#include "dawn/native/d3d12/PlatformFunctions.h"
+#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
#include "dawn/native/d3d12/QuerySetD3D12.h"
#include "dawn/native/d3d12/QueueD3D12.h"
#include "dawn/native/d3d12/RenderPipelineD3D12.h"
diff --git a/src/dawn/native/d3d12/FenceD3D12.cpp b/src/dawn/native/d3d12/FenceD3D12.cpp
index 5838ca0..562f8ba 100644
--- a/src/dawn/native/d3d12/FenceD3D12.cpp
+++ b/src/dawn/native/d3d12/FenceD3D12.cpp
@@ -18,7 +18,7 @@
#include "dawn/common/Log.h"
#include "dawn/native/Error.h"
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
namespace dawn::native::d3d12 {
diff --git a/src/dawn/native/d3d12/HeapAllocatorD3D12.cpp b/src/dawn/native/d3d12/HeapAllocatorD3D12.cpp
index 2834981..dd71270 100644
--- a/src/dawn/native/d3d12/HeapAllocatorD3D12.cpp
+++ b/src/dawn/native/d3d12/HeapAllocatorD3D12.cpp
@@ -16,7 +16,7 @@
#include <utility>
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/HeapD3D12.h"
#include "dawn/native/d3d12/ResidencyManagerD3D12.h"
diff --git a/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp b/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp
index aaab8c6..1b972f9 100644
--- a/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp
+++ b/src/dawn/native/d3d12/PipelineLayoutD3D12.cpp
@@ -19,10 +19,10 @@
#include "dawn/common/Assert.h"
#include "dawn/common/BitSetIterator.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/BindGroupLayoutD3D12.h"
-#include "dawn/native/d3d12/D3D12Error.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
-#include "dawn/native/d3d12/PlatformFunctions.h"
+#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
using Microsoft::WRL::ComPtr;
diff --git a/src/dawn/native/d3d12/PlatformFunctionsD3D12.cpp b/src/dawn/native/d3d12/PlatformFunctionsD3D12.cpp
new file mode 100644
index 0000000..a249997
--- /dev/null
+++ b/src/dawn/native/d3d12/PlatformFunctionsD3D12.cpp
@@ -0,0 +1,99 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
+
+#include <comdef.h>
+
+#include <algorithm>
+#include <array>
+#include <sstream>
+#include <utility>
+
+#include "dawn/common/DynamicLib.h"
+
+namespace dawn::native::d3d12 {
+
+PlatformFunctions::PlatformFunctions() = default;
+PlatformFunctions::~PlatformFunctions() = default;
+
+MaybeError PlatformFunctions::LoadFunctions() {
+ DAWN_TRY(Base::LoadFunctions());
+
+ DAWN_TRY(LoadD3D12());
+ DAWN_TRY(LoadD3D11());
+ LoadPIXRuntime();
+ return {};
+}
+
+MaybeError PlatformFunctions::LoadD3D12() {
+#if DAWN_PLATFORM_IS(WINUWP)
+ d3d12CreateDevice = &D3D12CreateDevice;
+ d3d12GetDebugInterface = &D3D12GetDebugInterface;
+ d3d12SerializeRootSignature = &D3D12SerializeRootSignature;
+ d3d12CreateRootSignatureDeserializer = &D3D12CreateRootSignatureDeserializer;
+ d3d12SerializeVersionedRootSignature = &D3D12SerializeVersionedRootSignature;
+ d3d12CreateVersionedRootSignatureDeserializer = &D3D12CreateVersionedRootSignatureDeserializer;
+#else
+ std::string error;
+ if (!mD3D12Lib.Open("d3d12.dll", &error) ||
+ !mD3D12Lib.GetProc(&d3d12CreateDevice, "D3D12CreateDevice", &error) ||
+ !mD3D12Lib.GetProc(&d3d12GetDebugInterface, "D3D12GetDebugInterface", &error) ||
+ !mD3D12Lib.GetProc(&d3d12SerializeRootSignature, "D3D12SerializeRootSignature", &error) ||
+ !mD3D12Lib.GetProc(&d3d12CreateRootSignatureDeserializer,
+ "D3D12CreateRootSignatureDeserializer", &error) ||
+ !mD3D12Lib.GetProc(&d3d12SerializeVersionedRootSignature,
+ "D3D12SerializeVersionedRootSignature", &error) ||
+ !mD3D12Lib.GetProc(&d3d12CreateVersionedRootSignatureDeserializer,
+ "D3D12CreateVersionedRootSignatureDeserializer", &error)) {
+ return DAWN_INTERNAL_ERROR(error.c_str());
+ }
+#endif
+
+ return {};
+}
+
+MaybeError PlatformFunctions::LoadD3D11() {
+#if DAWN_PLATFORM_IS(WINUWP)
+ d3d11on12CreateDevice = &D3D11On12CreateDevice;
+#else
+ std::string error;
+ if (!mD3D11Lib.Open("d3d11.dll", &error) ||
+ !mD3D11Lib.GetProc(&d3d11on12CreateDevice, "D3D11On12CreateDevice", &error)) {
+ return DAWN_INTERNAL_ERROR(error.c_str());
+ }
+#endif
+
+ return {};
+}
+
+bool PlatformFunctions::IsPIXEventRuntimeLoaded() const {
+ return mPIXEventRuntimeLib.Valid();
+}
+
+void PlatformFunctions::LoadPIXRuntime() {
+ // TODO(dawn:766):
+ // In UWP PIX should be statically linked WinPixEventRuntime_UAP.lib
+ // So maybe we should put WinPixEventRuntime as a third party package
+ // Currently PIX is not going to be loaded in UWP since the following
+ // mPIXEventRuntimeLib.Open will fail.
+ if (!mPIXEventRuntimeLib.Open("WinPixEventRuntime.dll") ||
+ !mPIXEventRuntimeLib.GetProc(&pixBeginEventOnCommandList, "PIXBeginEventOnCommandList") ||
+ !mPIXEventRuntimeLib.GetProc(&pixEndEventOnCommandList, "PIXEndEventOnCommandList") ||
+ !mPIXEventRuntimeLib.GetProc(&pixSetMarkerOnCommandList, "PIXSetMarkerOnCommandList")) {
+ mPIXEventRuntimeLib.Close();
+ }
+}
+
+} // namespace dawn::native::d3d12
diff --git a/src/dawn/native/d3d12/PlatformFunctions.h b/src/dawn/native/d3d12/PlatformFunctionsD3D12.h
similarity index 67%
rename from src/dawn/native/d3d12/PlatformFunctions.h
rename to src/dawn/native/d3d12/PlatformFunctionsD3D12.h
index fca1e51..af6ae35 100644
--- a/src/dawn/native/d3d12/PlatformFunctions.h
+++ b/src/dawn/native/d3d12/PlatformFunctionsD3D12.h
@@ -19,6 +19,7 @@
#include <string>
+#include "dawn/native/d3d/PlatformFunctions.h"
#include "dawn/native/d3d12/d3d12_platform.h"
#include "dawn/common/DynamicLib.h"
@@ -29,14 +30,13 @@
// Loads the functions required from the platform dynamically so that we don't need to rely on
// them being present in the system. For example linking against d3d12.lib would prevent
// dawn_native from loading on Windows 7 system where d3d12.dll doesn't exist.
-class PlatformFunctions {
+class PlatformFunctions : public d3d::PlatformFunctions {
public:
PlatformFunctions();
- ~PlatformFunctions();
+ ~PlatformFunctions() override;
MaybeError LoadFunctions();
bool IsPIXEventRuntimeLoaded() const;
- bool IsDXCBinaryAvailable() const;
// Functions from d3d12.dll
PFN_D3D12_CREATE_DEVICE d3d12CreateDevice = nullptr;
@@ -48,27 +48,6 @@
PFN_D3D12_CREATE_VERSIONED_ROOT_SIGNATURE_DESERIALIZER
d3d12CreateVersionedRootSignatureDeserializer = nullptr;
- // Functions from dxgi.dll
- using PFN_DXGI_GET_DEBUG_INTERFACE1 = HRESULT(WINAPI*)(UINT Flags,
- REFIID riid,
- _COM_Outptr_ void** pDebug);
- PFN_DXGI_GET_DEBUG_INTERFACE1 dxgiGetDebugInterface1 = nullptr;
-
- using PFN_CREATE_DXGI_FACTORY2 = HRESULT(WINAPI*)(UINT Flags,
- REFIID riid,
- _COM_Outptr_ void** ppFactory);
- PFN_CREATE_DXGI_FACTORY2 createDxgiFactory2 = nullptr;
-
- // Functions from dxcompiler.dll
- using PFN_DXC_CREATE_INSTANCE = HRESULT(WINAPI*)(REFCLSID rclsid,
- REFIID riid,
- _COM_Outptr_ void** ppCompiler);
- PFN_DXC_CREATE_INSTANCE dxcCreateInstance = nullptr;
-
- // Functions from d3d3compiler.dll
- pD3DCompile d3dCompile = nullptr;
- pD3DDisassemble d3dDisassemble = nullptr;
-
// Functions from WinPixEventRuntime.dll
using PFN_PIX_END_EVENT_ON_COMMAND_LIST =
HRESULT(WINAPI*)(ID3D12GraphicsCommandList* commandList);
@@ -90,21 +69,14 @@
PFN_D3D11ON12_CREATE_DEVICE d3d11on12CreateDevice = nullptr;
private:
+ using Base = d3d::PlatformFunctions;
+
MaybeError LoadD3D12();
MaybeError LoadD3D11();
- MaybeError LoadDXGI();
- void LoadDXCLibraries();
- void LoadDXIL(const std::string& baseWindowsSDKPath);
- void LoadDXCompiler(const std::string& baseWindowsSDKPath);
- MaybeError LoadFXCompiler();
void LoadPIXRuntime();
DynamicLib mD3D12Lib;
DynamicLib mD3D11Lib;
- DynamicLib mDXGILib;
- DynamicLib mDXILLib;
- DynamicLib mDXCompilerLib;
- DynamicLib mFXCompilerLib;
DynamicLib mPIXEventRuntimeLib;
};
diff --git a/src/dawn/native/d3d12/QuerySetD3D12.cpp b/src/dawn/native/d3d12/QuerySetD3D12.cpp
index 2f8ea05..9f7ed07 100644
--- a/src/dawn/native/d3d12/QuerySetD3D12.cpp
+++ b/src/dawn/native/d3d12/QuerySetD3D12.cpp
@@ -16,7 +16,7 @@
#include <algorithm>
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/UtilsD3D12.h"
diff --git a/src/dawn/native/d3d12/QueueD3D12.cpp b/src/dawn/native/d3d12/QueueD3D12.cpp
index 5d4ca09..22fea57 100644
--- a/src/dawn/native/d3d12/QueueD3D12.cpp
+++ b/src/dawn/native/d3d12/QueueD3D12.cpp
@@ -18,8 +18,8 @@
#include "dawn/native/CommandValidation.h"
#include "dawn/native/Commands.h"
#include "dawn/native/DynamicUploader.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/CommandBufferD3D12.h"
-#include "dawn/native/d3d12/D3D12Error.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/UtilsD3D12.h"
#include "dawn/platform/DawnPlatform.h"
diff --git a/src/dawn/native/d3d12/RenderPipelineD3D12.cpp b/src/dawn/native/d3d12/RenderPipelineD3D12.cpp
index 563dab6..6cfa55d 100644
--- a/src/dawn/native/d3d12/RenderPipelineD3D12.cpp
+++ b/src/dawn/native/d3d12/RenderPipelineD3D12.cpp
@@ -22,11 +22,11 @@
#include "dawn/common/Assert.h"
#include "dawn/common/Log.h"
#include "dawn/native/CreatePipelineAsyncTask.h"
-#include "dawn/native/d3d12/BlobD3D12.h"
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/BlobD3D.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/PipelineLayoutD3D12.h"
-#include "dawn/native/d3d12/PlatformFunctions.h"
+#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
#include "dawn/native/d3d12/ShaderModuleD3D12.h"
#include "dawn/native/d3d12/TextureD3D12.h"
#include "dawn/native/d3d12/UtilsD3D12.h"
diff --git a/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp b/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp
index 2952505..f6fb404 100644
--- a/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp
+++ b/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp
@@ -17,8 +17,8 @@
#include <algorithm>
#include <vector>
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/AdapterD3D12.h"
-#include "dawn/native/d3d12/D3D12Error.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/Forward.h"
#include "dawn/native/d3d12/HeapD3D12.h"
diff --git a/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp b/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp
index a4329e6..2e62d7c 100644
--- a/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp
+++ b/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp
@@ -18,7 +18,7 @@
#include <limits>
#include <utility>
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/HeapAllocatorD3D12.h"
#include "dawn/native/d3d12/HeapD3D12.h"
diff --git a/src/dawn/native/d3d12/ResourceHeapAllocationD3D12.cpp b/src/dawn/native/d3d12/ResourceHeapAllocationD3D12.cpp
index 862f87b..77db184 100644
--- a/src/dawn/native/d3d12/ResourceHeapAllocationD3D12.cpp
+++ b/src/dawn/native/d3d12/ResourceHeapAllocationD3D12.cpp
@@ -16,7 +16,7 @@
#include <utility>
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/HeapD3D12.h"
namespace dawn::native::d3d12 {
diff --git a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
index 903ecea..a7047b1 100644
--- a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
+++ b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
@@ -32,14 +32,14 @@
#include "dawn/native/CacheRequest.h"
#include "dawn/native/Pipeline.h"
#include "dawn/native/TintUtils.h"
+#include "dawn/native/d3d/BlobD3D.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/AdapterD3D12.h"
#include "dawn/native/d3d12/BackendD3D12.h"
#include "dawn/native/d3d12/BindGroupLayoutD3D12.h"
-#include "dawn/native/d3d12/BlobD3D12.h"
-#include "dawn/native/d3d12/D3D12Error.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/PipelineLayoutD3D12.h"
-#include "dawn/native/d3d12/PlatformFunctions.h"
+#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
#include "dawn/native/d3d12/UtilsD3D12.h"
#include "dawn/native/stream/BlobSource.h"
#include "dawn/native/stream/ByteVectorSink.h"
diff --git a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp
index fe99a63..14a117b 100644
--- a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp
+++ b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp
@@ -18,7 +18,7 @@
#include <limits>
#include <utility>
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/GPUDescriptorHeapAllocationD3D12.h"
#include "dawn/native/d3d12/ResidencyManagerD3D12.h"
diff --git a/src/dawn/native/d3d12/StagingDescriptorAllocatorD3D12.cpp b/src/dawn/native/d3d12/StagingDescriptorAllocatorD3D12.cpp
index f30016a..2960ed0 100644
--- a/src/dawn/native/d3d12/StagingDescriptorAllocatorD3D12.cpp
+++ b/src/dawn/native/d3d12/StagingDescriptorAllocatorD3D12.cpp
@@ -17,7 +17,7 @@
#include <utility>
#include "dawn/common/Math.h"
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
namespace dawn::native::d3d12 {
diff --git a/src/dawn/native/d3d12/SwapChainD3D12.cpp b/src/dawn/native/d3d12/SwapChainD3D12.cpp
index fa562f2..7e814f8 100644
--- a/src/dawn/native/d3d12/SwapChainD3D12.cpp
+++ b/src/dawn/native/d3d12/SwapChainD3D12.cpp
@@ -20,7 +20,7 @@
#include "dawn/dawn_wsi.h"
#include "dawn/native/Surface.h"
-#include "dawn/native/d3d12/D3D12Error.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/TextureD3D12.h"
diff --git a/src/dawn/native/d3d12/TextureD3D12.cpp b/src/dawn/native/d3d12/TextureD3D12.cpp
index 2d08a14..3c99d88 100644
--- a/src/dawn/native/d3d12/TextureD3D12.cpp
+++ b/src/dawn/native/d3d12/TextureD3D12.cpp
@@ -25,10 +25,10 @@
#include "dawn/native/IntegerTypes.h"
#include "dawn/native/ResourceMemoryAllocation.h"
#include "dawn/native/ToBackend.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/BufferD3D12.h"
#include "dawn/native/d3d12/CommandRecordingContext.h"
#include "dawn/native/d3d12/D3D11on12Util.h"
-#include "dawn/native/d3d12/D3D12Error.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
#include "dawn/native/d3d12/Forward.h"
#include "dawn/native/d3d12/HeapD3D12.h"
diff --git a/src/dawn/native/d3d12/UtilsD3D12.cpp b/src/dawn/native/d3d12/UtilsD3D12.cpp
index e706d8f..b508300 100644
--- a/src/dawn/native/d3d12/UtilsD3D12.cpp
+++ b/src/dawn/native/d3d12/UtilsD3D12.cpp
@@ -21,9 +21,9 @@
#include "dawn/common/Assert.h"
#include "dawn/native/CommandValidation.h"
#include "dawn/native/Format.h"
+#include "dawn/native/d3d/D3DError.h"
#include "dawn/native/d3d12/BufferD3D12.h"
#include "dawn/native/d3d12/CommandRecordingContext.h"
-#include "dawn/native/d3d12/D3D12Error.h"
#include "dawn/native/d3d12/DeviceD3D12.h"
namespace dawn::native::d3d12 {
diff --git a/src/dawn/native/d3d12/d3d12_platform.h b/src/dawn/native/d3d12/d3d12_platform.h
index 59542bf..c0db1b5 100644
--- a/src/dawn/native/d3d12/d3d12_platform.h
+++ b/src/dawn/native/d3d12/d3d12_platform.h
@@ -15,24 +15,9 @@
#ifndef SRC_DAWN_NATIVE_D3D12_D3D12_PLATFORM_H_
#define SRC_DAWN_NATIVE_D3D12_D3D12_PLATFORM_H_
-// Pre-emptively include windows.h but remove its macros so that they aren't set when declaring the
-// COM interfaces. Otherwise ID3D12InfoQueue::GetMessage would be either GetMessageA or GetMessageW
-// which causes compilation errors.
-// NOLINTNEXTLINE(build/include_order)
-#include "dawn/common/windows_with_undefs.h"
+#include "dawn/native/d3d/d3d_platform.h"
-#include <d3d11_2.h> // NOLINT(build/include_order)
#include <d3d11on12.h> // NOLINT(build/include_order)
#include <d3d12.h> // NOLINT(build/include_order)
-#include <dxcapi.h> // NOLINT(build/include_order)
-#include <dxgi1_4.h> // NOLINT(build/include_order)
-#include <wrl.h> // NOLINT(build/include_order)
-
-// DXProgrammableCapture.h takes a dependency on other platform header
-// files, so it must be defined after them.
-#include <DXProgrammableCapture.h> // NOLINT(build/include_order)
-#include <dxgidebug.h> // NOLINT(build/include_order)
-
-using Microsoft::WRL::ComPtr;
#endif // SRC_DAWN_NATIVE_D3D12_D3D12_PLATFORM_H_