16 :m_Image2DSupport( nullptr ), m_Image3DSupport( nullptr ),
17 m_GpuContext( nullptr )
22 this->m_Image2DSupport =
new unsigned char[matrixSize];
23 this->m_Image3DSupport =
new unsigned char[matrixSize];
25 for(
unsigned int i = 0; i<matrixSize; i++ )
27 this->m_Image2DSupport[i] = 0;
28 this->m_Image3DSupport[i] = 0;
36 void mitk::OclImageFormats::PrintSelf()
38 std::stringstream outputstream;
39 outputstream <<
"Values: Read-Write(1) ReadOnly(2) , WriteOnly(4) \n";
40 outputstream <<
"ROWS: [CL_A, CL_R, CL_RA, CL_RG, CL_RGB, CL_RGBA, CL_ARGB, CL_BGRA, CL_LUM, CL_INT] \n";
44 for(
unsigned int i = 0; i<matrixSize; i++ )
46 outputstream << (int) this->m_Image2DSupport[i] <<
", \t";
47 if( (i+1) % MAX_DATA_TYPES == 0 )
48 outputstream <<
" \n";
50 outputstream <<
"========================== \n";
52 for(
unsigned int i = 0; i<matrixSize; i++ )
54 outputstream << (int) this->m_Image3DSupport[i] <<
", \t";
55 if( (i+1) % MAX_DATA_TYPES == 0 )
56 outputstream <<
" \n";
61 unsigned int mitk::OclImageFormats::GetOffset(cl_image_format format)
66 switch( format.image_channel_order )
99 switch ( format.image_channel_data_type )
115 case CL_SIGNED_INT16:
118 case CL_SIGNED_INT32:
121 case CL_UNSIGNED_INT8:
124 case CL_UNSIGNED_INT16:
127 case CL_UNSIGNED_INT32:
147 if ( this->m_Image2DSupport[ GetOffset(*format)] > 4 )
155 bool returnValue =
false;
158 outputformat->image_channel_data_type = inputformat->image_channel_data_type;
159 outputformat->image_channel_order = inputformat->image_channel_order;
171 cl_image_format
test;
172 test.image_channel_order = CL_RGBA;
173 test.image_channel_data_type = inputformat->image_channel_data_type;
177 outputformat->image_channel_order = CL_RGBA;
185 this->m_GpuContext = context;
190 void mitk::OclImageFormats::SortFormats(cl_image_format *formats, cl_uint count,
int val,
int dims)
193 unsigned char *target = this->m_Image2DSupport;
196 target = this->m_Image3DSupport;
199 for(
unsigned int i=0; i<count; i++)
202 target[ this->GetOffset( formats[i] ) ]+=val;
208 if( this->m_GpuContext ==
nullptr)
210 mitkThrow() <<
"No GPU context was set! Use SetGPUContext() before calling this method!";
213 const unsigned int entries = 100;
214 cl_image_format* formats =
new cl_image_format[entries];
220 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, entries, formats, &written);
223 this->SortFormats( formats, written, 1 );
227 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE2D, entries, formats, &written);
230 this->SortFormats( formats, written, 2 );
234 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_WRITE_ONLY, CL_MEM_OBJECT_IMAGE2D, entries, formats, &written);
237 this->SortFormats( formats, written, 4 );
243 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE3D, entries, formats, &written);
246 this->SortFormats( formats, written, 1, 3 );
250 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE3D, entries, formats, &written);
253 this->SortFormats( formats, written, 2, 3 );
257 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_WRITE_ONLY, CL_MEM_OBJECT_IMAGE3D, entries, formats, &written);
260 this->SortFormats( formats, written, 4, 3 );
#define CHECK_OCL_ERR(_er)
Follow Up Storage - Class to facilitate loading/accessing structured follow-up data.