xref: /aosp_15_r20/external/OpenCL-CTS/test_conformance/images/clCopyImage/test_copy_2D_3D.cpp (revision 6467f958c7de8070b317fc65bcb0f6472e388d82)
1 //
2 // Copyright (c) 2017 The Khronos Group Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //    http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #include "../testBase.h"
17 #include "../common.h"
18 
19 extern int test_copy_image_generic( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
20                                    const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
21 
set_image_dimensions(image_descriptor * imageInfo,size_t width,size_t height,size_t depth,size_t rowPadding,size_t slicePadding)22 static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t depth, size_t rowPadding, size_t slicePadding )
23 {
24     size_t pixelSize = get_pixel_size( imageInfo->format );
25 
26     imageInfo->width = width;
27     imageInfo->height = height;
28     imageInfo->depth = depth;
29     imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
30 
31     if (gEnablePitch)
32     {
33         do {
34             rowPadding++;
35             imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
36         } while ((imageInfo->rowPitch % pixelSize) != 0);
37     }
38 
39     imageInfo->slicePitch = imageInfo->rowPitch * (imageInfo->height + slicePadding);
40 
41     if (depth == 0)
42         imageInfo->type = CL_MEM_OBJECT_IMAGE2D;
43     else
44         imageInfo->type = CL_MEM_OBJECT_IMAGE3D;
45 }
46 
47 
test_copy_image_size_2D_3D(cl_context context,cl_command_queue queue,image_descriptor * srcImageInfo,image_descriptor * dstImageInfo,MTdata d)48 int test_copy_image_size_2D_3D( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
49 {
50     size_t sourcePos[ 4 ] = { 0 }, destPos[ 4 ] = { 0 }, regionSize[ 3 ];
51     int ret = 0, retCode;
52 
53     image_descriptor *threeImage, *twoImage;
54 
55     if( srcImageInfo->depth > 0 )
56     {
57         threeImage = srcImageInfo;
58         twoImage = dstImageInfo;
59     }
60     else
61     {
62         threeImage = dstImageInfo;
63         twoImage = srcImageInfo;
64     }
65 
66     size_t twoImage_lod = 0, twoImage_width_lod = twoImage->width, twoImage_row_pitch_lod;
67     size_t twoImage_height_lod = twoImage->height;
68     size_t threeImage_lod = 0, threeImage_width_lod = threeImage->width, threeImage_row_pitch_lod, threeImage_slice_pitch_lod;
69     size_t threeImage_height_lod = threeImage->height, depth_lod = threeImage->depth;
70     size_t width_lod, height_lod;
71     size_t twoImage_max_mip_level,threeImage_max_mip_level;
72 
73     if( gTestMipmaps )
74     {
75         twoImage_max_mip_level = twoImage->num_mip_levels;
76         threeImage_max_mip_level = threeImage->num_mip_levels;
77         // Work at random mip levels
78         twoImage_lod = (size_t)random_in_range( 0, twoImage_max_mip_level ? twoImage_max_mip_level - 1 : 0, d );
79         threeImage_lod = (size_t)random_in_range( 0, threeImage_max_mip_level ? threeImage_max_mip_level - 1 : 0, d );
80         twoImage_width_lod = ( twoImage->width >> twoImage_lod )? ( twoImage->width >> twoImage_lod ) : 1;
81         threeImage_width_lod = ( threeImage->width >> threeImage_lod )? ( threeImage->width >> threeImage_lod ) : 1;
82         twoImage_height_lod = ( twoImage->height >> twoImage_lod )? ( twoImage->height >> twoImage_lod ) : 1;
83         threeImage_height_lod = ( threeImage->height >> threeImage_lod )? ( threeImage->height >> threeImage_lod ) : 1;
84         depth_lod = ( threeImage->depth >> threeImage_lod )? ( threeImage->depth >> threeImage_lod ) : 1;
85         twoImage_row_pitch_lod = twoImage_width_lod * get_pixel_size( twoImage->format );
86         threeImage_row_pitch_lod = threeImage_width_lod * get_pixel_size( threeImage->format );
87         threeImage_slice_pitch_lod = threeImage_height_lod * threeImage_row_pitch_lod;
88     }
89     width_lod  = ( twoImage_width_lod > threeImage_width_lod ) ? threeImage_width_lod : twoImage_width_lod;
90     height_lod  = ( twoImage_height_lod > threeImage_height_lod ) ? threeImage_height_lod : twoImage_height_lod;
91 
92     // First, try just a full covering region
93     sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = sourcePos[ 3 ] = 0;
94     destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = destPos[ 3 ] = 0;
95     regionSize[ 0 ] = width_lod;
96     regionSize[ 1 ] = height_lod;
97     regionSize[ 2 ] = 1;
98 
99     if( srcImageInfo->depth == 0 )
100     {
101         // 2D to 3D
102         destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->depth - 1, d );
103         if(gTestMipmaps)
104         {
105             destPos[ 2 ] = (size_t)random_in_range( 0, (int)depth_lod - 1, d );
106             sourcePos[ 2 ] = twoImage_lod;
107             destPos[ 3 ] = threeImage_lod;
108             regionSize[ 0 ] = width_lod;
109             regionSize[ 1 ] = height_lod;
110         }
111     }
112     else
113     {
114         // 3D to 2D
115         sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->depth - 1, d );
116         if(gTestMipmaps)
117         {
118             sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)depth_lod - 1, d );
119             sourcePos[ 3 ] = threeImage_lod;
120             destPos[ 2 ] = twoImage_lod;
121             regionSize[ 0 ] = width_lod;
122             regionSize[ 1 ] = height_lod;
123         }
124     }
125 
126     retCode = test_copy_image_generic( context, queue, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
127     if( retCode < 0 )
128         return retCode;
129     else
130         ret += retCode;
131 
132     // Now try a sampling of different random regions
133     for( int i = 0; i < 8; i++ )
134     {
135         if( gTestMipmaps )
136         {
137             // Work at a random mip level
138             twoImage_lod = (size_t)random_in_range( 0, twoImage_max_mip_level ? twoImage_max_mip_level - 1 : 0, d );
139             threeImage_lod = (size_t)random_in_range( 0, threeImage_max_mip_level ? threeImage_max_mip_level - 1 : 0, d );
140             twoImage_width_lod = ( twoImage->width >> twoImage_lod )? ( twoImage->width >> twoImage_lod ) : 1;
141             threeImage_width_lod = ( threeImage->width >> threeImage_lod )? ( threeImage->width >> threeImage_lod ) : 1;
142             twoImage_height_lod = ( twoImage->height >> twoImage_lod )? ( twoImage->height >> twoImage_lod ) : 1;
143             threeImage_height_lod = ( threeImage->height >> threeImage_lod )? ( threeImage->height >> threeImage_lod ) : 1;
144             width_lod  = ( twoImage_width_lod > threeImage_width_lod ) ? threeImage_width_lod : twoImage_width_lod;
145             height_lod  = ( twoImage_height_lod > threeImage_height_lod ) ? threeImage_height_lod : twoImage_height_lod;
146             depth_lod = ( threeImage->depth >> threeImage_lod )? ( threeImage->depth >> threeImage_lod ) : 1;
147         }
148         // Pick a random size
149         regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
150         regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
151         if( gTestMipmaps )
152         {
153             regionSize[ 0 ] = ( width_lod > 8 ) ? random_in_range( 8, width_lod, d ) : width_lod;
154             regionSize[ 1 ] = ( height_lod > 8) ? random_in_range( 8, height_lod, d ): height_lod;
155         }
156 
157         // Now pick positions within valid ranges
158         sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
159         sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
160         sourcePos[ 2 ] = ( srcImageInfo->depth > 0 ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->depth - 1 ), d ) : 0;
161 
162         if (gTestMipmaps)
163         {
164             if( srcImageInfo->depth > 0 )
165             {
166                 sourcePos[ 0 ] = ( threeImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
167                 sourcePos[ 1 ] = ( threeImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
168                 sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)( depth_lod - 1 ), d );
169                 sourcePos[ 3 ] = threeImage_lod;
170             }
171             else
172             {
173                 sourcePos[ 0 ] = ( twoImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
174                 sourcePos[ 1 ] = ( twoImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
175 
176             }
177         }
178 
179         destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
180         destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
181         destPos[ 2 ] = ( dstImageInfo->depth > 0 ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->depth - 1 ), d ) : 0;
182 
183         if (gTestMipmaps)
184         {
185             if( dstImageInfo->depth > 0 )
186             {
187                 destPos[ 0 ] = ( threeImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
188                 destPos[ 1 ] = ( threeImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
189                 destPos[ 2 ] = (size_t)random_in_range( 0, (int)( depth_lod - 1 ), d );
190                 destPos[ 3 ] = threeImage_lod;
191             }
192             else
193             {
194                 destPos[ 0 ] = ( twoImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
195                 destPos[ 1 ] = ( twoImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
196 
197             }
198         }
199 
200         // Go for it!
201         retCode = test_copy_image_generic( context, queue, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
202         if( retCode < 0 )
203             return retCode;
204         else
205             ret += retCode;
206     }
207 
208     return ret;
209 }
210 
211 
test_copy_image_set_2D_3D(cl_device_id device,cl_context context,cl_command_queue queue,cl_image_format * format,bool reverse=false)212 int test_copy_image_set_2D_3D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, bool reverse = false )
213 {
214     size_t maxWidth, maxHeight, max3DWidth, max3DHeight, max3DDepth;
215     cl_ulong maxAllocSize, memSize;
216     image_descriptor srcImageInfo = { 0 };
217     image_descriptor dstImageInfo = { 0 };
218     RandomSeed  seed( gRandomSeed );
219 
220     srcImageInfo.format = dstImageInfo.format = format;
221 
222     int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
223     error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
224     error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( max3DWidth ), &max3DWidth, NULL );
225     error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( max3DHeight ), &max3DHeight, NULL );
226     error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof( max3DDepth ), &max3DDepth, NULL );
227     error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
228     error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
229     test_error( error, "Unable to get max image 2D or 3D size from device" );
230 
231     if (memSize > (cl_ulong)SIZE_MAX) {
232       memSize = (cl_ulong)SIZE_MAX;
233       maxAllocSize = (cl_ulong)SIZE_MAX;
234     }
235 
236     if( gTestSmallImages )
237     {
238         for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
239         {
240             for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
241             {
242                 for( dstImageInfo.depth = 4; dstImageInfo.depth < 9; dstImageInfo.depth++ )
243                 {
244                     size_t rowPadding = gEnablePitch ? 256 : 0;
245                     size_t slicePadding = gEnablePitch ? 3 : 0;
246 
247                     set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth, rowPadding, slicePadding );
248                     set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, 0, rowPadding, slicePadding );
249 
250                     if (gTestMipmaps)
251                     {
252                       srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed);
253                       srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D;
254                       dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth), seed);
255                       dstImageInfo.type = CL_MEM_OBJECT_IMAGE3D;
256                       srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format );
257                       srcImageInfo.slicePitch = 0;
258                       dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format );
259                       dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height;
260                     }
261 
262                     if( gDebugTrace )
263                         log_info( "   at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
264 
265                     int ret;
266                     if( reverse )
267                         ret = test_copy_image_size_2D_3D( context, queue, &dstImageInfo, &srcImageInfo, seed );
268                     else
269                         ret = test_copy_image_size_2D_3D( context, queue, &srcImageInfo, &dstImageInfo, seed );
270                     if( ret )
271                         return -1;
272                 }
273             }
274         }
275     }
276     else if( gTestMaxImages )
277     {
278         // Try a specific set of maximum sizes
279         size_t numberOfSizes3D, numberOfSizes2D;
280         size_t sizes3D[100][3], sizes2D[100][3];
281 
282         // Try to allocate a bit smaller images because we need the 2D ones as well for the copy.
283         get_max_sizes(&numberOfSizes3D, 100, sizes3D, max3DWidth, max3DHeight, max3DDepth, 1, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE3D, dstImageInfo.format);
284         get_max_sizes(&numberOfSizes2D, 100, sizes2D, maxWidth, maxHeight, 1, 1, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D, srcImageInfo.format);
285 
286         for( size_t i = 0; i < numberOfSizes2D; i++ )
287         for( size_t j = 0; j < numberOfSizes3D; j++ )
288         {
289             size_t rowPadding = gEnablePitch ? 256 : 0;
290             size_t slicePadding = gEnablePitch ? 3 : 0;
291 
292             set_image_dimensions( &dstImageInfo, sizes3D[ j ][ 0 ], sizes3D[ j ][ 1 ], sizes3D[ j ][ 2 ], rowPadding, slicePadding );
293             set_image_dimensions( &srcImageInfo, sizes2D[ i ][ 0 ], sizes2D[ i ][ 1 ], 0, rowPadding, slicePadding );
294             cl_ulong dstSize = get_image_size(&dstImageInfo);
295             cl_ulong srcSize = get_image_size(&srcImageInfo);
296 
297             if (gTestMipmaps)
298             {
299               srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed);
300               srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D;
301               dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth), seed);
302               dstImageInfo.type = CL_MEM_OBJECT_IMAGE3D;
303               srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format );
304               srcImageInfo.slicePitch = 0;
305               dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format );
306               dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height;
307               dstSize = 4 * compute_mipmapped_image_size( dstImageInfo );
308               srcSize = 4 * compute_mipmapped_image_size( srcImageInfo );
309             }
310 
311             if( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) && srcSize < maxAllocSize && srcSize < ( memSize / 3 ) )
312             {
313                 log_info( "Testing %d x %d to %d x %d x %d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
314                 if( gDebugTrace )
315                     log_info( "   at max size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
316                 int ret;
317                 if( reverse )
318                     ret = test_copy_image_size_2D_3D( context, queue, &dstImageInfo, &srcImageInfo, seed );
319                 else
320                     ret = test_copy_image_size_2D_3D( context, queue, &srcImageInfo, &dstImageInfo, seed );
321                 if( ret )
322                     return -1;
323             }
324             else
325             {
326                 log_info("Not testing max size %d x %d to %d x %d x %d due to memory constraints.\n",
327                          (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth);
328             }
329 
330         }
331     }
332     else
333     {
334         for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
335         {
336             cl_ulong srcSize, dstSize;
337             size_t rowPadding = gEnablePitch ? 256 : 0;
338             size_t slicePadding = gEnablePitch ? 3 : 0;
339 
340             // Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
341             // image, the result array, plus offset arrays, will fit in the global ram space
342             do
343             {
344                 dstImageInfo.width = (size_t)random_log_in_range( 16, (int)max3DWidth / 32, seed );
345                 dstImageInfo.height = (size_t)random_log_in_range( 16, (int)max3DHeight / 32, seed );
346                 dstImageInfo.depth = (size_t)random_log_in_range( 16, (int)max3DDepth / 32, seed );
347                 srcImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
348                 srcImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
349 
350                 if (gTestMipmaps)
351                 {
352                     srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed);
353                     srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D;
354                     dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth), seed);
355                     dstImageInfo.type = CL_MEM_OBJECT_IMAGE3D;
356                     srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format );
357                     srcImageInfo.slicePitch = 0;
358                     dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format );
359                     dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height;
360                     srcSize = 4 * compute_mipmapped_image_size( srcImageInfo );
361                     dstSize = 4 * compute_mipmapped_image_size( dstImageInfo );
362                 }
363                 else
364                 {
365                     set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, 0, rowPadding, slicePadding );
366                     set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth, rowPadding, slicePadding );
367 
368                     srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4;
369                     dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.depth * 4;
370                 }
371             } while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize);
372 
373             if( gDebugTrace )
374                 log_info( "   at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth );
375             int ret;
376             if( reverse )
377                 ret = test_copy_image_size_2D_3D( context, queue, &dstImageInfo, &srcImageInfo, seed );
378             else
379                 ret = test_copy_image_size_2D_3D( context, queue, &srcImageInfo, &dstImageInfo, seed );
380             if( ret )
381                 return -1;
382         }
383     }
384 
385     return 0;
386 }
387