From 7b3f84aae8e1448606347c7548671cf5392eb0a4 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Fri, 3 Mar 2017 22:48:05 +0100 Subject: [PATCH] More buildfixes for Windows on ARM --- Common/ArmEmitter.h | 2 +- Common/ColorConv.h | 13 +++++++------ Common/MemoryUtil.cpp | 1 + Core/Util/AudioFormat.h | 2 +- GPU/Common/TextureDecoderNEON.cpp | 12 +++++++++--- GPU/D3D11/ShaderManagerD3D11.cpp | 3 ++- Globals.h | 4 ++-- Windows/GPU/D3D11Context.cpp | 4 ++++ ext/native/base/logging.h | 6 ++++-- ext/native/ext/jpge/jpgd.cpp | 2 +- ext/native/thin3d/d3d11_loader.cpp | 4 ++++ ext/native/thin3d/d3d11_loader.h | 4 ++++ ppsspp_config.h | 6 +++++- 13 files changed, 45 insertions(+), 18 deletions(-) diff --git a/Common/ArmEmitter.h b/Common/ArmEmitter.h index f875596fe9..1b77020355 100644 --- a/Common/ArmEmitter.h +++ b/Common/ArmEmitter.h @@ -18,7 +18,7 @@ #pragma once #include -#include +#include #include "Common.h" #include "ArmCommon.h" diff --git a/Common/ColorConv.h b/Common/ColorConv.h index 11a5b6f013..3947f8bf52 100644 --- a/Common/ColorConv.h +++ b/Common/ColorConv.h @@ -17,6 +17,7 @@ #pragma once +#include "ppsspp_config.h" #include "CommonTypes.h" #include "ColorConvNEON.h" @@ -138,25 +139,25 @@ void ConvertRGBA4444ToABGR4444Basic(u16 *dst, const u16 *src, u32 numPixels); void ConvertRGBA5551ToABGR1555Basic(u16 *dst, const u16 *src, u32 numPixels); void ConvertRGB565ToBGR565Basic(u16 *dst, const u16 *src, u32 numPixels); -#if defined(ARM64) +#if PPSSPP_ARCH(ARM64) #define ConvertRGBA4444ToABGR4444 ConvertRGBA4444ToABGR4444NEON -#elif !defined(ARM) +#elif !PPSSPP_ARCH(ARM) #define ConvertRGBA4444ToABGR4444 ConvertRGBA4444ToABGR4444Basic #else extern Convert16bppTo16bppFunc ConvertRGBA4444ToABGR4444; #endif -#if defined(ARM64) +#if PPSSPP_ARCH(ARM64) #define ConvertRGBA5551ToABGR1555 ConvertRGBA5551ToABGR1555NEON -#elif !defined(ARM) +#elif !PPSSPP_ARCH(ARM) #define ConvertRGBA5551ToABGR1555 ConvertRGBA5551ToABGR1555Basic #else extern Convert16bppTo16bppFunc ConvertRGBA5551ToABGR1555; #endif -#if defined(ARM64) +#if PPSSPP_ARCH(ARM64) #define ConvertRGB565ToBGR565 ConvertRGB565ToBGR565NEON -#elif !defined(ARM) +#elif !PPSSPP_ARCH(ARM) #define ConvertRGB565ToBGR565 ConvertRGB565ToBGR565Basic #else extern Convert16bppTo16bppFunc ConvertRGB565ToBGR565; diff --git a/Common/MemoryUtil.cpp b/Common/MemoryUtil.cpp index 9d33abfe0b..1eeff3a8a8 100644 --- a/Common/MemoryUtil.cpp +++ b/Common/MemoryUtil.cpp @@ -15,6 +15,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ +#include "ppsspp_config.h" #include "Common.h" #include "MemoryUtil.h" #include "StringUtils.h" diff --git a/Core/Util/AudioFormat.h b/Core/Util/AudioFormat.h index 4f23dcf076..b39d3feaa6 100644 --- a/Core/Util/AudioFormat.h +++ b/Core/Util/AudioFormat.h @@ -22,7 +22,7 @@ #include "Globals.h" static inline s16 ApplySampleVolume(s16 sample, int vol) { -#if PPSSPP_ARCH(ARM) +#if PPSSPP_ARCH(ARM) && !defined(_MSC_VER) register int r; asm volatile("smulwb %0, %1, %2\n\t" \ "ssat %0, #16, %0" \ diff --git a/GPU/Common/TextureDecoderNEON.cpp b/GPU/Common/TextureDecoderNEON.cpp index 011b078f6c..e30d1c8101 100644 --- a/GPU/Common/TextureDecoderNEON.cpp +++ b/GPU/Common/TextureDecoderNEON.cpp @@ -28,12 +28,16 @@ static const u16 MEMORY_ALIGNED16(QuickTexHashInitial[8]) = {0xc00bU, 0x9bd9U, 0x4b73U, 0xb651U, 0x4d9bU, 0x4309U, 0x0083U, 0x0001U}; +#ifdef _MSC_VER +#define __builtin_prefetch(a,b,c) +#endif + u32 QuickTexHashNEON(const void *checkp, u32 size) { u32 check = 0; __builtin_prefetch(checkp, 0, 0); if (((intptr_t)checkp & 0xf) == 0 && (size & 0x3f) == 0) { -#if defined(IOS) || PPSSPP_ARCH(ARM64) +#if defined(IOS) || PPSSPP_ARCH(ARM64) || defined(_MSC_VER) uint32x4_t cursor = vdupq_n_u32(0); uint16x8_t cursor2 = vld1q_u16(QuickTexHashInitial); uint16x8_t update = vdupq_n_u16(0x2455U); @@ -210,8 +214,7 @@ u32 ReliableHash32NEON(const void *input, size_t len, u32 seed) { uint32x4_t prime32_2q = vdupq_n_u32(PRIME32_2); uint32x4_t vq = vcombine_u32(vcreate_u32(v1 | ((U64)v2 << 32)), vcreate_u32(v3 | ((U64)v4 << 32))); - do - { + do { __builtin_prefetch(p + 0xc0, 0, 0); vq = vmlaq_u32(vq, vld1q_u32((const U32*)p), prime32_2q); vq = vorrq_u32(vshlq_n_u32(vq, 13), vshrq_n_u32(vq, 32 - 13)); @@ -263,12 +266,15 @@ static inline bool VectorIsNonZeroNEON(const uint32x4_t &v) { return (low | high) != 0; } +#ifndef _MSC_VER +// MSVC consider this function the same as the one above! uint16x8_t is typedef'd to the same type as uint32x4_t. static inline bool VectorIsNonZeroNEON(const uint16x8_t &v) { u64 low = vgetq_lane_u64(vreinterpretq_u64_u16(v), 0); u64 high = vgetq_lane_u64(vreinterpretq_u64_u16(v), 1); return (low | high) != 0; } +#endif CheckAlphaResult CheckAlphaRGBA8888NEON(const u32 *pixelData, int stride, int w, int h) { const uint32x4_t zero = vdupq_n_u32(0); diff --git a/GPU/D3D11/ShaderManagerD3D11.cpp b/GPU/D3D11/ShaderManagerD3D11.cpp index b352b64f6f..5ae80f0000 100644 --- a/GPU/D3D11/ShaderManagerD3D11.cpp +++ b/GPU/D3D11/ShaderManagerD3D11.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #include #include @@ -25,7 +27,6 @@ #include "math/math_util.h" #include "math/dataconv.h" #include "util/text/utf8.h" -#include "thin3d/d3d11_loader.h" #include "Common/Common.h" #include "Core/Config.h" #include "Core/Reporting.h" diff --git a/Globals.h b/Globals.h index 4d3fcf7f16..3cf4d4308a 100644 --- a/Globals.h +++ b/Globals.h @@ -32,7 +32,7 @@ #define IS_BIG_ENDIAN (*(const u16 *)"\0\xff" < 0x100) static inline u8 clamp_u8(int i) { -#if PPSSPP_ARCH(ARM) +#if PPSSPP_ARCH(ARM) && !defined(_MSC_VER) asm("usat %0, #8, %1" : "=r"(i) : "r"(i)); #else if (i > 255) @@ -44,7 +44,7 @@ static inline u8 clamp_u8(int i) { } static inline s16 clamp_s16(int i) { -#if PPSSPP_ARCH(ARM) +#if PPSSPP_ARCH(ARM) && !defined(_MSC_VER) asm("ssat %0, #16, %1" : "=r"(i) : "r"(i)); #else if (i > 32767) diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index b77afb4c05..fb8e53c83f 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -14,6 +14,10 @@ #include "thin3d/thin3d.h" #include "thin3d/d3d11_loader.h" +#if PPSSPP_PLATFORM(UWP) +#error This file should not be compiled for UWP. +#endif + D3D11Context::D3D11Context() : draw_(nullptr), adapterId(-1), hDC(nullptr), hWnd_(nullptr), hD3D11(nullptr) { } diff --git a/ext/native/base/logging.h b/ext/native/base/logging.h index 2659aabbe4..bea7bb5356 100644 --- a/ext/native/base/logging.h +++ b/ext/native/base/logging.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include "base/arch.h" #include "base/backtrace.h" @@ -22,8 +22,10 @@ #ifdef _M_X64 inline void Crash() { int *x = (int *)1337; *x = 1; } -#else +#elif defined(_M_IX86) inline void Crash() { __asm { int 3 }; } +#elif defined(_M_ARM) +inline void Crash() { int *x = (int *)1337; *x = 1; } #endif #else diff --git a/ext/native/ext/jpge/jpgd.cpp b/ext/native/ext/jpge/jpgd.cpp index cc47bd721c..5fdc1ba52a 100644 --- a/ext/native/ext/jpge/jpgd.cpp +++ b/ext/native/ext/jpge/jpgd.cpp @@ -3088,7 +3088,7 @@ unsigned char *decompress_jpeg_image_from_stream(jpeg_decoder_stream *pStream, i for (int y = 0; y < image_height; y++) { - const uint8* pScan_line; + const uint8* pScan_line = nullptr; uint scan_line_len; if (decoder.decode((const void**)&pScan_line, &scan_line_len) != JPGD_SUCCESS) { diff --git a/ext/native/thin3d/d3d11_loader.cpp b/ext/native/thin3d/d3d11_loader.cpp index 3fa61ea6ad..32ded1792f 100644 --- a/ext/native/thin3d/d3d11_loader.cpp +++ b/ext/native/thin3d/d3d11_loader.cpp @@ -1,5 +1,9 @@ #include "thin3d/d3d11_loader.h" +#if PPSSPP_PLATFORM(UWP) +#error This file should not be compiled for UWP. +#endif + static HMODULE g_DXGIModule; static HMODULE g_D3D11Module; static HMODULE g_D3DCompileModule; diff --git a/ext/native/thin3d/d3d11_loader.h b/ext/native/thin3d/d3d11_loader.h index 53f4678938..750d1da980 100644 --- a/ext/native/thin3d/d3d11_loader.h +++ b/ext/native/thin3d/d3d11_loader.h @@ -9,6 +9,10 @@ #include #include +#if PPSSPP_PLATFORM(UWP) +#error This file should not be compiled for UWP. +#endif + typedef HRESULT (WINAPI *LPCREATEDXGIFACTORY)(REFIID, void **); typedef HRESULT (WINAPI *LPD3D11CREATEDEVICEANDSWAPCHAIN)(__in_opt IDXGIAdapter *pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, __in_ecount_opt(FeatureLevels) CONST D3D_FEATURE_LEVEL *pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, __in_opt CONST DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, __out_opt IDXGISwapChain **ppSwapChain, __out_opt ID3D11Device **ppDevice, __out_opt D3D_FEATURE_LEVEL *pFeatureLevel, __out_opt ID3D11DeviceContext **ppImmediateContext); typedef HRESULT (WINAPI *LPD3D11CREATEDEVICE)(IDXGIAdapter *, D3D_DRIVER_TYPE, HMODULE, UINT32, D3D_FEATURE_LEVEL *, UINT, UINT32, ID3D11Device **, D3D_FEATURE_LEVEL *, ID3D11DeviceContext **); diff --git a/ppsspp_config.h b/ppsspp_config.h index a05ce6fbe7..9d7a38b41c 100644 --- a/ppsspp_config.h +++ b/ppsspp_config.h @@ -25,7 +25,7 @@ #endif #endif -#if defined(__arm__) +#if defined(__arm__) || defined(_M_ARM) #define PPSSPP_ARCH_ARM 1 #define PPSSPP_ARCH_32BIT 1 @@ -43,6 +43,10 @@ #define PPSSPP_ARCH_ARM_NEON 1 #endif + #if defined(_M_ARM) + #define PPSSPP_ARCH_ARMV7 1 + #define PPSSPP_ARCH_ARM_NEON 1 + #endif //TODO: Remove this compat define #ifndef ARM #define ARM 1