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:
Sonicadvance1
2009-10-07 02:48:21 +00:00
parent f474788e01
commit 0146f3f58f
8 changed files with 406 additions and 51 deletions

View File

@ -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
}
};
};