Giter Site home page Giter Site logo

joshua-ashton / dxvk-native Goto Github PK

View Code? Open in Web Editor NEW
404.0 12.0 30.0 12.15 MB

D3D9/11 but it runs natively on Linux!

License: zlib License

C 48.82% C++ 50.64% Meson 0.26% Shell 0.09% GLSL 0.20%
dxvk vulkan direct3d d3d9 d3d11 spirv native directx

dxvk-native's Introduction

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:

  • __uuidof(type) is supported, but __uuidof(variable) is not supported. Use __uuidof_var(variable) instead.

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:

  • A C++17 compiler (eg. GCC, Clang, MSVC)
  • Meson build system (at least version 0.46)
  • glslang compiler

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:

  • devinfo: Displays the name of the GPU and the driver version.
  • fps: Shows the current frame rate.
  • frametimes: Shows a frame time graph.
  • submissions: Shows the number of command buffers submitted per frame.
  • drawcalls: Shows the number of draw calls and render passes per frame.
  • pipelines: Shows the total number of graphics and compute pipelines.
  • memory: Shows the amount of device memory allocated and used.
  • gpuload: Shows estimated GPU load. May be inaccurate.
  • version: Shows DXVK version.
  • api: Shows the D3D feature level used by the application.
  • compiler: Shows shader compiler activity
  • samplers: Shows the current number of sampler pairs used [D3D9 Only]
  • scale=x: Scales the HUD by a factor of x (e.g. 1.5)

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:

  • DXVK_FILTER_DEVICE_NAME="Device Name" Selects devices with a matching Vulkan device name, which can be retrieved with tools such as vulkaninfo. Matches on substrings, so "VEGA" or "AMD RADV VEGA10" is supported if the full device name is "AMD RADV VEGA10 (LLVM 9.0.0)", for example. If the substring matches more than one device, the first device matched will be used.

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:

  • DXVK_STATE_CACHE=0 Disables the state cache.
  • DXVK_STATE_CACHE_PATH=/some/directory Specifies a directory where to put the cache files. Defaults to the current working directory of the application.

Debugging

The following environment variables can be used for debugging purposes.

  • VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation Enables Vulkan debug layers. Highly recommended for troubleshooting rendering issues and driver crashes. Requires the Vulkan SDK to be installed on the host system.
  • DXVK_LOG_LEVEL=none|error|warn|info|debug Controls message logging.
  • DXVK_LOG_PATH=/some/directory Changes path where log files are stored. Set to none to disable log file creation entirely, without disabling logging.
  • DXVK_CONFIG_FILE=/xxx/dxvk.conf Sets path to the configuration file.
  • DXVK_PERF_EVENTS=1 Enables use of the VK_EXT_debug_utils extension for translating performance event markers.

dxvk-native's People

Contributors

aeikum avatar aviau avatar cdavis5e avatar cjacek avatar cme42 avatar cwabbott0 avatar dadschoorse avatar dhewg avatar doitsujin avatar entryhazard avatar guy1524 avatar hakzsam avatar joshua-ashton avatar jp7677 avatar k0bin avatar liam-middlebrook avatar libcg avatar mixaill avatar notaz avatar pchome avatar pendingchaos avatar raffarti avatar rbernon avatar shmerl avatar ssorgatem avatar svesop avatar tayarani avatar varris1 avatar w-flo avatar zerofault avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dxvk-native's Issues

[request] pass off d9d9 to gallum-nine if the driver supports it.

It should be reasonably possible to have this library optionally use Mesa's native d3d9 implementation if is is available.
Using gallium nine is often more performant than translating d3d9 to Vulkan, however this is hampered by not being supported on anything other than the open source drivers.

There is an opportunity here to have this library transparently use it if the user is able to. These performance gains are worth the trouble, especially on late d3d9 renderers, Valve's own games should benefit from this.

Getting started with dxvk-native

Hey @Joshua-Ashton. Since building with dxvk-native may be quite different than with dxvk, I figured it will need it's own Getting started - guide. Can you possibly answer some or all of the questions below? I will try to figure out the rest ๐Ÿ’ƒ

Use case (Correct me if I am wrong)

As a developer I want to use dxvk-native to compile and run my DirectX-engine natively on Linux. (Not inside Wine!)

Getting started / FAQ for beginners

  • Which versions of which compilers are supported? gcc? clang?
  • Do I have to use Meson? Is Cmake supported?
  • How do I link dxvk-native to my own program?
  • Is static linking supported?
  • Are there code examples?

Expose VkInstance

I think it would be useful if we could use VkInstance but it's not exposed anywhere so the only option is forking/patching dxvk-native or hooking vkCreateInstance or is there any other way we can access it? Or using D3D9InterfaceEx directly is also an option.

Q: dynapi-like interface

Hello Joshua ๐Ÿธ

Quite an interesting project. However, I think every single point that led to the creation of SDL2's dynapi applies here.

Basically, is there an easy way to override the library with a newer version once it has been statically built and linked with an executable? This could help a lot with forward compatibility, though I don't even know if static linking is supported at the moment?

I suppose LD_PRELOAD might somewhat get around this issue, but I haven't tried it, and AFAIK it shouldn't work after stripping?

Thanks a lot.

fatal error: dxgi1_5.h: No such file or directory

Hi, I am trying to build dxvk-native for the first time (Because I finally know what Meson is ๐Ÿš€) . My issue is that that the dxgi1_5.h-header file is not found. See detailed output below.

I found a similar issue here doitsujin/dxvk#1239. The answer given is to update mingw-w64 to version >= 6.0.

Is mingw-w64 still required to compile dxvk-native though?

Screenshot
image

meson build --reconfigure

โžœ  dxvk-native git:(master) โœ— meson build --reconfigure
The Meson build system
Version: 0.54.0
Source dir: /home/jonas/git/github/dxvk-native
Build dir: /home/jonas/git/github/dxvk-native/build
Build type: native build
Project name: dxvk
Project version: v1.5.5
C compiler for the host machine: cc (gcc 9.2.1 "cc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008")
C linker for the host machine: cc ld.bfd 2.33
C++ compiler for the host machine: c++ (gcc 9.2.1 "c++ (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008")
C++ linker for the host machine: c++ ld.bfd 2.33
Host machine cpu family: x86_64
Host machine cpu: x86_64
Checking if "winelib check" compiles: NO (cached)
Library vulkan found: YES
Library SDL2 found: YES
Program echo found: YES (/usr/bin/echo)
Program glslangValidator found: YES (/home/jonas/bin/glslangValidator)
Dependency threads found: YES unknown (cached)
Dependency threads found: YES unknown (cached)
src/meson.build:14: WARNING: Ignoring D3D10... Not supported for DXVK native.
Build targets in project: 11

Found ninja-1.10.0 at /home/jonas/bin/ninja

ninja -C build

โžœ  dxvk-native git:(master) โœ— ninja -C build
ninja: Entering directory `build'
[1/238] Compiling C++ object 'src/util/ed6d25d@@util@sta/com_com_guid.cpp.o'
FAILED: src/util/ed6d25d@@util@sta/com_com_guid.cpp.o 
c++ -Isrc/util/ed6d25d@@util@sta -Isrc/util -I../src/util -I../include -I../include/native -I../include/native/windows -I../include/native/directx -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++17 -g -DNOMINMAX -DDXVK_NATIVE -DDXVK_WSI_SDL2 -DDXVK_PLATFORM_LINUX -fPIC -MD -MQ 'src/util/ed6d25d@@util@sta/com_com_guid.cpp.o' -MF 'src/util/ed6d25d@@util@sta/com_com_guid.cpp.o.d' -o 'src/util/ed6d25d@@util@sta/com_com_guid.cpp.o' -c ../src/util/com/com_guid.cpp
In file included from ../src/util/com/../../d3d11/../dxgi/dxgi_format.h:3,
                 from ../src/util/com/../../d3d11/../dxgi/dxgi_interfaces.h:5,
                 from ../src/util/com/../../d3d11/d3d11_interfaces.h:3,
                 from ../src/util/com/com_guid.cpp:3:
../src/util/com/../../d3d11/../dxgi/dxgi_include.h:31:10: fatal error: dxgi1_5.h: No such file or directory
   31 | #include <dxgi1_5.h>
      |          ^~~~~~~~~~~
compilation terminated.
[2/238] Generating version.h with a custom command
fatal: No names found, cannot describe anything.
[8/238] Compiling C++ object 'src/spirv/e922df6@@spirv@sta/spirv_module.cpp.o'
ninja: build stopped: subcommand failed.

[include] C Compiler Support

I was taking a look at compiling our upcoming D3D11 renderer for FNA3D against dxvk-native, but ran into some issues with the C++-isms in the Windows headers. For compatibility, the headers will likely need to act more like the real deal and work with C applications.

The build support is already integrated and ready to go, so it's just a matter of making it compile (it probably won't run since we need a d3dcompiler):

git clone --recursive https://github.com/FNA-XNA/FNA3D
git clone https://github.com/Joshua-Ashton/dxvk-native
mkdir FNA3D/flibitBuild
cd FNA3D/flibitBuild
cmake .. -DBUILD_DXVK_NATIVE=ON
make

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.