mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 13:49:53 -06:00
OpenCL: Moved the OpenCL code from the compiled source to a separate file TextureDecoder.cl and added a .rules files to copy the updated version to the build directory.
Fixed RGB5A3 decoding with alpha New CMPR decoding, blocks with no alpha are great, still have to figure the problems with transparent blocks. Disabled for now. Added a better error reporting to the base OpenCL functions git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4439 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -45,7 +45,7 @@ bool Initialize() {
|
||||
err = clGetDeviceIDs(NULL, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
PanicAlert("Error: Failed to create a device group!");
|
||||
HandleCLError(err, "Failed to create a device group!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ bool Initialize() {
|
||||
g_context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
|
||||
if (!g_context)
|
||||
{
|
||||
PanicAlert("Error: Failed to create a compute context!");
|
||||
HandleCLError(err, "Failed to create a compute context!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ bool Initialize() {
|
||||
g_cmdq = clCreateCommandQueue(g_context, device_id, 0, &err);
|
||||
if (!g_cmdq)
|
||||
{
|
||||
PanicAlert("Error: Failed to create a command commands!");
|
||||
HandleCLError(err, "Failed to create a command commands!");
|
||||
return false;
|
||||
}
|
||||
//PanicAlert("Initialized OpenCL fine!");
|
||||
@ -88,7 +88,7 @@ cl_program CompileProgram(const char *Kernel) {
|
||||
program = clCreateProgramWithSource(OpenCL::g_context, 1, (const char **) & Kernel, NULL, &err);
|
||||
if (!program)
|
||||
{
|
||||
printf("Error: Failed to create compute program!");
|
||||
HandleCLError(err, "Error: Failed to create compute program!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ cl_kernel CompileKernel(cl_program program, const char *Function)
|
||||
cl_kernel kernel = clCreateKernel(program, Function, &err);
|
||||
if (!kernel || err != CL_SUCCESS)
|
||||
{
|
||||
PanicAlert("Error: Failed to create compute kernel!");
|
||||
HandleCLError(err, "Failed to create compute kernel!");
|
||||
return NULL;
|
||||
}
|
||||
return kernel;
|
||||
@ -130,5 +130,66 @@ void Destroy() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void HandleCLError(cl_int error, char* str)
|
||||
{
|
||||
char* name;
|
||||
switch(error)
|
||||
{
|
||||
#define CL_ERROR(x) case (x): name = #x; break
|
||||
CL_ERROR(CL_SUCCESS);
|
||||
CL_ERROR(CL_DEVICE_NOT_FOUND);
|
||||
CL_ERROR(CL_DEVICE_NOT_AVAILABLE);
|
||||
CL_ERROR(CL_COMPILER_NOT_AVAILABLE);
|
||||
CL_ERROR(CL_MEM_OBJECT_ALLOCATION_FAILURE);
|
||||
CL_ERROR(CL_OUT_OF_RESOURCES);
|
||||
CL_ERROR(CL_OUT_OF_HOST_MEMORY);
|
||||
CL_ERROR(CL_PROFILING_INFO_NOT_AVAILABLE);
|
||||
CL_ERROR(CL_MEM_COPY_OVERLAP);
|
||||
CL_ERROR(CL_IMAGE_FORMAT_MISMATCH);
|
||||
CL_ERROR(CL_IMAGE_FORMAT_NOT_SUPPORTED);
|
||||
CL_ERROR(CL_BUILD_PROGRAM_FAILURE);
|
||||
CL_ERROR(CL_MAP_FAILURE);
|
||||
CL_ERROR(CL_INVALID_VALUE);
|
||||
CL_ERROR(CL_INVALID_DEVICE_TYPE);
|
||||
CL_ERROR(CL_INVALID_PLATFORM);
|
||||
CL_ERROR(CL_INVALID_DEVICE);
|
||||
CL_ERROR(CL_INVALID_CONTEXT);
|
||||
CL_ERROR(CL_INVALID_QUEUE_PROPERTIES);
|
||||
CL_ERROR(CL_INVALID_COMMAND_QUEUE);
|
||||
CL_ERROR(CL_INVALID_HOST_PTR);
|
||||
CL_ERROR(CL_INVALID_MEM_OBJECT);
|
||||
CL_ERROR(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR);
|
||||
CL_ERROR(CL_INVALID_IMAGE_SIZE);
|
||||
CL_ERROR(CL_INVALID_SAMPLER);
|
||||
CL_ERROR(CL_INVALID_BINARY);
|
||||
CL_ERROR(CL_INVALID_BUILD_OPTIONS);
|
||||
CL_ERROR(CL_INVALID_PROGRAM);
|
||||
CL_ERROR(CL_INVALID_PROGRAM_EXECUTABLE);
|
||||
CL_ERROR(CL_INVALID_KERNEL_NAME);
|
||||
CL_ERROR(CL_INVALID_KERNEL_DEFINITION);
|
||||
CL_ERROR(CL_INVALID_KERNEL);
|
||||
CL_ERROR(CL_INVALID_ARG_INDEX);
|
||||
CL_ERROR(CL_INVALID_ARG_VALUE);
|
||||
CL_ERROR(CL_INVALID_ARG_SIZE);
|
||||
CL_ERROR(CL_INVALID_KERNEL_ARGS);
|
||||
CL_ERROR(CL_INVALID_WORK_DIMENSION);
|
||||
CL_ERROR(CL_INVALID_WORK_GROUP_SIZE);
|
||||
CL_ERROR(CL_INVALID_WORK_ITEM_SIZE);
|
||||
CL_ERROR(CL_INVALID_GLOBAL_OFFSET);
|
||||
CL_ERROR(CL_INVALID_EVENT_WAIT_LIST);
|
||||
CL_ERROR(CL_INVALID_EVENT);
|
||||
CL_ERROR(CL_INVALID_OPERATION);
|
||||
CL_ERROR(CL_INVALID_GL_OBJECT);
|
||||
CL_ERROR(CL_INVALID_BUFFER_SIZE);
|
||||
CL_ERROR(CL_INVALID_MIP_LEVEL);
|
||||
#undef CL_ERROR
|
||||
default:
|
||||
name = "Unknown error code";
|
||||
}
|
||||
if(!str)
|
||||
str = "";
|
||||
PanicAlert("OpenCL error: %s %s (%d)", str, name, error);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user