Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[D3D12] Add support for building with pre-11.0.0 MinGW versions, make PIX runtime opt-in. #87624

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/d3d12/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if env["agility_sdk_path"] != "" and os.path.exists(env["agility_sdk_path"]):

# PIX.

if env["pix_path"] != "" and os.path.exists(env["pix_path"]):
if env["use_pix"]:
env_d3d12_rdd.Append(CPPDEFINES=["PIX_ENABLED"])
env_d3d12_rdd.Append(CPPPATH=[env["pix_path"] + "/Include"])

Expand Down
6 changes: 4 additions & 2 deletions drivers/d3d12/d3d12_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@

// Note: symbol is not available in MinGW and old MSVC import libraries.
const CLSID CLSID_D3D12DeviceFactoryGodot = __uuidof(ID3D12DeviceFactory);
const CLSID CLSID_D3D12DebugGodot = __uuidof(ID3D12Debug);
const CLSID CLSID_D3D12SDKConfigurationGodot = __uuidof(ID3D12SDKConfiguration);

extern "C" {
char godot_nir_arch_name[32];
Expand Down Expand Up @@ -285,7 +287,7 @@ Error D3D12Context::_initialize_debug_layers() {
ComPtr<ID3D12Debug> debug_controller;
HRESULT res;
if (device_factory) {
res = device_factory->GetConfigurationInterface(CLSID_D3D12Debug, IID_PPV_ARGS(&debug_controller));
res = device_factory->GetConfigurationInterface(CLSID_D3D12DebugGodot, IID_PPV_ARGS(&debug_controller));
} else {
res = D3D12GetDebugInterface(IID_PPV_ARGS(&debug_controller));
}
Expand Down Expand Up @@ -820,7 +822,7 @@ void D3D12Context::_init_device_factory() {
ERR_FAIL_COND(!d3d_D3D12GetInterface);

ID3D12SDKConfiguration *sdk_config = nullptr;
if (SUCCEEDED(d3d_D3D12GetInterface(CLSID_D3D12SDKConfiguration, IID_PPV_ARGS(&sdk_config)))) {
if (SUCCEEDED(d3d_D3D12GetInterface(CLSID_D3D12SDKConfigurationGodot, IID_PPV_ARGS(&sdk_config)))) {
ID3D12SDKConfiguration1 *sdk_config1 = nullptr;
if (SUCCEEDED(sdk_config->QueryInterface(&sdk_config1))) {
if (SUCCEEDED(sdk_config1->CreateDeviceFactory(agility_sdk_version, agility_sdk_path.ascii().get_data(), IID_PPV_ARGS(device_factory.GetAddressOf())))) {
Expand Down
4 changes: 2 additions & 2 deletions platform/windows/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if env["d3d12"]:
arch_bin_dir = "#bin/" + env["arch"]

# DXC
if env["dxc_path"] != "":
if env["dxc_path"] != "" and os.path.exists(env["dxc_path"]):
dxc_dll = "dxil.dll"
# Whether this one is loaded from arch-specific directory or not can be determined at runtime.
# Let's copy to both and let the user decide the distribution model.
Expand All @@ -121,7 +121,7 @@ if env["d3d12"]:
)

# PIX
if env["pix_path"] != "" and os.path.exists(env["pix_path"]):
if env["use_pix"]:
pix_dll = "WinPixEventRuntime.dll"
env.Command(
"#bin/" + pix_dll,
Expand Down
29 changes: 18 additions & 11 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def get_opts():
"Whether the Agility SDK DLLs will be stored in arch-specific subdirectories",
False,
),
BoolVariable("use_pix", "Use PIX (Performance tuning and debugging for DirectX 12) runtime", False),
(
"pix_path",
"Path to the PIX runtime distribution (optional for D3D12)",
Expand Down Expand Up @@ -474,7 +475,7 @@ def configure_msvc(env, vcvars_msvc_config):

if env["d3d12"]:
# Check whether we have d3d12 dependencies installed.
if not os.path.exists(env["mesa_libs"]) or not os.path.exists(env["dxc_path"]):
if not os.path.exists(env["mesa_libs"]):
print("The Direct3D 12 rendering driver requires dependencies to be installed.")
print("You can install them by running `python misc\scripts\install_d3d12_sdk_windows.py`.")
print("See the documentation for more information:")
Expand All @@ -491,10 +492,13 @@ def configure_msvc(env, vcvars_msvc_config):
if env["target"] == "release_debug":
env.Append(CXXFLAGS=["/bigobj"])

arch_subdir = "arm64" if env["arch"] == "arm64" else "x64"

# PIX
if env["pix_path"] != "" and os.path.exists(env["pix_path"]):
if not env["arch"] in ["x86_64", "arm64"] or env["pix_path"] == "" or not os.path.exists(env["pix_path"]):
env["use_pix"] = False

if env["use_pix"]:
arch_subdir = "arm64" if env["arch"] == "arm64" else "x64"

env.Append(LIBPATH=[env["pix_path"] + "/bin/" + arch_subdir])
LIBS += ["WinPixEventRuntime"]

Expand Down Expand Up @@ -695,13 +699,8 @@ def configure_mingw(env):
env.Append(LIBS=["vulkan"])

if env["d3d12"]:
env.AppendUnique(CPPDEFINES=["D3D12_ENABLED", "RD_ENABLED"])
env.Append(LIBS=["d3d12", "dxgi", "dxguid"])

arch_subdir = "arm64" if env["arch"] == "arm64" else "x64"

# Check whether we have d3d12 dependencies installed.
if not os.path.exists(env["mesa_libs"]) or not os.path.exists(env["dxc_path"]):
if not os.path.exists(env["mesa_libs"]):
print("The Direct3D 12 rendering driver requires dependencies to be installed.")
print("You can install them by running `python misc\scripts\install_d3d12_sdk_windows.py`.")
print("See the documentation for more information:")
Expand All @@ -710,8 +709,16 @@ def configure_mingw(env):
)
sys.exit(255)

env.AppendUnique(CPPDEFINES=["D3D12_ENABLED", "RD_ENABLED"])
env.Append(LIBS=["d3d12", "dxgi", "dxguid"])

# PIX
if env["pix_path"] != "" and os.path.exists(env["pix_path"]):
if not env["arch"] in ["x86_64", "arm64"] or env["pix_path"] == "" or not os.path.exists(env["pix_path"]):
env["use_pix"] = False

if env["use_pix"]:
arch_subdir = "arm64" if env["arch"] == "arm64" else "x64"

env.Append(LIBPATH=[env["pix_path"] + "/bin/" + arch_subdir])
env.Append(LIBS=["WinPixEventRuntime"])

Expand Down
Loading