diff --git a/CMakeLists.txt b/CMakeLists.txt index ea531f030c..5560b195e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -331,7 +331,7 @@ if(NOT ANDROID) message("bluez NOT found, disabling bluetooth support") endif(BLUEZ_FOUND) - check_lib(PULSEAUDIO libpulse QUIET) + check_lib(PULSEAUDIO libpulse-simple QUIET) if(PULSEAUDIO_FOUND) add_definitions(-DHAVE_PULSEAUDIO=1) message("PulseAudio found, enabling PulseAudio sound backend") diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp index af52498def..08a5db8217 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -35,6 +36,7 @@ #include //#define AUTHENTICATE_WIIMOTES +#define SHARE_WRITE_WIIMOTES typedef struct _HIDD_ATTRIBUTES { @@ -83,6 +85,11 @@ static int initialized = 0; std::unordered_map g_connect_times; +#ifdef SHARE_WRITE_WIIMOTES +std::unordered_set> g_connected_wiimotes; +std::mutex g_connected_wiimotes_lock; +#endif + inline void init_lib() { if (!initialized) @@ -258,11 +265,22 @@ bool Wiimote::Connect() if (IsConnected()) return false; +#ifdef SHARE_WRITE_WIIMOTES + std::lock_guard lk(g_connected_wiimotes_lock); + if (g_connected_wiimotes.count(devicepath) != 0) + return false; + + auto const open_flags = FILE_SHARE_READ | FILE_SHARE_WRITE; +#else + // Having no FILE_SHARE_WRITE disallows us from connecting to the same wiimote twice. + // (And disallows using wiimotes in use by other programs) + // This is what "WiiYourself" does. + // Apparently this doesn't work for everyone. It might be their fault. + auto const open_flags = FILE_SHARE_READ; +#endif + dev_handle = CreateFile(devicepath.c_str(), - GENERIC_READ | GENERIC_WRITE, - // Having no FILE_SHARE_WRITE disallows us from connecting to the same wiimote twice. - // This is what "WiiYourself" does. - FILE_SHARE_READ, + GENERIC_READ | GENERIC_WRITE, open_flags, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (dev_handle == INVALID_HANDLE_VALUE) @@ -297,6 +315,10 @@ bool Wiimote::Connect() ERROR_LOG(WIIMOTE, "Failed to set wiimote thread priority"); } */ +#ifdef SHARE_WRITE_WIIMOTES + g_connected_wiimotes.insert(devicepath); +#endif + return true; } @@ -310,6 +332,11 @@ void Wiimote::Disconnect() CloseHandle(hid_overlap_read.hEvent); CloseHandle(hid_overlap_write.hEvent); + +#ifdef SHARE_WRITE_WIIMOTES + std::lock_guard lk(g_connected_wiimotes_lock); + g_connected_wiimotes.erase(devicepath); +#endif } bool Wiimote::IsConnected() const diff --git a/Source/Core/VideoCommon/Src/GenericTextureDecoder.cpp b/Source/Core/VideoCommon/Src/GenericTextureDecoder.cpp index ad7cfeebf9..7546511515 100644 --- a/Source/Core/VideoCommon/Src/GenericTextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/GenericTextureDecoder.cpp @@ -1442,6 +1442,40 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth } } +void TexDecoder_DecodeTexelRGBA8FromTmem(u8 *dst, const u8 *src_ar, const u8* src_gb, int s, int t, int imageWidth) +{ + u16 sBlk = s >> 2; + u16 tBlk = t >> 2; + u16 widthBlks = (imageWidth >> 2) + 1; // TODO: Looks wrong. Shouldn't this be ((imageWidth-1)>>2)+1 ? + u32 base_ar = (tBlk * widthBlks + sBlk) << 4; + u32 base_gb = (tBlk * widthBlks + sBlk) << 4; + u16 blkS = s & 3; + u16 blkT = t & 3; + u32 blk_off = (blkT << 2) + blkS; + + u32 offset_ar = (base_ar + blk_off) << 1; + u32 offset_gb = (base_gb + blk_off) << 1; + const u8* val_addr_ar = src_ar + offset_ar; + const u8* val_addr_gb = src_gb + offset_gb; + + dst[3] = val_addr_ar[0]; // A + dst[0] = val_addr_ar[1]; // R + dst[1] = val_addr_gb[0]; // G + dst[2] = val_addr_gb[1]; // B +} + +PC_TexFormat TexDecoder_DecodeRGBA8FromTmem(u8* dst, const u8 *src_ar, const u8 *src_gb, int width, int height) +{ + // TODO for someone who cares: Make this less slow! + for (int y = 0; y < height; ++y) + for (int x = 0; x < width; ++x) + { + TexDecoder_DecodeTexelRGBA8FromTmem(dst, src_ar, src_gb, x, y, width-1); + dst += 4; + } + + return PC_TEX_FMT_RGBA32; +} const char* texfmt[] = { // pixel diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h index 09d38bb731..be46f047ca 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h @@ -69,7 +69,7 @@ bool OpenGL_ReportFBOError(const char *function, const char *file, int line); #define GL_REPORT_PROGRAM_ERROR() (void)0 #endif -#if defined __APPLE__ || defined __linux__ || defined _WIN32 +#if (defined __APPLE__ || defined __linux__ || defined _WIN32) && !(defined _M_ARM) #include #include #define HAVE_CG 1 diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.cpp index 95311eb98d..db47217655 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.cpp @@ -9,7 +9,7 @@ PerfQuery::PerfQuery() : m_query_read_pos() , m_query_count() { - for (int i = 0; i != ARRAYSIZE(m_query_buffer); ++i) + for (u32 i = 0; i != ARRAYSIZE(m_query_buffer); ++i) glGenQueries(1, &m_query_buffer[i].query_id); ResetQuery(); @@ -17,7 +17,7 @@ PerfQuery::PerfQuery() PerfQuery::~PerfQuery() { - for (int i = 0; i != ARRAYSIZE(m_query_buffer); ++i) + for (u32 i = 0; i != ARRAYSIZE(m_query_buffer); ++i) glDeleteQueries(1, &m_query_buffer[i].query_id); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.h b/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.h index 34c64e43a1..b96fe7a4a0 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/PerfQuery.h @@ -26,7 +26,7 @@ private: }; // when testing in SMS: 64 was too small, 128 was ok - static const int PERF_QUERY_BUFFER_SIZE = 512; + static const u32 PERF_QUERY_BUFFER_SIZE = 512; void WeakFlush(); // Only use when non-empty @@ -34,10 +34,10 @@ private: // This contains gl query objects with unretrieved results. ActiveQuery m_query_buffer[PERF_QUERY_BUFFER_SIZE]; - int m_query_read_pos; + u32 m_query_read_pos; // TODO: sloppy - volatile int m_query_count; + volatile u32 m_query_count; volatile u32 m_results[PQG_NUM_MEMBERS]; };