diff --git a/Externals/CLRun/SConscript b/Externals/CLRun/SConscript new file mode 100644 index 0000000000..03605da868 --- /dev/null +++ b/Externals/CLRun/SConscript @@ -0,0 +1,5 @@ +# -*- python -*- + +Import('env') + +env['CPPPATH'] += ['#Externals/CLRun/include'] diff --git a/Externals/CLRun/include/OpenCL/cl.h b/Externals/CLRun/include/OpenCL/cl.h new file mode 100644 index 0000000000..9e3d489a1d --- /dev/null +++ b/Externals/CLRun/include/OpenCL/cl.h @@ -0,0 +1 @@ +#include diff --git a/Externals/CLRun/include/OpenCL/cl_platform.h b/Externals/CLRun/include/OpenCL/cl_platform.h new file mode 100644 index 0000000000..00046849b2 --- /dev/null +++ b/Externals/CLRun/include/OpenCL/cl_platform.h @@ -0,0 +1 @@ +#include diff --git a/SConstruct b/SConstruct index c89886b959..4469c713a2 100644 --- a/SConstruct +++ b/SConstruct @@ -269,10 +269,6 @@ else: print "Must have CgGL to build" Exit(1) - env['HAVE_OPENCL'] = int(conf.CheckPKG('OpenCL') and \ - conf.CheckCXXHeader("CL/cl.h")) - conf.Define('HAVE_OPENCL', env['HAVE_OPENCL']) - # PGO - Profile Guided Optimization if env['pgo'] == 'generate': env['CCFLAGS'] += ['-fprofile-generate'] @@ -337,7 +333,7 @@ env['LIBPATH'].insert(0, env['local_libs']) dirs = [ 'Externals/Bochs_disasm', - #'Externals/CLRun', + 'Externals/CLRun', 'Externals/Lua', 'Externals/GLew', 'Externals/LZO', @@ -364,7 +360,6 @@ dirs = [ 'Source/Plugins/Plugin_DSP_LLE/Src', #'Source/Plugins/Plugin_VideoDX11/Src', #'Source/Plugins/Plugin_VideoDX9/Src', - #'Source/Plugins/Plugin_VideoMerge/Src', 'Source/Plugins/Plugin_VideoOGL/Src', 'Source/Plugins/Plugin_VideoSoftware/Src', 'Source/UnitTests', diff --git a/Source/Core/Common/Src/OpenCL.cpp b/Source/Core/Common/Src/OpenCL.cpp index c3d3f7e796..d1658ae486 100644 --- a/Source/Core/Common/Src/OpenCL.cpp +++ b/Source/Core/Common/Src/OpenCL.cpp @@ -21,18 +21,12 @@ #include "Common.h" #include "Timer.h" -#ifndef __APPLE__ -#include "clrun.h" -#endif - namespace OpenCL { -#if defined(HAVE_OPENCL) && HAVE_OPENCL cl_device_id device_id = NULL; cl_context g_context = NULL; cl_command_queue g_cmdq = NULL; -#endif bool g_bInitialized = false; @@ -41,7 +35,6 @@ bool Initialize() if(g_bInitialized) return true; -#if defined(HAVE_OPENCL) && HAVE_OPENCL if(g_context) return false; int err; // error code returned from api calls @@ -127,12 +120,8 @@ bool Initialize() g_bInitialized = true; return true; -#else - return false; -#endif } -#if defined(HAVE_OPENCL) && HAVE_OPENCL cl_context GetContext() { return g_context; @@ -204,11 +193,9 @@ cl_kernel CompileKernel(cl_program program, const char *Function) (float)(Common::Timer::GetTimeMs() - compileStart) / 1000.0); return kernel; } -#endif void Destroy() { -#if defined(HAVE_OPENCL) && HAVE_OPENCL if (g_cmdq) { clReleaseCommandQueue(g_cmdq); @@ -220,13 +207,10 @@ void Destroy() g_context = NULL; } g_bInitialized = false; -#endif } void HandleCLError(cl_int error, const char* str) { -#if defined(HAVE_OPENCL) && HAVE_OPENCL - const char* name; switch(error) { @@ -284,6 +268,5 @@ void HandleCLError(cl_int error, const char* str) if(!str) str = ""; ERROR_LOG(COMMON, "OpenCL error: %s %s (%d)", str, name, error); -#endif } } diff --git a/Source/Core/Common/Src/OpenCL.h b/Source/Core/Common/Src/OpenCL.h index 411a1697be..f299e9ff1e 100644 --- a/Source/Core/Common/Src/OpenCL.h +++ b/Source/Core/Common/Src/OpenCL.h @@ -20,46 +20,21 @@ #include "Common.h" -// The CLRun library provides the headers and all the imports -#ifndef __APPLE__ -#define HAVE_OPENCL 1 -#endif - -// We detect the presence of the 10.6 SDK, which has the OpenCL headers, -// by looking for the new blocks feature in the 10.6 version of gcc. -// This allows us to have the 10.5 SDK first in the search path. -#if defined __APPLE__ && defined __BLOCKS__ -#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER WEAK_IMPORT_ATTRIBUTE -#define HAVE_OPENCL 1 -#endif - -#if defined(HAVE_OPENCL) && HAVE_OPENCL - #ifdef __APPLE__ +#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER WEAK_IMPORT_ATTRIBUTE #include #else +// The CLRun library provides the headers and all the imports. #include -#endif - -#else - -typedef void *cl_context; -typedef void *cl_command_queue; -typedef void *cl_program; -typedef void *cl_kernel; -typedef void *cl_mem; -typedef void *cl_int; - +#include #endif namespace OpenCL { -#if defined(HAVE_OPENCL) && HAVE_OPENCL extern cl_device_id device_id; extern cl_context g_context; extern cl_command_queue g_cmdq; -#endif bool Initialize(); diff --git a/Source/Core/Common/Src/SConscript b/Source/Core/Common/Src/SConscript index 8c5ca2d832..34dcec56bb 100644 --- a/Source/Core/Common/Src/SConscript +++ b/Source/Core/Common/Src/SConscript @@ -5,7 +5,6 @@ import os import sys from SconsTests import utils -Execute(Delete(File('#Source/Core/Common/Src/svnrev.h').abspath)) utils.GenerateRevFile(env['flavor'], Dir('#Source/Core/Common/Src').abspath + os.sep + 'svnrev_template.h', 'svnrev.h') diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index 4372c2f701..1838ed9c14 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -75,9 +75,9 @@ elif sys.platform == 'darwin' and env['HAVE_WX']: for mo in mo_files: index_lo = mo.find("Languages/") + len("Languages/") index_hi = mo.find("/dolphin-emu.mo") - lang_name = mo[index_lo:index_hi] - install_loc = env['data_dir'] + "/" + lang_name + ".lproj/dolphin-emu.mo" - env.InstallAs(install_loc, mo) + lang = mo[index_lo:index_hi] + lproj = env['data_dir'] + '/' + lang + ".lproj/dolphin-emu.mo" + env.InstallAs(lproj, mo) from plistlib import writePlist def createPlist(target, source, env): diff --git a/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp b/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp index fbb81fb40d..ff4d6d1d97 100644 --- a/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp +++ b/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp @@ -43,10 +43,8 @@ #include "DataReader.h" #include "OpenCL.h" -#if defined(HAVE_OPENCL) && HAVE_OPENCL #include "OpenCL/OCLTextureDecoder.h" #include "VideoConfig.h" -#endif u8* g_pVideoData = 0; DataReadU32xNfunc DataReadU32xFuncs[16] = { @@ -403,25 +401,21 @@ void OpcodeDecoder_Init() { g_pVideoData = FAKE_GetFifoStartPtr(); -#if defined(HAVE_OPENCL) && HAVE_OPENCL if (g_Config.bEnableOpenCL) { OpenCL::Initialize(); TexDecoder_OpenCL_Initialize(); } -#endif } void OpcodeDecoder_Shutdown() { -#if defined(HAVE_OPENCL) && HAVE_OPENCL if (g_Config.bEnableOpenCL) { TexDecoder_OpenCL_Shutdown(); OpenCL::Destroy(); } -#endif } void OpcodeDecoder_Run(bool skipped_frame) diff --git a/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp b/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp index 0340952733..cacfcdf47d 100644 --- a/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp @@ -86,7 +86,6 @@ cl_mem g_clsrc, g_cldst; // texture buffer memory objects void TexDecoder_OpenCL_Initialize() { -#if defined(HAVE_OPENCL) && HAVE_OPENCL if(!g_Inited) { if(!OpenCL::Initialize()) @@ -240,12 +239,10 @@ void TexDecoder_OpenCL_Initialize() g_Inited = true; } -#endif } void TexDecoder_OpenCL_Shutdown() { -#if defined(HAVE_OPENCL) && HAVE_OPENCL && !defined(DEBUG_OPENCL) if (g_program) clReleaseProgram(g_program); @@ -264,12 +261,10 @@ void TexDecoder_OpenCL_Shutdown() clReleaseMemObject(g_cldst); g_Inited = false; -#endif } PC_TexFormat TexDecoder_Decode_OpenCL(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt, bool rgba) { -#if defined(HAVE_OPENCL) && HAVE_OPENCL cl_int err; sDecoderParameter& decoder = rgba ? g_DecodeParametersRGBA[texformat] : g_DecodeParametersNative[texformat]; if(!g_Inited || !decoder.name || !decoder.kernel || decoder.format == PC_TEX_FMT_NONE) @@ -310,7 +305,4 @@ PC_TexFormat TexDecoder_Decode_OpenCL(u8 *dst, const u8 *src, int width, int hei #endif return decoder.format; -#else - return PC_TEX_FMT_NONE; -#endif } diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index 7e6c168cc7..150f2b7ae2 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -21,10 +21,8 @@ #include "CPUDetect.h" #include "TextureDecoder.h" #include "OpenCL.h" -#if defined(HAVE_OPENCL) && HAVE_OPENCL #include "OpenCL/OCLTextureDecoder.h" #include "VideoConfig.h" -#endif #include "LookUpTables.h" @@ -1733,7 +1731,6 @@ PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width, int he const __m128i dxt = _mm_loadu_si128((__m128i *)(src + sizeof(struct DXTBlock) * 0)); __m128i argb888x4; const __m128i allFF = _mm_set_epi32(0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL); - const __m128i lowMask = _mm_srli_si128( allFF, 8 ); __m128i c1 = _mm_unpackhi_epi16(dxt, dxt); c1 = _mm_slli_si128(c1, 8); const __m128i c0 = _mm_or_si128(c1, _mm_srli_si128(_mm_slli_si128(_mm_unpacklo_epi16(dxt, dxt), 8), 8)); @@ -2039,10 +2036,8 @@ PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, in { PC_TexFormat retval = PC_TEX_FMT_NONE; -#if defined(HAVE_OPENCL) && HAVE_OPENCL if (g_Config.bEnableOpenCL) retval = TexDecoder_Decode_OpenCL(dst, src, width, height, texformat, tlutaddr, tlutfmt, rgbaOnly); -#endif if(retval == PC_TEX_FMT_NONE) retval = rgbaOnly ? TexDecoder_Decode_RGBA((u32*)dst,src,width,height,texformat,tlutaddr,tlutfmt) : TexDecoder_Decode_real(dst,src,width,height,texformat,tlutaddr,tlutfmt); diff --git a/Source/Core/VideoCommon/Src/XFBConvert.cpp b/Source/Core/VideoCommon/Src/XFBConvert.cpp index 72b0286b7d..de78f2a4f3 100644 --- a/Source/Core/VideoCommon/Src/XFBConvert.cpp +++ b/Source/Core/VideoCommon/Src/XFBConvert.cpp @@ -43,8 +43,7 @@ __m128i _b1[256]; __m128i _b2[256]; } // namespace -#if defined(HAVE_OPENCL) && HAVE_OPENCL -bool Inited = false; + bool Inited = false; cl_kernel To_kernel; cl_program To_program; @@ -110,7 +109,7 @@ void InitKernels() To_kernel = OpenCL::CompileKernel(To_program, "ConvertToXFB"); Inited = true; } -#endif + void InitXFBConvTables() { for (int i = 0; i < 256; i++) @@ -138,7 +137,6 @@ void ConvertFromXFB(u32 *dst, const u8* _pXFB, int width, int height) } const unsigned char *src = _pXFB; u32 numBlocks = ((width * height) / 2) / 2; - #if defined(HAVE_OPENCL) && HAVE_OPENCL if(!Inited) InitKernels(); int err; @@ -209,29 +207,6 @@ void ConvertFromXFB(u32 *dst, const u8* _pXFB, int width, int height) } clReleaseMemObject(_dst); clReleaseMemObject(_src); - #else - for (u32 i = 0; i < numBlocks; i++) - { - __m128i y1 = _y[src[0]]; - __m128i u = _u[src[1]]; - __m128i y2 = _y[src[2]]; - __m128i v = _v[src[3]]; - __m128i y1_2 = _y[src[4+0]]; - __m128i u_2 = _u[src[4+1]]; - __m128i y2_2 = _y[src[4+2]]; - __m128i v_2 = _v[src[4+3]]; - - __m128i c1 = _mm_srai_epi32(_mm_add_epi32(y1, _mm_add_epi32(u, v)), 16); - __m128i c2 = _mm_srai_epi32(_mm_add_epi32(y2, _mm_add_epi32(u, v)), 16); - __m128i c3 = _mm_srai_epi32(_mm_add_epi32(y1_2, _mm_add_epi32(u_2, v_2)), 16); - __m128i c4 = _mm_srai_epi32(_mm_add_epi32(y2_2, _mm_add_epi32(u_2, v_2)), 16); - - __m128i four_dest = _mm_packus_epi16(_mm_packs_epi32(c1, c2), _mm_packs_epi32(c3, c4)); - _mm_store_si128((__m128i *)dst, four_dest); - dst += 4; - src += 8; - } - #endif } @@ -243,7 +218,6 @@ void ConvertToXFB(u32 *dst, const u8* _pEFB, int width, int height) if (((size_t)dst & 0xF) != 0) { PanicAlert("ConvertToXFB - unaligned XFB"); } - #if defined(HAVE_OPENCL) && HAVE_OPENCL if(!Inited) InitKernels(); @@ -315,33 +289,4 @@ void ConvertToXFB(u32 *dst, const u8* _pEFB, int width, int height) } clReleaseMemObject(_dst); clReleaseMemObject(_src); - #else - for (u32 i = 0; i < numBlocks; i++) - { - __m128i yuyv0 = _mm_srai_epi32( - _mm_add_epi32( - _mm_add_epi32(_r1[src[0]], _mm_add_epi32(_g1[src[1]], _b1[src[2]])), - _mm_add_epi32(_r2[src[4]], _mm_add_epi32(_g2[src[5]], _b2[src[6]]))), 16); - src += 8; - __m128i yuyv1 = _mm_srai_epi32( - _mm_add_epi32( - _mm_add_epi32(_r1[src[0]], _mm_add_epi32(_g1[src[1]], _b1[src[2]])), - _mm_add_epi32(_r2[src[4]], _mm_add_epi32(_g2[src[5]], _b2[src[6]]))), 16); - src += 8; - __m128i yuyv2 = _mm_srai_epi32( - _mm_add_epi32( - _mm_add_epi32(_r1[src[0]], _mm_add_epi32(_g1[src[1]], _b1[src[2]])), - _mm_add_epi32(_r2[src[4]], _mm_add_epi32(_g2[src[5]], _b2[src[6]]))), 16); - src += 8; - __m128i yuyv3 = _mm_srai_epi32( - _mm_add_epi32( - _mm_add_epi32(_r1[src[0]], _mm_add_epi32(_g1[src[1]], _b1[src[2]])), - _mm_add_epi32(_r2[src[4]], _mm_add_epi32(_g2[src[5]], _b2[src[6]]))), 16); - src += 8; - __m128i four_dest = _mm_packus_epi16(_mm_packs_epi32(yuyv0, yuyv1), _mm_packs_epi32(yuyv2, yuyv3)); - _mm_store_si128((__m128i *)dst, four_dest); - dst += 4; - } - #endif } - diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SConscript b/Source/Plugins/Plugin_VideoOGL/Src/SConscript index fc8a14f255..81b753664f 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/SConscript +++ b/Source/Plugins/Plugin_VideoOGL/Src/SConscript @@ -25,7 +25,5 @@ libs = [ 'videocommon', 'videouicommon', 'GLEW', 'SOIL', 'common' ] if sys.platform == 'darwin' and not env['HAVE_WX']: files += [ 'cocoaGL.m' ] -elif not sys.platform == 'darwin' and env['HAVE_OPENCL']: - libs += [ 'OpenCL' ] env.SharedLibrary(env['plugin_dir'] + name, files, LIBS = env['LIBS'] + libs)