include: Replace MinGW hack with Win32 platform header

Replace this hack with a more versatile one that works for multiple compilation objects.

Consolidates this hack across all the code bases (soon to be used in a D3D12 standalone patch)

Signed-off-by: Joshua Ashton <joshua@froggi.es>
This commit is contained in:
Joshua Ashton 2020-07-02 16:29:34 +01:00 committed by Philip Rebohle
parent e24914b11f
commit cb4fcd5a98
4 changed files with 76 additions and 36 deletions

View File

@ -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 <vkd3d_win32.h>
#endif
#include <vkd3d_windows.h>

View File

@ -17,7 +17,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <vkd3d_dxgi1_4.h>
#include <stdbool.h>
#include <stdio.h>

71
include/vkd3d_win32.h Normal file
View File

@ -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 <vkd3d_windows.h>
#define VK_USE_PLATFORM_WIN32_KHR
#include <vulkan/vulkan.h>
#include <dxgi1_6.h>
/* 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 <vkd3d_d3d12.h>
#include <vkd3d_d3d12sdklayers.h>
/* 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 <vkd3d.h>
#endif

View File

@ -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 <vkd3d_win32.h>
#endif
#define COBJMACROS
@ -51,9 +36,7 @@ typedef int HRESULT;
#include <math.h>
#include <time.h>
#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"