Converting supported image/texture memory format information to readable string in opencl -


i want supported image formats of device. opencl function returns results in cl_image_format. want know results in string.

currently using following code:

cl_uint uinumsupportedformats = 0;  // 2d clgetsupportedimageformats((cl_context)image.clcxt->oclcontext(),                            cl_mem_write_only,                            cl_mem_object_image2d,                            null, null, &uinumsupportedformats);  cl_image_format* imageformats = new cl_image_format[uinumsupportedformats]; clgetsupportedimageformats((cl_context)image.clcxt->oclcontext(),                            cl_mem_write_only,                            cl_mem_object_image2d,                            uinumsupportedformats, imageformats, null);  for(unsigned int = 0; < uinumsupportedformats; i++) {      cout<<imageformats[i].image_channel_order<<endl;      cout<<imageformats[i].image_channel_data_type<<endl;  }  delete [] imageformats; 

right getting integer values. how can corresponding string value? example: cl_ra cl_unorm_int8

i using amd gpu device.

there no opencl standard way of getting string representation of these constants (or others), you'll have either write own or use utility you. it's pretty forward write you're own 'human-readable' print method image formats. this:

void printimageformat(cl_image_format format) { #define case(order) case order: cout << #order; break;   switch (format.image_channel_order)   {     case(cl_r);     case(cl_a);     case(cl_rg);     case(cl_ra);     case(cl_rgb);     case(cl_rgba);     case(cl_bgra);     case(cl_argb);     case(cl_intensity);     case(cl_luminance);     case(cl_rx);     case(cl_rgx);     case(cl_rgbx);     case(cl_depth);     case(cl_depth_stencil);   } #undef case    cout << " - ";  #define case(type) case type: cout << #type; break;   switch (format.image_channel_data_type)   {     case(cl_snorm_int8);     case(cl_snorm_int16);     case(cl_unorm_int8);     case(cl_unorm_int16);     case(cl_unorm_short_565);     case(cl_unorm_short_555);     case(cl_unorm_int_101010);     case(cl_signed_int8);     case(cl_signed_int16);     case(cl_signed_int32);     case(cl_unsigned_int8);     case(cl_unsigned_int16);     case(cl_unsigned_int32);     case(cl_half_float);     case(cl_float);     case(cl_unorm_int24);   } #undef case    cout << endl; } 

and call printimageformat(imageformats[i]); inside existing loop.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -