Skip to content

Commit

Permalink
Merge pull request libretro#6239 from aliaspider/master
Browse files Browse the repository at this point in the history
(msvc) CXX_BUILD + griffin fixes.
  • Loading branch information
inactive123 authored Feb 4, 2018
2 parents 69fedc6 + 5549b13 commit 377f556
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 83 deletions.
13 changes: 9 additions & 4 deletions Makefile.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions audio/drivers/xaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -101,19 +101,19 @@ 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;
InterlockedDecrement((LONG volatile*)&handle->buffers);
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,
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand All @@ -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

Expand Down
40 changes: 27 additions & 13 deletions audio/drivers/xaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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() \
Expand Down Expand Up @@ -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();
Expand All @@ -255,6 +267,8 @@ DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice)
STDMETHOD_(void, GetFrequencyRatio) (THIS_ float* pRatio) PURE;
};

#undef INTERFACE
#define INTERFACE IXAudio2

DECLARE_INTERFACE_(IXAudio2, IUnknown)
{
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions deps/libz/adler32.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define ZLIB_INTERNAL
#include <stdint.h>
#include <stddef.h>
#include <compat/zutil.h>

#define BASE 65521UL /* largest prime smaller than 65536 */
#define NMAX 5552
Expand Down
1 change: 1 addition & 0 deletions frontend/drivers/platform_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 16 additions & 40 deletions gfx/common/d3d12_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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,
},
};

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion gfx/common/d3d12_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ typedef struct
#endif
} d3d12_video_t;

enum
typedef enum
{
ROOT_ID_TEXTURE_T = 0,
ROOT_ID_SAMPLER_T,
Expand Down
6 changes: 3 additions & 3 deletions gfx/common/d3d_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions gfx/common/win32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gfx/include/d3d9/d3dx9core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down
1 change: 1 addition & 0 deletions griffin/griffin.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#define CINTERFACE
#define HAVE_IBXM 1

#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL)
Expand Down
4 changes: 2 additions & 2 deletions libretro-common/net/net_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion network/netplay/netplay_delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions ui/drivers/ui_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 0 additions & 5 deletions ui/drivers/win32/ui_win32_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 377f556

Please sign in to comment.