From 5549b136c2d31b66a846fdb0aef25b736616b4eb Mon Sep 17 00:00:00 2001 From: aliaspider Date: Mon, 5 Feb 2018 00:25:03 +0100 Subject: [PATCH] (msvc) CXX_BUILD + griffin fixes. --- Makefile.msvc | 13 ++++--- audio/drivers/xaudio.c | 22 ++++++------ audio/drivers/xaudio.h | 40 ++++++++++++++------- deps/libz/adler32.c | 1 + frontend/drivers/platform_win32.c | 1 + gfx/common/d3d12_common.c | 56 +++++++++--------------------- gfx/common/d3d12_common.h | 2 +- gfx/common/d3d_common.c | 6 ++-- gfx/common/win32_common.c | 2 -- gfx/include/d3d9/d3dx9core.h | 2 +- griffin/griffin.c | 1 + libretro-common/net/net_http.c | 4 +-- network/netplay/netplay_delta.c | 2 +- ui/drivers/ui_win32.h | 2 ++ ui/drivers/win32/ui_win32_window.c | 5 --- 15 files changed, 76 insertions(+), 83 deletions(-) diff --git a/Makefile.msvc b/Makefile.msvc index b21810c96f..7760279670 100644 --- a/Makefile.msvc +++ b/Makefile.msvc @@ -5,6 +5,7 @@ OS = Win32 ARCH = amd64 #TARGET_ARCH = x86 BUILD_DIR = objs/msvc +CXX_BUILD = 0 WindowsSdkDir = C:\Program Files (x86)\Windows Kits\10\$(NOTHING) @@ -59,7 +60,6 @@ include Makefile.common INCLUDE_DIRS := $(patsubst -isystem%,-I%,$(INCLUDE_DIRS)) CFLAGS := $(filter-out -Wno-unknown-pragmas,$(CFLAGS)) CXXFLAGS := $(filter-out -fpermissive -Wno-switch -Wno-sign-compare -fno-strict-aliasing -Wno-maybe-uninitialized -Wno-reorder -Wno-parentheses,$(CXXFLAGS)) -CXXFLAGS += $(CFLAGS) LIBS := $(filter-out -lstdc++,$(LIBS)) ifeq ($(ARCH),x64) @@ -124,11 +124,16 @@ FLAGS += -Gm- -Zc:inline -fp:precise -Zc:forScope -GR- -Gd -Oi -volatile:iso #FLAGS += -utf-8 #FLAGS += -source-charset:utf-8 +CXXFLAGS += $(CFLAGS) -TP -EHsc +ifeq ($(CXX_BUILD),1) + CFLAGS := $(CXXFLAGS) + DEFINES += -DCXX_BUILD +else + CFLAGS += -TC +endif -CFLAGS += -TC -CXXFLAGS += -TP -EHsc WARNINGS += -WX -W3 -WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018 -wd4800 +WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018 -wd4800 -wd4838 CC = cl.exe CXX = cl.exe diff --git a/audio/drivers/xaudio.c b/audio/drivers/xaudio.c index f267cb04e0..d344508b70 100644 --- a/audio/drivers/xaudio.c +++ b/audio/drivers/xaudio.c @@ -59,13 +59,13 @@ typedef struct size_t bufsize; } xa_t; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) struct xaudio2 : public IXAudio2VoiceCallback #else struct xaudio2 #endif { -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) xaudio2() : buf(0), pXAudio2(0), pMasterVoice(0), pSourceVoice(0), hEvent(0), buffers(0), bufsize(0), @@ -101,8 +101,8 @@ struct xaudio2 unsigned write_buffer; }; -#ifndef __cplusplus -static void WINAPI voice_on_buffer_end(void *handle_, void *data) +#if !defined(__cplusplus) || defined(CINTERFACE) +static void WINAPI voice_on_buffer_end(IXAudio2VoiceCallback *handle_, void *data) { xaudio2_t *handle = (xaudio2_t*)handle_; (void)data; @@ -110,10 +110,10 @@ static void WINAPI voice_on_buffer_end(void *handle_, void *data) SetEvent(handle->hEvent); } -static void WINAPI dummy_voidp(void *handle, void *data) { (void)handle; (void)data; } -static void WINAPI dummy_nil(void *handle) { (void)handle; } -static void WINAPI dummy_uint32(void *handle, UINT32 dummy) { (void)handle; (void)dummy; } -static void WINAPI dummy_voidp_hresult(void *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; } +static void WINAPI dummy_voidp(IXAudio2VoiceCallback *handle, void *data) { (void)handle; (void)data; } +static void WINAPI dummy_nil(IXAudio2VoiceCallback *handle) { (void)handle; } +static void WINAPI dummy_uint32(IXAudio2VoiceCallback *handle, UINT32 dummy) { (void)handle; (void)dummy; } +static void WINAPI dummy_voidp_hresult(IXAudio2VoiceCallback *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; } const struct IXAudio2VoiceCallbackVtbl voice_vtable = { dummy_uint32, @@ -189,7 +189,7 @@ static void xaudio2_free(xaudio2_t *handle) free(handle->buf); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) delete handle; #else free(handle); @@ -206,7 +206,7 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, CoInitializeEx(0, COINIT_MULTITHREADED); #endif -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) handle = new xaudio2; #else handle = (xaudio2_t*)calloc(1, sizeof(*handle)); @@ -215,7 +215,7 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, if (!handle) goto error; -#ifndef __cplusplus +#if !defined(__cplusplus) || defined(CINTERFACE) handle->lpVtbl = &voice_vtable; #endif diff --git a/audio/drivers/xaudio.h b/audio/drivers/xaudio.h index 4c03e60035..788fe16789 100644 --- a/audio/drivers/xaudio.h +++ b/audio/drivers/xaudio.h @@ -26,7 +26,7 @@ /* All structures defined in this file use tight field packing */ #pragma pack(push, 1) -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) #define X2DEFAULT(x) = (x) #else #define X2DEFAULT(x) @@ -183,6 +183,9 @@ typedef struct XAUDIO2_BUFFER void *pContext; } XAUDIO2_BUFFER; +#undef INTERFACE +#define INTERFACE IXAudio2VoiceCallback + DECLARE_INTERFACE(IXAudio2VoiceCallback) { STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) PURE; @@ -194,6 +197,9 @@ DECLARE_INTERFACE(IXAudio2VoiceCallback) STDMETHOD_(void, OnVoiceError) (THIS_ void *pBufferContext, HRESULT Error) PURE; }; +#undef INTERFACE +#define INTERFACE IXAudio2Voice + DECLARE_INTERFACE(IXAudio2Voice) { #define Declare_IXAudio2Voice_Methods() \ @@ -235,11 +241,17 @@ DECLARE_INTERFACE(IXAudio2Voice) Declare_IXAudio2Voice_Methods(); }; +#undef INTERFACE +#define INTERFACE IXAudio2MasteringVoice + DECLARE_INTERFACE_(IXAudio2MasteringVoice, IXAudio2Voice) { Declare_IXAudio2Voice_Methods(); }; +#undef INTERFACE +#define INTERFACE IXAudio2SourceVoice + DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice) { Declare_IXAudio2Voice_Methods(); @@ -255,6 +267,8 @@ DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice) STDMETHOD_(void, GetFrequencyRatio) (THIS_ float* pRatio) PURE; }; +#undef INTERFACE +#define INTERFACE IXAudio2 DECLARE_INTERFACE_(IXAudio2, IUnknown) { @@ -292,7 +306,7 @@ DECLARE_INTERFACE_(IXAudio2, IUnknown) void *pReserved X2DEFAULT(NULL)) PURE; }; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) /* C++ hooks */ #define IXAudio2_Initialize(handle,a,b) handle->Initialize(a, b) #define IXAudio2SourceVoice_SubmitSourceBuffer(handle, a, b) handle->SubmitSourceBuffer(a, b) @@ -305,17 +319,17 @@ DECLARE_INTERFACE_(IXAudio2, IUnknown) #define IXAudio2SourceVoice_Start(handle, a, b) handle->Start(a, b) #else /* C hooks */ -#define IXAudio2_Initialize(THIS,a,b) (THIS)->lpVtbl->Initialize(THIS, a, b) -#define IXAudio2_Release(THIS) (THIS)->lpVtbl->Release(THIS) -#define IXAudio2_CreateSourceVoice(THIS,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (THIS)->lpVtbl->CreateSourceVoice(THIS, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) -#define IXAudio2_CreateMasteringVoice(THIS,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (THIS)->lpVtbl->CreateMasteringVoice(THIS, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) -#define IXAudio2_GetDeviceCount(THIS, puCount) (THIS)->lpVtbl->GetDeviceCount(THIS, puCount) -#define IXAudio2_GetDeviceDetails(THIS, Index,pDeviceDetails) (THIS)->lpVtbl->GetDeviceDetails(THIS, Index, pDeviceDetails) -#define IXAudio2SourceVoice_Start(THIS, Flags, OperationSet) (THIS)->lpVtbl->Start(THIS, Flags, OperationSet) -#define IXAudio2SourceVoice_Stop(THIS, Flags, OperationSet) (THIS)->lpVtbl->Stop(THIS, Flags, OperationSet) -#define IXAudio2SourceVoice_SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) (THIS)->lpVtbl->SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) -#define IXAudio2SourceVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS) -#define IXAudio2MasteringVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS) +#define IXAudio2_Initialize(handle,a,b) (handle)->lpVtbl->Initialize(handle, a, b) +#define IXAudio2_Release(handle) (handle)->lpVtbl->Release(handle) +#define IXAudio2_CreateSourceVoice(handle,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (handle)->lpVtbl->CreateSourceVoice(handle, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) +#define IXAudio2_CreateMasteringVoice(handle,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (handle)->lpVtbl->CreateMasteringVoice(handle, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) +#define IXAudio2_GetDeviceCount(handle, puCount) (handle)->lpVtbl->GetDeviceCount(handle, puCount) +#define IXAudio2_GetDeviceDetails(handle, Index,pDeviceDetails) (handle)->lpVtbl->GetDeviceDetails(handle, Index, pDeviceDetails) +#define IXAudio2SourceVoice_Start(handle, Flags, OperationSet) (handle)->lpVtbl->Start(handle, Flags, OperationSet) +#define IXAudio2SourceVoice_Stop(handle, Flags, OperationSet) (handle)->lpVtbl->Stop(handle, Flags, OperationSet) +#define IXAudio2SourceVoice_SubmitSourceBuffer(handle, pBuffer, pBufferWMA) (handle)->lpVtbl->SubmitSourceBuffer(handle, pBuffer, pBufferWMA) +#define IXAudio2SourceVoice_DestroyVoice(handle) (handle)->lpVtbl->DestroyVoice(handle) +#define IXAudio2MasteringVoice_DestroyVoice(handle) (handle)->lpVtbl->DestroyVoice(handle) #endif #ifdef _XBOX diff --git a/deps/libz/adler32.c b/deps/libz/adler32.c index 67d6030f95..dad0dacf9d 100644 --- a/deps/libz/adler32.c +++ b/deps/libz/adler32.c @@ -8,6 +8,7 @@ #define ZLIB_INTERNAL #include #include +#include #define BASE 65521UL /* largest prime smaller than 65536 */ #define NMAX 5552 diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index b0dec9dd78..cce85bce6e 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -41,6 +41,7 @@ #include "../../defaults.h" #include "../../retroarch.h" #include "../../verbosity.h" +#include "../../ui/drivers/ui_win32.h" /* We only load this library once, so we let it be * unloaded at application shutdown, since unloading diff --git a/gfx/common/d3d12_common.c b/gfx/common/d3d12_common.c index b54a3604aa..d5d74b8b65 100644 --- a/gfx/common/d3d12_common.c +++ b/gfx/common/d3d12_common.c @@ -268,19 +268,12 @@ static void d3d12_init_sampler( D3D12_TEXTURE_ADDRESS_MODE address_mode, D3D12_GPU_DESCRIPTOR_HANDLE* dst) { - D3D12_SAMPLER_DESC sampler_desc = { - .Filter = filter, - .AddressU = address_mode, - .AddressV = address_mode, - .AddressW = address_mode, - .MipLODBias = 0, - .MaxAnisotropy = 0, - .ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER, - .BorderColor = { 0.0f }, - .MinLOD = 0.0f, - .MaxLOD = D3D12_FLOAT32_MAX, - }; - D3D12_CPU_DESCRIPTOR_HANDLE handle = { heap->cpu.ptr + heap_index * heap->stride }; + D3D12_SAMPLER_DESC sampler_desc = { filter, address_mode, address_mode, address_mode }; + D3D12_CPU_DESCRIPTOR_HANDLE handle = { heap->cpu.ptr + heap_index * heap->stride }; + + sampler_desc.ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER; + sampler_desc.MaxLOD = D3D12_FLOAT32_MAX; + D3D12CreateSampler(device, &sampler_desc, handle); dst->ptr = heap->gpu.ptr + heap_index * heap->stride; } @@ -290,23 +283,20 @@ bool d3d12_init_descriptors(d3d12_video_t* d3d12) D3D12_ROOT_SIGNATURE_DESC desc; static const D3D12_DESCRIPTOR_RANGE srv_table[] = { { - .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV, - .NumDescriptors = 1, - .BaseShaderRegister = 0, - .RegisterSpace = 0, -#if 0 - .Flags = D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC, /* version 1_1 only */ -#endif - .OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, + D3D12_DESCRIPTOR_RANGE_TYPE_SRV, + 1, + 0, + 0, + D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, }, }; static const D3D12_DESCRIPTOR_RANGE sampler_table[] = { { - .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, - .NumDescriptors = 1, - .BaseShaderRegister = 0, - .RegisterSpace = 0, - .OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, + D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, + 1, + 0, + 0, + D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, }, }; @@ -397,20 +387,6 @@ bool d3d12_init_pipeline(d3d12_video_t* d3d12) D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, }; - static const D3D12_RASTERIZER_DESC rasterizerDesc = { - .FillMode = D3D12_FILL_MODE_SOLID, - .CullMode = D3D12_CULL_MODE_BACK, - .FrontCounterClockwise = FALSE, - .DepthBias = D3D12_DEFAULT_DEPTH_BIAS, - .DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP, - .SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS, - .DepthClipEnable = TRUE, - .MultisampleEnable = FALSE, - .AntialiasedLineEnable = FALSE, - .ForcedSampleCount = 0, - .ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF, - }; - if (!d3d_compile(stock, sizeof(stock), NULL, "VSMain", "vs_5_0", &vs_code)) return false; diff --git a/gfx/common/d3d12_common.h b/gfx/common/d3d12_common.h index 38ca8994e0..6dce196957 100644 --- a/gfx/common/d3d12_common.h +++ b/gfx/common/d3d12_common.h @@ -1363,7 +1363,7 @@ typedef struct #endif } d3d12_video_t; -enum +typedef enum { ROOT_ID_TEXTURE_T = 0, ROOT_ID_SAMPLER_T, diff --git a/gfx/common/d3d_common.c b/gfx/common/d3d_common.c index b1e2ff0888..4d8fc4406b 100644 --- a/gfx/common/d3d_common.c +++ b/gfx/common/d3d_common.c @@ -2872,7 +2872,7 @@ void d3dxbuffer_release(void *data) if (!p) return; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) p->Release(); #else p->lpVtbl->Release(p); @@ -3053,7 +3053,7 @@ const void *d3dx_get_buffer_ptr(void *data) ID3DXBuffer *listing = (ID3DXBuffer*)data; if (!listing) return NULL; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) return listing->GetBufferPointer(); #else return listing->lpVtbl->GetBufferPointer(listing); @@ -3073,7 +3073,7 @@ const bool d3dx_constant_table_set_float(void *p, LPD3DXCONSTANTTABLE consttbl = (LPD3DXCONSTANTTABLE)p; if (!consttbl || !dev || !handle) return false; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) if (consttbl->SetFloat(dev, handle, val) == D3D_OK) return true; #else diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index ab37d7ab1e..64403356b1 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -561,8 +561,6 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, return 0; } -extern VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL); - static void win32_set_droppable(ui_window_win32_t *window, bool droppable) { if (DragAcceptFiles_func != NULL) diff --git a/gfx/include/d3d9/d3dx9core.h b/gfx/include/d3d9/d3dx9core.h index 1c0b755cdf..92ac586356 100644 --- a/gfx/include/d3d9/d3dx9core.h +++ b/gfx/include/d3d9/d3dx9core.h @@ -194,7 +194,7 @@ DECLARE_INTERFACE_(ID3DXFont, IUnknown) STDMETHOD(OnLostDevice)(THIS) PURE; STDMETHOD(OnResetDevice)(THIS) PURE; -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(CINTERFACE) #ifdef UNICODE HRESULT GetDesc(D3DXFONT_DESCW *pDesc) { return GetDescW(pDesc); } HRESULT PreloadText(LPCWSTR pString, INT Count) { return PreloadTextW(pString, Count); } diff --git a/griffin/griffin.c b/griffin/griffin.c index 7243b2fbcc..2cfe446c80 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -14,6 +14,7 @@ * If not, see . */ +#define CINTERFACE #define HAVE_IBXM 1 #if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index be1b90b91b..fb40d89b7d 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -398,9 +398,9 @@ struct http_t *net_http_new(struct http_connection_t *conn) post_len = strlen(conn->postdatacopy); #ifdef _WIN32 - len = snprintf(NULL, 0, "%"PRIuPTR, post_len); + len = snprintf(NULL, 0, "%" PRIuPTR, post_len); len_str = (char*)malloc(len + 1); - snprintf(len_str, len + 1, "%"PRIuPTR, post_len); + snprintf(len_str, len + 1, "%" PRIuPTR, post_len); #else len = snprintf(NULL, 0, "%llu", (long long unsigned)post_len); len_str = (char*)malloc(len + 1); diff --git a/network/netplay/netplay_delta.c b/network/netplay/netplay_delta.c index edfd225427..d6b7efe58b 100644 --- a/network/netplay/netplay_delta.c +++ b/network/netplay/netplay_delta.c @@ -152,7 +152,7 @@ netplay_input_state_t netplay_input_state_for(netplay_input_state_t *list, return NULL; /* Couldn't find a slot, allocate a fresh one */ - ret = calloc(1, sizeof(struct netplay_input_state) + (size-1) * sizeof(uint32_t)); + ret = (netplay_input_state_t)calloc(1, sizeof(struct netplay_input_state) + (size-1) * sizeof(uint32_t)); if (!ret) return NULL; *list = ret; diff --git a/ui/drivers/ui_win32.h b/ui/drivers/ui_win32.h index 89e0cb2aef..588207db57 100644 --- a/ui/drivers/ui_win32.h +++ b/ui/drivers/ui_win32.h @@ -42,6 +42,8 @@ typedef struct ui_window_win32 HWND hwnd; } ui_window_win32_t; +extern VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL); + RETRO_END_DECLS #endif diff --git a/ui/drivers/win32/ui_win32_window.c b/ui/drivers/win32/ui_win32_window.c index eb89047526..bd39aa50d6 100644 --- a/ui/drivers/win32/ui_win32_window.c +++ b/ui/drivers/win32/ui_win32_window.c @@ -75,11 +75,6 @@ static void ui_window_win32_set_title(void *data, char *buf) SetWindowText(window->hwnd, buf); } -#ifdef __cplusplus -extern "C" -#endif - VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL); - void ui_window_win32_set_droppable(void *data, bool droppable) { /* Minimum supported client: Windows XP, minimum supported server: Windows 2000 Server */