| 160 | } |
| 161 | |
| 162 | REGISTER_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 )); |
nothing calls this directly
no test coverage detected