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>
This commit is contained in:
Peng Huang 2023-03-14 01:12:29 +00:00 committed by Dawn LUCI CQ
parent 21c9f0f04c
commit fb27a0a3e4
38 changed files with 312 additions and 183 deletions

View File

@ -395,6 +395,18 @@ source_set("sources") {
# Somehow use dxcompiler.lib makes CoreApp unable to activate
# 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 += [
@ -406,8 +418,6 @@ source_set("sources") {
"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 @@ source_set("sources") {
"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 @@ source_set("sources") {
"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",

View File

@ -251,6 +251,18 @@ if (WINDOWS_STORE)
target_link_libraries(dawn_native PRIVATE debug dxgi.lib)
endif()
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"
@ -262,8 +274,6 @@ if (DAWN_ENABLE_D3D12)
"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 @@ if (DAWN_ENABLE_D3D12)
"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 @@ if (DAWN_ENABLE_D3D12)
"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"

View File

@ -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

View File

@ -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 {

View File

@ -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<ID3DBlob> blob);
Blob CreateBlob(ComPtr<IDxcBlob> blob);
} // namespace dawn::native
#endif // SRC_DAWN_NATIVE_D3D_BLOBD3D_H_

View File

@ -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 @@ MaybeError CheckOutOfMemoryHRESULTImpl(HRESULT result, const char* context) {
return CheckHRESULTImpl(result, context);
}
} // namespace dawn::native::d3d12
} // namespace dawn::native::d3d

View File

@ -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 =
@ -32,14 +32,14 @@ MaybeError CheckHRESULTImpl(HRESULT result, const char* context);
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)
::dawn::native::d3d::CheckHRESULTImpl( \
INJECT_ERROR_OR_RUN(resultIn, ::dawn::native::d3d::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), \
::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_

View File

@ -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;
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 @@ MaybeError PlatformFunctions::LoadFXCompiler() {
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

View File

@ -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_

View File

@ -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_

View File

@ -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 {

View File

@ -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 {

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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 {

View File

@ -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 {

View File

@ -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"

View File

@ -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 {

View File

@ -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"

View File

@ -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;

View File

@ -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

View File

@ -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 @@ namespace dawn::native::d3d12 {
// 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 @@ class PlatformFunctions {
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 @@ class PlatformFunctions {
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;
};

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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 {

View File

@ -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"

View File

@ -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"

View File

@ -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 {

View File

@ -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"

View File

@ -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"

View File

@ -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 {

View File

@ -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_