Windows: Make Direct3D 12 the default RD driver for new projects#113213
Windows: Make Direct3D 12 the default RD driver for new projects#113213akien-mga merged 1 commit intogodotengine:masterfrom
Conversation
5eb496d to
9313bdf
Compare
For compatibility reasons, `vulkan` is kept as the technical default for the setting, but projects created in Godot 4.6 and later will set `d3d12` as the driver automatically. Users upgrading to 4.6 are recommended to adopt `d3d12` as a default if it fits their needs. Enable `d3d12=yes` by default in SCons so that custom Windows builds include Direct3D 12 support.
bruvzg
left a comment
There was a problem hiding this comment.
Seems fine. I'm not sure which approach is best for the existing project settings.
9313bdf to
b87fcf7
Compare
I changed the implementation to use @Calinou's approach in #105737 instead used for making Jolt Physics the default 3D physics engine only on newly created projects. So this is now the same for D3D12, projects created in 4.6 will set This is a conservative approach that lets people use D3D12 by default on new projects but without risk of breaking projects in production. An advantage of this approach is that for users who select D3D12 explicitly in 4.6, and then switch back and forth between 4.5 and 4.6 for any reason, the setting will be preserved. With the former approach where the default value changed, the setting would be lost when it matches the engine version's default. We could consider going further in 4.7 and fully changing the default to D3D12 without further compatibility code, so all projects would be upgraded by then (and could still select back Vulkan after upgrade). We should document this well, both in the release page and in the online docs, so users understand that while their pre-existing projects aren't automatically updated, we strongly recommend that they switch to using D3D12 in production from 4.6. We could consider having some sort of post-upgrade dialog that gives users some options on how to deal with compatibility changes:
|
|
on my configuration the d3d12 rd doesn't work well, the editor especially is very slow and it also affects every other app i'm running alongside godot, while on vulkan i don't see slowdowns. similar issues using either the igpu (intel u630) or the dgpu (nvidia 1050ti). |
Godot uses the same Vulkan RD for all platforms, there's no Windows-specific implementation. It can't really stop development. |
yes i understand that, my remark is in context of this pr.. i mean, the team is willing to switch defaults because there are few kinks not working perfectly on windows yet. fine i guess (i might not think this is ready Yet, hence my comment, but i'm not The Community, so). i hope there's still will to keep vulkan on windows getting better, that's it, |
The Vulkan backend works great and is our most polished graphics API backend. The problem we are solving here is the fact that every couple of months AMD and NVidia ship broken Vulkan drivers that break every single Godot game. We can't improve the quality of the drivers shipped by AMD and NVidia, so our only option is to avoid Vulkan on Windows |
From the conversation here, it appears we are translating SPIRV to DXIL, which might explains the slower start-up time. |
|
I'm working on my engine which is based on Godot and I'm porting the entire render and shader pipeline to D3D12 and HLSL. While moving fully to D3D12 I encountered the same startup performance issue. Unfortunately, even with the changes @blueskythlikesclouds made, there is still a slowdown at startup. I spent the last two days tracking down the cause and here’s what I found: The main reason for the slowdown is not the Godot renderer itself, but rather the core design of Godot by running multiple instances from the same executable. Here's what's happening:
It doesn’t matter whether we're running the editor, debug mode or runtime first. When one instance is already active, a second instance cannot use the cache in D3DSCache because it is locked by the first process. I can think of two possible solutions at the moment:
I'm not certain whether implementing bool RenderingDeviceDriverD3D12::pipeline_cache_create(const Vector<uint8_t> &p_data) {
WARN_PRINT("PSO caching is not implemented yet in the Direct3D 12 driver.");
return false;
}
void RenderingDeviceDriverD3D12::pipeline_cache_free() {
ERR_FAIL_MSG("Not implemented.");
}
size_t RenderingDeviceDriverD3D12::pipeline_cache_query_size() {
ERR_FAIL_V_MSG(0, "Not implemented.");
}
Vector<uint8_t> RenderingDeviceDriverD3D12::pipeline_cache_serialize() {
ERR_FAIL_V_MSG(Vector<uint8_t>(), "Not implemented.");
}Related issue: #103844 |
if it was just the startup i wouldn't care much, actually.... the interface gets visibly slower, and it greatly affects other running apps aswell. alongside all the well known issues that are getting addressed. with all due respects, d3d drivers of all manifacturers get regressions all the time, just like in vulkan is getting, and the godot community is just witnessing issues because vulkan was the de facto renderer everyone used so far... but the choice has been made.. so.. |
The choice has been made just in time for the general public to test it. Feedback is always welcome. |
|
Follow up to #113213 (comment) Before proxifying (7000-12000ms per run) : D3DSCache-Before-Fix.mp4After proxifying (800-1500ms per run) : D3DSCache-After-Fix.mp4 |
|
I don't understand why D3DSCache would make a difference. That cache gets used to store the output of DXBC -> DXIL conversion the runtime does, but Godot already provides DXIL shaders. On my system, the cache is only a few KBs, which I assume contains shaders from some third-party injection software I used before. |
RandomShaper
left a comment
There was a problem hiding this comment.
Late to the party, but wanted to express I'm very happy this is possible now
|
i never cared about vulkan anyways because it doesn't support old hardware so i just sticked with opengl, with this change will i still be able to compile godot without d3d12 support? |
|
Yes. |
Are your frames limited to 60 FPS? The NVIDIA driver often downclocks the GPU to save power when the frame renders fast enough. |
It's not frame limited, I'm on a 165hz screen so it should be rendering at least 165fps. |


Direct3D 12 support was added for the Windows platform in Godot 4.3 by @RandomShaper and further refined in later releases by @DarioSamo (both sponsored by W4 Games, so I'll obama-medal-meme my company a bit).
In the 4.6 release cycle, @blueskythlikesclouds focused on fixing known issues with Direct3D 12, with the aim of making it the default RenderingDevice driver for Windows (this time sponsored by the Godot Foundation 🥇).
Why? Mainly because Vulkan support on Windows is giving us a lot of headache, with GPU drivers often being poorly maintained compared to their Direct3D 12 counterparts. We've seen many regressions in Nvidia and AMD drivers that would outright break Godot and games released with it (e.g. #109378 still ongoing). There are other issues such as Vulkan implicit layers which force us to use hacks to work around their harmful impact on Godot.
It's understandable, most Windows games use modern APIs target Direct3D 12 on Windows, and thus these are the drivers GPU vendors put most work and testing into.
So now that Direct3D 12 in Godot has more or less feature parity with Vulkan (see below), we want to try using it as the default option. See godotengine/godot-proposals#12234 for more arguments in favor of defaulting to Direct3D 12.
Some important aspects:
rendering/rendering_device/driver.windowsproject setting tod3d12manually.rendering/rendering_device/driver.windowsproject setting, or--rendering-driver vulkanon the command line.This PR attempts to preserve the behavior of pre-existing projects by explicitly setting the driver tovulkanif it was unconfigured (default) prior to upgrading to 4.6. (Uses the approach added by @KoBeWi in Add MeshInstance3D upgrade code #112607.) So by default, only new projects should default tod3d12.vulkanstays the default for this setting, butd3d12is configured automatically for new projects created in 4.6.rendering/rendering_device/driver.windowstod3d12if you want to use the new default (recommended).misc/scripts/install_d3d12_sdk_windows.pyscript. Alternatively, you can compile withd3d12=noif you don't need it for your development work.