|
|
|
@ -124,7 +124,7 @@ namespace cv |
|
|
|
|
build_options, finish_mode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cl_mem bindTexture(const oclMat &mat) |
|
|
|
|
cl_mem bindTexture(const oclMat &mat) |
|
|
|
|
{ |
|
|
|
|
cl_mem texture; |
|
|
|
|
cl_image_format format; |
|
|
|
@ -162,30 +162,37 @@ namespace cv |
|
|
|
|
CV_Error(-1, "Image forma is not supported"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if(Context::getContext()->supportsFeature(Context::CL_VER_1_2)) |
|
|
|
|
{ |
|
|
|
|
#if CL_VERSION_1_2 |
|
|
|
|
cl_image_desc desc; |
|
|
|
|
desc.image_type = CL_MEM_OBJECT_IMAGE2D; |
|
|
|
|
desc.image_width = mat.cols; |
|
|
|
|
desc.image_height = mat.rows; |
|
|
|
|
desc.image_depth = 0; |
|
|
|
|
desc.image_array_size = 1; |
|
|
|
|
desc.image_row_pitch = 0; |
|
|
|
|
desc.image_slice_pitch = 0; |
|
|
|
|
desc.buffer = NULL; |
|
|
|
|
desc.num_mip_levels = 0; |
|
|
|
|
desc.num_samples = 0; |
|
|
|
|
texture = clCreateImage((cl_context)mat.clCxt->oclContext(), CL_MEM_READ_WRITE, &format, &desc, NULL, &err); |
|
|
|
|
cl_image_desc desc; |
|
|
|
|
desc.image_type = CL_MEM_OBJECT_IMAGE2D; |
|
|
|
|
desc.image_width = mat.cols; |
|
|
|
|
desc.image_height = mat.rows; |
|
|
|
|
desc.image_depth = 0; |
|
|
|
|
desc.image_array_size = 1; |
|
|
|
|
desc.image_row_pitch = 0; |
|
|
|
|
desc.image_slice_pitch = 0; |
|
|
|
|
desc.buffer = NULL; |
|
|
|
|
desc.num_mip_levels = 0; |
|
|
|
|
desc.num_samples = 0; |
|
|
|
|
texture = clCreateImage((cl_context)mat.clCxt->oclContext(), CL_MEM_READ_WRITE, &format, &desc, NULL, &err); |
|
|
|
|
#else |
|
|
|
|
texture = clCreateImage2D( |
|
|
|
|
(cl_context)mat.clCxt->oclContext(), |
|
|
|
|
CL_MEM_READ_WRITE, |
|
|
|
|
&format, |
|
|
|
|
mat.cols, |
|
|
|
|
mat.rows, |
|
|
|
|
0, |
|
|
|
|
NULL, |
|
|
|
|
&err); |
|
|
|
|
CV_Error(CV_StsBadFunc, "Non-deprecated image creation API call is not supported.");
|
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
texture = clCreateImage2D( |
|
|
|
|
(cl_context)mat.clCxt->oclContext(), |
|
|
|
|
CL_MEM_READ_WRITE, |
|
|
|
|
&format, |
|
|
|
|
mat.cols, |
|
|
|
|
mat.rows, |
|
|
|
|
0, |
|
|
|
|
NULL, |
|
|
|
|
&err); |
|
|
|
|
} |
|
|
|
|
size_t origin[] = { 0, 0, 0 }; |
|
|
|
|
size_t region[] = { mat.cols, mat.rows, 1 }; |
|
|
|
|
|
|
|
|
@ -198,7 +205,7 @@ namespace cv |
|
|
|
|
clEnqueueCopyBufferRect((cl_command_queue)mat.clCxt->oclCommandQueue(), (cl_mem)mat.data, devData, origin, origin, |
|
|
|
|
regin, mat.step, 0, mat.cols * mat.elemSize(), 0, 0, NULL, NULL); |
|
|
|
|
clFlush((cl_command_queue)mat.clCxt->oclCommandQueue());
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
devData = (cl_mem)mat.data; |
|
|
|
@ -214,7 +221,6 @@ namespace cv |
|
|
|
|
openCLSafeCall(err); |
|
|
|
|
return texture; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void releaseTexture(cl_mem& texture) |
|
|
|
|
{ |
|
|
|
|
openCLFree(texture); |
|
|
|
|