Dynamically load OpenCL on Windows with CLRun. There shouldn't be the need to make a separate build now or download a big SDK to link Dolphin.

If compilation fails, rebuild the whole solution as Visual Studio struggles with the not so complex project dependencies.
ATI users still need to install the Stream SDK as it's the only way to have an OpenCL driver.
NVidia users just have to install a recent driver (version 197 is tested and working).

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5808 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Orphis 2010-06-29 02:23:09 +00:00
commit 685bae34e5
17 changed files with 3236 additions and 13 deletions

View file

@ -46,7 +46,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../PluginSpecs"
AdditionalIncludeDirectories="../../PluginSpecs;../../../Externals/CLRun/include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_SECURE_SCL=0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -116,7 +116,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../PluginSpecs"
AdditionalIncludeDirectories="../../PluginSpecs;../../../Externals/CLRun/include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_SECURE_SCL=0"
StringPooling="true"
MinimalRebuild="true"
@ -190,7 +190,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="2"
AdditionalIncludeDirectories="../../PluginSpecs"
AdditionalIncludeDirectories="../../PluginSpecs;../../../Externals/CLRun/include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0"
BufferSecurityCheck="false"
@ -264,7 +264,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="../../PluginSpecs"
AdditionalIncludeDirectories="../../PluginSpecs;../../../Externals/CLRun/include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="0"
@ -336,7 +336,7 @@
Name="VCCLCompilerTool"
Optimization="3"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="../../PluginSpecs"
AdditionalIncludeDirectories="../../PluginSpecs;../../../Externals/CLRun/include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;DEBUGFAST;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
BufferSecurityCheck="false"
@ -407,7 +407,7 @@
Name="VCCLCompilerTool"
Optimization="3"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="../../PluginSpecs"
AdditionalIncludeDirectories="../../PluginSpecs;../../../Externals/CLRun/include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;DEBUGFAST;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
FloatingPointModel="0"

View file

@ -21,6 +21,10 @@
#include "Common.h"
#include "Timer.h"
#ifdef _WIN32
#include "clrun.h"
#endif
namespace OpenCL
{
@ -41,7 +45,13 @@ bool Initialize()
if(g_context)
return false;
int err; // error code returned from api calls
#ifdef _WIN32
clrInit();
if(!clrHasOpenCL())
return false;
#endif
// Connect to a compute device
cl_uint numPlatforms;
cl_platform_id platform = NULL;

View file

@ -19,9 +19,11 @@
#define __OPENCL_H__
#include "Common.h"
// Change to #if 1 if you want to test OpenCL (and you have it) on Windows
#if 0
#pragma comment(lib, "OpenCL.lib")
// OpenCL on Windows is linked through the CLRun library
// It provides the headers and all the imports
// It could be safe to use it for Linux too, but will require to edit the SCons first
// OpenCL is linked on OSX when possible, it shouldn't require CLRun for now
#ifdef _WIN32
#define HAVE_OPENCL 1
#endif

View file

@ -152,7 +152,7 @@ PC_TexFormat TexDecoder_Decode_OpenCL(u8 *dst, const u8 *src, int width, int hei
#if defined(HAVE_OPENCL) && HAVE_OPENCL
cl_int err;
sDecoderParameter& decoder = rgba ? g_DecodeParametersRGBA[texformat] : g_DecodeParametersNative[texformat];
if(!decoder.name || !decoder.kernel || decoder.format == PC_TEX_FMT_NONE)
if(!g_Inited || !decoder.name || !decoder.kernel || decoder.format == PC_TEX_FMT_NONE)
return PC_TEX_FMT_NONE;
#ifdef DEBUG_OPENCL
@ -193,7 +193,5 @@ PC_TexFormat TexDecoder_Decode_OpenCL(u8 *dst, const u8 *src, int width, int hei
#else
return PC_TEX_FMT_NONE;
#endif
return PC_TEX_FMT_NONE;
}

View file

@ -51,6 +51,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dolphin", "Core\DolphinWX\D
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160} = {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}
{D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8} = {D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8}
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1} = {D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}
{8D612734-FAA5-4B8A-804F-4DEA2367D495} = {8D612734-FAA5-4B8A-804F-4DEA2367D495}
{05C75041-D67D-4903-A362-8395A7B35C75} = {05C75041-D67D-4903-A362-8395A7B35C75}
{636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18} = {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}
@ -79,6 +80,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Debugger", "Core\DebuggerWX
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoCommon", "Core\VideoCommon\VideoCommon.vcproj", "{E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA}"
ProjectSection(ProjectDependencies) = postProject
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1} = {D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}
{C0B84DA9-FF15-4FAB-9590-17132F3C6DE4} = {C0B84DA9-FF15-4FAB-9590-17132F3C6DE4}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
@ -213,6 +215,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoDX11", "Plugins
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CLRun", "..\Externals\CLRun\clrun\CLRun.vcproj", "{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -597,6 +601,17 @@ Global
{21DBE606-2958-43AC-A14E-B6B798D56554}.Release|Win32.Build.0 = Release|Win32
{21DBE606-2958-43AC-A14E-B6B798D56554}.Release|x64.ActiveCfg = Release|x64
{21DBE606-2958-43AC-A14E-B6B798D56554}.Release|x64.Build.0 = Release|x64
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.Debug|Win32.ActiveCfg = Debug|Win32
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.Debug|Win32.Build.0 = Debug|Win32
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.Debug|x64.ActiveCfg = Debug|x64
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.Debug|x64.Build.0 = Debug|x64
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.DebugFast|Win32.ActiveCfg = Release|x64
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.DebugFast|x64.ActiveCfg = Release|x64
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.DebugFast|x64.Build.0 = Release|x64
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.Release|Win32.ActiveCfg = Release|Win32
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.Release|Win32.Build.0 = Release|Win32
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.Release|x64.ActiveCfg = Release|x64
{D4833C30-FA5F-4DFE-BD32-109DE1F09ED1}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE