Skip to content

Use Direct3D 12 rendering driver by default on Windows #12234

Description

@Calinou

Describe the project you are working on

The Godot editor 🙂

Describe the problem or limitation you are having in your project

Godot runs into many driver bugs when using Vulkan on Windows. All GPU vendors are affected, but Intel generally has the Vulkan driver that runs into the most issues in Godot (such as godotengine/godot#86833).

On top of that, Vulkan allows applications to install layers which affect the rendering of any Vulkan application on the system. While this is an useful tool, applications often install broken layers or don't clean up layer files after uninstalling, which leads to various issues. In the worst case scenario, Godot is completely unable to start with Vulkan if a broken layer makes it crash on startup. In comparison, Direct3D 12 doesn't have a layer system, so it's impossible for this to happen.1

To summarize, the state of Vulkan drivers on Windows is less than ideal. It's overall better than OpenGL, but not quite at the level of Direct3D.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Godot has a Direct3D 12 rendering driver since 4.0, but it's not used by default.

Using Direct3D 12 by default would sidestep the Vulkan driver bugs that Godot runs into. Additionally, we gain a few upsides for using Direct3D 12:

  • Godot is automatically presented using DXGI when using D3D12, which is not the case when using Vulkan.
  • Special K injection works correctly when using D3D12, while it always crashes Godot on startup when using Vulkan (at least in my experience).
    • It's possible that this is a Godot bug, but I don't know what's causing this.

There are still a few roadblocks to using Direct3D 12 by default that we need to resolve first:

Does this affect visuals in existing projects?

Visuals are expected to be 100% identical across rendering drivers (barring renderer or driver bugs). Therefore, this should not lead to visual changes in existing projects unless you run into a bug. Please report any such bugs when using Direct3D 12; make sure to include comparison screenshots between Direct3D 12 and Vulkan.

What about performance?

Unlike the Metal rendering driver that replaces MoltenVK by default on macOS, there isn't expected to be a significant performance difference between Vulkan and Direct3D 12 on most GPUs. This may differ on Intel GPUs which are known to have performance problems in Vulkan applications, so the D3D12 driver may perform better on those GPUs.

If you want to check this for yourself, try switching your project's rendering/rendering_device/driver.windows project setting to d3d12. If you run into large performance drops that don't occur in Vulkan, please open an issue with a minimal reproduction project attached.

What if my GPU doesn't support Direct3D 12?

Any GPU that supports Vulkan also supports Direct3D 12 on Windows. If this was not the case anyway (or if you use a binary compiled without Direct3D 12 support), Godot automatically falls back to Vulkan since 4.4. If Vulkan is not supported either, then Godot automatically falls back to OpenGL.

Note

Projects that use the Compatibility rendering method are not affected by this proposal. Compatibility uses OpenGL by default, with a fallback to ANGLE on specific graphics drivers (which translates OpenGL to Direct3D 11).

What about users compiling their own binaries?

You need to go through some extra steps to enable Direct3D 12 support in self-compiled binaries.

This proposal would also enable Direct3D 12 support by default in self-compiled binaries. Compilation will fail if the D3D12 dependencies aren't installed. Users can still pass d3d12=no if they wish to build Vulkan-only binaries without having to install Direct3D 12 dependencies.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Change this line in main/main.cpp:

-		GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.windows", PROPERTY_HINT_ENUM, "vulkan,d3d12"), "vulkan");
+		GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.windows", PROPERTY_HINT_ENUM, "d3d12,vulkan"), "d3d12");

Also change this line in SConstruct:

-opts.Add(BoolVariable("d3d12", "Enable the Direct3D 12 rendering driver on supported platforms", False))
+opts.Add(BoolVariable("d3d12", "Enable the Direct3D 12 rendering driver on supported platforms", True))

If this enhancement will not be used often, can it be worked around with a few lines of script?

No.

Is there a reason why this should be core and not an add-on in the asset library?

This is about changing a rendering default setting.

Footnotes

  1. Vulkan layers are also supported on Linux, but are far less problematic overall due to apps being more behaved with layer usage there.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions