From f963fcfa66ff1112dda5d9a120edc6b5dd4546e5 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 1 May 2016 09:54:53 +0100 Subject: [PATCH 01/14] onepad:freebsd: Adjust ifdefs --- plugins/onepad/controller.h | 4 ---- plugins/onepad/keyboard.cpp | 6 +++--- plugins/onepad/keyboard.h | 2 +- plugins/onepad/onepad.cpp | 4 ++-- plugins/onepad/onepad.h | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/plugins/onepad/controller.h b/plugins/onepad/controller.h index bd7c9b7297..268090904d 100644 --- a/plugins/onepad/controller.h +++ b/plugins/onepad/controller.h @@ -21,11 +21,7 @@ #pragma once #include // for memset -#ifdef __linux__ #define MAX_KEYS 24 -#else -#define MAX_KEYS 20 -#endif enum KeyType { diff --git a/plugins/onepad/keyboard.cpp b/plugins/onepad/keyboard.cpp index 273809bd6f..ae82eb7bc7 100644 --- a/plugins/onepad/keyboard.cpp +++ b/plugins/onepad/keyboard.cpp @@ -28,7 +28,7 @@ #include #include "keyboard.h" -#ifndef __linux__ +#ifdef _WIN32 char* KeysymToChar(int keysym) { LPWORD temp; @@ -40,7 +40,7 @@ char* KeysymToChar(int keysym) void SetAutoRepeat(bool autorep) { - #ifdef __linux__ +#if defined(__unix__) if (toggleAutoRepeat) { if (autorep) @@ -51,7 +51,7 @@ void SetAutoRepeat(bool autorep) #endif } -#ifdef __linux__ +#if defined(__unix__) static bool s_grab_input = false; static bool s_Shift = false; static unsigned int s_previous_mouse_x = 0; diff --git a/plugins/onepad/keyboard.h b/plugins/onepad/keyboard.h index 0b352b6f7b..84171e6557 100644 --- a/plugins/onepad/keyboard.h +++ b/plugins/onepad/keyboard.h @@ -24,7 +24,7 @@ #include "onepad.h" -#ifdef __linux__ +#if defined(__unix__) #include "Linux/linux.h" diff --git a/plugins/onepad/onepad.cpp b/plugins/onepad/onepad.cpp index b9476deb18..ebaed83eee 100644 --- a/plugins/onepad/onepad.cpp +++ b/plugins/onepad/onepad.cpp @@ -263,7 +263,7 @@ EXPORT_C_(s32) PADopen(void *pDsp) pthread_spin_init(&mutex_KeyEvent, PTHREAD_PROCESS_PRIVATE); mutex_WasInit = true; -#ifdef __linux__ +#if defined(__unix__) GamePad::EnumerateGamePads(s_vgamePad); #endif return _PADopen(pDsp); @@ -595,7 +595,7 @@ EXPORT_C_(keyEvent*) PADkeyEvent() return &s_event; } -#ifdef __linux__ +#if defined(__unix__) EXPORT_C_(void) PADWriteEvent(keyEvent &evt) { // This function call be called before PADopen. Therefore we cann't diff --git a/plugins/onepad/onepad.h b/plugins/onepad/onepad.h index 8b73876eee..235d62eb13 100644 --- a/plugins/onepad/onepad.h +++ b/plugins/onepad/onepad.h @@ -49,7 +49,7 @@ using namespace std; #define PADdefs #include "PS2Edefs.h" -#ifdef __linux__ +#if defined(__unix__) #include "GamePad.h" #endif #include "bitwise.h" From f95c38f632fd51ae5c0d70ab008d0ba0e66efd11 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 1 May 2016 10:07:01 +0100 Subject: [PATCH 02/14] spu2-x:freebsd: Adjust cmake and ifdefs For now the SDL backend has been removed, mainly cause it makes the dialog code too messy. --- plugins/spu2-x/src/Linux/Config.cpp | 30 +++++++++++++++++-- plugins/spu2-x/src/Linux/Config.h | 2 +- plugins/spu2-x/src/Linux/ConfigDebug.cpp | 2 +- plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp | 2 +- plugins/spu2-x/src/Linux/Dialogs.cpp | 2 +- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp index 12f6df80cf..e6d766168e 100644 --- a/plugins/spu2-x/src/Linux/Config.cpp +++ b/plugins/spu2-x/src/Linux/Config.cpp @@ -19,8 +19,10 @@ #include "Dialogs.h" #include "Config.h" +#ifdef __linux__ #include #include +#endif #ifdef PCSX2_DEVBUILD static const int LATENCY_MAX = 3000; @@ -121,12 +123,20 @@ void ReadSettings() OutputModule = FindOutputModuleById( temp.c_str() );// find the driver index of this module // find current API +#ifdef __linux__ CfgReadStr( L"PORTAUDIO", L"HostApi", temp, L"ALSA" ); OutputAPI = -1; if (temp == L"ALSA") OutputAPI = 0; if (temp == L"OSS") OutputAPI = 1; if (temp == L"JACK") OutputAPI = 2; +#else + CfgReadStr( L"PORTAUDIO", L"HostApi", temp, L"OSS" ); + OutputAPI = -1; + if (temp == L"OSS") OutputAPI = 0; +#endif + +#ifdef __linux__ CfgReadStr( L"SDL", L"HostApi", temp, L"pulseaudio" ); SdlOutputAPI = -1; #if SDL_MAJOR_VERSION >= 2 @@ -135,13 +145,14 @@ void ReadSettings() if (!temp.Cmp(wxString(SDL_GetAudioDriver(i), wxConvUTF8))) SdlOutputAPI = i; } +#endif #endif SndOutLatencyMS = CfgReadInt(L"OUTPUT",L"Latency", 300); SynchMode = CfgReadInt( L"OUTPUT", L"Synch_Mode", 0); PortaudioOut->ReadSettings(); -#ifndef __APPLE__ +#ifdef __linux__ SDLOut->ReadSettings(); #endif SoundtouchCfg::ReadSettings(); @@ -187,7 +198,7 @@ void WriteSettings() CfgWriteInt(L"DEBUG", L"DelayCycles", delayCycles); PortaudioOut->WriteSettings(); -#ifndef __APPLE__ +#ifdef __linux__ SDLOut->WriteSettings(); #endif SoundtouchCfg::WriteSettings(); @@ -204,7 +215,7 @@ void debug_dialog() DebugConfig::DisplayDialog(); } -#ifdef __linux__ +#if defined(__unix__) void DisplayDialog() { int return_value; @@ -257,16 +268,22 @@ void DisplayDialog() mod_box = gtk_combo_box_text_new (); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "0 - No Sound (emulate SPU2 only)"); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "1 - PortAudio (cross-platform)"); +#ifdef __linux__ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "2 - SDL Audio (recommended for PulseAudio)"); +#endif //gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "3 - Alsa (probably doesn't work)"); gtk_combo_box_set_active(GTK_COMBO_BOX(mod_box), OutputModule); api_label = gtk_label_new ("PortAudio API:"); api_box = gtk_combo_box_text_new (); +#ifdef __linux__ // In order to keep it the menu light, I only put linux major api gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "0 - ALSA (recommended)"); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "1 - OSS (legacy)"); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "2 - JACK"); +#else + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "OSS"); +#endif gtk_combo_box_set_active(GTK_COMBO_BOX(api_box), OutputAPI); #if SDL_MAJOR_VERSION >= 2 @@ -360,12 +377,19 @@ void DisplayDialog() if (gtk_combo_box_get_active(GTK_COMBO_BOX(api_box)) != -1) { OutputAPI = gtk_combo_box_get_active(GTK_COMBO_BOX(api_box)); +#ifdef __linux__ switch(OutputAPI) { case 0: PortaudioOut->SetApiSettings(L"ALSA"); break; case 1: PortaudioOut->SetApiSettings(L"OSS"); break; case 2: PortaudioOut->SetApiSettings(L"JACK"); break; default: PortaudioOut->SetApiSettings(L"Unknown"); } +#else + switch(OutputAPI) { + case 0: PortaudioOut->SetApiSettings(L"OSS"); break; + default: PortaudioOut->SetApiSettings(L"Unknown"); + } +#endif } #if SDL_MAJOR_VERSION >= 2 diff --git a/plugins/spu2-x/src/Linux/Config.h b/plugins/spu2-x/src/Linux/Config.h index 538f445e83..28e015ee94 100644 --- a/plugins/spu2-x/src/Linux/Config.h +++ b/plugins/spu2-x/src/Linux/Config.h @@ -18,7 +18,7 @@ #ifndef CONFIG_H_INCLUDED #define CONFIG_H_INCLUDED -#ifdef __linux__ +#if defined(__unix__) #include #endif diff --git a/plugins/spu2-x/src/Linux/ConfigDebug.cpp b/plugins/spu2-x/src/Linux/ConfigDebug.cpp index 249985cf8e..bdc5449bef 100644 --- a/plugins/spu2-x/src/Linux/ConfigDebug.cpp +++ b/plugins/spu2-x/src/Linux/ConfigDebug.cpp @@ -154,7 +154,7 @@ void WriteSettings() } -#ifdef __linux__ +#ifdef __unix__ void DisplayDialog() { GtkWidget *dialog; diff --git a/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp b/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp index 5b06256ea8..2c799a2ee9 100644 --- a/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp +++ b/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp @@ -71,7 +71,7 @@ namespace SoundtouchCfg CfgWriteInt( L"SOUNDTOUCH", L"OverlapMS", OverlapMS ); } -#ifdef __linux__ +#ifdef __unix__ static GtkWidget *seq_label, *seek_label, *over_label; static GtkWidget *seq_slide, *seek_slide, *over_slide; diff --git a/plugins/spu2-x/src/Linux/Dialogs.cpp b/plugins/spu2-x/src/Linux/Dialogs.cpp index 522d9ff728..74acd6e527 100644 --- a/plugins/spu2-x/src/Linux/Dialogs.cpp +++ b/plugins/spu2-x/src/Linux/Dialogs.cpp @@ -20,7 +20,7 @@ #include "Dialogs.h" #include -#ifdef __linux__ +#if defined(__unix__) #include void SysMessage(const char *fmt, ...) From e23b6e34840b4aed05984cf1312018b311028ad3 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 1 May 2016 10:14:44 +0100 Subject: [PATCH 03/14] cmake: Setup FreeBSD --- cmake/BuildParameters.cmake | 2 +- cmake/FindLibc.cmake | 9 +++++++-- cmake/SearchForStuff.cmake | 7 ++++++- cmake/SelectPcsx2Plugins.cmake | 6 +++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 36513febee..ed93b1f782 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -293,7 +293,7 @@ set(AGGRESSIVE_WARNING "-Wstrict-aliasing -Wstrict-overflow=2 ") if (USE_CLANG) # -Wno-deprecated-register: glib issue... set(DEFAULT_WARNINGS "${DEFAULT_WARNINGS} -Wno-deprecated-register -Wno-c++14-extensions") - if (NOT APPLE) + if (Linux) set(COMMON_FLAG "${COMMON_FLAG} -no-integrated-as") endif() set(DBG "-g -fno-omit-frame-pointer") diff --git a/cmake/FindLibc.cmake b/cmake/FindLibc.cmake index 1456ae974a..35642e52d1 100644 --- a/cmake/FindLibc.cmake +++ b/cmake/FindLibc.cmake @@ -7,15 +7,20 @@ if(LIBC_LIBRARIES) set(LIBC_FIND_QUIETLY TRUE) endif(LIBC_LIBRARIES) -find_library(libdl NAMES dl) find_library(libm NAMES m) # OSX doesn't have rt. On Linux timer and aio dependency. if(APPLE) + find_library(libdl NAMES dl) set(LIBC_LIBRARIES ${librt} ${libdl} ${libm}) -else() +elseif(Linux) + find_library(libdl NAMES dl) find_library(librt NAMES rt) set(LIBC_LIBRARIES ${librt} ${libdl} ${libm}) +else() + # FreeBSD doesn't have libdl + find_library(librt NAMES rt) + set(LIBC_LIBRARIES ${librt} ${libm}) endif() # handle the QUIETLY and REQUIRED arguments and set LIBC_FOUND to TRUE if diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 2e9f82b04a..00757da140 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -2,7 +2,9 @@ # Search all libraries on the system #------------------------------------------------------------------------------- ## Use cmake package to find module -find_package(ALSA) +if (Linux) + find_package(ALSA) +endif() find_package(Gettext) # translation tool if(EXISTS ${PROJECT_SOURCE_DIR}/.git) find_package(Git) @@ -50,6 +52,9 @@ if(CMAKE_CROSSCOMPILING) endif() endif() else() + if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set(wxWidgets_CONFIG_EXECUTABLE "/usr/local/bin/wxgtk2u-3.0-config") + endif() if(EXISTS "/usr/bin/wx-config-3.0") set(wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config-3.0") endif() diff --git a/cmake/SelectPcsx2Plugins.cmake b/cmake/SelectPcsx2Plugins.cmake index 350ce2f953..6c041fa973 100644 --- a/cmake/SelectPcsx2Plugins.cmake +++ b/cmake/SelectPcsx2Plugins.cmake @@ -218,7 +218,7 @@ endif() #--------------------------------------- # Not ready to be packaged if(EXTRA_PLUGINS OR NOT PACKAGE_MODE) - if(GTKn_FOUND AND X11_FOUND) + if(Linux AND GTKn_FOUND AND X11_FOUND) set(LilyPad TRUE) endif() endif() @@ -257,8 +257,8 @@ endif() # -SDL # -common_libs #--------------------------------------- -if((APPLE AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND SDLn_FOUND AND common_libs) - OR (Linux AND ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND SDLn_FOUND AND common_libs)) +if((PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND SDLn_FOUND AND common_libs) + AND ((Linux AND ALSA_FOUND) OR (UNIX AND NOT Linux))) set(spu2-x TRUE) elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/spu2-x") set(spu2-x FALSE) From 280ca1dd85e7e7dda738d450be3ec43c1e7ac20b Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 8 May 2016 20:17:19 +0000 Subject: [PATCH 04/14] utilities: Add FreeBSD thread name implementation --- common/src/Utilities/Linux/LnxThreads.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/common/src/Utilities/Linux/LnxThreads.cpp b/common/src/Utilities/Linux/LnxThreads.cpp index ccd784a333..fb6c2c1503 100644 --- a/common/src/Utilities/Linux/LnxThreads.cpp +++ b/common/src/Utilities/Linux/LnxThreads.cpp @@ -16,16 +16,20 @@ #include "../PrecompiledHeader.h" #include "PersistentThread.h" -#include #include +#if defined(__linux__) +#include +#elif defined(__unix__) +#include +#endif // We wont need this until we actually have this more then just stubbed out, so I'm commenting this out // to remove an unneeded dependency. //#include "x86emitter/tools.h" -#if !defined(__linux__) && !defined(__WXMAC__) +#if !defined(__unix__) -# pragma message( "LnxThreads.cpp should only be compiled by projects or makefiles targeted at Linux/Mac distros.") +# pragma message( "LnxThreads.cpp should only be compiled by projects or makefiles targeted at Linux/BSD distros.") #else @@ -68,7 +72,7 @@ static u64 get_thread_time(uptr id = 0) { clockid_t cid; if (id) { - int err = pthread_getcpuclockid(id, &cid); + int err = pthread_getcpuclockid((pthread_t)id, &cid); if (err) return 0; } else { cid = CLOCK_THREAD_CPUTIME_ID; @@ -113,9 +117,13 @@ void Threading::pxThread::_platform_specific_OnCleanupInThread() void Threading::pxThread::_DoSetThreadName( const char* name ) { +#if defined(__linux__) // Extract of manpage: "The name can be up to 16 bytes long, and should be // null-terminated if it contains fewer bytes." prctl(PR_SET_NAME, name, 0, 0, 0); +#elif defined(__unix__) + pthread_set_name_np(pthread_self(), name); +#endif } #endif From 7aa6564dcc837f4cc2ce37e664d12aaf754b80f7 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 1 May 2016 10:26:18 +0100 Subject: [PATCH 05/14] common:freebsd: Fix compilation --- common/include/PS2Eext.h | 4 ++-- common/include/Utilities/Console.h | 2 +- common/src/Utilities/Console.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/include/PS2Eext.h b/common/include/PS2Eext.h index a5f607ae98..289c1e8646 100644 --- a/common/include/PS2Eext.h +++ b/common/include/PS2Eext.h @@ -30,7 +30,7 @@ #define EXPORT_C_(type) extern "C" type CALLBACK -#elif defined(__linux__) +#elif defined(__unix__) #include #include @@ -193,7 +193,7 @@ struct PluginConf } }; -#if defined(__linux__) +#if defined(__unix__) static void SysMessage(const char *fmt, ...) { diff --git a/common/include/Utilities/Console.h b/common/include/Utilities/Console.h index 476519e8c4..1a07ec236e 100644 --- a/common/include/Utilities/Console.h +++ b/common/include/Utilities/Console.h @@ -234,7 +234,7 @@ public: extern IConsoleWriter Console; -#ifdef __linux__ +#if defined(__unix__) extern void Console_SetStdout(FILE *fp); #endif extern void Console_SetActiveHandler( const IConsoleWriter& writer, FILE* flushfp=NULL ); diff --git a/common/src/Utilities/Console.cpp b/common/src/Utilities/Console.cpp index dea8cf4c11..6b3106ae4f 100644 --- a/common/src/Utilities/Console.cpp +++ b/common/src/Utilities/Console.cpp @@ -113,7 +113,7 @@ const IConsoleWriter ConsoleWriter_Null = // Console_Stdout // -------------------------------------------------------------------------------------- -#ifdef __linux__ +#if defined(__unix__) static __fi const char* GetLinuxConsoleColor(ConsoleColors color) { switch(color) @@ -174,7 +174,7 @@ static void __concall ConsoleStdout_Newline() static void __concall ConsoleStdout_DoSetColor( ConsoleColors color ) { -#ifdef __linux__ +#if defined(__unix__) fprintf(stdout_fp, "\033[0m%s", GetLinuxConsoleColor(color)); fflush(stdout_fp); #endif @@ -182,7 +182,7 @@ static void __concall ConsoleStdout_DoSetColor( ConsoleColors color ) static void __concall ConsoleStdout_SetTitle( const wxString& title ) { -#ifdef __linux__ +#if defined(__unix__) fputs("\033]0;", stdout_fp); fputs(title.utf8_str(), stdout_fp); fputs("\007", stdout_fp); From 5f6658ae9a97ec76695533a74c8df2b4a07b2ef5 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 1 May 2016 10:27:11 +0100 Subject: [PATCH 06/14] common:freebsd: Kill some warnings --- common/include/Pcsx2Defs.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/include/Pcsx2Defs.h b/common/include/Pcsx2Defs.h index 0aaf732026..862068d845 100644 --- a/common/include/Pcsx2Defs.h +++ b/common/include/Pcsx2Defs.h @@ -213,9 +213,12 @@ static const int __pagesize = PCSX2_PAGESIZE; // GCC / Intel Compilers Section // -------------------------------------------------------------------------------------- +#ifndef __packed # define __packed __attribute__((packed)) - +#endif +#ifndef __aligned # define __aligned(alig) __attribute__((aligned(alig))) +#endif # define __aligned16 __attribute__((aligned(16))) # define __aligned32 __attribute__((aligned(32))) # define __pagealigned __attribute__((aligned(PCSX2_PAGESIZE))) @@ -232,14 +235,18 @@ static const int __pagesize = PCSX2_PAGESIZE; // warnings when a static inlined function isn't used in the scope of a single file (which // happens *by design* like all the friggen time >_<) +#ifndef __fastcall # define __fastcall __attribute__((fastcall)) +#endif # define _inline __inline__ __attribute__((unused)) # ifdef NDEBUG # define __forceinline __attribute__((always_inline,unused)) # else # define __forceinline __attribute__((unused)) # endif +#ifndef __noinline # define __noinline __attribute__((noinline)) +#endif # define __threadlocal __thread # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) From e10ed744bcfb968c7543ec711af188ac6299c499 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Tue, 17 May 2016 23:43:02 +0100 Subject: [PATCH 07/14] pcsx2:freebsd: Fix build --- pcsx2/AsyncFileReader.h | 2 +- pcsx2/CMakeLists.txt | 12 ++++++++++++ pcsx2/IPU/yuv2rgb.cpp | 7 ++++--- pcsx2/PrecompiledHeader.h | 8 +------- pcsx2/gui/ConsoleLogger.cpp | 6 +++--- pcsx2/gui/FrameForGS.cpp | 8 ++++---- pcsx2/gui/MainFrame.cpp | 4 ++-- pcsx2/gui/i18n.cpp | 2 +- 8 files changed, 28 insertions(+), 21 deletions(-) diff --git a/pcsx2/AsyncFileReader.h b/pcsx2/AsyncFileReader.h index decc97ceb5..368cf777dd 100644 --- a/pcsx2/AsyncFileReader.h +++ b/pcsx2/AsyncFileReader.h @@ -20,7 +20,7 @@ # undef Yield #elif defined(__linux__) # include -#elif defined(__APPLE__) +#elif defined(__POSIX__) # include #endif #include diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index b294cc7e5f..222cf3fd5c 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -397,6 +397,12 @@ set(pcsx2OSXSources Darwin/DarwinFlatFileReader.cpp ) +set(pcsx2FreeBSDSources + Linux/LnxConsolePipe.cpp + Linux/LnxKeyCodes.cpp + Darwin/DarwinFlatFileReader.cpp + ) + # Linux headers set(pcsx2LinuxHeaders ) @@ -615,6 +621,12 @@ if(APPLE) ${pcsx2LinuxHeaders}) endif() +if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set(Platform + ${pcsx2FreeBSDSources} + ${pcsx2LinuxHeaders}) +endif() + set(pcsx2FinalSources ${Common} ${Platform} diff --git a/pcsx2/IPU/yuv2rgb.cpp b/pcsx2/IPU/yuv2rgb.cpp index 5fae01f7b6..ffd9ce1cca 100644 --- a/pcsx2/IPU/yuv2rgb.cpp +++ b/pcsx2/IPU/yuv2rgb.cpp @@ -58,13 +58,13 @@ void yuv2rgb_reference(void) } } +#if defined(_M_X86_32) // TODO OSX optimize me -#ifdef __APPLE__ +#if defined(__clang__) && !defined(__linux__) void yuv2rgb_sse2() { yuv2rgb_reference(); } - -#elif defined(_M_X86_32) +#else // Everything below is bit accurate to the IPU specification (except maybe rounding). // Know the specification before you touch it. #define SSE_BYTES(x) {x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x} @@ -411,3 +411,4 @@ ihatemsvc: #endif } #endif +#endif diff --git a/pcsx2/PrecompiledHeader.h b/pcsx2/PrecompiledHeader.h index a9dc78ab24..1bd728c9fe 100644 --- a/pcsx2/PrecompiledHeader.h +++ b/pcsx2/PrecompiledHeader.h @@ -96,13 +96,7 @@ typedef FnType_Void* Fnptr_Void; #else // must be GCC or Clang -# include -# include - -// Definitions added Feb 16, 2006 by efp -# ifndef __declspec -# define __declspec(x) -# endif +#include #endif diff --git a/pcsx2/gui/ConsoleLogger.cpp b/pcsx2/gui/ConsoleLogger.cpp index 4307e62a80..fb3eb86132 100644 --- a/pcsx2/gui/ConsoleLogger.cpp +++ b/pcsx2/gui/ConsoleLogger.cpp @@ -1017,11 +1017,11 @@ void Pcsx2App::ProgramLog_PostEvent( wxEvent& evt ) static void __concall ConsoleToFile_Newline() { -#ifdef __linux__ +#if defined(__unix__) if ((g_Conf) && (g_Conf->EmuOptions.ConsoleToStdio)) ConsoleWriter_Stdout.Newline(); #endif -#ifdef __linux__ +#if defined(__unix__) fputc( '\n', emuLog ); #else fputs( "\r\n", emuLog ); @@ -1030,7 +1030,7 @@ static void __concall ConsoleToFile_Newline() static void __concall ConsoleToFile_DoWrite( const wxString& fmt ) { -#ifdef __linux__ +#if defined(__unix__) if ((g_Conf) && (g_Conf->EmuOptions.ConsoleToStdio)) ConsoleWriter_Stdout.WriteRaw(fmt); #endif diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index 6a754baaa7..de18b01bb6 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -222,7 +222,7 @@ void GSPanel::OnMouseEvent( wxMouseEvent& evt ) DoShowMouse(); } -#ifdef __linux__ +#if defined(__unix__) // HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad plugin. Wx deletes // the event before the pad see it. So you send key event directly to the pad. if( (PADWriteEvent != NULL) && (GSopen2 != NULL) ) { @@ -285,7 +285,7 @@ void GSPanel::OnKeyDownOrUp( wxKeyEvent& evt ) // to the APP level message handler, which in turn routes them right back here -- yes it's // silly, but oh well). -#ifdef __linux__ +#if defined(__unix__) // HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad plugin. Wx deletes // the event before the pad see it. So you send key event directly to the pad. if( (PADWriteEvent != NULL) && (GSopen2 != NULL) ) { @@ -367,7 +367,7 @@ void GSPanel::OnFocus( wxFocusEvent& evt ) else DoShowMouse(); -#ifdef __linux__ +#if defined(__unix__) // HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad plugin. Wx deletes // the event before the pad see it. So you send key event directly to the pad. if( (PADWriteEvent != NULL) && (GSopen2 != NULL) ) { @@ -385,7 +385,7 @@ void GSPanel::OnFocusLost( wxFocusEvent& evt ) evt.Skip(); m_HasFocus = false; DoShowMouse(); -#ifdef __linux__ +#if defined(__unix__) // HACK2: In gsopen2 there is one event buffer read by both wx/gui and pad plugin. Wx deletes // the event before the pad see it. So you send key event directly to the pad. if( (PADWriteEvent != NULL) && (GSopen2 != NULL) ) { diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index fa7ff78bbf..a9b46d767c 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -503,7 +503,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) // ------------------------------------------------------------------------ m_menuMisc.Append( &m_MenuItem_Console ); -#ifdef __linux__ +#if defined(__unix__) m_menuMisc.Append( &m_MenuItem_Console_Stdio ); #endif //Todo: Though not many people need this one :p @@ -695,7 +695,7 @@ void MainEmuFrame::ApplyConfigToGui(AppConfig& configToApply, int flags) menubar.Check( MenuId_EnableCheats, configToApply.EmuOptions.EnableCheats ); menubar.Check( MenuId_EnableWideScreenPatches, configToApply.EmuOptions.EnableWideScreenPatches ); menubar.Check( MenuId_EnableHostFs, configToApply.EmuOptions.HostFs ); -#ifdef __linux__ +#if defined(__unix__) menubar.Check( MenuId_Console_Stdio, configToApply.EmuOptions.ConsoleToStdio ); #endif diff --git a/pcsx2/gui/i18n.cpp b/pcsx2/gui/i18n.cpp index 8bd1726ad3..77e8dd7c55 100644 --- a/pcsx2/gui/i18n.cpp +++ b/pcsx2/gui/i18n.cpp @@ -362,7 +362,7 @@ void i18n_SetLanguagePath() // default location for windows wxLocale::AddCatalogLookupPathPrefix( wxGetCwd() ); // additional location for linux -#ifdef __linux__ +#ifdef __unix__ wxLocale::AddCatalogLookupPathPrefix( PathDefs::GetLangs().ToString() ); #endif From 6362b9c9b234e600563d21450908ea4ae0ec272a Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Wed, 18 May 2016 00:10:27 +0100 Subject: [PATCH 08/14] pcsx2: aio: Complete POSIX AIO reader --- pcsx2/AsyncFileReader.h | 3 +- pcsx2/Darwin/DarwinFlatFileReader.cpp | 78 +++++++++++++-------------- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/pcsx2/AsyncFileReader.h b/pcsx2/AsyncFileReader.h index 368cf777dd..5ba95afde7 100644 --- a/pcsx2/AsyncFileReader.h +++ b/pcsx2/AsyncFileReader.h @@ -78,7 +78,8 @@ class FlatFileReader : public AsyncFileReader io_context_t m_aio_context; #elif defined(__POSIX__) int m_fd; // TODO OSX don't know if overlap as an equivalent on OSX - struct aiocb m_aio_context; + struct aiocb m_aiocb; + bool m_read_in_progress; #endif bool shareWrite; diff --git a/pcsx2/Darwin/DarwinFlatFileReader.cpp b/pcsx2/Darwin/DarwinFlatFileReader.cpp index 6e2efb8936..24cae8d940 100644 --- a/pcsx2/Darwin/DarwinFlatFileReader.cpp +++ b/pcsx2/Darwin/DarwinFlatFileReader.cpp @@ -16,15 +16,16 @@ #include "PrecompiledHeader.h" #include "AsyncFileReader.h" -#warning This reader is not yet implemented. Crash boom bang if used +#if defined(__APPLE__) +#warning Tested on FreeBSD, not OS X. Be very afraid. +#endif //FlatFileReader::FlatFileReader(void) FlatFileReader::FlatFileReader(bool shareWrite) : shareWrite(shareWrite) { - printf("FLATC\n"); m_blocksize = 2048; - m_fd = 0; - //m_aio_context = 0; + m_fd = -1; + m_read_in_progress = false; } FlatFileReader::~FlatFileReader(void) @@ -34,79 +35,74 @@ FlatFileReader::~FlatFileReader(void) bool FlatFileReader::Open(const wxString& fileName) { - printf("OB\n"); m_filename = fileName; - int err = 0; //io_setup(64, &m_aio_context); - if (err) return false; - m_fd = wxOpen(fileName, O_RDONLY, 0); - return (m_fd != 0); + return (m_fd != -1); } int FlatFileReader::ReadSync(void* pBuffer, uint sector, uint count) { - printf("RAD\n"); BeginRead(pBuffer, sector, count); return FinishRead(); } void FlatFileReader::BeginRead(void* pBuffer, uint sector, uint count) { - printf("RWEADB\n"); - u64 offset; - offset = sector * (u64)m_blocksize + m_dataoffset; + u64 offset = sector * (u64)m_blocksize + m_dataoffset; u32 bytesToRead = count * m_blocksize; - struct aiocb iocb; - struct aiocb* iocbs = &iocb; + m_aiocb = {0}; + m_aiocb.aio_fildes = m_fd; + m_aiocb.aio_offset = offset; + m_aiocb.aio_nbytes = bytesToRead; + m_aiocb.aio_buf = pBuffer; - //io_prep_pread(&iocb, m_fd, pBuffer, bytesToRead, offset); - //io_submit(m_aio_context, 1, &iocbs); + if (aio_read(&m_aiocb) != 0) { +#if defined(__FreeBSD__) + if (errno == ENOSYS) + Console.Error("AIO read failed: Check the aio kernel module is loaded"); + else + Console.Error("AIO read failed: error code %d", errno); +#else + Console.Error("AIO read failed: error code %d\n", errno); +#endif + return; + } + m_read_in_progress = true; } int FlatFileReader::FinishRead(void) { - printf("FINISH\n"); - u32 bytes; + struct aiocb *aiocb_list[] = {&m_aiocb}; - int min_nr = 1; - int max_nr = 1; - /* struct io_event* events = new io_event[max_nr]; + while (aio_suspend(aiocb_list, 1, nullptr) == -1) + if (errno != EINTR) + break; - int event = io_getevents(m_aio_context, min_nr, max_nr, events, NULL); - if (event < 1) { - return -1; - }*/ - - return 1; + m_read_in_progress = false; + return aio_return(&m_aiocb) == -1? -1: 1; } void FlatFileReader::CancelRead(void) { - printf("CANCEL\n"); - // Will be done when m_aio_context context is destroyed - // Note: io_cancel exists but need the iocb structure as parameter - // int io_cancel(aio_context_t ctx_id, struct iocb *iocb, - // struct io_event *result); + aio_cancel(m_fd, &m_aiocb); + m_read_in_progress = false; } void FlatFileReader::Close(void) { - printf("CLOSE\n"); - if (m_fd) close(m_fd); + if (m_read_in_progress) + CancelRead(); + if (m_fd != -1) + close(m_fd); - //io_destroy(m_aio_context); - aio_cancel(m_fd, &m_aio_context); - - m_fd = 0; - //m_aio_context = 0; + m_fd = -1; } uint FlatFileReader::GetBlockCount(void) const { - printf("BLOCKS\n"); return (int)(Path::GetFileSize(m_filename) / m_blocksize); } From da2046e90e7cd5965e153c29896956a17d056cb1 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Thu, 12 May 2016 00:24:37 +0100 Subject: [PATCH 09/14] gsdx: Use alignas instead of __aligned __aligned is defined in FreeBSD headers and will cause compile errors. --- plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp | 2 +- plugins/GSdx/GPUDrawScanlineCodeGenerator.h | 4 ++-- plugins/GSdx/GPUDrawingEnvironment.h | 2 +- plugins/GSdx/GPUScanlineEnvironment.h | 4 ++-- plugins/GSdx/GPUVertex.h | 2 +- plugins/GSdx/GS.h | 2 +- plugins/GSdx/GSBlock.h | 12 ++++++------ plugins/GSdx/GSClut.h | 6 +++--- plugins/GSdx/GSDeviceDX.h | 4 ++-- plugins/GSdx/GSDeviceOGL.h | 6 +++--- plugins/GSdx/GSDeviceSW.cpp | 2 +- plugins/GSdx/GSDrawScanlineCodeGenerator.cpp | 2 +- plugins/GSdx/GSDrawScanlineCodeGenerator.h | 2 +- plugins/GSdx/GSDrawingContext.h | 2 +- plugins/GSdx/GSDrawingEnvironment.h | 2 +- plugins/GSdx/GSLocalMemory.cpp | 4 ++-- plugins/GSdx/GSLocalMemory.h | 6 +++--- plugins/GSdx/GSRasterizer.h | 4 ++-- plugins/GSdx/GSRendererCL.h | 4 ++-- plugins/GSdx/GSRendererCS.h | 4 ++-- plugins/GSdx/GSRendererSW.h | 2 +- plugins/GSdx/GSScanlineEnvironment.h | 4 ++-- plugins/GSdx/GSVector.h | 8 ++++---- plugins/GSdx/GSVertex.h | 4 ++-- plugins/GSdx/GSVertexHW.h | 2 +- plugins/GSdx/GSVertexSW.h | 4 ++-- plugins/GSdx/GSVertexTrace.h | 2 +- plugins/GSdx/stdafx.h | 10 +++++----- 28 files changed, 56 insertions(+), 56 deletions(-) diff --git a/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp b/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp index c92e28d7c3..2ada9f269f 100644 --- a/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp +++ b/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp @@ -1022,7 +1022,7 @@ const GSVector4i GPUDrawScanlineCodeGenerator::m_test[8] = GSVector4i::zero(), }; -__aligned(const uint16, 32) GPUDrawScanlineCodeGenerator::m_dither[4][16] = +alignas(32) const uint16_t GPUDrawScanlineCodeGenerator::m_dither[4][16] = { {7, 0, 6, 1, 7, 0, 6, 1, 7, 0, 6, 1, 7, 0, 6, 1}, {2, 5, 3, 4, 2, 5, 3, 4, 2, 5, 3, 4, 2, 5, 3, 4}, diff --git a/plugins/GSdx/GPUDrawScanlineCodeGenerator.h b/plugins/GSdx/GPUDrawScanlineCodeGenerator.h index 00eff14c6d..9caf2c171c 100644 --- a/plugins/GSdx/GPUDrawScanlineCodeGenerator.h +++ b/plugins/GSdx/GPUDrawScanlineCodeGenerator.h @@ -56,5 +56,5 @@ public: GPUDrawScanlineCodeGenerator(void* param, uint32 key, void* code, size_t maxsize); static const GSVector4i m_test[8]; - static __aligned(const uint16, 32) m_dither[4][16]; -}; \ No newline at end of file + alignas(32) static const uint16 m_dither[4][16]; +}; diff --git a/plugins/GSdx/GPUDrawingEnvironment.h b/plugins/GSdx/GPUDrawingEnvironment.h index 674bfb2830..2d3d0b8ac3 100644 --- a/plugins/GSdx/GPUDrawingEnvironment.h +++ b/plugins/GSdx/GPUDrawingEnvironment.h @@ -23,7 +23,7 @@ #include "GPU.h" -__aligned(class, 32) GPUDrawingEnvironment +class alignas(32) GPUDrawingEnvironment { public: GPURegSTATUS STATUS; diff --git a/plugins/GSdx/GPUScanlineEnvironment.h b/plugins/GSdx/GPUScanlineEnvironment.h index ad9d7fa1fd..bd3b927f0c 100644 --- a/plugins/GSdx/GPUScanlineEnvironment.h +++ b/plugins/GSdx/GPUScanlineEnvironment.h @@ -56,7 +56,7 @@ union GPUScanlineSelector operator uint32() const {return key;} }; -__aligned(struct, 32) GPUScanlineGlobalData +struct alignas(32) GPUScanlineGlobalData { GPUScanlineSelector sel; @@ -66,7 +66,7 @@ __aligned(struct, 32) GPUScanlineGlobalData GSVector4i twin; // TWW, TWH, TWX, TWY }; -__aligned(struct, 32) GPUScanlineLocalData +struct alignas(32) GPUScanlineLocalData { const GPUScanlineGlobalData* gd; diff --git a/plugins/GSdx/GPUVertex.h b/plugins/GSdx/GPUVertex.h index 05455a4c42..3803ae81f0 100644 --- a/plugins/GSdx/GPUVertex.h +++ b/plugins/GSdx/GPUVertex.h @@ -26,7 +26,7 @@ #pragma pack(push, 1) -__aligned(struct, 32) GPUVertex +struct alignas(32) GPUVertex { union { diff --git a/plugins/GSdx/GS.h b/plugins/GSdx/GS.h index 9df86a1d98..d5d0b89cab 100644 --- a/plugins/GSdx/GS.h +++ b/plugins/GSdx/GS.h @@ -1101,7 +1101,7 @@ REG128_SET(GIFPackedReg) GIFPackedNOP NOP; REG_SET_END -__aligned(struct, 32) GIFPath +struct alignas(32) GIFPath { GIFTag tag; uint32 nloop; diff --git a/plugins/GSdx/GSBlock.h b/plugins/GSdx/GSBlock.h index a18f597299..1c38fcb529 100644 --- a/plugins/GSdx/GSBlock.h +++ b/plugins/GSdx/GSBlock.h @@ -1917,7 +1917,7 @@ public: #else - __aligned(uint16, 32) block[16 * 8]; + alignas(32) uint16 block[16 * 8]; ReadBlock16(src, (uint8*)block, sizeof(block) / 8); @@ -1976,7 +1976,7 @@ public: #else - __aligned(uint8, 32) block[16 * 16]; + alignas(32) uint8 block[16 * 16]; ReadBlock8(src, (uint8*)block, sizeof(block) / 16); @@ -2053,7 +2053,7 @@ public: #else - __aligned(uint8, 32) block[(32 / 2) * 16]; + alignas(32) uint8 block[(32 / 2) * 16]; ReadBlock4(src, (uint8*)block, sizeof(block) / 16); @@ -2096,7 +2096,7 @@ public: #else - __aligned(uint32, 32) block[8 * 8]; + alignas(32) uint32 block[8 * 8]; ReadBlock32(src, (uint8*)block, sizeof(block) / 8); @@ -2139,7 +2139,7 @@ public: #else - __aligned(uint32, 32) block[8 * 8]; + alignas(32) uint32 block[8 * 8]; ReadBlock32(src, (uint8*)block, sizeof(block) / 8); @@ -2182,7 +2182,7 @@ public: #else - __aligned(uint32, 32) block[8 * 8]; + alignas(32) uint32 block[8 * 8]; ReadBlock32(src, (uint8*)block, sizeof(block) / 8); diff --git a/plugins/GSdx/GSClut.h b/plugins/GSdx/GSClut.h index 171e5e1452..d39eb1602f 100644 --- a/plugins/GSdx/GSClut.h +++ b/plugins/GSdx/GSClut.h @@ -28,7 +28,7 @@ class GSLocalMemory; -__aligned(class, 32) GSClut : public GSAlignedClass<32> +class alignas(32) GSClut : public GSAlignedClass<32> { GSLocalMemory* m_mem; @@ -37,7 +37,7 @@ __aligned(class, 32) GSClut : public GSAlignedClass<32> uint32* m_buff32; uint64* m_buff64; - __aligned(struct, 32) WriteState + struct alignas(32) WriteState { GIFRegTEX0 TEX0; GIFRegTEXCLUT TEXCLUT; @@ -45,7 +45,7 @@ __aligned(class, 32) GSClut : public GSAlignedClass<32> bool IsDirty(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT); } m_write; - __aligned(struct, 32) ReadState + struct alignas(32) ReadState { GIFRegTEX0 TEX0; GIFRegTEXA TEXA; diff --git a/plugins/GSdx/GSDeviceDX.h b/plugins/GSdx/GSDeviceDX.h index cdf03312ad..36bb0ae13f 100644 --- a/plugins/GSdx/GSDeviceDX.h +++ b/plugins/GSdx/GSDeviceDX.h @@ -30,7 +30,7 @@ class GSDeviceDX : public GSDevice public: #pragma pack(push, 1) - __aligned(struct, 32) VSConstantBuffer + struct alignas(32) VSConstantBuffer { GSVector4 VertexScale; GSVector4 VertexOffset; @@ -86,7 +86,7 @@ public: VSSelector() : key(0) {} }; - __aligned(struct, 32) PSConstantBuffer + struct alignas(32) PSConstantBuffer { GSVector4 FogColor_AREF; GSVector4 HalfTexel; diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 28e436e5f4..2bf30b632b 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -116,8 +116,8 @@ public: class GSDeviceOGL final : public GSDevice { - public: - __aligned(struct, 32) VSConstantBuffer +public: + struct alignas(32) VSConstantBuffer { GSVector4 Vertex_Scale_Offset; GSVector4 TextureScale; @@ -187,7 +187,7 @@ class GSDeviceOGL final : public GSDevice GSSelector(uint32 k) : key(k) {} }; - __aligned(struct, 32) PSConstantBuffer + struct alignas(32) PSConstantBuffer { GSVector4 FogColor_AREF; GSVector4 WH; diff --git a/plugins/GSdx/GSDeviceSW.cpp b/plugins/GSdx/GSDeviceSW.cpp index 5518e5eecd..dfcf63bea6 100644 --- a/plugins/GSdx/GSDeviceSW.cpp +++ b/plugins/GSdx/GSDeviceSW.cpp @@ -186,7 +186,7 @@ public: } }; -__aligned(class, 16) ShaderFactorBlend : public ShaderBase +class alignas(16) ShaderFactorBlend : public ShaderBase { GSVector4i m_f; diff --git a/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp b/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp index 3909a6e787..09a233a6ae 100644 --- a/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp +++ b/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp @@ -24,7 +24,7 @@ #if _M_SSE >= 0x501 -__aligned(const uint8, 8) GSDrawScanlineCodeGenerator::m_test[16][8] = +alignas(8) const uint8 GSDrawScanlineCodeGenerator::m_test[16][8] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, diff --git a/plugins/GSdx/GSDrawScanlineCodeGenerator.h b/plugins/GSdx/GSDrawScanlineCodeGenerator.h index 282285bcbd..5ff54b4d4b 100644 --- a/plugins/GSdx/GSDrawScanlineCodeGenerator.h +++ b/plugins/GSdx/GSDrawScanlineCodeGenerator.h @@ -135,7 +135,7 @@ public: GSDrawScanlineCodeGenerator(void* param, uint64 key, void* code, size_t maxsize); #if _M_SSE >= 0x501 - static __aligned(const uint8, 8) m_test[16][8]; + alignas(8) static const uint8 m_test[16][8]; static const GSVector8 m_log2_coef[4]; #else static const GSVector4i m_test[8]; diff --git a/plugins/GSdx/GSDrawingContext.h b/plugins/GSdx/GSDrawingContext.h index 9ac9f92c09..df764d9310 100644 --- a/plugins/GSdx/GSDrawingContext.h +++ b/plugins/GSdx/GSDrawingContext.h @@ -24,7 +24,7 @@ #include "GS.h" #include "GSLocalMemory.h" -__aligned(class, 32) GSDrawingContext +class alignas(32) GSDrawingContext { public: GIFRegXYOFFSET XYOFFSET; diff --git a/plugins/GSdx/GSDrawingEnvironment.h b/plugins/GSdx/GSDrawingEnvironment.h index 07c6d4eab2..4acf9d4db0 100644 --- a/plugins/GSdx/GSDrawingEnvironment.h +++ b/plugins/GSdx/GSDrawingEnvironment.h @@ -23,7 +23,7 @@ #include "GS.h" -__aligned(class, 32) GSDrawingEnvironment +class alignas(32) GSDrawingEnvironment { public: GIFRegPRIM PRIM; diff --git a/plugins/GSdx/GSLocalMemory.cpp b/plugins/GSdx/GSLocalMemory.cpp index 16ac0f62ed..c37bfaec3c 100644 --- a/plugins/GSdx/GSLocalMemory.cpp +++ b/plugins/GSdx/GSLocalMemory.cpp @@ -770,7 +770,7 @@ void GSLocalMemory::WriteImageLeftRight(int l, int r, int y, int h, const uint8* template void GSLocalMemory::WriteImageTopBottom(int l, int r, int y, int h, const uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) { - __aligned(uint8, 32) buff[64]; // merge buffer for one column + alignas(32) uint8 buff[64]; // merge buffer for one column uint32 bp = BITBLTBUF.DBP; uint32 bw = BITBLTBUF.DBW; @@ -2055,7 +2055,7 @@ uint32* GSOffset::GetPages(const GSVector4i& rect, uint32* pages, GSVector4i* bb pages = new uint32[limit]; } - __aligned(uint32, 16) tmp[16]; + alignas(16) uint32 tmp[16]; ((GSVector4i*)tmp)[0] = GSVector4i::zero(); ((GSVector4i*)tmp)[1] = GSVector4i::zero(); diff --git a/plugins/GSdx/GSLocalMemory.h b/plugins/GSdx/GSLocalMemory.h index 4f0e2efe1b..f52d438fb6 100644 --- a/plugins/GSdx/GSLocalMemory.h +++ b/plugins/GSdx/GSLocalMemory.h @@ -30,13 +30,13 @@ class GSOffset : public GSAlignedClass<32> { public: - __aligned(struct, 32) Block + struct alignas(32) Block { short row[256]; // yn (n = 0 8 16 ...) short* col; // blockOffset* }; - __aligned(struct, 32) Pixel + struct alignas(32) Pixel { int row[4096]; // yn (n = 0 1 2 ...) NOTE: this wraps around above 2048, only transfers should address the upper half (dark cloud 2 inventing) int* col[8]; // rowOffset* @@ -95,7 +95,7 @@ public: typedef void (GSLocalMemory::*readTexture)(const GSOffset* RESTRICT off, const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA); typedef void (GSLocalMemory::*readTextureBlock)(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - __aligned(struct, 128) psm_t + struct alignas(128) psm_t { pixelAddress pa, bn; readPixel rp; diff --git a/plugins/GSdx/GSRasterizer.h b/plugins/GSdx/GSRasterizer.h index 35d42c8ff4..f4eeb04c25 100644 --- a/plugins/GSdx/GSRasterizer.h +++ b/plugins/GSdx/GSRasterizer.h @@ -28,7 +28,7 @@ #include "GSPerfMon.h" #include "GSThread_CXX11.h" -__aligned(class, 32) GSRasterizerData : public GSAlignedClass<32> +class alignas(32) GSRasterizerData : public GSAlignedClass<32> { static int s_counter; @@ -122,7 +122,7 @@ public: virtual void PrintStats() = 0; }; -__aligned(class, 32) GSRasterizer : public IRasterizer +class alignas(32) GSRasterizer : public IRasterizer { protected: GSPerfMon* m_perfmon; diff --git a/plugins/GSdx/GSRendererCL.h b/plugins/GSdx/GSRendererCL.h index 46e7f0467f..d1b849b6cd 100644 --- a/plugins/GSdx/GSRendererCL.h +++ b/plugins/GSdx/GSRendererCL.h @@ -25,7 +25,7 @@ #ifdef ENABLE_OPENCL -__aligned(struct, 32) GSVertexCL +struct alignas(32) GSVertexCL { GSVector4 p, t; }; @@ -145,7 +145,7 @@ class GSRendererCL : public GSRenderer } }; - __aligned(struct, 32) TFXParameter + struct alignas(32) TFXParameter { GSVector4i scissor; GSVector4i dimx; // 4x4 signed char diff --git a/plugins/GSdx/GSRendererCS.h b/plugins/GSdx/GSRendererCS.h index 5b1def1ff7..01f9071b18 100644 --- a/plugins/GSdx/GSRendererCS.h +++ b/plugins/GSdx/GSRendererCS.h @@ -44,7 +44,7 @@ class GSRendererCS : public GSRenderer VSSelector() : key(0) {} }; - __aligned(struct, 32) VSConstantBuffer + struct alignas(32) VSConstantBuffer { GSVector4 VertexScale; GSVector4 VertexOffset; @@ -86,7 +86,7 @@ class GSRendererCS : public GSRenderer PSSelector() : key(0) {} }; - __aligned(struct, 32) PSConstantBuffer + struct alignas(32) PSConstantBuffer { uint32 fm; uint32 zm; diff --git a/plugins/GSdx/GSRendererSW.h b/plugins/GSdx/GSRendererSW.h index badb702592..b2e1c2155b 100644 --- a/plugins/GSdx/GSRendererSW.h +++ b/plugins/GSdx/GSRendererSW.h @@ -29,7 +29,7 @@ class GSRendererSW : public GSRenderer { class SharedData : public GSDrawScanline::SharedData { - __aligned(struct, 16) TextureLevel + struct alignas(16) TextureLevel { GSVector4i r; GSTextureCacheSW::Texture* t; diff --git a/plugins/GSdx/GSScanlineEnvironment.h b/plugins/GSdx/GSScanlineEnvironment.h index cc71026b72..e9f0551e40 100644 --- a/plugins/GSdx/GSScanlineEnvironment.h +++ b/plugins/GSdx/GSScanlineEnvironment.h @@ -105,7 +105,7 @@ union GSScanlineSelector } }; -__aligned(struct, 32) GSScanlineGlobalData // per batch variables, this is like a pixel shader constant buffer +struct alignas(32) GSScanlineGlobalData // per batch variables, this is like a pixel shader constant buffer { GSScanlineSelector sel; @@ -150,7 +150,7 @@ __aligned(struct, 32) GSScanlineGlobalData // per batch variables, this is like #endif }; -__aligned(struct, 32) GSScanlineLocalData // per prim variables, each thread has its own +struct alignas(32) GSScanlineLocalData // per prim variables, each thread has its own { #if _M_SSE >= 0x501 diff --git a/plugins/GSdx/GSVector.h b/plugins/GSdx/GSVector.h index b8ebe1bb3a..da46a64f71 100644 --- a/plugins/GSdx/GSVector.h +++ b/plugins/GSdx/GSVector.h @@ -90,7 +90,7 @@ class GSVector8i; #endif -__aligned(class, 16) GSVector4i +class alignas(16) GSVector4i { static const GSVector4i m_xff[17]; static const GSVector4i m_x0f[17]; @@ -2421,7 +2421,7 @@ public: __forceinline static GSVector4i x0f(int n) {return m_x0f[n];} }; -__aligned(class, 16) GSVector4 +class alignas(16) GSVector4 { public: union @@ -3341,7 +3341,7 @@ GSVector.h:2973:15: error: shadows template parm 'int i' #if _M_SSE >= 0x501 -__aligned(class, 32) GSVector8i +class alignas(32) GSVector8i { static const GSVector8i m_xff[33]; static const GSVector8i m_x0f[33]; @@ -5133,7 +5133,7 @@ public: #if _M_SSE >= 0x500 -__aligned(class, 32) GSVector8 +class alignas(32) GSVector8 { public: union diff --git a/plugins/GSdx/GSVertex.h b/plugins/GSdx/GSVertex.h index 198fbb93d0..5d6b82135f 100644 --- a/plugins/GSdx/GSVertex.h +++ b/plugins/GSdx/GSVertex.h @@ -28,7 +28,7 @@ #pragma pack(push, 1) -__aligned(struct, 32) GSVertex +struct alignas(32) GSVertex { union { @@ -52,7 +52,7 @@ struct GSVertexP GSVector4 p; }; -__aligned(struct, 32) GSVertexPT1 +struct alignas(32) GSVertexPT1 { GSVector4 p; GSVector2 t; diff --git a/plugins/GSdx/GSVertexHW.h b/plugins/GSdx/GSVertexHW.h index e0fe308b62..f249f5731a 100644 --- a/plugins/GSdx/GSVertexHW.h +++ b/plugins/GSdx/GSVertexHW.h @@ -26,7 +26,7 @@ #pragma pack(push, 1) -__aligned(struct, 32) GSVertexHW9 +struct alignas(32) GSVertexHW9 { GSVector4 t; GSVector4 p; diff --git a/plugins/GSdx/GSVertexSW.h b/plugins/GSdx/GSVertexSW.h index 0d977658d7..b902fd4f41 100644 --- a/plugins/GSdx/GSVertexSW.h +++ b/plugins/GSdx/GSVertexSW.h @@ -23,7 +23,7 @@ #include "GSVector.h" -__aligned(struct, 32) GSVertexSW +struct alignas(32) GSVertexSW { GSVector4 p, _pad, t, c; @@ -237,7 +237,7 @@ __aligned(struct, 32) GSVertexSW #if _M_SSE >= 0x501 -__aligned(struct, 32) GSVertexSW2 +struct alignas(32) GSVertexSW2 { GSVector4 p, _pad; GSVector8 tc; diff --git a/plugins/GSdx/GSVertexTrace.h b/plugins/GSdx/GSVertexTrace.h index b3ee0b73e6..caaa75a18e 100644 --- a/plugins/GSdx/GSVertexTrace.h +++ b/plugins/GSdx/GSVertexTrace.h @@ -29,7 +29,7 @@ class GSState; -__aligned(class, 32) GSVertexTrace : public GSAlignedClass<32> +class alignas(32) GSVertexTrace : public GSAlignedClass<32> { public: struct Vertex {GSVector4i c; GSVector4 p, t;}; diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index 7417a262a3..851f18b6e0 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -197,17 +197,17 @@ using namespace stdext; #endif #ifdef _MSC_VER - - #define __aligned(t, n) __declspec(align(n)) t +#if _MSC_VER < 1900 + #define alignas(n) __declspec(align(n)) +#endif #define EXPORT_C_(type) extern "C" __declspec(dllexport) type __stdcall #define EXPORT_C EXPORT_C_(void) - #define ALIGN_STACK(n) __aligned(int, n) __dummy; + #define ALIGN_STACK(n) alignas(n) int dummy__; #else - #define __aligned(t, n) t __attribute__((aligned(n))) #define __fastcall __attribute__((fastcall)) #define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type @@ -227,7 +227,7 @@ using namespace stdext; #else // TODO Check clang behavior - #define ALIGN_STACK(n) __aligned(int, n) __dummy; + #define ALIGN_STACK(n) alignas(n) int dummy__; #endif From 57cdf0bf1605a9f451cf4149aeb3e9c126cb9fab Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Fri, 13 May 2016 23:43:36 +0100 Subject: [PATCH 10/14] gsdx:linux: Use clock_gettime instead of ftime ftime is obsolete and not present in recent POSIX specifications. --- plugins/GSdx/GS.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 7415fcaa0a..f886c775ac 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -1499,16 +1499,13 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow #ifdef __linux__ -#include -#include // ftime(), struct timeb #include "GSLzma.h" inline unsigned long timeGetTime() { - timeb t; - ftime(&t); - - return (unsigned long)(t.time*1000 + t.millitm); + struct timespec t; + clock_gettime(CLOCK_REALTIME, &t); + return (unsigned long)(t.tv_sec*1000 + t.tv_nsec/1000000); } // Note From 571432a7aaed85adf30d3e088f912992d9608c57 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 1 May 2016 10:43:18 +0100 Subject: [PATCH 11/14] gsdx:freebsd: Fix compilation --- plugins/GSdx/GS.cpp | 10 +++++----- plugins/GSdx/GSCapture.cpp | 8 ++++---- plugins/GSdx/GSCapture.h | 2 +- plugins/GSdx/GSLzma.cpp | 2 +- plugins/GSdx/GSLzma.h | 2 +- plugins/GSdx/GSPerfMon.cpp | 2 +- plugins/GSdx/GSRenderer.cpp | 4 ++-- plugins/GSdx/GSSetting.cpp | 2 +- plugins/GSdx/GSSetting.h | 2 +- plugins/GSdx/GSState.cpp | 2 +- plugins/GSdx/GSUtil.h | 2 +- plugins/GSdx/GSWndEGL.cpp | 2 +- plugins/GSdx/GSWndEGL.h | 2 +- plugins/GSdx/GSWndOGL.cpp | 2 +- plugins/GSdx/GSWndOGL.h | 2 +- plugins/GSdx/GSdx.cpp | 4 ++-- plugins/GSdx/GSdx.h | 4 ++-- plugins/GSdx/config.h | 2 +- plugins/GSdx/stdafx.h | 4 +++- 19 files changed, 31 insertions(+), 29 deletions(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index f886c775ac..3b3ab17034 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -365,7 +365,7 @@ static int _GSopen(void** dsp, const char* title, GSRendererType renderer, int t int w = theApp.GetConfig("ModeWidth", 0); int h = theApp.GetConfig("ModeHeight", 0); -#ifdef __linux__ +#if defined(__unix__) for(uint32 i = 0; i < 2; i++) { try { @@ -408,7 +408,7 @@ static int _GSopen(void** dsp, const char* title, GSRendererType renderer, int t { s_gs->SetMultithreaded(true); -#ifdef __linux__ +#if defined(__unix__) if (s_gs->m_wnd) { // A window was already attached to s_gs so we also // need to restore the window state (Attach) @@ -510,7 +510,7 @@ EXPORT_C_(int) GSopen2(void** dsp, uint32 flags) } #endif -#ifdef __linux__ +#if defined(__unix__) switch(renderer) { // Use alternative renderer (SW if currently using HW renderer, and vice versa) case GSRendererType::OGL_SW: renderer = GSRendererType::OGL_HW; break; @@ -882,7 +882,7 @@ EXPORT_C_(int) GSsetupRecording(int start, void* data) printf("GSdx: no s_gs for recording\n"); return 0; } -#ifdef __linux__ +#if defined(__unix__) if (!theApp.GetConfig("capture_enabled", 0)) { printf("GSdx: Recording is disabled\n"); return 0; @@ -1497,7 +1497,7 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow #endif -#ifdef __linux__ +#if defined(__unix__) #include "GSLzma.h" diff --git a/plugins/GSdx/GSCapture.cpp b/plugins/GSdx/GSCapture.cpp index d31a0873d5..0c564edc51 100644 --- a/plugins/GSdx/GSCapture.cpp +++ b/plugins/GSdx/GSCapture.cpp @@ -382,7 +382,7 @@ GSCapture::GSCapture() { m_out_dir = theApp.GetConfig("capture_out_dir", "/tmp/GSdx_Capture"); m_threads = theApp.GetConfig("capture_threads", 4); -#ifdef __linux__ +#if defined(__unix__) m_compression_level = theApp.GetConfig("png_compression_level", Z_BEST_SPEED); #endif } @@ -481,7 +481,7 @@ bool GSCapture::BeginCapture(float fps, GSVector2i recomendedResolution, float a CComQIPtr(m_src)->DeliverNewSegment(); -#elif __linux__ +#elif defined(__unix__) // Note I think it doesn't support multiple depth creation GSmkdir(m_out_dir.c_str()); @@ -521,7 +521,7 @@ bool GSCapture::DeliverFrame(const void* bits, int pitch, bool rgba) return true; } -#elif __linux__ +#elif defined(__unix__) std::string out_file = m_out_dir + format("/frame.%010d.png", m_frame); //GSPng::Save(GSPng::RGB_PNG, out_file, (uint8*)bits, m_size.x, m_size.y, pitch, m_compression_level); @@ -554,7 +554,7 @@ bool GSCapture::EndCapture() m_graph = NULL; } -#elif __linux__ +#elif defined(__unix__) for(size_t i = 0; i < m_workers.size(); i++) { m_workers[i]->Wait(); } diff --git a/plugins/GSdx/GSCapture.h b/plugins/GSdx/GSCapture.h index 3fdb7afde1..ba7dcfb258 100644 --- a/plugins/GSdx/GSCapture.h +++ b/plugins/GSdx/GSCapture.h @@ -42,7 +42,7 @@ class GSCapture CComPtr m_graph; CComPtr m_src; - #elif __linux__ + #elif defined(__unix__) vector m_workers; int m_compression_level; diff --git a/plugins/GSdx/GSLzma.cpp b/plugins/GSdx/GSLzma.cpp index 77a76dc55e..d18791ea04 100644 --- a/plugins/GSdx/GSLzma.cpp +++ b/plugins/GSdx/GSLzma.cpp @@ -21,7 +21,7 @@ #include "stdafx.h" #include "GSLzma.h" -#ifdef __linux__ +#if defined(__unix__) GSDumpFile::GSDumpFile(char* filename) { m_fp = fopen(filename, "rb"); diff --git a/plugins/GSdx/GSLzma.h b/plugins/GSdx/GSLzma.h index 596d97e255..0fc955017a 100644 --- a/plugins/GSdx/GSLzma.h +++ b/plugins/GSdx/GSLzma.h @@ -18,7 +18,7 @@ * */ -#ifdef __linux__ +#if defined(__unix__) #ifdef LZMA_SUPPORTED #include diff --git a/plugins/GSdx/GSPerfMon.cpp b/plugins/GSdx/GSPerfMon.cpp index 52a82006ef..b2ee9d23bf 100644 --- a/plugins/GSdx/GSPerfMon.cpp +++ b/plugins/GSdx/GSPerfMon.cpp @@ -38,7 +38,7 @@ void GSPerfMon::Put(counter_t c, double val) #ifndef DISABLE_PERF_MON if(c == Frame) { -#ifdef __linux__ +#if defined(__unix__) // clock on linux will return CLOCK_PROCESS_CPUTIME_ID. // CLOCK_THREAD_CPUTIME_ID is much more useful to measure the fps struct timespec ts; diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index 53c7f71014..a5f2bb5a94 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -21,7 +21,7 @@ #include "stdafx.h" #include "GSRenderer.h" -#ifdef __linux__ +#if defined(__unix__) #include #endif @@ -581,7 +581,7 @@ void GSRenderer::KeyEvent(GSKeyEventData* e) } } -#elif defined(__linux__) +#elif defined(__unix__) if(e->type == KEYPRESS) { int step = m_shift_key ? -1 : 1; diff --git a/plugins/GSdx/GSSetting.cpp b/plugins/GSdx/GSSetting.cpp index d1352e4f13..ecc5203494 100644 --- a/plugins/GSdx/GSSetting.cpp +++ b/plugins/GSdx/GSSetting.cpp @@ -21,7 +21,7 @@ #include "stdafx.h" #include "GSSetting.h" -#ifndef __linux__ +#ifdef _WIN32 #include "resource.h" #endif diff --git a/plugins/GSdx/GSSetting.h b/plugins/GSdx/GSSetting.h index ba47d92810..c42c25ee28 100644 --- a/plugins/GSdx/GSSetting.h +++ b/plugins/GSdx/GSSetting.h @@ -40,7 +40,7 @@ struct GSSetting const char* dialog_message(int ID, bool* updateText = NULL); -#ifdef __linux__ +#ifndef _WIN32 enum { IDC_FILTER, IDC_SKIPDRAWHACK, diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index bdc80a04d0..2519ba6733 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -56,7 +56,7 @@ GSState::GSState() s_savef = !!theApp.GetConfig("savef", 0); s_saven = theApp.GetConfig("saven", 0); s_savel = theApp.GetConfig("savel", 5000); -#ifdef __linux__ +#if defined(__unix__) if (s_dump) { GSmkdir("/tmp/GS_HW_dump"); GSmkdir("/tmp/GS_SW_dump"); diff --git a/plugins/GSdx/GSUtil.h b/plugins/GSdx/GSUtil.h index f1372775e3..6342509448 100644 --- a/plugins/GSdx/GSUtil.h +++ b/plugins/GSdx/GSUtil.h @@ -65,6 +65,6 @@ public: #endif }; -#ifdef __linux__ +#if defined(__unix__) void GSmkdir(const char* dir); #endif diff --git a/plugins/GSdx/GSWndEGL.cpp b/plugins/GSdx/GSWndEGL.cpp index 3b51fe02d1..ee66b05109 100644 --- a/plugins/GSdx/GSWndEGL.cpp +++ b/plugins/GSdx/GSWndEGL.cpp @@ -22,7 +22,7 @@ #include "stdafx.h" #include "GSWndEGL.h" -#if defined(__linux__) && defined(EGL_SUPPORTED) +#if defined(__unix__) && defined(EGL_SUPPORTED) GSWndEGL::GSWndEGL() : m_NativeWindow(0), m_NativeDisplay(NULL) diff --git a/plugins/GSdx/GSWndEGL.h b/plugins/GSdx/GSWndEGL.h index 17804bb726..7ff86f157e 100644 --- a/plugins/GSdx/GSWndEGL.h +++ b/plugins/GSdx/GSWndEGL.h @@ -21,7 +21,7 @@ #include "GSWnd.h" -#if defined(__linux__) && defined(EGL_SUPPORTED) +#if defined(__unix__) && defined(EGL_SUPPORTED) #include #include #include diff --git a/plugins/GSdx/GSWndOGL.cpp b/plugins/GSdx/GSWndOGL.cpp index 5537f2d555..786cb86701 100644 --- a/plugins/GSdx/GSWndOGL.cpp +++ b/plugins/GSdx/GSWndOGL.cpp @@ -22,7 +22,7 @@ #include "stdafx.h" #include "GSWndOGL.h" -#if defined(__linux__) +#if defined(__unix__) GSWndOGL::GSWndOGL() : m_NativeWindow(0), m_NativeDisplay(NULL), m_context(0), m_swapinterval(NULL) { diff --git a/plugins/GSdx/GSWndOGL.h b/plugins/GSdx/GSWndOGL.h index 7f71c049ab..c54e6f24e3 100644 --- a/plugins/GSdx/GSWndOGL.h +++ b/plugins/GSdx/GSWndOGL.h @@ -21,7 +21,7 @@ #include "GSWnd.h" -#if defined(__linux__) +#if defined(__unix__) #include #include diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp index 6be615ded0..47576fc39a 100644 --- a/plugins/GSdx/GSdx.cpp +++ b/plugins/GSdx/GSdx.cpp @@ -172,7 +172,7 @@ GSdxApp::GSdxApp() m_gs_upscale_multiplier.push_back(GSSetting(5, "5x Native", "")); m_gs_upscale_multiplier.push_back(GSSetting(6, "6x Native", "")); m_gs_upscale_multiplier.push_back(GSSetting(8, "8x Native", "")); -#ifndef __linux__ +#ifndef __unix__ m_gs_upscale_multiplier.push_back(GSSetting(0, "Custom", "")); #endif @@ -237,7 +237,7 @@ GSdxApp::GSdxApp() m_gpu_scale.push_back(GSSetting(2 | (2 << 2), "H x 4 - V x 4", "")); } -#ifdef __linux__ +#if defined(__unix__) void GSdxApp::ReloadConfig() { if (m_configuration_map.empty()) return; diff --git a/plugins/GSdx/GSdx.h b/plugins/GSdx/GSdx.h index 6ddaf2cb9e..ece0ed88e9 100644 --- a/plugins/GSdx/GSdx.h +++ b/plugins/GSdx/GSdx.h @@ -27,7 +27,7 @@ class GSdxApp { std::string m_ini; std::string m_section; -#ifdef __linux__ +#if defined(__unix__) std::map< std::string, std::string > m_configuration_map; #endif @@ -40,7 +40,7 @@ public: HMODULE GetModuleHandle() {return (HMODULE)GetModuleHandlePtr();} #endif -#ifdef __linux__ +#if defined(__unix__) void BuildConfigurationMap(const char* lpFileName); void ReloadConfig(); diff --git a/plugins/GSdx/config.h b/plugins/GSdx/config.h index 3493559055..2e292f56d5 100644 --- a/plugins/GSdx/config.h +++ b/plugins/GSdx/config.h @@ -45,7 +45,7 @@ //#define ENABLE_OGL_DEBUG_MEM_BW // compute the quantity of data transfered (debug purpose) #endif -#if defined(__linux__) && !(defined(_DEBUG) || defined(_DEVEL)) +#if defined(__unix__) && !(defined(_DEBUG) || defined(_DEVEL)) #define DISABLE_PERF_MON // Burn cycle for nothing in release mode #endif diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index 851f18b6e0..cc26846fb5 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -208,7 +208,9 @@ using namespace stdext; #else - #define __fastcall __attribute__((fastcall)) + #ifndef __fastcall + #define __fastcall __attribute__((fastcall)) + #endif #define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type #define EXPORT_C EXPORT_C_(void) From eaa4abea451348723be2e39c35eead154a63e981 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Thu, 12 May 2016 18:27:05 +0100 Subject: [PATCH 12/14] ipu: Convert yuv2rgb sse2 inline assembly to intrinsics It's more portable. Use _mm_shuffle_epi32 instead of _mm_movehl_ps - I think it avoids data bypass delays going from integer to float domains on older processors, and Agner's tables indicate that the instruction has the same latency and occasionally has higher throughput (depending on cpu). And switch the _mm_xor_si128 and _mm_unpacklo_epi8 around so the same constant can be used for both C bias and alpha. --- pcsx2/IPU/yuv2rgb.cpp | 409 ++++++++---------------------------------- pcsx2/IPU/yuv2rgb.h | 7 +- 2 files changed, 75 insertions(+), 341 deletions(-) diff --git a/pcsx2/IPU/yuv2rgb.cpp b/pcsx2/IPU/yuv2rgb.cpp index ffd9ce1cca..46c196b8b3 100644 --- a/pcsx2/IPU/yuv2rgb.cpp +++ b/pcsx2/IPU/yuv2rgb.cpp @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2010 PCSX2 Dev Team + * Copyright (C) 2002-2016 PCSX2 Dev Team * * PCSX2 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 Found- @@ -58,357 +58,94 @@ void yuv2rgb_reference(void) } } -#if defined(_M_X86_32) -// TODO OSX optimize me -#if defined(__clang__) && !defined(__linux__) -void yuv2rgb_sse2() { - yuv2rgb_reference(); -} -#else -// Everything below is bit accurate to the IPU specification (except maybe rounding). -// Know the specification before you touch it. -#define SSE_BYTES(x) {x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x} -#define SSE_WORDS(x) {x, x, x, x, x, x, x, x} -#define SSE_COEFFICIENTS(x) SSE_WORDS((s16)((x)<<2)) - -struct SSE2_Tables +// Suikoden Tactics FMV speed results: Reference - ~72fps, SSE2 - ~120fps +// An AVX2 version is only slightly faster than an SSE2 version (+2-3fps) +// (or I'm a poor optimiser), though it might be worth attempting again +// once we've ported to 64 bits (the extra registers should help). +__ri void yuv2rgb_sse2() { - u16 C_bias[8]; // offset -64 - u8 Y_bias[16]; // offset -48 - u16 Y_mask[8]; // offset -32 - u16 round_1bit[8]; // offset -16 - - s16 Y_coefficients[8]; // offset 0 - s16 GCr_coefficients[8];// offset 16 - s16 GCb_coefficients[8];// offset 32 - s16 RCr_coefficients[8];// offset 48 - s16 BCb_coefficients[8];// offset 64 -}; - -enum -{ - C_BIAS = -0x40, - Y_BIAS = -0x30, - Y_MASK = -0x20, - ROUND_1BIT = -0x10, - - Y_COEFF = 0x00, - GCr_COEFF = 0x10, - GCb_COEFF = 0x20, - RCr_COEFF = 0x30, - BCb_COEFF = 0x40 -}; - -static const __aligned16 SSE2_Tables sse2_tables = -{ - SSE_WORDS(0x8000), // c_bias - SSE_BYTES(IPU_Y_BIAS), // y_bias - SSE_WORDS(0xff00), // y_mask - + const __m128i c_bias = _mm_set1_epi8(s8(IPU_C_BIAS)); + const __m128i y_bias = _mm_set1_epi8(IPU_Y_BIAS); + const __m128i y_mask = _mm_set1_epi16(s16(0xFF00)); // Specifying round off instead of round down as everywhere else // implies that this is right - SSE_WORDS(1), // round_1bit + const __m128i round_1bit = _mm_set1_epi16(0x0001);; - SSE_COEFFICIENTS(IPU_Y_COEFF), - SSE_COEFFICIENTS(IPU_GCR_COEFF), - SSE_COEFFICIENTS(IPU_GCB_COEFF), - SSE_COEFFICIENTS(IPU_RCR_COEFF), - SSE_COEFFICIENTS(IPU_BCB_COEFF), -}; + const __m128i y_coefficient = _mm_set1_epi16(s16(IPU_Y_COEFF << 2)); + const __m128i gcr_coefficient = _mm_set1_epi16(s16(u16(IPU_GCR_COEFF) << 2)); + const __m128i gcb_coefficient = _mm_set1_epi16(s16(u16(IPU_GCB_COEFF) << 2)); + const __m128i rcr_coefficient = _mm_set1_epi16(s16(IPU_RCR_COEFF << 2)); + const __m128i bcb_coefficient = _mm_set1_epi16(s16(IPU_BCB_COEFF << 2)); -static __aligned16 u16 yuv2rgb_temp[3][8]; + // Alpha set to 0x80 here. The threshold stuff is done later. + const __m128i& alpha = c_bias; -// This could potentially be improved for SSE4 -__ri void yuv2rgb_sse2(void) -{ -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) - __asm { - mov eax, 1 - xor esi, esi - xor edi, edi + for (int n = 0; n < 8; ++n) { + // could skip the loadl_epi64 but most SSE instructions require 128-bit + // alignment so two versions would be needed. + __m128i cb = _mm_loadl_epi64(reinterpret_cast<__m128i*>(&decoder.mb8.Cb[n][0])); + __m128i cr = _mm_loadl_epi64(reinterpret_cast<__m128i*>(&decoder.mb8.Cr[n][0])); - // Use ecx and edx as base pointers, to allow for Mod/RM form on memOps. - // This saves 2-3 bytes per instruction where these are used. :) - mov ecx, offset yuv2rgb_temp - mov edx, offset sse2_tables+64; + // (Cb - 128) << 8, (Cr - 128) << 8 + cb = _mm_xor_si128(cb, c_bias); + cr = _mm_xor_si128(cr, c_bias); + cb = _mm_unpacklo_epi8(_mm_setzero_si128(), cb); + cr = _mm_unpacklo_epi8(_mm_setzero_si128(), cr); - align 16 -tworows: - movq xmm3, qword ptr [decoder.mb8+256+esi] - movq xmm1, qword ptr [decoder.mb8+320+esi] - pxor xmm2, xmm2 - pxor xmm0, xmm0 - // could skip the movq but punpck requires 128-bit alignment - // for some reason, so two versions would be needed, - // bloating the function (further) - punpcklbw xmm2, xmm3 - punpcklbw xmm0, xmm1 - // unfortunately I don't think this will matter despite being - // technically potentially a little faster, but this is - // equivalent to an add or sub - pxor xmm2, xmmword ptr [edx+C_BIAS] // xmm2 <-- 8 x (Cb - 128) << 8 - pxor xmm0, xmmword ptr [edx+C_BIAS] // xmm0 <-- 8 x (Cr - 128) << 8 + __m128i rc = _mm_mulhi_epi16(cr, rcr_coefficient); + __m128i gc = _mm_adds_epi16(_mm_mulhi_epi16(cr, gcr_coefficient), _mm_mulhi_epi16(cb, gcb_coefficient)); + __m128i bc = _mm_mulhi_epi16(cb, bcb_coefficient); - movaps xmm1, xmm0 - movaps xmm3, xmm2 - pmulhw xmm1, xmmword ptr [edx+GCr_COEFF] - pmulhw xmm3, xmmword ptr [edx+GCb_COEFF] - pmulhw xmm0, xmmword ptr [edx+RCr_COEFF] - pmulhw xmm2, xmmword ptr [edx+BCb_COEFF] - paddsw xmm1, xmm3 - // store for the next line; looking at the code above - // compared to the code below, I have to wonder whether - // this was worth the hassle - movaps xmmword ptr [ecx], xmm0 - movaps xmmword ptr [ecx+16], xmm1 - movaps xmmword ptr [ecx+32], xmm2 - jmp ihatemsvc + for (int m = 0; m < 2; ++m) { + __m128i y = _mm_load_si128(reinterpret_cast<__m128i*>(&decoder.mb8.Y[n * 2 + m][0])); + y = _mm_subs_epu8(y, y_bias); + // Y << 8 for pixels 0, 2, 4, 6, 8, 10, 12, 14 + __m128i y_even = _mm_slli_epi16(y, 8); + // Y << 8 for pixels 1, 3, 5, 7 ,9, 11, 13, 15 + __m128i y_odd = _mm_and_si128(y, y_mask); - align 16 -onerow: - movaps xmm0, xmmword ptr [ecx] - movaps xmm1, xmmword ptr [ecx+16] - movaps xmm2, xmmword ptr [ecx+32] + y_even = _mm_mulhi_epu16(y_even, y_coefficient); + y_odd = _mm_mulhi_epu16(y_odd, y_coefficient); -// If masm directives worked properly in inline asm, I'd be using them, -// but I'm not inclined to write ~70 line #defines to simulate them. -// Maybe the function's faster like this anyway because it's smaller? -// I'd have to write a 70 line #define to benchmark it. + __m128i r_even = _mm_adds_epi16(rc, y_even); + __m128i r_odd = _mm_adds_epi16(rc, y_odd); + __m128i g_even = _mm_adds_epi16(gc, y_even); + __m128i g_odd = _mm_adds_epi16(gc, y_odd); + __m128i b_even = _mm_adds_epi16(bc, y_even); + __m128i b_odd = _mm_adds_epi16(bc, y_odd); -ihatemsvc: - movaps xmm3, xmm0 - movaps xmm4, xmm1 - movaps xmm5, xmm2 + // round + r_even = _mm_srai_epi16(_mm_add_epi16(r_even, round_1bit), 1); + r_odd = _mm_srai_epi16(_mm_add_epi16(r_odd, round_1bit), 1); + g_even = _mm_srai_epi16(_mm_add_epi16(g_even, round_1bit), 1); + g_odd = _mm_srai_epi16(_mm_add_epi16(g_odd, round_1bit), 1); + b_even = _mm_srai_epi16(_mm_add_epi16(b_even, round_1bit), 1); + b_odd = _mm_srai_epi16(_mm_add_epi16(b_odd, round_1bit), 1); - movaps xmm6, xmmword ptr [decoder.mb8+edi] - psubusb xmm6, xmmword ptr [edx+Y_BIAS] - movaps xmm7, xmm6 - psllw xmm6, 8 // xmm6 <- Y << 8 for pixels 0,2,4,6,8,10,12,14 - pand xmm7, xmmword ptr [edx+Y_MASK] // xmm7 <- Y << 8 for pixels 1,3,5,7,9,11,13,15 + // combine even and odd bytes in original order + __m128i r = _mm_packus_epi16(r_even, r_odd); + __m128i g = _mm_packus_epi16(g_even, g_odd); + __m128i b = _mm_packus_epi16(b_even, b_odd); - pmulhuw xmm6, xmmword ptr [edx+Y_COEFF] - pmulhuw xmm7, xmmword ptr [edx+Y_COEFF] + r = _mm_unpacklo_epi8(r, _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 2, 3, 2))); + g = _mm_unpacklo_epi8(g, _mm_shuffle_epi32(g, _MM_SHUFFLE(3, 2, 3, 2))); + b = _mm_unpacklo_epi8(b, _mm_shuffle_epi32(b, _MM_SHUFFLE(3, 2, 3, 2))); - paddsw xmm0, xmm6 - paddsw xmm3, xmm7 - paddsw xmm1, xmm6 - paddsw xmm4, xmm7 - paddsw xmm2, xmm6 - paddsw xmm5, xmm7 + // Create RGBA (we could generate A here, but we don't) quads + __m128i rg_l = _mm_unpacklo_epi8(r, g); + __m128i ba_l = _mm_unpacklo_epi8(b, alpha); + __m128i rgba_ll = _mm_unpacklo_epi16(rg_l, ba_l); + __m128i rgba_lh = _mm_unpackhi_epi16(rg_l, ba_l); - // 0x80; a constant is probably so much better - pcmpeqb xmm7, xmm7 - psllw xmm7, 15 - psrlw xmm7, 8 - packuswb xmm7, xmm7 + __m128i rg_h = _mm_unpackhi_epi8(r, g); + __m128i ba_h = _mm_unpackhi_epi8(b, alpha); + __m128i rgba_hl = _mm_unpacklo_epi16(rg_h, ba_h); + __m128i rgba_hh = _mm_unpackhi_epi16(rg_h, ba_h); - // round - movaps xmm6, xmmword ptr [edx+ROUND_1BIT] - paddw xmm0, xmm6 - paddw xmm1, xmm6 - paddw xmm2, xmm6 - paddw xmm3, xmm6 - paddw xmm4, xmm6 - paddw xmm5, xmm6 - psraw xmm0, 1 - psraw xmm1, 1 - psraw xmm2, 1 - psraw xmm3, 1 - psraw xmm4, 1 - psraw xmm5, 1 - - // combine even and odd bytes - packuswb xmm0, xmm3 - packuswb xmm1, xmm4 - packuswb xmm2, xmm5 - movhlps xmm3, xmm0 - movhlps xmm4, xmm1 - movhlps xmm5, xmm2 - punpcklbw xmm0, xmm3 // Red bytes, back in order - punpcklbw xmm1, xmm4 // Green "" - punpcklbw xmm2, xmm5 // Blue "" - movaps xmm3, xmm0 - movaps xmm4, xmm1 - movaps xmm5, xmm2 - - // Create RGBA (we could generate A here, but we don't) quads - punpcklbw xmm0, xmm1 - punpcklbw xmm2, xmm7 - movaps xmm1, xmm0 - punpcklwd xmm0, xmm2 - punpckhwd xmm1, xmm2 - - punpckhbw xmm3, xmm4 - punpckhbw xmm5, xmm7 - movaps xmm4, xmm3 - punpcklwd xmm3, xmm5 - punpckhwd xmm4, xmm5 - - // at last - movaps xmmword ptr [decoder.rgb32+edi*4+0], xmm0 - movaps xmmword ptr [decoder.rgb32+edi*4+16], xmm1 - movaps xmmword ptr [decoder.rgb32+edi*4+32], xmm3 - movaps xmmword ptr [decoder.rgb32+edi*4+48], xmm4 - - add edi, 16 - - neg eax - jl onerow // run twice - - add esi, 8 - cmp esi, 64 - jne tworows + _mm_store_si128(reinterpret_cast<__m128i*>(&decoder.rgb32.c[n * 2 + m][0]), rgba_ll); + _mm_store_si128(reinterpret_cast<__m128i*>(&decoder.rgb32.c[n * 2 + m][4]), rgba_lh); + _mm_store_si128(reinterpret_cast<__m128i*>(&decoder.rgb32.c[n * 2 + m][8]), rgba_hl); + _mm_store_si128(reinterpret_cast<__m128i*>(&decoder.rgb32.c[n * 2 + m][12]), rgba_hh); + } } - -#elif defined(__GNUC__) - - // offset to the middle of the sse2 table, so that we can use 1-byte address displacement - // to access all fields: - static const u8* sse2_tableoffset = ((u8*)&sse2_tables) + 64; - static const u8* mb8 = (u8*)&decoder.mb8; - static u8* rgb32 = (u8*)&decoder.rgb32; - - __asm__ __volatile__ ( - ".intel_syntax noprefix\n" - "xor esi, esi\n" - "xor edi, edi\n" - - ".align 16\n" -"tworows_%=:\n" - "movq xmm3, qword ptr [%[mb8]+256+esi]\n" - "movq xmm1, qword ptr [%[mb8]+320+esi]\n" - "pxor xmm2, xmm2\n" - "pxor xmm0, xmm0\n" - // could skip the movq but punpck requires 128-bit alignment - // for some reason, so two versions would be needed, - // bloating the function (further) - "punpcklbw xmm2, xmm3\n" - "punpcklbw xmm0, xmm1\n" - // unfortunately I don't think this will matter despite being - // technically potentially a little faster, but this is - // equivalent to an add or sub - "pxor xmm2, xmmword ptr [%[sse2_tables]+%c[C_BIAS]]\n" // xmm2 <-- 8 x (Cb - 128) << 8 - "pxor xmm0, xmmword ptr [%[sse2_tables]+%c[C_BIAS]]\n" // xmm0 <-- 8 x (Cr - 128) << 8 - - "movaps xmm1, xmm0\n" - "movaps xmm3, xmm2\n" - "pmulhw xmm1, xmmword ptr [%[sse2_tables]+%c[GCr_COEFF]]\n" - "pmulhw xmm3, xmmword ptr [%[sse2_tables]+%c[GCb_COEFF]]\n" - "pmulhw xmm0, xmmword ptr [%[sse2_tables]+%c[RCr_COEFF]]\n" - "pmulhw xmm2, xmmword ptr [%[sse2_tables]+%c[BCb_COEFF]]\n" - "paddsw xmm1, xmm3\n" - // store for the next line; looking at the code above - // compared to the code below, I have to wonder whether - // this was worth the hassle - "movaps xmmword ptr [%[yuv2rgb_temp]], xmm0\n" - "movaps xmmword ptr [%[yuv2rgb_temp]+16], xmm1\n" - "movaps xmmword ptr [%[yuv2rgb_temp]+32], xmm2\n" - "jmp ihategcctoo_%=\n" - - ".align 16\n" -"onerow_%=:\n" - "movaps xmm0, xmmword ptr [%[yuv2rgb_temp]]\n" - "movaps xmm1, xmmword ptr [%[yuv2rgb_temp]+16]\n" - "movaps xmm2, xmmword ptr [%[yuv2rgb_temp]+32]\n" - -"ihategcctoo_%=:\n" - "movaps xmm3, xmm0\n" - "movaps xmm4, xmm1\n" - "movaps xmm5, xmm2\n" - - "movaps xmm6, xmmword ptr [%[mb8]+edi]\n" - "psubusb xmm6, xmmword ptr [%[sse2_tables]+%c[Y_BIAS]]\n" - "movaps xmm7, xmm6\n" - "psllw xmm6, 8\n" // xmm6 <- Y << 8 for pixels 0,2,4,6,8,10,12,14 - "pand xmm7, xmmword ptr [%[sse2_tables]+%c[Y_MASK]]\n" // xmm7 <- Y << 8 for pixels 1,3,5,7,9,11,13,15 - - "pmulhuw xmm6, xmmword ptr [%[sse2_tables]+%c[Y_COEFF]]\n" - "pmulhuw xmm7, xmmword ptr [%[sse2_tables]+%c[Y_COEFF]]\n" - - "paddsw xmm0, xmm6\n" - "paddsw xmm3, xmm7\n" - "paddsw xmm1, xmm6\n" - "paddsw xmm4, xmm7\n" - "paddsw xmm2, xmm6\n" - "paddsw xmm5, xmm7\n" - - // 0x80; a constant is probably so much better - "pcmpeqb xmm7, xmm7\n" - "psllw xmm7, 15\n" - "psrlw xmm7, 8\n" - "packuswb xmm7, xmm7\n" - - // round - "movaps xmm6, xmmword ptr [%[sse2_tables]+%c[ROUND_1BIT]]\n" - "paddw xmm0, xmm6\n" - "paddw xmm1, xmm6\n" - "paddw xmm2, xmm6\n" - "paddw xmm3, xmm6\n" - "paddw xmm4, xmm6\n" - "paddw xmm5, xmm6\n" - "psraw xmm0, 1\n" - "psraw xmm1, 1\n" - "psraw xmm2, 1\n" - "psraw xmm3, 1\n" - "psraw xmm4, 1\n" - "psraw xmm5, 1\n" - - // combine even and odd bytes - "packuswb xmm0, xmm3\n" - "packuswb xmm1, xmm4\n" - "packuswb xmm2, xmm5\n" - "movhlps xmm3, xmm0\n" - "movhlps xmm4, xmm1\n" - "movhlps xmm5, xmm2\n" - "punpcklbw xmm0, xmm3\n" // Red bytes, back in order - "punpcklbw xmm1, xmm4\n" // Green "" - "punpcklbw xmm2, xmm5\n" // Blue "" - "movaps xmm3, xmm0\n" - "movaps xmm4, xmm1\n" - "movaps xmm5, xmm2\n" - - // Create RGBA (we could generate A here, but we don't) quads - "punpcklbw xmm0, xmm1\n" - "punpcklbw xmm2, xmm7\n" - "movaps xmm1, xmm0\n" - "punpcklwd xmm0, xmm2\n" - "punpckhwd xmm1, xmm2\n" - - "punpckhbw xmm3, xmm4\n" - "punpckhbw xmm5, xmm7\n" - "movaps xmm4, xmm3\n" - "punpcklwd xmm3, xmm5\n" - "punpckhwd xmm4, xmm5\n" - - // at last - "movaps xmmword ptr [%[rgb32]+edi*4+0], xmm0\n" - "movaps xmmword ptr [%[rgb32]+edi*4+16], xmm1\n" - "movaps xmmword ptr [%[rgb32]+edi*4+32], xmm3\n" - "movaps xmmword ptr [%[rgb32]+edi*4+48], xmm4\n" - - "add edi, 16\n" - - // run twice the onerow <=> edi = 16 or 48 or 80 etc... <=> check bit 5 - "test edi, 16\n" - "jnz onerow_%=\n" - - "add esi, 8\n" - "cmp esi, 64\n" - "jne tworows_%=\n" - ".att_syntax\n" - : - :[C_BIAS]"i"(C_BIAS), [Y_BIAS]"i"(Y_BIAS), [Y_MASK]"i"(Y_MASK), - [ROUND_1BIT]"i"(ROUND_1BIT), [Y_COEFF]"i"(Y_COEFF), [GCr_COEFF]"i"(GCr_COEFF), - [GCb_COEFF]"i"(GCb_COEFF), [RCr_COEFF]"i"(RCr_COEFF), [BCb_COEFF]"i"(BCb_COEFF), - // Use ecx and edx as base pointers, to allow for Mod/RM form on memOps. - // This saves 2-3 bytes per instruction where these are used. :) - [yuv2rgb_temp]"c"(yuv2rgb_temp), [sse2_tables]"d"(sse2_tableoffset), - [mb8]"r"(mb8), [rgb32]"r"(rgb32) - : "esi", "edi", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "memory" - ); -#else -# error Unsupported compiler -#endif } -#endif -#endif diff --git a/pcsx2/IPU/yuv2rgb.h b/pcsx2/IPU/yuv2rgb.h index 73ca28df88..98382014dd 100644 --- a/pcsx2/IPU/yuv2rgb.h +++ b/pcsx2/IPU/yuv2rgb.h @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2010 PCSX2 Dev Team + * Copyright (C) 2002-2016 PCSX2 Dev Team * * PCSX2 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 Found- @@ -16,9 +16,6 @@ #pragma once extern void yuv2rgb_reference(); -#ifdef _M_X86_32 + #define yuv2rgb yuv2rgb_sse2 extern void yuv2rgb_sse2(); -#else -#define yuv2rgb yuv2rgb_reference -#endif From bde5960581c17bbd7131fde933033c7f52a94adb Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Thu, 19 May 2016 21:47:06 +0100 Subject: [PATCH 13/14] iop: Use count_leading_sign_bits for err, counting sign bits Replaces the inline assembly and generic version with the unified implementation. --- pcsx2/IopGte.cpp | 58 +++--------------------------------------------- 1 file changed, 3 insertions(+), 55 deletions(-) diff --git a/pcsx2/IopGte.cpp b/pcsx2/IopGte.cpp index 53270f8137..3e7b4fa4d0 100644 --- a/pcsx2/IopGte.cpp +++ b/pcsx2/IopGte.cpp @@ -20,6 +20,7 @@ #include "IopGte.h" //#include "R3000A.h" #include "IopCommon.h" +#include "Utilities/MathUtils.h" #ifdef GTE_DUMP #define G_OP(name,delay) fprintf(gteLog, "* : %08X : %02d : %s\n", psxRegs.code, delay, name); #define G_SD(reg) fprintf(gteLog, "+D%02d : %08X\n", reg, psxRegs.CP2D.r[reg]); @@ -175,8 +176,6 @@ __inline unsigned long MFC2(int reg) { } __inline void MTC2(unsigned long value, int reg) { - int a; - switch (reg) { case 8: case 9: case 10: case 11: psxRegs.CP2D.r[reg] = (short)value; @@ -208,58 +207,7 @@ __inline void MTC2(unsigned long value, int reg) { case 30: psxRegs.CP2D.r[30] = value; - - a = psxRegs.CP2D.r[30]; -#if defined(_MSC_VER_) - if (a > 0) { - __asm { - mov eax, a; - bsr eax, eax; - mov a, eax; - } - psxRegs.CP2D.r[31] = 31 - a; - } - else if (a < 0) { - __asm { - mov eax, a; - xor eax, 0xffffffff; - bsr eax, eax; - mov a, eax; - } - psxRegs.CP2D.r[31] = 31 - a; - } - else { - psxRegs.CP2D.r[31] = 32; - } -#elif defined(__linux__) || defined(__MINGW32__) - if (a > 0) { - __asm__("bsrl %1, %0\n" : "=r"(a) : "r"(a)); - psxRegs.CP2D.r[31] = 31 - a; - } - else if (a < 0) { - a ^= 0xffffffff; - __asm__("bsrl %1, %0\n" : "=r"(a) : "r"(a)); - psxRegs.CP2D.r[31] = 31 - a; - } - else { - psxRegs.CP2D.r[31] = 32; - } -#else - if (a > 0) { - int i; - for (i = 31; (a & (1 << i)) == 0 && i >= 0; i--); - psxRegs.CP2D.r[31] = 31 - i; - } - else if (a < 0) { - int i; - a ^= 0xffffffff; - for (i = 31; (a & (1 << i)) == 0 && i >= 0; i--); - psxRegs.CP2D.r[31] = 31 - i; - } - else { - psxRegs.CP2D.r[31] = 32; - } -#endif + psxRegs.CP2D.r[31] = count_leading_sign_bits(value); break; default: @@ -3158,4 +3106,4 @@ void gteCDP() { //test opcode G_GC(31); } #endif -} \ No newline at end of file +} From d2e5c32c8344971e959e4d6664bfdf30a6a39e0d Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Fri, 20 May 2016 22:20:57 +0100 Subject: [PATCH 14/14] cmake: Disable SuperVU for non-Linux OS Doesn't work on FreeBSD, would be annoying to port. --- cmake/BuildParameters.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index ed93b1f782..ce62f853c7 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -201,6 +201,11 @@ if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "i386") endif() endif() + # Don't bother porting SuperVU + if (NOT Linux) + set(DISABLE_SVU TRUE) + endif() + add_definitions(-D_ARCH_32=1 -D_M_X86=1 -D_M_X86_32=1) set(_ARCH_32 1) set(_M_X86 1)