@@ -2855,35 +2855,6 @@ int dt_opencl_read_host_from_device_rowpitch(const int devid,
28552855 region , rowpitch , CL_TRUE );
28562856}
28572857
2858- int dt_opencl_read_host_from_device_non_blocking (const int devid ,
2859- void * host ,
2860- void * device ,
2861- const int width ,
2862- const int height ,
2863- const int bpp )
2864- {
2865- return dt_opencl_read_host_from_device_rowpitch_non_blocking (devid , host , device ,
2866- width , height ,
2867- bpp * width );
2868- }
2869-
2870- int dt_opencl_read_host_from_device_rowpitch_non_blocking (const int devid ,
2871- void * host ,
2872- void * device ,
2873- const int width ,
2874- const int height ,
2875- const int rowpitch )
2876- {
2877- if (!_cldev_running (devid ))
2878- return DT_OPENCL_NODEVICE ;
2879- const size_t origin [] = { 0 , 0 , 0 };
2880- const size_t region [] = { width , height , 1 };
2881- // non-blocking.
2882- return dt_opencl_read_host_from_device_raw (devid , host , device , origin ,
2883- region , rowpitch , CL_FALSE );
2884- }
2885-
2886-
28872858int dt_opencl_read_host_from_device_raw (const int devid ,
28882859 void * host ,
28892860 void * device ,
@@ -2940,37 +2911,6 @@ int dt_opencl_write_host_to_device_rowpitch(const int devid,
29402911 region , rowpitch , CL_TRUE );
29412912}
29422913
2943- int dt_opencl_write_host_to_device_non_blocking (const int devid ,
2944- void * host ,
2945- void * device ,
2946- const int width ,
2947- const int height ,
2948- const int bpp )
2949- {
2950- return dt_opencl_write_host_to_device_rowpitch_non_blocking (devid , host , device ,
2951- width , height , width * bpp );
2952- }
2953-
2954- int dt_opencl_write_host_to_device_rowpitch_non_blocking (const int devid ,
2955- void * host ,
2956- void * device ,
2957- const int width ,
2958- const int height ,
2959- const int rowpitch )
2960- {
2961- if (!_cldev_running (devid ))
2962- return DT_OPENCL_NODEVICE ;
2963-
2964- const size_t origin [] = { 0 , 0 , 0 };
2965- const size_t region [] = { width , height , 1 };
2966- // non-blocking.
2967-
2968- const cl_int err = dt_opencl_write_host_to_device_raw (devid , host , device ,
2969- origin , region , rowpitch , CL_FALSE );
2970- _check_clmem_err (devid , err );
2971- return err ;
2972- }
2973-
29742914int dt_opencl_write_host_to_device_raw (const int devid ,
29752915 void * host ,
29762916 void * device ,
@@ -3164,16 +3104,8 @@ void *dt_opencl_copy_host_to_device_constant(const int devid,
31643104 return dev ;
31653105}
31663106
3167- void * dt_opencl_copy_host_to_device (const int devid ,
3168- void * host ,
3169- const int width ,
3170- const int height ,
3171- const int bpp )
3172- {
3173- return dt_opencl_copy_host_to_device_rowpitch (devid , host , width , height , bpp , 0 );
3174- }
31753107
3176- void * dt_opencl_copy_host_to_device_rowpitch (const int devid ,
3108+ static void * _opencl_copy_host_to_device_rowpitch (const int devid ,
31773109 void * host ,
31783110 const int width ,
31793111 const int height ,
@@ -3214,6 +3146,14 @@ void *dt_opencl_copy_host_to_device_rowpitch(const int devid,
32143146 return dev ;
32153147}
32163148
3149+ void * dt_opencl_copy_host_to_device (const int devid ,
3150+ void * host ,
3151+ const int width ,
3152+ const int height ,
3153+ const int bpp )
3154+ {
3155+ return _opencl_copy_host_to_device_rowpitch (devid , host , width , height , bpp , 0 );
3156+ }
32173157
32183158void dt_opencl_release_mem_object (cl_mem mem )
32193159{
@@ -3320,56 +3260,6 @@ void *dt_opencl_alloc_device(const int devid,
33203260 return dev ;
33213261}
33223262
3323-
3324- void * dt_opencl_alloc_device_use_host_pointer (const int devid ,
3325- const int width ,
3326- const int height ,
3327- const int bpp ,
3328- const int rowpitch ,
3329- void * host )
3330- {
3331- if (!_cldev_running (devid ))
3332- return NULL ;
3333-
3334- dt_opencl_t * cl = darktable .opencl ;
3335- if (cl -> dev [devid ].max_image_width < width || cl -> dev [devid ].max_image_height < height )
3336- return NULL ;
3337-
3338- cl_int err = CL_SUCCESS ;
3339- cl_image_format fmt ;
3340- // guess pixel format from bytes per pixel
3341- if (bpp == 4 * sizeof (float ))
3342- fmt = (cl_image_format ){ CL_RGBA , CL_FLOAT };
3343- else if (bpp == 2 * sizeof (float ))
3344- fmt = (cl_image_format ){ CL_RG , CL_FLOAT };
3345- else if (bpp == sizeof (float ))
3346- fmt = (cl_image_format ){ CL_R , CL_FLOAT };
3347- else if (bpp == sizeof (uint16_t ))
3348- fmt = (cl_image_format ){ CL_R , CL_UNSIGNED_INT16 };
3349- else
3350- return NULL ;
3351-
3352- const cl_image_desc desc = (cl_image_desc )
3353- {CL_MEM_OBJECT_IMAGE2D , width , height , 0 , 0 , rowpitch , 0 , 0 , 0 , NULL };
3354-
3355- cl_mem dev = (cl -> dlocl -> symbols -> dt_clCreateImage )
3356- (cl -> dev [devid ].context ,
3357- CL_MEM_READ_WRITE | ((host == NULL ) ? CL_MEM_ALLOC_HOST_PTR : CL_MEM_USE_HOST_PTR ),
3358- & fmt , & desc , host , & err );
3359-
3360- if (err != CL_SUCCESS || dev == NULL )
3361- dt_print (DT_DEBUG_OPENCL ,
3362- "[opencl alloc_device_use_host_pointer]"
3363- " could not allocate cl image on device '%s' id=%d: %s" ,
3364- cl -> dev [devid ].fullname , devid , cl_errstr (err ));
3365-
3366- _check_clmem_err (devid , err );
3367- dt_opencl_memory_statistics (devid , dev , OPENCL_MEMORY_ADD );
3368-
3369- return dev ;
3370- }
3371-
3372-
33733263void * dt_opencl_alloc_device_buffer (const int devid ,
33743264 const size_t size )
33753265{
0 commit comments