diff --git a/demos/demo.h b/demos/demo.h index b2b93172..e8022a12 100644 --- a/demos/demo.h +++ b/demos/demo.h @@ -16,21 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -/* Hack for MinGW-w64 headers. - * - * We want to use WIDL C inline wrappers because some methods - * in D3D12 interfaces return aggregate objects. Unfortunately, - * WIDL C inline wrappers are broken when used with MinGW-w64 - * headers because FORCEINLINE expands to extern inline - * which leads to the "multiple storage classes in declaration - * specifiers" compiler error. - */ -#ifdef __MINGW32__ -#include <_mingw.h> -# ifdef __MINGW64_VERSION_MAJOR -# undef __forceinline -# define __forceinline __inline__ __attribute__((__always_inline__,__gnu_inline__)) -# endif +#ifdef _WIN32 +# include #endif #include diff --git a/demos/demo_win32.h b/demos/demo_win32.h index d2a54989..10123c53 100644 --- a/demos/demo_win32.h +++ b/demos/demo_win32.h @@ -17,7 +17,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include #include diff --git a/include/vkd3d_win32.h b/include/vkd3d_win32.h new file mode 100644 index 00000000..828250a2 --- /dev/null +++ b/include/vkd3d_win32.h @@ -0,0 +1,71 @@ +/* + * Copyright 2020 Joshua Ashton for Valve Software + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#ifndef __VKD3D_WIN32_H +#define __VKD3D_WIN32_H + +/* Hack for MinGW-w64 headers. + * + * We want to use WIDL C inline wrappers because some methods + * in D3D12 interfaces return aggregate objects. Unfortunately, + * WIDL C inline wrappers are broken when used with MinGW-w64 + * headers because FORCEINLINE expands to extern inline + * which leads to the "multiple storage classes in declaration + * specifiers" compiler error. + * + * This hack will define static to be meaningless when these + * headers are included, which are the only things declared + * static. + */ +#ifdef __MINGW32__ +# define static +#endif + +#define INITGUID +#define COBJMACROS +#define WIDL_C_INLINE_WRAPPERS +#include + +#define VK_USE_PLATFORM_WIN32_KHR +#include + +#include + +/* We already included regular DXGI... + * let's not redefine everything under a new header + */ +#define __vkd3d_dxgibase_h__ +#define __vkd3d_dxgi_h__ +#define __vkd3d_dxgi1_2_h__ +#define __vkd3d_dxgi1_3_h__ +#define __vkd3d_dxgi1_4_h__ + +#include +#include + +/* End of MinGW hack. All Windows headers have been included */ +#ifdef __MINGW32__ +# undef static +#endif + +#define VKD3D_NO_WIN32_TYPES +#define VKD3D_NO_VULKAN_H +#include + +#endif \ No newline at end of file diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h index e4ad26f2..334daf28 100644 --- a/tests/d3d12_crosstest.h +++ b/tests/d3d12_crosstest.h @@ -19,23 +19,8 @@ #ifndef __VKD3D_D3D12_CROSSTEST_H #define __VKD3D_D3D12_CROSSTEST_H -/* Hack for MinGW-w64 headers. - * - * We want to use WIDL C inline wrappers because some methods - * in D3D12 interfaces return aggregate objects. Unfortunately, - * WIDL C inline wrappers are broken when used with MinGW-w64 - * headers because FORCEINLINE expands to extern inline - * which leads to the "multiple storage classes in declaration - * specifiers" compiler error. - */ -#ifdef __MINGW32__ -#include <_mingw.h> -# ifdef __MINGW64_VERSION_MAJOR -# undef __forceinline -# define __forceinline __inline__ __attribute__((__always_inline__,__gnu_inline__)) -# endif -# define _HRESULT_DEFINED -typedef int HRESULT; +#ifdef _WIN32 +# include #endif #define COBJMACROS @@ -51,9 +36,7 @@ typedef int HRESULT; #include #include -#if defined(_WIN32) && !defined(VKD3D_FORCE_UTILS_WRAPPER) -# include "vkd3d_dxgi1_4.h" -#else +#if !defined(_WIN32) || defined(VKD3D_FORCE_UTILS_WRAPPER) # include "vkd3d_threads.h" # include "vkd3d.h" # include "vkd3d_utils.h"