Skip to content

Commit

Permalink
[build] Initial support for winegcc MinGW Compatible Compiler
Browse files Browse the repository at this point in the history
 * x86_64 only (winebuild bug: always uses lib64 in paths)
 * Installed libd3dcompiler_47.def and libvulkan-1.def required
  • Loading branch information
pchome committed Feb 15, 2018
1 parent 8ebffc1 commit e7102cc
Show file tree
Hide file tree
Showing 19 changed files with 171 additions and 5 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ ninja install

The two libraries `dxgi.dll` and `d3d11.dll`as well as some demo executables will be located in `/your/dxvk/directory/bin`.

### Building native WINE DLLs
Inside the dxvk directory, run:
```
meson -Dwine-build=true --cross-file build-win64-wine.txt build.x86_64
cd build.x86_64
meson configure -Dprefix=/your/dxvk/directory/ -Dbuildtype=release
ninja
ninja install
```
## How to use
In order to set up a wine prefix to use DXVK instead of wined3d globally, run:
```
Expand Down
19 changes: 19 additions & 0 deletions build-win64-wine.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[binaries]
c = '/usr/bin/winegcc'
cpp = '/usr/bin/wineg++'
ar = '/usr/bin/ar'
strip = '/usr/bin/strip'
exe_wrapper = 'sh'

[properties]
c_args = ['-march=native']
c_link_args = []

cpp_args = ['-march=native', '-DNOMINMAX']
cpp_link_args = []

[host_machine]
system = 'linux'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
11 changes: 11 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cpu_family = target_machine.cpu_family()
dxvk_compiler = meson.get_compiler('cpp')
dxvk_include_path = include_directories('./include')

if (get_option('wine-build') == false)
if (cpu_family == 'x86_64')
dxvk_library_path = meson.source_root() + '/lib'
else
Expand All @@ -13,6 +14,16 @@ endif

lib_vulkan = dxvk_compiler.find_library('vulkan-1', dirs : dxvk_library_path)

else
add_global_arguments('-DNOMINMAX', language : 'cpp')
add_global_arguments('-DWINEBUILD', language : ['c', 'cpp'])

wine_gcc = find_program('winegcc', required : true)
wine_gpp = find_program('wineg++', required : true)

lib_vulkan = dxvk_compiler.find_library('vulkan-1')
endif

lib_d3d11 = dxvk_compiler.find_library('d3d11')
lib_dxgi = dxvk_compiler.find_library('dxgi')
lib_d3dcompiler_47 = dxvk_compiler.find_library('d3dcompiler_47')
Expand Down
28 changes: 28 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- mode: meson -*-

option('wine-build', type : 'boolean', value : 'false',
description : 'build with winebuild wrapper')


option('hud', type : 'boolean', value : 'true',
description : 'HUD support')

option('logger', type : 'boolean', value : 'true',
description : 'builtin logger support')

option('env', type : 'boolean', value : 'true',
description : 'support environment variables to interract with libraries')


option('utils', type : 'boolean', value : 'true',
description : 'build utils')

option('install-utils', type : 'boolean', value : 'false',
description : 'install utils')


option('tests', type : 'boolean', value : 'true',
description : 'build test executables')

option('install-tests', type : 'boolean', value : 'false',
description : 'install test executables')
2 changes: 2 additions & 0 deletions src/d3d11/d3d11.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ stdcall D3D11CreateDevice(ptr long ptr long ptr long long ptr ptr ptr)
@ stdcall D3D11CreateDeviceAndSwapChain(ptr long ptr long ptr long long ptr ptr ptr ptr ptr)
6 changes: 5 additions & 1 deletion src/d3d11/d3d11_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// For some strange reason, we cannot use the structures
// directly, although others from the same header work.
// Some structures are missing from the mingw headers.
#ifndef WINEBUILD
typedef struct D3D11_FEATURE_DATA_THREADING {
BOOL DriverConcurrentCreates;
BOOL DriverCommandLists;
Expand Down Expand Up @@ -58,4 +59,7 @@ typedef struct D3D11_QUERY_DATA_PIPELINE_STATISTICS {
UINT64 HSInvocations;
UINT64 DSInvocations;
UINT64 CSInvocations;
} D3D11_QUERY_DATA_PIPELINE_STATISTICS;
} D3D11_QUERY_DATA_PIPELINE_STATISTICS;
#else
typedef BOOL WINBOOL;
#endif
10 changes: 10 additions & 0 deletions src/d3d11/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,22 @@ d3d11_src = [
'd3d11_view_uav.cpp',
]

if (get_option('wine-build'))
d3d11_dll = shared_library('d3d11.dll', d3d11_src,
name_prefix : '',
link_with : [ util_lib ],
dependencies : [ lib_dxgi, dxbc_dep, dxvk_dep ], # position metter
include_directories : dxvk_include_path,
objects : 'd3d11.spec',
install : true)
else
d3d11_dll = shared_library('d3d11', d3d11_src,
name_prefix : '',
link_with : [ util_lib ],
dependencies : [ dxvk_dep, dxgi_dep, dxbc_dep ],
include_directories : dxvk_include_path,
install : true)
endif

d3d11_dep = declare_dependency(
link_with : [ d3d11_dll ],
Expand Down
6 changes: 6 additions & 0 deletions src/dxbc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ dxbc_src = files([
'dxbc_util.cpp',
])

if (get_option('wine-build'))
dxbc_lib = static_library('dxbc', dxbc_src,
dependencies : [ spirv_dep ],
include_directories : [ dxvk_include_path ])
else
dxbc_lib = static_library('dxbc', dxbc_src,
include_directories : [ dxvk_include_path ])
endif

dxbc_dep = declare_dependency(
link_with : [ dxbc_lib ],
Expand Down
3 changes: 3 additions & 0 deletions src/dxgi/dxgi.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ stdcall CreateDXGIFactory(ptr ptr)
@ stdcall CreateDXGIFactory1(ptr ptr)
@ stdcall DXGICreateDevicePrivate(ptr ptr ptr)
6 changes: 5 additions & 1 deletion src/dxgi/dxgi_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@
#define DXGI_RESOURCE_PRIORITY_NORMAL (0x78000000)
#define DXGI_RESOURCE_PRIORITY_HIGH (0xa0000000)
#define DXGI_RESOURCE_PRIORITY_MAXIMUM (0xc8000000)
#endif
#endif

#ifdef WINEBUILD
#define _countof(x) (sizeof(x)/sizeof(x[0]))
#endif
8 changes: 8 additions & 0 deletions src/dxgi/dxgi_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ namespace dxvk {
::MONITORINFOEX monInfo;

monInfo.cbSize = sizeof(monInfo);
#ifdef WINEBUILD
if (!::GetMonitorInfo(m_monitor, (LPMONITORINFO)&monInfo)) {
#else
if (!::GetMonitorInfo(m_monitor, &monInfo)) {
#endif
Logger::err("DxgiOutput: Failed to query monitor info");
return E_FAIL;
}
Expand Down Expand Up @@ -86,7 +90,11 @@ namespace dxvk {
::MONITORINFOEX monInfo;

monInfo.cbSize = sizeof(monInfo);
#ifdef WINEBUILD
if (!::GetMonitorInfo(m_monitor, (LPMONITORINFO)&monInfo)) {
#else
if (!::GetMonitorInfo(m_monitor, &monInfo)) {
#endif
Logger::err("DxgiOutput: Failed to query monitor info");
return E_FAIL;
}
Expand Down
10 changes: 10 additions & 0 deletions src/dxgi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ dxgi_src = [
'dxgi_swapchain.cpp',
]

if (get_option('wine-build'))
dxgi_dll = shared_library('dxgi.dll', dxgi_src,
name_prefix : '',
link_with : [ util_lib ],
dependencies : [ dxvk_dep ],
include_directories : dxvk_include_path,
objects : 'dxgi.spec',
install : true)
else
dxgi_dll = shared_library('dxgi', dxgi_src,
name_prefix : '',
link_with : [ util_lib ],
dependencies : [ dxvk_dep ],
include_directories : dxvk_include_path,
install : true)
endif

dxgi_dep = declare_dependency(
link_with : [ dxgi_dll ],
Expand Down
7 changes: 7 additions & 0 deletions src/dxvk/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,19 @@ dxvk_src = files([
'vulkan/dxvk_vulkan_names.cpp',
])

if (get_option('wine-build'))
dxvk_lib = static_library('dxvk', dxvk_src, glsl_generator.process(dxvk_hud_shaders),
link_with : [ util_lib, spirv_lib ],
dependencies : [ lib_vulkan, declare_dependency(link_args : ['-lpthread']) ],
include_directories : [ dxvk_include_path ])
else
thread_dep = dependency('threads')

dxvk_lib = static_library('dxvk', dxvk_src, glsl_generator.process(dxvk_hud_shaders),
link_with : [ util_lib, spirv_lib ],
dependencies : [ thread_dep, lib_vulkan ],
include_directories : [ dxvk_include_path ])
endif

dxvk_dep = declare_dependency(
link_with : [ dxvk_lib ],
Expand Down
6 changes: 6 additions & 0 deletions src/spirv/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ spirv_src = files([

spirv_lib = static_library('spirv', spirv_src,
include_directories : [ dxvk_include_path ])

if (get_option('wine-build'))
spirv_dep = declare_dependency(
link_with : [ spirv_lib ],
include_directories : [ dxvk_include_path, include_directories('.') ])
endif
5 changes: 5 additions & 0 deletions src/util/com/com_guid.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

#include "com_include.h"

#ifdef WINEBUILD
#define DXVK_DEFINE_GUID(iface) \
template<> inline GUID const& __wine_uuidof<iface> () { return iface::guid; }
#else
#define DXVK_DEFINE_GUID(iface) \
template<> inline GUID const& __mingw_uuidof<iface> () { return iface::guid; }
#endif

std::ostream& operator << (std::ostream& os, REFIID guid);
6 changes: 5 additions & 1 deletion src/util/com/com_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <unknwn.h>
#include <unknwn.h>

#ifdef WINEBUILD
#define typeof __typeof
#endif
12 changes: 11 additions & 1 deletion tests/d3d11/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
if (get_option('wine-build'))
test_d3d11_deps = [ util_dep, lib_dxgi, lib_d3d11, lib_d3dcompiler_47, declare_dependency(link_args : ['-mwindows']) ]

executable('d3d11-compute', files('test_d3d11_compute.cpp'), dependencies : test_d3d11_deps, name_suffix: 'exe', install : true)
executable('d3d11-triangle', files('test_d3d11_triangle.cpp'), dependencies : test_d3d11_deps, name_suffix: 'exe', install : true)

executable('d3d11-compute.exe', build_by_default: false, name_suffix: 'so', install : true)
executable('d3d11-triangle.exe', build_by_default: false, name_suffix: 'so', install : true)
else
test_d3d11_deps = [ util_dep, lib_dxgi, lib_d3d11, lib_d3dcompiler_47 ]

executable('d3d11-compute', files('test_d3d11_compute.cpp'), dependencies : test_d3d11_deps, install : true)
executable('d3d11-triangle', files('test_d3d11_triangle.cpp'), dependencies : test_d3d11_deps, install : true)
executable('d3d11-triangle', files('test_d3d11_triangle.cpp'), dependencies : test_d3d11_deps, install : true)
endif
12 changes: 12 additions & 0 deletions tests/dxbc/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
if (get_option('wine-build'))
test_dxbc_deps = [ dxbc_dep, dxvk_dep, declare_dependency(link_args : ['-mwindows']) ]

executable('dxbc-compiler', files('test_dxbc_compiler.cpp'), dependencies : test_dxbc_deps, name_suffix: 'exe', install : true)
executable('dxbc-disasm', files('test_dxbc_disasm.cpp'), dependencies : [ test_dxbc_deps, lib_d3dcompiler_47 ], name_suffix: 'exe', install : true)
executable('hlsl-compiler', files('test_hlsl_compiler.cpp'), dependencies : [ test_dxbc_deps, lib_d3dcompiler_47 ], name_suffix: 'exe', install : true)

executable('dxbc-compiler.exe', build_by_default: false, name_suffix: 'so', install : true)
executable('dxbc-disasm.exe', build_by_default: false, name_suffix: 'so', install : true)
executable('hlsl-compiler.exe', build_by_default: false, name_suffix: 'so', install : true)
else
test_dxbc_deps = [ dxbc_dep, dxvk_dep ]

executable('dxbc-compiler', files('test_dxbc_compiler.cpp'), dependencies : test_dxbc_deps, install : true)
executable('dxbc-disasm', files('test_dxbc_disasm.cpp'), dependencies : [ test_dxbc_deps, lib_d3dcompiler_47 ], install : true)
executable('hlsl-compiler', files('test_hlsl_compiler.cpp'), dependencies : [ test_dxbc_deps, lib_d3dcompiler_47 ], install : true)
endif
10 changes: 9 additions & 1 deletion tests/dxgi/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
if (get_option('wine-build'))
test_dxgi_deps = [ util_dep, lib_dxgi, declare_dependency(link_args : ['-mwindows']) ]

executable('dxgi-factory', files('test_dxgi_factory.cpp'), dependencies : test_dxgi_deps, name_suffix: 'exe', install: true)

executable('dxgi-factory.exe', build_by_default: false, name_suffix: 'so', install : true)
else
test_dxgi_deps = [ util_dep, lib_dxgi ]

executable('dxgi-factory', files('test_dxgi_factory.cpp'), dependencies : test_dxgi_deps, install: true)
executable('dxgi-factory', files('test_dxgi_factory.cpp'), dependencies : test_dxgi_deps, install: true)
endif

0 comments on commit e7102cc

Please sign in to comment.