mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
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:
63
Externals/CLRun/clrun/dynamiclib.c
vendored
Normal file
63
Externals/CLRun/clrun/dynamiclib.c
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
HINSTANCE library = NULL;
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
void *library = NULL;
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
int loadLib(const char *filename) {
|
||||
if (library)
|
||||
return -1;
|
||||
|
||||
if (!filename || strlen(filename) == 0)
|
||||
return -2;
|
||||
|
||||
#ifdef _WIN32
|
||||
library = LoadLibrary(filename);
|
||||
#else
|
||||
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
||||
#endif
|
||||
|
||||
if (!library)
|
||||
return -3;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unloadLib()
|
||||
{
|
||||
int retval;
|
||||
if (!library)
|
||||
return -1;
|
||||
|
||||
#ifdef _WIN32
|
||||
retval = FreeLibrary(library);
|
||||
#else
|
||||
retval = dlclose(library);
|
||||
#endif
|
||||
|
||||
library = NULL;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void *getFunction(const char *funcname) {
|
||||
void* retval;
|
||||
|
||||
if (!library) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
retval = GetProcAddress(library, funcname);
|
||||
#else
|
||||
retval = dlsym(library, funcname);
|
||||
#endif
|
||||
|
||||
if (!retval)
|
||||
return NULL;
|
||||
|
||||
return retval;
|
||||
}
|
Reference in New Issue
Block a user