@@ -2865,35 +2865,6 @@ int dt_opencl_read_host_from_device_rowpitch(const int devid,
28652865 region , rowpitch , CL_TRUE );
28662866}
28672867
2868- int dt_opencl_read_host_from_device_non_blocking (const int devid ,
2869- void * host ,
2870- void * device ,
2871- const int width ,
2872- const int height ,
2873- const int bpp )
2874- {
2875- return dt_opencl_read_host_from_device_rowpitch_non_blocking (devid , host , device ,
2876- width , height ,
2877- bpp * width );
2878- }
2879-
2880- int dt_opencl_read_host_from_device_rowpitch_non_blocking (const int devid ,
2881- void * host ,
2882- void * device ,
2883- const int width ,
2884- const int height ,
2885- const int rowpitch )
2886- {
2887- if (!_cldev_running (devid ))
2888- return DT_OPENCL_NODEVICE ;
2889- const size_t origin [] = { 0 , 0 , 0 };
2890- const size_t region [] = { width , height , 1 };
2891- // non-blocking.
2892- return dt_opencl_read_host_from_device_raw (devid , host , device , origin ,
2893- region , rowpitch , CL_FALSE );
2894- }
2895-
2896-
28972868int dt_opencl_read_host_from_device_raw (const int devid ,
28982869 void * host ,
28992870 void * device ,
@@ -2950,37 +2921,6 @@ int dt_opencl_write_host_to_device_rowpitch(const int devid,
29502921 region , rowpitch , CL_TRUE );
29512922}
29522923
2953- int dt_opencl_write_host_to_device_non_blocking (const int devid ,
2954- void * host ,
2955- void * device ,
2956- const int width ,
2957- const int height ,
2958- const int bpp )
2959- {
2960- return dt_opencl_write_host_to_device_rowpitch_non_blocking (devid , host , device ,
2961- width , height , width * bpp );
2962- }
2963-
2964- int dt_opencl_write_host_to_device_rowpitch_non_blocking (const int devid ,
2965- void * host ,
2966- void * device ,
2967- const int width ,
2968- const int height ,
2969- const int rowpitch )
2970- {
2971- if (!_cldev_running (devid ))
2972- return DT_OPENCL_NODEVICE ;
2973-
2974- const size_t origin [] = { 0 , 0 , 0 };
2975- const size_t region [] = { width , height , 1 };
2976- // non-blocking.
2977-
2978- const cl_int err = dt_opencl_write_host_to_device_raw (devid , host , device ,
2979- origin , region , rowpitch , CL_FALSE );
2980- _check_clmem_err (devid , err );
2981- return err ;
2982- }
2983-
29842924int dt_opencl_write_host_to_device_raw (const int devid ,
29852925 void * host ,
29862926 void * device ,
@@ -3178,16 +3118,8 @@ void *dt_opencl_copy_host_to_device_constant(const int devid,
31783118 return dev ;
31793119}
31803120
3181- void * dt_opencl_copy_host_to_device (const int devid ,
3182- void * host ,
3183- const int width ,
3184- const int height ,
3185- const int bpp )
3186- {
3187- return dt_opencl_copy_host_to_device_rowpitch (devid , host , width , height , bpp , 0 );
3188- }
31893121
3190- void * dt_opencl_copy_host_to_device_rowpitch (const int devid ,
3122+ static void * _opencl_copy_host_to_device_rowpitch (const int devid ,
31913123 void * host ,
31923124 const int width ,
31933125 const int height ,
@@ -3228,6 +3160,14 @@ void *dt_opencl_copy_host_to_device_rowpitch(const int devid,
32283160 return dev ;
32293161}
32303162
3163+ void * dt_opencl_copy_host_to_device (const int devid ,
3164+ void * host ,
3165+ const int width ,
3166+ const int height ,
3167+ const int bpp )
3168+ {
3169+ return _opencl_copy_host_to_device_rowpitch (devid , host , width , height , bpp , 0 );
3170+ }
32313171
32323172void dt_opencl_release_mem_object (cl_mem mem )
32333173{
@@ -3334,56 +3274,6 @@ void *dt_opencl_alloc_device(const int devid,
33343274 return dev ;
33353275}
33363276
3337-
3338- void * dt_opencl_alloc_device_use_host_pointer (const int devid ,
3339- const int width ,
3340- const int height ,
3341- const int bpp ,
3342- const int rowpitch ,
3343- void * host )
3344- {
3345- if (!_cldev_running (devid ))
3346- return NULL ;
3347-
3348- dt_opencl_t * cl = darktable .opencl ;
3349- if (cl -> dev [devid ].max_image_width < width || cl -> dev [devid ].max_image_height < height )
3350- return NULL ;
3351-
3352- cl_int err = CL_SUCCESS ;
3353- cl_image_format fmt ;
3354- // guess pixel format from bytes per pixel
3355- if (bpp == 4 * sizeof (float ))
3356- fmt = (cl_image_format ){ CL_RGBA , CL_FLOAT };
3357- else if (bpp == 2 * sizeof (float ))
3358- fmt = (cl_image_format ){ CL_RG , CL_FLOAT };
3359- else if (bpp == sizeof (float ))
3360- fmt = (cl_image_format ){ CL_R , CL_FLOAT };
3361- else if (bpp == sizeof (uint16_t ))
3362- fmt = (cl_image_format ){ CL_R , CL_UNSIGNED_INT16 };
3363- else
3364- return NULL ;
3365-
3366- const cl_image_desc desc = (cl_image_desc )
3367- {CL_MEM_OBJECT_IMAGE2D , width , height , 0 , 0 , rowpitch , 0 , 0 , 0 , NULL };
3368-
3369- cl_mem dev = (cl -> dlocl -> symbols -> dt_clCreateImage )
3370- (cl -> dev [devid ].context ,
3371- CL_MEM_READ_WRITE | ((host == NULL ) ? CL_MEM_ALLOC_HOST_PTR : CL_MEM_USE_HOST_PTR ),
3372- & fmt , & desc , host , & err );
3373-
3374- if (err != CL_SUCCESS || dev == NULL )
3375- dt_print (DT_DEBUG_OPENCL ,
3376- "[opencl alloc_device_use_host_pointer]"
3377- " could not allocate cl image on device '%s' id=%d: %s" ,
3378- cl -> dev [devid ].fullname , devid , cl_errstr (err ));
3379-
3380- _check_clmem_err (devid , err );
3381- dt_opencl_memory_statistics (devid , dev , OPENCL_MEMORY_ADD );
3382-
3383- return dev ;
3384- }
3385-
3386-
33873277void * dt_opencl_alloc_device_buffer (const int devid ,
33883278 const size_t size )
33893279{
0 commit comments