mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
More OpenCL work, got XFB converting which needs more optimization. I haven't checked for FPS changes. My desktop isn't the best to test on anyway (Phenom 1, 32 stream processors). The package check doesn't work for me, so I just checked true if you compile with opencl=true. Requires a bit of cleanup still
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4369 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -21,18 +21,19 @@
|
||||
#include "Common.h"
|
||||
|
||||
namespace OpenCL {
|
||||
|
||||
cl_context g_context = NULL;
|
||||
cl_command_queue g_cmdq = NULL;
|
||||
#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 Initialize() {
|
||||
if(g_context)
|
||||
return false;
|
||||
|
||||
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
||||
|
||||
if(g_context)
|
||||
return false;
|
||||
int err; // error code returned from api calls
|
||||
cl_device_id device_id;
|
||||
|
||||
|
||||
// Connect to a compute device
|
||||
//
|
||||
@ -61,13 +62,13 @@ bool Initialize() {
|
||||
PanicAlert("Error: Failed to create a command commands!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("Initialized OpenCL fine!\n");
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
||||
cl_context GetInstance() {
|
||||
return g_context;
|
||||
}
|
||||
@ -76,20 +77,56 @@ cl_command_queue GetCommandQueue() {
|
||||
return g_cmdq;
|
||||
}
|
||||
|
||||
cl_program CompileProgram(const char *program, unsigned int size) {
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
||||
cl_program CompileProgram(const char *Kernel) {
|
||||
int err;
|
||||
cl_program program;
|
||||
program = clCreateProgramWithSource(OpenCL::g_context, 1, (const char **) & Kernel, NULL, &err);
|
||||
if (!program)
|
||||
{
|
||||
printf("Error: Failed to create compute program!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Build the program executable
|
||||
//
|
||||
err = clBuildProgram(program , 0, NULL, NULL, NULL, NULL);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
size_t len;
|
||||
char buffer[2048];
|
||||
|
||||
printf("Error: Failed to build program executable!\n");
|
||||
clGetProgramBuildInfo(program , OpenCL::device_id, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len);
|
||||
printf("%s\n", buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return program;
|
||||
}
|
||||
cl_kernel CompileKernel(cl_program program, const char *Function)
|
||||
{
|
||||
int err;
|
||||
// Create the compute kernel in the program we wish to run
|
||||
//
|
||||
cl_kernel kernel = clCreateKernel(program, Function, &err);
|
||||
if (!kernel || err != CL_SUCCESS)
|
||||
{
|
||||
printf("Error: Failed to create compute kernel!\n");
|
||||
return NULL;
|
||||
}
|
||||
return kernel;
|
||||
}
|
||||
#endif
|
||||
void Destroy() {
|
||||
if(!g_context)
|
||||
return;
|
||||
|
||||
#if defined(HAVE_OPENCL) && HAVE_OPENCL
|
||||
if(!g_context)
|
||||
return;
|
||||
clReleaseCommandQueue(g_cmdq);
|
||||
clReleaseContext(g_context);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
#ifndef __OPENCL_H__
|
||||
#define __OPENCL_H__
|
||||
|
||||
#include "Config.h"
|
||||
// Change to #if 1 if you want to test OpenCL (and you have it) on Windows
|
||||
#if 0
|
||||
#pragma comment(lib, "OpenCL.lib")
|
||||
@ -37,10 +38,16 @@
|
||||
typedef void *cl_context;
|
||||
typedef void *cl_command_queue;
|
||||
typedef void *cl_program;
|
||||
typedef void *cl_kernel;
|
||||
|
||||
#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();
|
||||
|
||||
@ -50,7 +57,8 @@ cl_command_queue GetCommandQueue();
|
||||
|
||||
void Destroy();
|
||||
|
||||
cl_program CompileProgram(const char *program, unsigned int size);
|
||||
cl_program CompileProgram(const char *Kernel);
|
||||
cl_kernel CompileKernel(cl_program program, const char *Function);
|
||||
|
||||
};
|
||||
|
||||
|
@ -23,6 +23,7 @@ files = [
|
||||
"MemoryUtil.cpp",
|
||||
"Misc.cpp",
|
||||
"MsgHandler.cpp",
|
||||
"OpenCL.cpp",
|
||||
"Plugin.cpp",
|
||||
"PluginDSP.cpp",
|
||||
"PluginWiimote.cpp",
|
||||
|
Reference in New Issue
Block a user