diff --git a/drivers/d3d12/SCsub b/drivers/d3d12/SCsub index 6b23e1bad05b..35227ebe08b7 100644 --- a/drivers/d3d12/SCsub +++ b/drivers/d3d12/SCsub @@ -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"]) diff --git a/drivers/d3d12/d3d12_context.cpp b/drivers/d3d12/d3d12_context.cpp index 0ba3f591198b..03bde5b2d96c 100644 --- a/drivers/d3d12/d3d12_context.cpp +++ b/drivers/d3d12/d3d12_context.cpp @@ -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]; @@ -285,7 +287,7 @@ Error D3D12Context::_initialize_debug_layers() { ComPtr 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)); } @@ -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())))) { diff --git a/platform/windows/SCsub b/platform/windows/SCsub index 2df644136b34..7aaf70e62564 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -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. @@ -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, diff --git a/platform/windows/detect.py b/platform/windows/detect.py index b1dd66ca4877..e5e0a07f82cc 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -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)", @@ -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:") @@ -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"] @@ -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:") @@ -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"])