20 :m_Image2DSupport( NULL ), m_Image3DSupport( NULL ),
26 this->m_Image2DSupport =
new unsigned char[matrixSize];
27 this->m_Image3DSupport =
new unsigned char[matrixSize];
29 for(
unsigned int i = 0; i<matrixSize; i++ )
31 this->m_Image2DSupport[i] = 0;
32 this->m_Image3DSupport[i] = 0;
40 void mitk::OclImageFormats::PrintSelf()
42 std::stringstream outputstream;
43 outputstream <<
"Values: Read-Write(1) ReadOnly(2) , WriteOnly(4) \n";
44 outputstream <<
"ROWS: [CL_A, CL_R, CL_RA, CL_RG, CL_RGB, CL_RGBA, CL_ARGB, CL_BGRA, CL_LUM, CL_INT] \n";
48 for(
unsigned int i = 0; i<matrixSize; i++ )
50 outputstream << (int) this->m_Image2DSupport[i] <<
", \t";
51 if( (i+1) % MAX_DATA_TYPES == 0 )
52 outputstream <<
" \n";
54 outputstream <<
"========================== \n";
56 for(
unsigned int i = 0; i<matrixSize; i++ )
58 outputstream << (int) this->m_Image3DSupport[i] <<
", \t";
59 if( (i+1) % MAX_DATA_TYPES == 0 )
60 outputstream <<
" \n";
65 unsigned int mitk::OclImageFormats::GetOffset(cl_image_format format)
70 switch( format.image_channel_order )
103 switch ( format.image_channel_data_type )
119 case CL_SIGNED_INT16:
122 case CL_SIGNED_INT32:
125 case CL_UNSIGNED_INT8:
128 case CL_UNSIGNED_INT16:
131 case CL_UNSIGNED_INT32:
151 if ( this->m_Image2DSupport[ GetOffset(*format)] > 4 )
159 bool returnValue =
false;
162 outputformat->image_channel_data_type = inputformat->image_channel_data_type;
163 outputformat->image_channel_order = inputformat->image_channel_order;
166 if( this->IsFormatSupported(inputformat) )
175 cl_image_format
test;
176 test.image_channel_order = CL_RGBA;
177 test.image_channel_data_type = inputformat->image_channel_data_type;
179 if(this->IsFormatSupported( &test) )
181 outputformat->image_channel_order = CL_RGBA;
189 this->m_GpuContext = context;
191 this->CollectAvailableFormats();
194 void mitk::OclImageFormats::SortFormats(cl_image_format *formats, cl_uint count,
int val,
int dims)
197 unsigned char *target = this->m_Image2DSupport;
200 target = this->m_Image3DSupport;
203 for(
unsigned int i=0; i<count; i++)
206 target[ this->GetOffset( formats[i] ) ]+=val;
212 if( this->m_GpuContext == NULL)
214 mitkThrow() <<
"No GPU context was set! Use SetGPUContext() before calling this method!";
217 const unsigned int entries = 100;
218 cl_image_format* formats =
new cl_image_format[entries];
224 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, entries, formats, &written);
227 this->SortFormats( formats, written, 1 );
231 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE2D, entries, formats, &written);
234 this->SortFormats( formats, written, 2 );
238 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_WRITE_ONLY, CL_MEM_OBJECT_IMAGE2D, entries, formats, &written);
241 this->SortFormats( formats, written, 4 );
247 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE3D, entries, formats, &written);
250 this->SortFormats( formats, written, 1, 3 );
254 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE3D, entries, formats, &written);
257 this->SortFormats( formats, written, 2, 3 );
261 clErr = clGetSupportedImageFormats( m_GpuContext, CL_MEM_WRITE_ONLY, CL_MEM_OBJECT_IMAGE3D, entries, formats, &written);
264 this->SortFormats( formats, written, 4, 3 );
#define CHECK_OCL_ERR(_er)
Follow Up Storage - Class to facilitate loading/accessing structured follow-up data.