1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

Add support for MSVC, attempt 3 (#130)

* [dxvk] fixes for MSVC

* nullptr -> int is illegal conversion for MSVC. nullptr was replaced with VK_NULL_HANDLE
* MSVC does not support source code strings longer than 65535 chars. String was replaced with array of chars.

* [utils] fixes for MSVC

* __mingw_uuidof() does not exists in MSVC
* apply GCC pragma only for GCC
* added missing header

* [dxbc] fixes for MSVC

*added missing header

* [dxgi] fixes for MSVC

* user __declspec(uuid()) instead of _mingw_uuidof()
* do not use DLLEXPORT macro for MSVC

* [d3d11] fixes for MSVC

* replace WINBOOL with BOOL
* do not declare D3D11 structs for MSVC
* do not use DLLEXPORT macro for MSVC

* [meson] fix build scripts for MSVC

* change cpp version from c++1z to c++latest for MSVC
* set -DOMINMAX definition for MSVC
* disable test and wine_utils for MSVC
* use .def files instead of __declspec(dllexport) for MSVC (bypass 'C2375: redefinition; different linkage' error)
* fix .def files for MinGW
* add --enable-stdcall-fixup linker flag for MinGW
This commit is contained in:
Mikhail Paulyshka 2018-03-06 20:34:34 +03:00 committed by Philip Rebohle
parent 88c4e363e5
commit 9deb73a2a7
29 changed files with 1840 additions and 1789 deletions

View File

@ -10,7 +10,7 @@ c_args = ['-Og', '-gdwarf-2']
c_link_args = ['-static', '-static-libgcc']
cpp_args = ['-Og', '-gdwarf-2']
cpp_link_args = ['-static', '-static-libgcc', '-static-libstdc++', '-Wl,--add-stdcall-alias']
cpp_link_args = ['-static', '-static-libgcc', '-static-libstdc++', '-Wl,--add-stdcall-alias,--enable-stdcall-fixup']
[host_machine]
system = 'windows'

View File

@ -1,8 +1,15 @@
project('dxvk', ['c', 'cpp'], default_options : ['cpp_std=c++1z'])
project('dxvk', ['c', 'cpp'])
cpu_family = target_machine.cpu_family()
dxvk_compiler = meson.get_compiler('cpp')
if dxvk_compiler.get_id() == 'msvc'
add_global_arguments('-DNOMINMAX', language : 'cpp')
dxvk_cpp_std='c++latest'
else
dxvk_cpp_std='c++1z'
endif
dxvk_include_path = include_directories('./include')
if (cpu_family == 'x86_64')
@ -18,7 +25,9 @@ lib_spirvtools_opt = dxvk_compiler.find_library('libSPIRV-Tools-opt', dirs : dxv
lib_d3d11 = dxvk_compiler.find_library('d3d11')
lib_dxgi = dxvk_compiler.find_library('dxgi')
lib_d3dcompiler_47 = dxvk_compiler.find_library('d3dcompiler_47')
if dxvk_compiler.get_id() != 'msvc'
lib_d3dcompiler_47 = dxvk_compiler.find_library('d3dcompiler_47')
endif
glsl_compiler = find_program('glslangValidator')
glsl_generator = generator(glsl_compiler,
@ -26,5 +35,7 @@ glsl_generator = generator(glsl_compiler,
arguments : [ '-V', '--vn', '@BASENAME@', '@INPUT@', '-o', '@OUTPUT@' ])
subdir('src')
subdir('tests')
subdir('wine_utils')
if dxvk_compiler.get_id() != 'msvc'
subdir('tests')
subdir('wine_utils')
endif

4
src/d3d11/d3d11.def Normal file
View File

@ -0,0 +1,4 @@
LIBRARY D3D11.DLL
EXPORTS
D3D11CreateDevice
D3D11CreateDeviceAndSwapChain

View File

@ -225,14 +225,14 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11DeviceContext::SetPredication(
ID3D11Predicate* pPredicate,
WINBOOL PredicateValue) {
BOOL PredicateValue) {
Logger::err("D3D11DeviceContext::SetPredication: Not implemented");
}
void STDMETHODCALLTYPE D3D11DeviceContext::GetPredication(
ID3D11Predicate** ppPredicate,
WINBOOL* pPredicateValue) {
BOOL* pPredicateValue) {
Logger::err("D3D11DeviceContext::GetPredication: Not implemented");
}

View File

@ -40,11 +40,11 @@ namespace dxvk {
void STDMETHODCALLTYPE SetPredication(
ID3D11Predicate* pPredicate,
WINBOOL PredicateValue) final;
BOOL PredicateValue) final;
void STDMETHODCALLTYPE GetPredication(
ID3D11Predicate** ppPredicate,
WINBOOL* pPredicateValue) final;
BOOL* pPredicateValue) final;
void STDMETHODCALLTYPE CopySubresourceRegion(
ID3D11Resource* pDstResource,

View File

@ -30,7 +30,7 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11DeferredContext::ExecuteCommandList(
ID3D11CommandList* pCommandList,
WINBOOL RestoreContextState) {
BOOL RestoreContextState) {
static_cast<D3D11CommandList*>(pCommandList)->EmitToCommandList(m_commandList.ptr());
if (RestoreContextState)
@ -41,7 +41,7 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11DeferredContext::FinishCommandList(
WINBOOL RestoreDeferredContextState,
BOOL RestoreDeferredContextState,
ID3D11CommandList **ppCommandList) {
if (ppCommandList != nullptr)
*ppCommandList = m_commandList.ref();

View File

@ -22,10 +22,10 @@ namespace dxvk {
void STDMETHODCALLTYPE ExecuteCommandList(
ID3D11CommandList* pCommandList,
WINBOOL RestoreContextState) final;
BOOL RestoreContextState) final;
HRESULT STDMETHODCALLTYPE FinishCommandList(
WINBOOL RestoreDeferredContextState,
BOOL RestoreDeferredContextState,
ID3D11CommandList **ppCommandList) final;
HRESULT STDMETHODCALLTYPE Map(

View File

@ -64,7 +64,7 @@ namespace dxvk {
void STDMETHODCALLTYPE D3D11ImmediateContext::ExecuteCommandList(
ID3D11CommandList* pCommandList,
WINBOOL RestoreContextState) {
BOOL RestoreContextState) {
static_cast<D3D11CommandList*>(pCommandList)->EmitToCsThread(&m_csThread);
if (RestoreContextState)
@ -75,7 +75,7 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11ImmediateContext::FinishCommandList(
WINBOOL RestoreDeferredContextState,
BOOL RestoreDeferredContextState,
ID3D11CommandList **ppCommandList) {
Logger::err("D3D11: FinishCommandList called on immediate context");
return DXGI_ERROR_INVALID_CALL;

View File

@ -25,10 +25,10 @@ namespace dxvk {
void STDMETHODCALLTYPE ExecuteCommandList(
ID3D11CommandList* pCommandList,
WINBOOL RestoreContextState) final;
BOOL RestoreContextState) final;
HRESULT STDMETHODCALLTYPE FinishCommandList(
WINBOOL RestoreDeferredContextState,
BOOL RestoreDeferredContextState,
ID3D11CommandList **ppCommandList) final;
HRESULT STDMETHODCALLTYPE Map(

View File

@ -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 _MSC_VER
typedef struct D3D11_FEATURE_DATA_THREADING {
BOOL DriverConcurrentCreates;
BOOL DriverCommandLists;
@ -58,4 +59,5 @@ typedef struct D3D11_QUERY_DATA_PIPELINE_STATISTICS {
UINT64 HSInvocations;
UINT64 DSInvocations;
UINT64 CSInvocations;
} D3D11_QUERY_DATA_PIPELINE_STATISTICS;
} D3D11_QUERY_DATA_PIPELINE_STATISTICS;
#endif

View File

@ -30,7 +30,9 @@ d3d11_dll = shared_library('d3d11', d3d11_src,
link_with : [ util_lib ],
dependencies : [ dxvk_dep, dxgi_dep, dxbc_dep ],
include_directories : dxvk_include_path,
install : true)
install : true,
vs_module_defs : 'd3d11.def',
override_options : ['cpp_std='+dxvk_cpp_std])
d3d11_dep = declare_dependency(
link_with : [ d3d11_dll ],

View File

@ -1,5 +1,7 @@
#pragma once
#include <cctype>
#include "dxbc_common.h"
#include "dxbc_decoder.h"
#include "dxbc_enums.h"

View File

@ -14,7 +14,8 @@ dxbc_src = files([
])
dxbc_lib = static_library('dxbc', dxbc_src,
include_directories : [ dxvk_include_path ])
include_directories : [ dxvk_include_path ],
override_options : ['cpp_std='+dxvk_cpp_std])
dxbc_dep = declare_dependency(
link_with : [ dxbc_lib ],

6
src/dxgi/dxgi.def Normal file
View File

@ -0,0 +1,6 @@
LIBRARY DXGI.DLL
EXPORTS
CreateDXGIFactory
CreateDXGIFactory1
CreateDXGIFactory2
DXGICreateDevicePrivate

View File

@ -72,7 +72,7 @@ namespace dxvk {
extern "C" {
DLLEXPORT HRESULT __stdcall DXGICreateDevicePrivate(
HRESULT __stdcall DXGICreateDevicePrivate(
IDXGIAdapterPrivate* pAdapter,
const VkPhysicalDeviceFeatures* features,
IDXGIDevicePrivate** ppDevice);

View File

@ -1,6 +1,11 @@
#pragma once
#define DLLEXPORT __declspec(dllexport)
//for some reason we need to specify __declspec(dllexport) for MinGW
#ifdef _MSC_VER
#define DLLEXPORT
#else
#define DLLEXPORT __declspec(dllexport)
#endif
#include "../util/com/com_guid.h"
#include "../util/com/com_object.h"

View File

@ -155,8 +155,14 @@ IDXGIPresentDevicePrivate : public IUnknown {
void** ppDevice) = 0;
};
#ifdef _MSC_VER
struct __declspec(uuid("907bf281-ea3c-43b4-a8e4-9f231107b4ff")) IDXGIAdapterPrivate;
struct __declspec(uuid("7a622cf6-627a-46b2-b52f-360ef3da831c")) IDXGIDevicePrivate;
struct __declspec(uuid("5679becd-8547-4d93-96a1-e61a1ce7ef37")) IDXGIPresentBackBuffer;
struct __declspec(uuid("79352328-16f2-4f81-9746-9c2e2ccd43cf")) IDXGIPresentDevicePrivate;
#else
DXVK_DEFINE_GUID(IDXGIAdapterPrivate);
DXVK_DEFINE_GUID(IDXGIDevicePrivate);
DXVK_DEFINE_GUID(IDXGIPresentBackBuffer);
DXVK_DEFINE_GUID(IDXGIPresentDevicePrivate);
#endif

View File

@ -14,7 +14,9 @@ dxgi_dll = shared_library('dxgi', dxgi_src,
link_with : [ util_lib ],
dependencies : [ dxvk_dep ],
include_directories : dxvk_include_path,
install : true)
install : true,
vs_module_defs : 'dxgi.def',
override_options : ['cpp_std='+dxvk_cpp_std])
dxgi_dep = declare_dependency(
link_with : [ dxgi_dll ],

View File

@ -25,7 +25,7 @@ namespace dxvk {
DxvkMemory::DxvkMemory(DxvkMemory&& other)
: m_chunk (std::exchange(other.m_chunk, nullptr)),
m_heap (std::exchange(other.m_heap, nullptr)),
m_memory (std::exchange(other.m_memory, VkDeviceMemory(nullptr))),
m_memory (std::exchange(other.m_memory, VkDeviceMemory(VK_NULL_HANDLE))),
m_offset (std::exchange(other.m_offset, 0)),
m_length (std::exchange(other.m_length, 0)),
m_mapPtr (std::exchange(other.m_mapPtr, nullptr)) { }
@ -34,7 +34,7 @@ namespace dxvk {
DxvkMemory& DxvkMemory::operator = (DxvkMemory&& other) {
m_chunk = std::exchange(other.m_chunk, nullptr);
m_heap = std::exchange(other.m_heap, nullptr);
m_memory = std::exchange(other.m_memory, VkDeviceMemory(nullptr));
m_memory = std::exchange(other.m_memory, VkDeviceMemory(VK_NULL_HANDLE));
m_offset = std::exchange(other.m_offset, 0);
m_length = std::exchange(other.m_length, 0);
m_mapPtr = std::exchange(other.m_mapPtr, nullptr);

File diff suppressed because it is too large Load Diff

View File

@ -63,7 +63,8 @@ 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 ])
include_directories : [ dxvk_include_path ],
override_options : ['cpp_std='+dxvk_cpp_std])
dxvk_dep = declare_dependency(
link_with : [ dxvk_lib ],

View File

@ -5,4 +5,5 @@ spirv_src = files([
spirv_lib = static_library('spirv', spirv_src,
include_directories : [ dxvk_include_path ],
dependencies : [ lib_spirvtools, lib_spirvtools_opt ])
dependencies : [ lib_spirvtools, lib_spirvtools_opt ],
override_options : ['cpp_std='+dxvk_cpp_std])

View File

@ -5,7 +5,9 @@
#include "com_include.h"
#ifndef _MSC_VER
#define DXVK_DEFINE_GUID(iface) \
template<> inline GUID const& __mingw_uuidof<iface> () { return iface::guid; }
#endif
std::ostream& operator << (std::ostream& os, REFIID guid);

View File

@ -2,7 +2,9 @@
// GCC complains about the COM interfaces
// not having virtual destructors
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif // __GNUC__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

View File

@ -1,5 +1,6 @@
#pragma once
#include <array>
#include <fstream>
#include <iostream>
#include <mutex>

View File

@ -12,7 +12,8 @@ util_src = files([
])
util_lib = static_library('util', util_src,
include_directories : [ dxvk_include_path ])
include_directories : [ dxvk_include_path ],
override_options : ['cpp_std='+dxvk_cpp_std])
util_dep = declare_dependency(
link_with : [ util_lib ])

View File

@ -1,4 +1,4 @@
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-compute', files('test_d3d11_compute.cpp'), dependencies : test_d3d11_deps, install : true, override_options: ['cpp_std='+dxvk_cpp_std])
executable('d3d11-triangle', files('test_d3d11_triangle.cpp'), dependencies : test_d3d11_deps, install : true, override_options: ['cpp_std='+dxvk_cpp_std])

View File

@ -1,5 +1,5 @@
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)
executable('dxbc-compiler', files('test_dxbc_compiler.cpp'), dependencies : test_dxbc_deps, install : true, override_options: ['cpp_std='+dxvk_cpp_std])
executable('dxbc-disasm', files('test_dxbc_disasm.cpp'), dependencies : [ test_dxbc_deps, lib_d3dcompiler_47 ], install : true, override_options: ['cpp_std='+dxvk_cpp_std])
executable('hlsl-compiler', files('test_hlsl_compiler.cpp'), dependencies : [ test_dxbc_deps, lib_d3dcompiler_47 ], install : true, override_options: ['cpp_std='+dxvk_cpp_std])

View File

@ -1,3 +1,3 @@
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, override_options: ['cpp_std='+dxvk_cpp_std])