MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCL-CTS / REGISTER_TEST

Function REGISTER_TEST

test_conformance/basic/test_image_param.cpp:162–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162REGISTER_TEST(image_param)
163{
164 size_t sizes[] = { 64, 100, 128, 250, 512 };
165 cl_image_format formats[] = { { CL_RGBA, CL_UNORM_INT8 }, { CL_RGBA, CL_UNORM_INT16 }, { CL_RGBA, CL_FLOAT }, { CL_BGRA, CL_UNORM_INT8 } };
166 cl_image_format *supported_formats;
167 ExplicitType types[] = { kUChar, kUShort, kFloat, kUChar };
168 int error;
169 size_t i, j, idx;
170 size_t threads[ 2 ];
171 MTdata d;
172 int supportsBGRA = 0;
173 cl_uint numSupportedFormats = 0;
174
175 const size_t numSizes = sizeof( sizes ) / sizeof( sizes[ 0 ] );
176 const size_t numFormats = sizeof( formats ) / sizeof( formats[ 0 ] );
177 const size_t numAttempts = numSizes * numFormats;
178
179
180 clProgramWrapper program;
181 clKernelWrapper kernel;
182 clMemWrapper streams[ numAttempts ][ 2 ];
183 BufferOwningPtr<char> inputs[ numAttempts ];
184
185 PASSIVE_REQUIRE_IMAGE_SUPPORT( device )
186
187 if(gIsEmbedded)
188 {
189 /* Get the supported image formats to see if BGRA is supported */
190 clGetSupportedImageFormats (context, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, 0, NULL, &numSupportedFormats);
191 supported_formats = (cl_image_format *) malloc(sizeof(cl_image_format) * numSupportedFormats);
192 clGetSupportedImageFormats (context, CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, numFormats, supported_formats, NULL);
193
194 for(i = 0; i < numSupportedFormats; i++)
195 {
196 if(supported_formats[i].image_channel_order == CL_BGRA)
197 {
198 supportsBGRA = 1;
199 break;
200 }
201 }
202 }
203 else
204 {
205 supportsBGRA = 1;
206 }
207
208 d = init_genrand( gRandomSeed );
209 for( i = 0, idx = 0; i < numSizes; i++ )
210 {
211 for( j = 0; j < numFormats; j++, idx++ )
212 {
213 if(formats[j].image_channel_order == CL_BGRA && !supportsBGRA)
214 continue;
215
216 // For each attempt, we create a pair: an input image, whose parameters keep changing, and an output buffer
217 // that we can read values from. The output buffer will remain consistent to ensure that any changes we
218 // witness are due to the image changes
219 inputs[ idx ].reset(create_random_data( types[ j ], d, sizes[ i ] * sizes[ i ] * 4 ));

Callers

nothing calls this directly

Calls 9

init_genrandFunction · 0.85
create_random_dataFunction · 0.85
create_image_2dFunction · 0.85
GetChannelOrderNameFunction · 0.85
GetChannelTypeNameFunction · 0.85
free_mtdataFunction · 0.85
validate_resultsFunction · 0.85
resetMethod · 0.45

Tested by

no test coverage detected