diff --git a/CMakeLists.txt b/CMakeLists.txt index e6f573c77f..7374907069 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,11 @@ include(ccache) # Remove soon? set(USE_FFMPEG ON) +# the libraries in the ffmpeg/ directory are not compatible with mingw +if(MINGW AND NOT DEFINED USE_SYSTEM_FFMPEG) + set(USE_SYSTEM_FFMPEG ON) +endif() + if(NOT ANDROID AND NOT IOS) if(ARM OR SIMULATOR) set(USING_EGL ON) @@ -243,7 +248,7 @@ if(NOT MSVC) add_definitions(-Wno-deprecated-register) # Don't compile with strict aliasing, we're not 100% aliasing-safe - add_definitions(-fno-strict-aliasing) + add_compile_options(-fno-strict-aliasing) if (${CMAKE_C_COMPILER_ID} STREQUAL "Intel") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -parallel -fopenmp") endif() @@ -273,13 +278,16 @@ if(NOT MSVC) else() # Disable warnings about MS-specific _s variants of libc functions add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_definitions(-D_UNICODE -DUNICODE) - add_definitions(-DUSING_WIN_UI) add_definitions(-MP) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_NDEBUG") endif() +if(WIN32) + add_definitions(-D_UNICODE -DUNICODE) + add_definitions(-DUSING_WIN_UI) +endif() + if(NOT ANDROID) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") @@ -419,7 +427,15 @@ target_link_libraries(Common Ext::Snappy) if(WIN32) include_directories(dx9sdk/Include) - target_link_libraries(Common winmm d3d9 dxguid dsound) + include_directories(dx9sdk/Include/DX11) + if(MINGW) + set(CMAKE_RC_COMPILE_OBJECT " -O coff ") + # required when using the dx9sdk include paths + add_definitions(-include ${CMAKE_CURRENT_SOURCE_DIR}/Windows/mingw_defines.h) + else() + target_link_libraries(Common dxguid) + endif() + target_link_libraries(Common winmm d3d9 dsound) endif() if(TARGET SDL2::SDL2) @@ -772,24 +788,6 @@ elseif(USING_QT_UI) set(nativeExtraLibs ${nativeExtraLibs} Qt5::Multimedia) endif() -elseif(TARGET SDL2::SDL2) - set(TargetBin PPSSPPSDL) - # Require SDL - add_definitions(-DSDL) - set(nativeExtra ${nativeExtra} - SDL/SDLJoystick.h - SDL/SDLJoystick.cpp - SDL/SDLMain.cpp - SDL/SDLGLGraphicsContext.cpp - SDL/SDLVulkanGraphicsContext.cpp) - set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2) - if(APPLE) - set(nativeExtra ${nativeExtra} SDL/SDLMain.h SDL/SDLMain.mm) - set(nativeExtraLibs ${nativeExtraLibs} ${COCOA_LIBRARY}) - elseif(USING_EGL) - set(nativeExtraLibs ${nativeExtraLibs} pthread) - endif() - set(TargetBin PPSSPPSDL) elseif(WIN32) # Don't care about SDL. set(TargetBin PPSSPPWindows) @@ -798,6 +796,25 @@ elseif(WIN32) else() link_directories(dx9sdk/Lib/x86) endif() + set(nativeExtra ${nativeExtra} ext/native/base/logging.cpp) +elseif(TARGET SDL2::SDL2) + set(TargetBin PPSSPPSDL) + # Require SDL + add_definitions(-DSDL) + set(nativeExtra ${nativeExtra} + SDL/SDLJoystick.h + SDL/SDLJoystick.cpp + SDL/SDLMain.cpp + SDL/SDLGLGraphicsContext.cpp + SDL/SDLVulkanGraphicsContext.cpp) + set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2) + if(APPLE) + set(nativeExtra ${nativeExtra} SDL/SDLMain.h SDL/SDLMain.mm) + set(nativeExtraLibs ${nativeExtraLibs} ${COCOA_LIBRARY}) + elseif(USING_EGL) + set(nativeExtraLibs ${nativeExtraLibs} pthread) + endif() + set(TargetBin PPSSPPSDL) else() message(FATAL_ERROR "Could not find SDL2. Failing.") endif() @@ -1031,7 +1048,7 @@ if(ANDROID) SET(ATOMIC_LIB atomic) endif() -target_link_libraries(native ${LIBZIP_LIBRARY} ${ZLIB_LIBRARY} ${PNG_LIBRARY} rg_etc1 vjson udis86 ${RT_LIB} ${nativeExtraLibs} ${ATOMIC_LIB}) +target_link_libraries(native ${LIBZIP_LIBRARY} ${PNG_LIBRARY} ${ZLIB_LIBRARY} rg_etc1 vjson udis86 ${RT_LIB} ${nativeExtraLibs} ${ATOMIC_LIB}) if(TARGET Ext::GLEW) target_link_libraries(native Ext::GLEW) endif() @@ -1080,7 +1097,7 @@ include_directories(ext/xxhash) set(CoreExtra) set(CoreExtraLibs) -if(WINDOWS OR ANDROID) +if(WIN32 OR ANDROID) set(CoreExtraLibs ${CoreExtraLibs} armips) endif() @@ -1689,6 +1706,10 @@ set(CoreExtraLibs ${CoreExtraLibs} armips) set(GlslangLibs glslang OGLCompiler OSDependent SPIRV SPVRemapper spirv-cross-glsl) +if(WIN32) + set(GlslangLibs ${GlslangLibs} spirv-cross-hlsl) +endif() + target_link_libraries(${CoreLibName} Common native kirk cityhash sfmt19937 xbrz xxhash ${GlslangLibs} ${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${CMAKE_DL_LIBS}) @@ -1700,6 +1721,7 @@ if(FFmpeg_FOUND) FFmpeg::avutil FFmpeg::swresample FFmpeg::swscale + ${ZLIB_LIBRARY} ) endif() @@ -1765,7 +1787,6 @@ set(WindowsFiles Windows/EmuThread.cpp Windows/EmuThread.h Windows/GeDebugger/GeDebugger.cpp - Windows/Globals.cpp Windows/GPU/D3D9Context.cpp Windows/GPU/D3D9Context.h Windows/GPU/D3D11Context.cpp @@ -1813,7 +1834,7 @@ set(WindowsFiles list(APPEND LinkCommon ${CoreLibName} ${CMAKE_THREAD_LIBS_INIT}) if(WIN32) - list(APPEND LinkCommon kernel32 user32 gdi32 shell32 comctl32 dsound xinput) + list(APPEND LinkCommon kernel32 user32 gdi32 shell32 comctl32 dsound xinput d3d9 winmm dinput8 ole32 winspool ksuser) #setup_target_project(${TargetBin} Windows) list(APPEND NativeAppSource ${WindowsFiles}) endif() @@ -1892,7 +1913,11 @@ if (TargetBin) endif() elseif(WIN32) add_executable(${TargetBin} WIN32 ${NativeAppSource}) - set_target_properties(${TargetBin} PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") + if(MSVC) + set_target_properties(${TargetBin} PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") + else() + set_target_properties(${TargetBin} PROPERTIES LINK_FLAGS "-Wl,-subsystem,windows") + endif() set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TargetBin}) else() add_executable(${TargetBin} ${NativeAppSource}) diff --git a/Common/CommonFuncs.h b/Common/CommonFuncs.h index b8a9aea66d..cfcbbe0e78 100644 --- a/Common/CommonFuncs.h +++ b/Common/CommonFuncs.h @@ -61,8 +61,10 @@ inline u64 __rotr64(u64 x, unsigned int shift){ #else // WIN32 // Function Cross-Compatibility +#ifndef __MINGW32__ #define strcasecmp _stricmp #define strncasecmp _strnicmp +#endif #define unlink _unlink #define __rotl _rotl #define __rotl64 _rotl64 diff --git a/Common/LogManager.cpp b/Common/LogManager.cpp index 57dde3beff..c138f34533 100644 --- a/Common/LogManager.cpp +++ b/Common/LogManager.cpp @@ -176,6 +176,7 @@ void LogManager::ChangeFileLog(const char *filename) { if (fileLog_) { RemoveListener(fileLog_); delete fileLog_; + fileLog_ = nullptr; } if (filename) { @@ -245,16 +246,20 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const } char msgBuf[1024]; + va_list args_copy; + + va_copy(args_copy, args); size_t neededBytes = vsnprintf(msgBuf, sizeof(msgBuf), format, args); if (neededBytes > sizeof(msgBuf)) { // Needed more space? Re-run vsnprintf. message.msg.resize(neededBytes + 1); - vsnprintf(&message.msg[0], neededBytes + 1, format, args); + vsnprintf(&message.msg[0], neededBytes + 1, format, args_copy); } else { message.msg.resize(neededBytes + 1); memcpy(&message.msg[0], msgBuf, neededBytes); } message.msg[message.msg.size() - 1] = '\n'; + va_end(args_copy); std::lock_guard listeners_lock(listeners_lock_); for (auto &iter : listeners_) { diff --git a/Common/Misc.cpp b/Common/Misc.cpp index 460b64c3ee..af573729b9 100644 --- a/Common/Misc.cpp +++ b/Common/Misc.cpp @@ -43,13 +43,13 @@ const char *GetLastErrorMsg() const char *GetStringErrorMsg(int errCode) { static const size_t buff_size = 1023; #ifdef _WIN32 - static __declspec(thread) wchar_t err_strw[buff_size] = {}; + static __THREAD wchar_t err_strw[buff_size] = {}; FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err_strw, buff_size, NULL); - static __declspec(thread) char err_str[buff_size] = {}; + static __THREAD char err_str[buff_size] = {}; snprintf(err_str, buff_size, "%s", ConvertWStringToUTF8(err_strw).c_str()); #else static __thread char err_str[buff_size] = {}; diff --git a/Common/OSVersion.cpp b/Common/OSVersion.cpp index ef60b85ef5..eaddb29c42 100644 --- a/Common/OSVersion.cpp +++ b/Common/OSVersion.cpp @@ -1,6 +1,6 @@ #include "ppsspp_config.h" -#ifdef _MSC_VER +#ifdef _WIN32 #include #include "OSVersion.h" @@ -93,4 +93,4 @@ std::string GetWindowsSystemArchitecture() { return "(Unknown)"; } -#endif \ No newline at end of file +#endif diff --git a/Common/OSVersion.h b/Common/OSVersion.h index 2b17d304eb..1f441e412c 100644 --- a/Common/OSVersion.h +++ b/Common/OSVersion.h @@ -2,11 +2,11 @@ #include -#ifdef _MSC_VER +#ifdef _WIN32 bool IsVistaOrHigher(); bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, bool acceptGreater); std::string GetWindowsVersion(); std::string GetWindowsSystemArchitecture(); -#endif \ No newline at end of file +#endif diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index 77fa7ed392..6a173e4db1 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -1151,6 +1151,10 @@ void VulkanDeleteList::Take(VulkanDeleteList &del) { } void VulkanDeleteList::PerformDeletes(VkDevice device) { + for (auto &callback : callbacks_) { + callback.func(callback.userdata); + } + callbacks_.clear(); for (auto &cmdPool : cmdPools_) { vkDestroyCommandPool(device, cmdPool, nullptr); } @@ -1211,8 +1215,4 @@ void VulkanDeleteList::PerformDeletes(VkDevice device) { vkDestroyDescriptorSetLayout(device, descSetLayout, nullptr); } descSetLayouts_.clear(); - for (auto &callback : callbacks_) { - callback.func(callback.userdata); - } - callbacks_.clear(); } diff --git a/Common/Vulkan/VulkanLoader.h b/Common/Vulkan/VulkanLoader.h index d51d833da5..680fbe46ac 100644 --- a/Common/Vulkan/VulkanLoader.h +++ b/Common/Vulkan/VulkanLoader.h @@ -22,8 +22,10 @@ #elif defined(_WIN32) #define VK_USE_PLATFORM_WIN32_KHR #define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX #define NOMINMAX #endif +#endif #define VK_NO_PROTOTYPES diff --git a/Common/stdafx.h b/Common/stdafx.h index 037c0bd0a5..1f18c24ec4 100644 --- a/Common/stdafx.h +++ b/Common/stdafx.h @@ -20,16 +20,16 @@ #ifdef _WIN32 #ifndef _WIN32_WINNT -#if _MSC_VER < 1700 +#if defined(_MSC_VER) && _MSC_VER < 1700 #error You need a newer version of Visual Studio. #else -#define _WIN32_WINNT 0x600 +#define _WIN32_WINNT 0x601 #endif #endif // #ifndef _WIN32_WINNT #undef WINVER -#define WINVER 0x0600 +#define WINVER _WIN32_WINNT #ifndef _WIN32_IE #define _WIN32_IE 0x0600 // Default value is 0x0400 #endif diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 5b80b23e79..a37184a45f 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -15,6 +15,10 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#ifdef __MINGW32__ +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L +#endif + #include #include "i18n/i18n.h" diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index b6febf7fa3..8e8ffc4f8c 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -387,8 +387,8 @@ protected: bool gameUsesSequentialCopies_ = false; // Sampled in BeginFrame for safety. - float renderWidth_; - float renderHeight_; + float renderWidth_ = 0.0f; + float renderHeight_ = 0.0f; int pixelWidth_; int pixelHeight_; int bloomHack_ = 0; diff --git a/GPU/D3D11/D3D11Util.cpp b/GPU/D3D11/D3D11Util.cpp index ac2a904fa9..a3b2e963af 100644 --- a/GPU/D3D11/D3D11Util.cpp +++ b/GPU/D3D11/D3D11Util.cpp @@ -1,6 +1,7 @@ #include "ppsspp_config.h" #include +#include #include #include #include @@ -151,4 +152,4 @@ void StockObjectsD3D11::Destroy() { samplerLinear2DClamp->Release(); } -StockObjectsD3D11 stockD3D11; \ No newline at end of file +StockObjectsD3D11 stockD3D11; diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index afd0add47b..44bb9ab6d2 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -332,8 +332,8 @@ protected: bool debugRecording_; bool interruptsEnabled_; bool resized_; - DrawType lastDraw_; - GEPrimitiveType lastPrim_; + DrawType lastDraw_ = DRAW_UNKNOWN; + GEPrimitiveType lastPrim_ = GE_PRIM_INVALID; int vertexCost_ = 0; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 73085778f1..3811641bb6 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -182,7 +182,9 @@ void TextureCacheVulkan::DeviceLost() { } samplerCache_.DeviceLost(); - vulkan_->Delete().QueueDeleteSampler(samplerNearest_); + + if (samplerNearest_) + vulkan_->Delete().QueueDeleteSampler(samplerNearest_); nextTexture_ = nullptr; } diff --git a/SDL/SDLJoystick.h b/SDL/SDLJoystick.h index c5d8113efc..970b105199 100644 --- a/SDL/SDLJoystick.h +++ b/SDL/SDLJoystick.h @@ -1,5 +1,5 @@ #pragma once -#ifdef _WIN32 +#ifdef _MSC_VER #include "SDL/SDL.h" #include "SDL/SDL_thread.h" #else diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index b27503e452..3a831e4ccb 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -712,7 +712,11 @@ void GameSettingsScreen::CreateViews() { SavePathInMyDocumentChoice->SetEnabled(false); } else { if (installed_ && (result == S_OK)) { +#ifdef _MSC_VER std::ifstream inputFile(ConvertUTF8ToWString(installedFile)); +#else + std::ifstream inputFile(installedFile); +#endif if (!inputFile.fail() && inputFile.is_open()) { std::string tempString; std::getline(inputFile, tempString); diff --git a/Windows/DSoundStream.cpp b/Windows/DSoundStream.cpp index d7bb534fc9..79d8d2699e 100644 --- a/Windows/DSoundStream.cpp +++ b/Windows/DSoundStream.cpp @@ -1,8 +1,15 @@ #include "Common/CommonWindows.h" #include -#include #include +#ifdef __MINGW32__ +#define __null +#endif +#include +#ifdef __MINGW32__ +#undef __null +#endif + #include "thread/threadutil.h" #include "Common/OSVersion.h" #include "Core/Reporting.h" @@ -317,8 +324,16 @@ int WASAPIAudioBackend::RunThread() { REFERENCE_TIME hnsBufferDuration, hnsActualDuration; UINT32 pNumBufferFrames; UINT32 pNumPaddingFrames, pNumAvFrames; + short *shortBuf = nullptr; + int numSamples; hnsBufferDuration = REFTIMES_PER_SEC; + enum { + UNKNOWN_FORMAT = 0, + IEEE_FLOAT = 1, + PCM16 = 2, + } format = UNKNOWN_FORMAT; + HRESULT hresult; hresult = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, /*Object is not created as the part of the aggregate */ @@ -357,12 +372,6 @@ int WASAPIAudioBackend::RunThread() { sampleRate_ = pDeviceFormat->Format.nSamplesPerSec; - enum { - UNKNOWN_FORMAT = 0, - IEEE_FLOAT = 1, - PCM16 = 2, - } format = UNKNOWN_FORMAT; - // Don't know if PCM16 ever shows up here, the documentation only talks about float... but let's blindly // try to support it :P @@ -383,11 +392,10 @@ int WASAPIAudioBackend::RunThread() { } } - short *shortBuf = nullptr; BYTE *pData; hresult = pAudioRenderClient->GetBuffer(pNumBufferFrames, &pData); - int numSamples = pNumBufferFrames * pDeviceFormat->Format.nChannels; + numSamples = pNumBufferFrames * pDeviceFormat->Format.nChannels; if (format == IEEE_FLOAT) { memset(pData, 0, sizeof(float) * numSamples); shortBuf = new short[pNumBufferFrames * pDeviceFormat->Format.nChannels]; diff --git a/Windows/Debugger/Debugger_Misc.cpp b/Windows/Debugger/Debugger_Misc.cpp index 5cd6e47f06..60655866ed 100644 --- a/Windows/Debugger/Debugger_Misc.cpp +++ b/Windows/Debugger/Debugger_Misc.cpp @@ -3,7 +3,6 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" -#include "../../Globals.h" ///////////////////////////////////////////////////////////////////////////////////////////////////// // I M P L E M E N T A T I O N ////////////////////////////////////////////////////////////////////// diff --git a/Windows/DinputDevice.cpp b/Windows/DinputDevice.cpp index 8d0f2cd953..7a67e976a0 100644 --- a/Windows/DinputDevice.cpp +++ b/Windows/DinputDevice.cpp @@ -15,8 +15,10 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "stdafx.h" #include #include +#include #include "Core/HLE/sceCtrl.h" #include "DinputDevice.h" diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 03a8124725..d3181c8493 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -45,7 +45,6 @@ extern std::vector GetWideCmdLine(); class GraphicsContext; static GraphicsContext *g_graphicsContext; -void EmuThreadFunc(GraphicsContext *graphicsContext); void MainThreadFunc(); // On most other platforms, we let the "main" thread become the render thread and diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index e42ddd2eed..28b1540af3 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -17,6 +17,11 @@ #include "thin3d/thin3d_create.h" #include "thin3d/d3d11_loader.h" +#ifdef __MINGW32__ +#undef __uuidof +#define __uuidof(type) IID_##type +#endif + #if PPSSPP_PLATFORM(UWP) #error This file should not be compiled for UWP. #endif diff --git a/Windows/InputBox.h b/Windows/InputBox.h index 19feafab28..e82c785e5d 100644 --- a/Windows/InputBox.h +++ b/Windows/InputBox.h @@ -1,5 +1,6 @@ #pragma once +#include #include "Common/CommonWindows.h" diff --git a/Windows/KeyboardDevice.cpp b/Windows/KeyboardDevice.cpp index cb546e082d..ff7033323f 100644 --- a/Windows/KeyboardDevice.cpp +++ b/Windows/KeyboardDevice.cpp @@ -5,7 +5,7 @@ #include "KeyMap.h" #include "KeyboardDevice.h" #include "../Common/CommonTypes.h" -#include "WinUser.h" +#include "../Common/CommonWindows.h" // TODO: More keys need to be added, but this is more than diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index f15bcfe3a5..67a820042e 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -20,7 +20,7 @@ // NOTE: Apologies for the quality of this code, this is really from pre-opensource Dolphin - that is, 2003. // It's improving slowly, though. :) - +#include "stdafx.h" #include "Common/CommonWindows.h" #include "Common/KeyMap.h" #include "Common/OSVersion.h" diff --git a/Windows/TouchInputHandler.cpp b/Windows/TouchInputHandler.cpp index cab9cf085f..b4f4bd38c7 100644 --- a/Windows/TouchInputHandler.cpp +++ b/Windows/TouchInputHandler.cpp @@ -1,4 +1,4 @@ -#define NOMINMAX +#include "stdafx.h" #include #include "Windows/TouchInputHandler.h" @@ -7,6 +7,7 @@ #include "base/display.h" #include "Common/CommonWindows.h" #include "Common/CommonFuncs.h" +#include "Common/Log.h" #include "base/NativeApp.h" #include "Windows/MainWindow.h" diff --git a/Windows/W32Util/Misc.cpp b/Windows/W32Util/Misc.cpp index f7db70d477..7c2953b2d6 100644 --- a/Windows/W32Util/Misc.cpp +++ b/Windows/W32Util/Misc.cpp @@ -56,7 +56,7 @@ namespace W32Util void NiceSizeFormat(size_t size, char *out) { - char *sizes[] = {"B","KB","MB","GB","TB","PB","EB"}; + const char *sizes[] = {"B","KB","MB","GB","TB","PB","EB"}; int s = 0; int frac = 0; while (size>=1024) @@ -172,7 +172,7 @@ GenericListControl::GenericListControl(HWND hwnd, const GenericListViewDef& def) int totalListSize = rect.right-rect.left; for (int i = 0; i < columnCount; i++) { lvc.cx = columns[i].size * totalListSize; - lvc.pszText = columns[i].name; + lvc.pszText = (LPTSTR)columns[i].name; if (columns[i].flags & GLVC_CENTERED) lvc.fmt = LVCFMT_CENTER; @@ -385,4 +385,4 @@ void GenericListControl::SelectAll() int GenericListControl::GetSelectedIndex() { return ListView_GetNextItem(handle, -1, LVNI_SELECTED); -} \ No newline at end of file +} diff --git a/Windows/W32Util/Misc.h b/Windows/W32Util/Misc.h index f73e72b548..457874450e 100644 --- a/Windows/W32Util/Misc.h +++ b/Windows/W32Util/Misc.h @@ -1,5 +1,6 @@ #pragma once +#include #include "Common/CommonWindows.h" namespace W32Util @@ -15,7 +16,7 @@ namespace W32Util struct GenericListViewColumn { - wchar_t *name; + const wchar_t *name; float size; int flags; }; @@ -71,4 +72,4 @@ private: // Used for hacky workaround to fix a rare hang (see issue #5184) volatile bool inResizeColumns; volatile bool updating; -}; \ No newline at end of file +}; diff --git a/Windows/W32Util/TabControl.cpp b/Windows/W32Util/TabControl.cpp index b2a9545a66..3da65ff4b9 100644 --- a/Windows/W32Util/TabControl.cpp +++ b/Windows/W32Util/TabControl.cpp @@ -15,7 +15,7 @@ TabControl::TabControl(HWND handle, bool noDisplayArea) hasButtons = (GetWindowLong(handle,GWL_STYLE) & TCS_BUTTONS) != 0; } -HWND TabControl::AddTabWindow(wchar_t* className, wchar_t* title, DWORD style) +HWND TabControl::AddTabWindow(const wchar_t* className, const wchar_t *title, DWORD style) { TabInfo info; info.hasBorder = (style & WS_BORDER) != 0; @@ -50,13 +50,13 @@ HWND TabControl::AddTabWindow(wchar_t* className, wchar_t* title, DWORD style) return tabHandle; } -void TabControl::AddTabDialog(Dialog* dialog, wchar_t* title) +void TabControl::AddTabDialog(Dialog* dialog, const wchar_t* title) { HWND handle = dialog->GetDlgHandle(); AddTab(handle,title); } -void TabControl::AddTab(HWND handle, wchar_t* title) +void TabControl::AddTab(HWND handle, const wchar_t* title) { if (showTabTitles) AppendPageToControl(title); @@ -93,13 +93,13 @@ void TabControl::AddTab(HWND handle, wchar_t* title) ShowTab(index); } -int TabControl::AppendPageToControl(wchar_t* title) +int TabControl::AppendPageToControl(const wchar_t *title) { TCITEM tcItem; ZeroMemory (&tcItem,sizeof (tcItem)); tcItem.mask = TCIF_TEXT; tcItem.dwState = 0; - tcItem.pszText = title; + tcItem.pszText = (LPTSTR)title; tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; tcItem.iImage = 0; @@ -304,4 +304,4 @@ LRESULT CALLBACK TabControl::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM } return (LRESULT)CallWindowProc((WNDPROC)tabControl->oldProc,hwnd,msg,wParam,lParam); -} \ No newline at end of file +} diff --git a/Windows/W32Util/TabControl.h b/Windows/W32Util/TabControl.h index 4640ec40c9..e6229166c4 100644 --- a/Windows/W32Util/TabControl.h +++ b/Windows/W32Util/TabControl.h @@ -11,9 +11,9 @@ class TabControl public: TabControl(HWND handle, bool noDisplayArea = false); void HandleNotify(LPARAM lParam); - HWND AddTabWindow(wchar_t* className, wchar_t* title, DWORD style = 0); - void AddTabDialog(Dialog* dialog, wchar_t* title); - void AddTab(HWND hwnd, wchar_t* title); + HWND AddTabWindow(const wchar_t* className, const wchar_t* title, DWORD style = 0); + void AddTabDialog(Dialog* dialog, const wchar_t* title); + void AddTab(HWND hwnd, const wchar_t* title); void ShowTab(int index, bool setControlIndex = true); void ShowTab(HWND pageHandle); void NextTab(bool cycle); @@ -33,7 +33,7 @@ public: private: static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); void OnResize(); - int AppendPageToControl(wchar_t* title); + int AppendPageToControl(const wchar_t* title); struct TabInfo { @@ -52,4 +52,4 @@ private: int currentTab; bool hasButtons; bool noDisplayArea_; -}; \ No newline at end of file +}; diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index f6110b5493..ce306cbfe0 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -247,7 +247,7 @@ void WindowsHost::BootDone() { Core_EnableStepping(!g_Config.bAutoRun); } -static std::string SymbolMapFilename(const char *currentFilename, char* ext) { +static std::string SymbolMapFilename(const char *currentFilename, const char* ext) { FileInfo info; std::string result = currentFilename; @@ -256,9 +256,9 @@ static std::string SymbolMapFilename(const char *currentFilename, char* ext) { getFileInfo(currentFilename, &info); if (info.isDirectory) { #ifdef _WIN32 - char* slash = "\\"; + const char* slash = "\\"; #else - char* slash = "/"; + const char* slash = "/"; #endif if (!endsWith(result,slash)) result += slash; diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index d7d2198c35..f05aeca316 100644 --- a/Windows/WindowsHost.h +++ b/Windows/WindowsHost.h @@ -18,6 +18,7 @@ #include "../Core/Host.h" #include "InputDevice.h" #include "KeyboardDevice.h" +#include "Common/CommonWindows.h" #include #include diff --git a/Windows/XinputDevice.cpp b/Windows/XinputDevice.cpp index d1f40f7e83..575f4891d4 100644 --- a/Windows/XinputDevice.cpp +++ b/Windows/XinputDevice.cpp @@ -5,6 +5,7 @@ #include "base/NativeApp.h" #include "Core/Config.h" +#include "Common/CommonWindows.h" #include "Common/KeyMap.h" #include "Common/Log.h" #include "input/input_state.h" diff --git a/Windows/main.cpp b/Windows/main.cpp index 0e9259b93d..cf04660d4e 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -15,6 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "stdafx.h" #include #include diff --git a/Windows/mingw_defines.h b/Windows/mingw_defines.h new file mode 100644 index 0000000000..ff49b2dbaa --- /dev/null +++ b/Windows/mingw_defines.h @@ -0,0 +1,237 @@ + +/* these defines are needed when using the msvc headers from the dx9sdk directory with mingw */ + +#pragma once + +#define WINAPI_FAMILY_ONE_PARTITION(vset, v) ((WINAPI_FAMILY & vset) == v) + +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +/* Pointer parameters */ +#define _In_ +#define _Out_ +#define _Inout_ +#define _In_z_ +#define _Inout_z_ +#define _In_reads_(s) +#define _In_reads_bytes_(s) +#define _In_reads_z_(s) +#define _In_reads_or_z_(s) +#define _Out_writes_(s) +#define _Out_writes_bytes_(s) +#define _Out_writes_z_(s) +#define _Inout_updates_(s) +#define _Inout_updates_bytes_(s) +#define _Inout_updates_z_(s) +#define _Out_writes_to_(s,c) +#define _Out_writes_bytes_to_(s, c) +#define _Out_writes_all_(s) +#define _Out_writes_bytes_all_(s) +#define _Inout_updates_to_(s, c) +#define _Inout_updates_bytes_to_(s, c) +#define _Inout_updates_all_(s) +#define _Inout_updates_bytes_all_(s) +#define _In_reads_to_ptr_(p) +#define _In_reads_to_ptr_z_(p) +#define _Out_writes_to_ptr_(p) +#define _Out_writes_to_ptr_z(p) + +/* Optional pointer parameters */ +#define __in_opt +#define __out_opt +#define __inout_opt +#define _In_opt_ +#define _Out_opt_ +#define _Inout_opt_ +#define _In_opt_z_ +#define _Inout_opt_z_ +#define _In_reads_opt_(s) +#define _In_reads_bytes_opt_(s) +#define _In_reads_opt_z_(s) + +#define _Out_writes_opt_(s) +#define _Out_writes_opt_z_(s) +#define _Inout_updates_opt_(s) +#define _Inout_updates_bytes_opt_(s) +#define _Inout_updates_opt_z_(s) +#define _Out_writes_to_opt_(s, c) +#define _Out_writes_bytes_to_opt_(s, c) +#define _Out_writes_all_opt_(s) +#define _Out_writes_bytes_all_opt_(s) + +#define _Inout_updates_to_opt_(s, c) +#define _Inout_updates_bytes_to_opt_(s, c) +#define _Inout_updates_all_opt_(s) +#define _Inout_updates_bytes_all_opt_(s) +#define _In_reads_to_ptr_opt_(p) +#define _In_reads_to_ptr_opt_z_(p) +#define _Out_writes_to_ptr_opt_(p) +#define _Out_writes_to_ptr_opt_z_(p) + +/* Output pointer parameters */ +#define _Outptr_ +#define _Outptr_opt_ +#define _Outptr_result_maybenull_ +#define _Outptr_opt_result_maybenull_ +#define _Outptr_result_z_ +#define _Outptr_opt_result_z_ +#define _Outptr_result_maybenull_z_ +#define _Outptr_opt_result_maybenull_z_ +#define _COM_Outptr_ +#define _COM_Outptr_opt_ +#define _COM_Outptr_result_maybenull_ +#define _COM_Outptr_opt_result_maybenull_ +#define _Outptr_result_buffer_(s) +#define _Outptr_result_bytebuffer_(s) +#define _Outptr_opt_result_buffer_(s) +#define _Outptr_opt_result_bytebuffer_(s) +#define _Outptr_result_buffer_to_(s, c) +#define _Outptr_result_bytebuffer_to_(s, c) +#define _Outptr_result_bytebuffer_maybenull_(s) +#define _Outptr_opt_result_buffer_to_(s, c) +#define _Outptr_opt_result_bytebuffer_to_(s, c) +#define _Result_nullonfailure_ +#define _Result_zeroonfailure_ +#define _Outptr_result_nullonfailure_ +#define _Outptr_opt_result_nullonfailure_ +#define _Outref_result_nullonfailure_ + +/* Output reference parameters */ +#define _Outref_ +#define _Outref_result_maybenull_ +#define _Outref_result_buffer_(s) +#define _Outref_result_bytebuffer_(s) +#define _Outref_result_buffer_to_(s, c) +#define _Outref_result_bytebuffer_to_(s, c) +#define _Outref_result_buffer_all_(s) +#define _Outref_result_bytebuffer_all_(s) +#define _Outref_result_buffer_maybenull_(s) +#define _Outref_result_bytebuffer_maybenull_(s) +#define _Outref_result_buffer_to_maybenull_(s, c) +#define _Outref_result_bytebuffer_to_maybenull_(s, c) +#define _Outref_result_buffer_all_maybenull_(s) +#define _Outref_result_bytebuffer_all_maybenull_(s) + +/* Return values */ +#define _Ret_z_ +#define _Ret_writes_(s) +#define _Ret_writes_bytes_(s) +#define _Ret_writes_z_(s) +#define _Ret_writes_bytes_to_(s, c) +#define _Ret_writes_maybenull_(s) +#define _Ret_writes_to_maybenull_(s, c) +#define _Ret_writes_maybenull_z_(s) +#define _Ret_maybenull_ +#define _Ret_maybenull_z_ +#define _Ret_null_ +#define _Ret_notnull_ +#define _Ret_writes_bytes_to_(s, c) +#define _Ret_writes_bytes_maybenull_(s) +#define _Ret_writes_bytes_to_maybenull_(s, c) + +/* Other common annotations */ +#define _In_range_(low, hi) +#define _Out_range_(low, hi) +#define _Ret_range_(low, hi) +#define _Deref_in_range_(low, hi) +#define _Deref_out_range_(low, hi) +#define _Deref_inout_range_(low, hi) +#define _Pre_equal_to_(expr) +#define _Post_equal_to_(expr) +#define _Struct_size_bytes_(size) + +/* Function annotations */ +#define _Called_from_function_class_(name) +#define _Check_return_ __checkReturn +#define _Function_class_(name) +#define _Raises_SEH_exception_ +#define _Maybe_raises_SEH_exception_ +#define _Must_inspect_result_ +#define _Use_decl_annotations_ + +/* Success/failure annotations */ +#define _Always_(anno_list) +#define _On_failure_(anno_list) +#define _Return_type_success_(expr) +#define _Success_(expr) + +#define _Reserved_ +#define _Const_ + +/* Buffer properties */ +#define _Readable_bytes_(s) +#define _Readable_elements_(s) +#define _Writable_bytes_(s) +#define _Writable_elements_(s) +#define _Null_terminated_ +#define _NullNull_terminated_ +#define _Pre_readable_size_(s) +#define _Pre_writable_size_(s) +#define _Pre_readable_byte_size_(s) +#define _Pre_writable_byte_size_(s) +#define _Post_readable_size_(s) +#define _Post_writable_size_(s) +#define _Post_readable_byte_size_(s) +#define _Post_writable_byte_size_(s) + +/* Field properties */ +#define _Field_size_(s) +#define _Field_size_full_(s) +#define _Field_size_full_opt_(s) +#define _Field_size_opt_(s) +#define _Field_size_part_(s, c) +#define _Field_size_part_opt_(s, c) +#define _Field_size_bytes_(size) +#define _Field_size_bytes_full_(size) +#define _Field_size_bytes_full_opt_(s) +#define _Field_size_bytes_opt_(s) +#define _Field_size_bytes_part_(s, c) +#define _Field_size_bytes_part_opt_(s, c) +#define _Field_z_ +#define _Field_range_(min, max) + +/* Structural annotations */ +#define _At_(e, a) +#define _At_buffer_(e, i, c, a) +#define _Group_(a) +#define _When_(e, a) + +/* printf/scanf annotations */ +#define _Printf_format_string_ +#define _Scanf_format_string_ +#define _Scanf_s_format_string_ +#define _Format_string_impl_(kind,where) +#define _Printf_format_string_params_(x) +#define _Scanf_format_string_params_(x) +#define _Scanf_s_format_string_params_(x) + +/* Analysis */ +#define _Analysis_assume_(expr) +#define _Analysis_assume_nullterminated_(expr) + +#define __in +#define __out +#define __deref_out + +#define __in_bcount(size) +#define __in_bcount_opt(size) +#define __in_ecount(size) +#define __out_bcount(size) +#define __out_bcount_opt(size) +#define __out_bcount_part(size, length) +#define __out_ecount(size) +#define __out_ecount_opt(size) +#define __inout +#define __deref_out_bcount(size) +#define __deref_opt_out_bcount(size) +#define __deref_out_ecount(size) +#define __in_ecount_opt(s) + +#define _In_ +#define _In_opt_ +#define _Null_ +#define _Out_writes_bytes_opt_(s) +#define _Out_writes_bytes_(s) +#define _In_reads_bytes_(s) +#define _Inout_opt_bytecount_(s) + +#define __reserved diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 075640f669..466752e4df 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -111,8 +111,48 @@ END // Version // -#include "version.rc" +// no utf-16 support when using mingw's resource compiler +#ifdef __MINGW32__ +// win-version.h is generated by git-version-gen.cmd. +#include "win-version.h" +VS_VERSION_INFO VERSIONINFO + FILEVERSION PPSSPP_WIN_VERSION_COMMA + PRODUCTVERSION PPSSPP_WIN_VERSION_COMMA + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "PPSSPP PSP emulator" + VALUE "CompanyName", "Henrik Rydgård" + VALUE "FileDescription", "PPSSPP" + VALUE "FileVersion", PPSSPP_WIN_VERSION_STRING + VALUE "InternalName", "PPSSPPEmu" + VALUE "LegalCopyright", "Copyright (C) 2006-2015 by Henrik Rydgård" + VALUE "LegalTrademarks", "All product names are trademarks of their respective owners." + VALUE "OriginalFilename", "PPSSPP.exe" + VALUE "ProductName", "PPSSPP" + VALUE "ProductVersion", PPSSPP_WIN_VERSION_STRING + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END +#else +#include "version.rc" +#endif #endif // Neutral (Default) resources ///////////////////////////////////////////////////////////////////////////// @@ -228,8 +268,27 @@ BEGIN CONTROL "",IDC_GEDBG_MATRICES,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT | WS_BORDER | WS_TABSTOP,7,7,217,86 END - +// no utf-16 support when using mingw's resource compiler +#ifdef __MINGW32__ +IDD_ABOUTBOX DIALOGEX 0, 0, 301, 163 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "About" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + DEFPUSHBUTTON "OK",IDOK,243,140,50,14 + ICON IDI_PPSSPP,IDC_STATIC,10,9,21,20 + LTEXT "PPSSPP",IDC_VERSION,40,8,127,9 + LTEXT "Copyright (c) by Henrik Rydgård the PPSSPP project 2012-",IDC_STATIC,40,33,253,8 + LTEXT "All trademarks are property of their respective owners.\nThe emulator is for educational and development purposes only and it may not be used to play games you do not legally own.",IDC_STATIC,40,102,253,24 + LTEXT "PSP emulator and debugger",IDC_STATIC,40,19,253,8 + LTEXT "CISO decompression code by BOOSTER",IDC_STATIC,48,73,240,8 + LTEXT "PSPSDK by #pspdev (freenode)",IDC_STATIC,48,62,240,8 + LTEXT "zlib by Jean-loup Gailly (compression) and Mark Adler (decompression)",IDC_STATIC,48,85,240,8 + LTEXT "Additional credits:",IDC_STATIC,40,49,253,8 +END +#else #include "aboutbox.rc" +#endif IDD_MEMORY DIALOGEX 0, 0, 566, 287 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME @@ -466,7 +525,7 @@ BEGIN MENUITEM "Ignore Windows Key", ID_OPTIONS_IGNOREWINKEY MENUITEM "Language...", ID_OPTIONS_LANGUAGE MENUITEM "Control Mapping...", ID_OPTIONS_CONTROLS - MENUITEM "Display Layout Editor" ID_OPTIONS_DISPLAY_LAYOUT + MENUITEM "Display Layout Editor", ID_OPTIONS_DISPLAY_LAYOUT MENUITEM "More Settings...", ID_OPTIONS_MORE_SETTINGS MENUITEM SEPARATOR MENUITEM "Fullscreen", ID_OPTIONS_FULLSCREEN @@ -502,10 +561,10 @@ BEGIN POPUP "Backend" BEGIN - MENUITEM "Direct3D9" ID_OPTIONS_DIRECT3D9 - MENUITEM "Direct3D11" ID_OPTIONS_DIRECT3D11 - MENUITEM "OpenGL" ID_OPTIONS_OPENGL - MENUITEM "Vulkan" ID_OPTIONS_VULKAN + MENUITEM "Direct3D9", ID_OPTIONS_DIRECT3D9 + MENUITEM "Direct3D11", ID_OPTIONS_DIRECT3D11 + MENUITEM "OpenGL", ID_OPTIONS_OPENGL + MENUITEM "Vulkan", ID_OPTIONS_VULKAN END POPUP "Rendering Mode" @@ -640,7 +699,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Run to Cursor", ID_DISASM_RUNTOHERE MENUITEM "Jump to Cursor", ID_DISASM_SETPCTOHERE - MENUITEM "Set Stall" ID_GEDBG_SETSTALLADDR + MENUITEM "Set Stall", ID_GEDBG_SETSTALLADDR MENUITEM "Toggle Breakpoint", ID_DISASM_TOGGLEBREAKPOINT MENUITEM SEPARATOR MENUITEM "Go to Displaylist PC", ID_GEDBG_GOTOPC @@ -661,7 +720,7 @@ BEGIN POPUP "gepreviewoptions" BEGIN MENUITEM "Export Image...", ID_GEDBG_EXPORT_IMAGE - MENUITEM "Show Prim Preview" ID_GEDBG_ENABLE_PREVIEW + MENUITEM "Show Prim Preview", ID_GEDBG_ENABLE_PREVIEW END END diff --git a/Windows/stdafx.h b/Windows/stdafx.h index 8d896ecfb5..a7f4a49287 100644 --- a/Windows/stdafx.h +++ b/Windows/stdafx.h @@ -19,19 +19,16 @@ #pragma warning(disable:4996) -// WinSock2 MUST be included before !!! -#include - #undef _WIN32_WINNT -#if _MSC_VER < 1700 +#if defined(_MSC_VER) && _MSC_VER < 1700 #error You need a newer version of Visual Studio #else -#define _WIN32_WINNT 0x600 // Compile for Vista on Visual Studio 2012 and above +#define _WIN32_WINNT 0x601 // Compile for Win7 on Visual Studio 2012 and above #endif #undef WINVER -#define WINVER 0x0600 +#define WINVER _WIN32_WINNT #ifndef _WIN32_IE #define _WIN32_IE 0x0600 // Default value is 0x0400 #endif @@ -47,6 +44,16 @@ #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif + +// WinSock2 MUST be included before !!! +#include + #include "Common/CommonWindows.h" #include diff --git a/ext/native/base/basictypes.h b/ext/native/base/basictypes.h index 48fb002a7c..8cd0fd0e1e 100644 --- a/ext/native/base/basictypes.h +++ b/ext/native/base/basictypes.h @@ -54,7 +54,7 @@ inline uint32_t swap32(const uint8_t* _pData) {return swap32(*(const uint32_t*)_ inline uint64_t swap64(const uint8_t* _pData) {return swap64(*(const uint64_t*)_pData);} // Thread local storage -#ifdef _WIN32 +#ifdef _MSC_VER #define __THREAD __declspec( thread ) #else #define __THREAD __thread diff --git a/ext/native/gfx/d3d9_shader.cpp b/ext/native/gfx/d3d9_shader.cpp index 5e38a5363a..51b918c21d 100644 --- a/ext/native/gfx/d3d9_shader.cpp +++ b/ext/native/gfx/d3d9_shader.cpp @@ -1,4 +1,4 @@ -#ifdef _MSC_VER +#ifdef _WIN32 #include "d3d9_shader.h" #include "thin3d/d3dx9_loader.h" @@ -88,4 +88,4 @@ bool CompileVertexShader(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DV } // namespace -#endif \ No newline at end of file +#endif diff --git a/ext/native/gfx/d3d9_shader.h b/ext/native/gfx/d3d9_shader.h index e16ebcd129..289ed24954 100644 --- a/ext/native/gfx/d3d9_shader.h +++ b/ext/native/gfx/d3d9_shader.h @@ -1,7 +1,7 @@ #pragma once #include "Common/CommonWindows.h" - +#include #include #include diff --git a/ext/native/gfx/d3d9_state.cpp b/ext/native/gfx/d3d9_state.cpp index 4fadf21b44..aa20d88151 100644 --- a/ext/native/gfx/d3d9_state.cpp +++ b/ext/native/gfx/d3d9_state.cpp @@ -1,4 +1,4 @@ -#ifdef _MSC_VER +#ifdef _WIN32 #include "d3d9_state.h" #include diff --git a/ext/native/thin3d/d3dx9_loader.cpp b/ext/native/thin3d/d3dx9_loader.cpp index 6a1893a37f..d7e5fa807f 100644 --- a/ext/native/thin3d/d3dx9_loader.cpp +++ b/ext/native/thin3d/d3dx9_loader.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "base/logging.h" #include "thin3d/d3dx9_loader.h" @@ -184,4 +185,4 @@ HRESULT dyn_D3DXCompileShader(LPCSTR pSrcData, UINT srcDataLen, CONST D3DXMACRO* return m_TFunc_D3DXCompileShader(pSrcData, srcDataLen, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); -} \ No newline at end of file +} diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index 2b2c761279..82b9759fd8 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -13,11 +13,17 @@ #include "Common/ColorConv.h" #include +#include #include #include #include #include +#ifdef __MINGW32__ +#undef __uuidof +#define __uuidof(type) IID_##type +#endif + namespace Draw { // A problem is that we can't get the D3Dcompiler.dll without using a later SDK than 7.1, which was the last that @@ -717,13 +723,14 @@ public: }; Texture *D3D11DrawContext::CreateTexture(const TextureDesc &desc) { - D3D11Texture *tex = new D3D11Texture(desc); if (!(GetDataFormatSupport(desc.format) & FMT_TEXTURE)) { // D3D11 does not support this format as a texture format. - return false; + return nullptr; } + D3D11Texture *tex = new D3D11Texture(desc); + bool generateMips = desc.generateMips; if (desc.generateMips && !(GetDataFormatSupport(desc.format) & FMT_AUTOGEN_MIPS)) { // D3D11 does not support autogenerating mipmaps for this format. diff --git a/ext/native/thin3d/thin3d_d3d9.cpp b/ext/native/thin3d/thin3d_d3d9.cpp index 627031991d..62321d36c7 100644 --- a/ext/native/thin3d/thin3d_d3d9.cpp +++ b/ext/native/thin3d/thin3d_d3d9.cpp @@ -648,7 +648,8 @@ Pipeline *D3D9Context::CreateGraphicsPipeline(const PipelineDesc &desc) { for (auto iter : desc.shaders) { if (!iter) { ELOG("NULL shader passed to CreateGraphicsPipeline"); - return false; + delete pipeline; + return NULL; } if (iter->GetStage() == ShaderStage::FRAGMENT) { pipeline->pshader = static_cast(iter);