Merge pull request #1335 from turtleli/freebsd

Support FreeBSD
This commit is contained in:
Jonathan Li 2016-05-25 18:55:51 +01:00
commit db81925c4b
76 changed files with 317 additions and 582 deletions

View File

@ -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)
@ -293,7 +298,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")

View File

@ -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

View File

@ -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()

View File

@ -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)

View File

@ -30,7 +30,7 @@
#define EXPORT_C_(type) extern "C" type CALLBACK
#elif defined(__linux__)
#elif defined(__unix__)
#include <gtk/gtk.h>
#include <cstring>
@ -193,7 +193,7 @@ struct PluginConf
}
};
#if defined(__linux__)
#if defined(__unix__)
static void SysMessage(const char *fmt, ...)
{

View File

@ -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)

View File

@ -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 );

View File

@ -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);

View File

@ -16,16 +16,20 @@
#include "../PrecompiledHeader.h"
#include "PersistentThread.h"
#include <sys/prctl.h>
#include <unistd.h>
#if defined(__linux__)
#include <sys/prctl.h>
#elif defined(__unix__)
#include <pthread_np.h>
#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

View File

@ -20,7 +20,7 @@
# undef Yield
#elif defined(__linux__)
# include <libaio.h>
#elif defined(__APPLE__)
#elif defined(__POSIX__)
# include <aio.h>
#endif
#include <memory>
@ -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;

View File

@ -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}

View File

@ -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);
}

View File

@ -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,356 +58,94 @@ void yuv2rgb_reference(void)
}
}
// TODO OSX optimize me
#ifdef __APPLE__
void yuv2rgb_sse2() {
yuv2rgb_reference();
}
#elif defined(_M_X86_32)
// 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

View File

@ -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

View File

@ -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
}
}

View File

@ -96,13 +96,7 @@ typedef FnType_Void* Fnptr_Void;
#else // must be GCC or Clang
# include <sys/types.h>
# include <sys/timeb.h>
// Definitions added Feb 16, 2006 by efp
# ifndef __declspec
# define __declspec(x)
# endif
#include <sys/types.h>
#endif

View File

@ -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

View File

@ -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) ) {

View File

@ -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

View File

@ -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

View File

@ -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},

View File

@ -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];
};
alignas(32) static const uint16 m_dither[4][16];
};

View File

@ -23,7 +23,7 @@
#include "GPU.h"
__aligned(class, 32) GPUDrawingEnvironment
class alignas(32) GPUDrawingEnvironment
{
public:
GPURegSTATUS STATUS;

View File

@ -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;

View File

@ -26,7 +26,7 @@
#pragma pack(push, 1)
__aligned(struct, 32) GPUVertex
struct alignas(32) GPUVertex
{
union
{

View File

@ -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,18 +1497,15 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow
#endif
#ifdef __linux__
#if defined(__unix__)
#include <sys/time.h>
#include <sys/timeb.h> // 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

View File

@ -1101,7 +1101,7 @@ REG128_SET(GIFPackedReg)
GIFPackedNOP NOP;
REG_SET_END
__aligned(struct, 32) GIFPath
struct alignas(32) GIFPath
{
GIFTag tag;
uint32 nloop;

View File

@ -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);

View File

@ -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<IGSSource>(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();
}

View File

@ -42,7 +42,7 @@ class GSCapture
CComPtr<IGraphBuilder> m_graph;
CComPtr<IBaseFilter> m_src;
#elif __linux__
#elif defined(__unix__)
vector<GSPng::Worker*> m_workers;
int m_compression_level;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -186,7 +186,7 @@ public:
}
};
__aligned(class, 16) ShaderFactorBlend : public ShaderBase
class alignas(16) ShaderFactorBlend : public ShaderBase
{
GSVector4i m_f;

View File

@ -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},

View File

@ -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];

View File

@ -24,7 +24,7 @@
#include "GS.h"
#include "GSLocalMemory.h"
__aligned(class, 32) GSDrawingContext
class alignas(32) GSDrawingContext
{
public:
GIFRegXYOFFSET XYOFFSET;

View File

@ -23,7 +23,7 @@
#include "GS.h"
__aligned(class, 32) GSDrawingEnvironment
class alignas(32) GSDrawingEnvironment
{
public:
GIFRegPRIM PRIM;

View File

@ -770,7 +770,7 @@ void GSLocalMemory::WriteImageLeftRight(int l, int r, int y, int h, const uint8*
template<int psm, int bsx, int bsy, int trbpp>
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();

View File

@ -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;

View File

@ -21,7 +21,7 @@
#include "stdafx.h"
#include "GSLzma.h"
#ifdef __linux__
#if defined(__unix__)
GSDumpFile::GSDumpFile(char* filename) {
m_fp = fopen(filename, "rb");

View File

@ -18,7 +18,7 @@
*
*/
#ifdef __linux__
#if defined(__unix__)
#ifdef LZMA_SUPPORTED
#include <lzma.h>

View File

@ -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;

View File

@ -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;

View File

@ -21,7 +21,7 @@
#include "stdafx.h"
#include "GSRenderer.h"
#ifdef __linux__
#if defined(__unix__)
#include <X11/keysym.h>
#endif
@ -585,7 +585,7 @@ void GSRenderer::KeyEvent(GSKeyEventData* e)
}
}
#elif defined(__linux__)
#elif defined(__unix__)
if(e->type == KEYPRESS)
{
int step = m_shift_key ? -1 : 1;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -21,7 +21,7 @@
#include "stdafx.h"
#include "GSSetting.h"
#ifndef __linux__
#ifdef _WIN32
#include "resource.h"
#endif

View File

@ -40,7 +40,7 @@ struct GSSetting
const char* dialog_message(int ID, bool* updateText = NULL);
#ifdef __linux__
#ifndef _WIN32
enum {
IDC_FILTER,
IDC_SKIPDRAWHACK,

View File

@ -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");

View File

@ -65,6 +65,6 @@ public:
#endif
};
#ifdef __linux__
#if defined(__unix__)
void GSmkdir(const char* dir);
#endif

View File

@ -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

View File

@ -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;

View File

@ -26,7 +26,7 @@
#pragma pack(push, 1)
__aligned(struct, 32) GSVertexHW9
struct alignas(32) GSVertexHW9
{
GSVector4 t;
GSVector4 p;

View File

@ -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;

View File

@ -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;};

View File

@ -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)

View File

@ -21,7 +21,7 @@
#include "GSWnd.h"
#if defined(__linux__) && defined(EGL_SUPPORTED)
#if defined(__unix__) && defined(EGL_SUPPORTED)
#include <X11/Xlib.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>

View File

@ -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)
{

View File

@ -21,7 +21,7 @@
#include "GSWnd.h"
#if defined(__linux__)
#if defined(__unix__)
#include <X11/Xlib.h>
#include <GL/glx.h>

View File

@ -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;

View File

@ -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();

View File

@ -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

View File

@ -197,18 +197,20 @@ 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))
#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)
@ -227,7 +229,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

View File

@ -21,11 +21,7 @@
#pragma once
#include <string.h> // for memset
#ifdef __linux__
#define MAX_KEYS 24
#else
#define MAX_KEYS 20
#endif
enum KeyType
{

View File

@ -28,7 +28,7 @@
#include <gdk/gdkkeysyms.h>
#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;

View File

@ -24,7 +24,7 @@
#include "onepad.h"
#ifdef __linux__
#if defined(__unix__)
#include "Linux/linux.h"

View File

@ -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

View File

@ -49,7 +49,7 @@ using namespace std;
#define PADdefs
#include "PS2Edefs.h"
#ifdef __linux__
#if defined(__unix__)
#include "GamePad.h"
#endif
#include "bitwise.h"

View File

@ -19,8 +19,10 @@
#include "Dialogs.h"
#include "Config.h"
#ifdef __linux__
#include <SDL.h>
#include <SDL_audio.h>
#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

View File

@ -18,7 +18,7 @@
#ifndef CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED
#ifdef __linux__
#if defined(__unix__)
#include <gtk/gtk.h>
#endif

View File

@ -154,7 +154,7 @@ void WriteSettings()
}
#ifdef __linux__
#ifdef __unix__
void DisplayDialog()
{
GtkWidget *dialog;

View File

@ -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;

View File

@ -20,7 +20,7 @@
#include "Dialogs.h"
#include <cstring>
#ifdef __linux__
#if defined(__unix__)
#include <gtk/gtk.h>
void SysMessage(const char *fmt, ...)