Joshua-Ashton / dxvk-native

D3D9/11 but it runs natively on Linux!
zlib License
404 stars 30 forks source link
d3d11 d3d9 direct3d directx dxvk native spirv vulkan

DXVK Native

DXVK Native is a port of DXVK to Linux which allows it to be used natively without Wine.

This is primarily useful for game and application ports to either avoid having to write another rendering backend, or to help with port bringup during development.

Release builds are built using the Steam Runtime.

How does it work?

DXVK Native replaces certain Windows-isms with a platform and framework-agnostic replacement, for example, HWNDs can become SDL_Window*s, etc. All it takes to do that is to add another WSI backend.

DXVK Native comes with a slim set of Windows header definitions required for D3D9/11 and the MinGW headers for D3D9/11. In most cases, it will end up being plug and play with your renderer, but there may be certain teething issues such as:

DXVK Native also has some performance tweaks for D3D9, disabling float emulation and some validation. This is configurable in d3d9_config.h.

Games/Projects Using DXVK Native

Build instructions

Requirements:

Steam Runtime

DXVK Native can be built in the Steam Runtime using docker. If you don't care about this, simply skip this section.

To build in a Steam Runtime docker, simply cd to the DXVK directory and run:

for 32-bit: docker run -e USER=$USER -e USERID=$UID -it --rm -v $(pwd):/dxvk-native registry.gitlab.steamos.cloud/steamrt/scout/sdk/i386 /bin/bash

for 64-bit: docker run -e USER=$USER -e USERID=$UID -it --rm -v $(pwd):/dxvk-native registry.gitlab.steamos.cloud/steamrt/scout/sdk /bin/bash

Building the library

Inside the DXVK directory, run either:

On your host machine:

./package-native.sh master /your/target/directory --no-package

With Steam Runtime:

./package-native-steamrt.sh master /your/target/directory --no-package

This will create a folder dxvk-native-master in /your/target/directory which will contain a the libraries and tests.

In order to preserve the build directories and symbols for development, pass --dev-build to the script.

HUD

The DXVK_HUD environment variable controls a HUD which can display the framerate and some stat counters. It accepts a comma-separated list of the following options:

Additionally, DXVK_HUD=1 has the same effect as DXVK_HUD=devinfo,fps, and DXVK_HUD=full enables all available HUD elements.

Frame rate limit

The DXVK_FRAME_RATE environment variable can be used to limit the frame rate. A value of 0 uncaps the frame rate, while any positive value will limit rendering to the given number of frames per second. Alternatively, the configuration file can be used.

Device filter

Some applications do not provide a method to select a different GPU. In that case, DXVK can be forced to use a given device:

Note: If the device filter is configured incorrectly, it may filter out all devices and applications will be unable to create a D3D device.

State cache

DXVK caches pipeline state by default, so that shaders can be recompiled ahead of time on subsequent runs of an application, even if the driver's own shader cache got invalidated in the meantime. This cache is enabled by default, and generally reduces stuttering.

The following environment variables can be used to control the cache:

Debugging

The following environment variables can be used for debugging purposes.