diff --git a/test_common/harness/imageHelpers.h b/test_common/harness/imageHelpers.h index d49f358e..1de416c3 100644 --- a/test_common/harness/imageHelpers.h +++ b/test_common/harness/imageHelpers.h @@ -126,6 +126,7 @@ typedef struct const cl_image_format *format; cl_mem buffer; cl_mem_object_type type; + cl_mem_flags mem_flags; cl_uint num_mip_levels; } image_descriptor; diff --git a/test_conformance/images/clCopyImage/test_copy_1D.cpp b/test_conformance/images/clCopyImage/test_copy_1D.cpp index 7d13eaab..9d075ac0 100644 --- a/test_conformance/images/clCopyImage/test_copy_1D.cpp +++ b/test_conformance/images/clCopyImage/test_copy_1D.cpp @@ -18,32 +18,41 @@ extern int test_copy_image_generic( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d ); -int test_copy_image_size_1D( cl_context context, cl_command_queue queue, image_descriptor *imageInfo, MTdata d ) +int test_copy_image_size_1D(cl_context context, cl_command_queue queue, + image_descriptor *srcImageInfo, + image_descriptor *dstImageInfo, MTdata d) { size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ]; int ret = 0, retCode; - size_t src_lod = 0, src_width_lod = imageInfo->width, src_row_pitch_lod; - size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_row_pitch_lod; - size_t width_lod = imageInfo->width; - size_t max_mip_level = 0; + size_t src_lod = 0, src_width_lod = srcImageInfo->width, src_row_pitch_lod; + size_t dst_lod = 0, dst_width_lod = srcImageInfo->width, dst_row_pitch_lod; + size_t width_lod = srcImageInfo->width; + size_t max_mip_level = 0; - if( gTestMipmaps ) - { - max_mip_level = imageInfo->num_mip_levels; - // Work at a random mip level - src_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); - dst_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); - src_width_lod = ( imageInfo->width >> src_lod )? ( imageInfo->width >> src_lod ) : 1; - dst_width_lod = ( imageInfo->width >> dst_lod )? ( imageInfo->width >> dst_lod ) : 1; - width_lod = ( src_width_lod > dst_width_lod ) ? dst_width_lod : src_width_lod; - src_row_pitch_lod = src_width_lod * get_pixel_size( imageInfo->format ); - dst_row_pitch_lod = dst_width_lod * get_pixel_size( imageInfo->format ); - } + if (gTestMipmaps) + { + max_mip_level = srcImageInfo->num_mip_levels; + // Work at a random mip level + src_lod = + (size_t)random_in_range(0, max_mip_level ? max_mip_level - 1 : 0, d); + dst_lod = + (size_t)random_in_range(0, max_mip_level ? max_mip_level - 1 : 0, d); + src_width_lod = (srcImageInfo->width >> src_lod) + ? (srcImageInfo->width >> src_lod) + : 1; + dst_width_lod = (dstImageInfo->width >> dst_lod) + ? (dstImageInfo->width >> dst_lod) + : 1; + width_lod = + (src_width_lod > dst_width_lod) ? dst_width_lod : src_width_lod; + src_row_pitch_lod = src_width_lod * get_pixel_size(srcImageInfo->format); + dst_row_pitch_lod = dst_width_lod * get_pixel_size(dstImageInfo->format); + } // First, try just a full covering region sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0; destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0; - regionSize[ 0 ] = imageInfo->width; + regionSize[0] = dstImageInfo->width; regionSize[ 1 ] = 1; regionSize[ 2 ] = 1; @@ -54,7 +63,9 @@ int test_copy_image_size_1D( cl_context context, cl_command_queue queue, image_d regionSize[ 0 ] = width_lod; } - retCode = test_copy_image_generic( context, queue, imageInfo, imageInfo, sourcePos, destPos, regionSize, d ); + retCode = + test_copy_image_generic(context, queue, srcImageInfo, dstImageInfo, + sourcePos, destPos, regionSize, d); if( retCode < 0 ) return retCode; else @@ -68,8 +79,12 @@ int test_copy_image_size_1D( cl_context context, cl_command_queue queue, image_d // Work at a random mip level src_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); dst_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); - src_width_lod = ( imageInfo->width >> src_lod )? ( imageInfo->width >> src_lod ) : 1; - dst_width_lod = ( imageInfo->width >> dst_lod )? ( imageInfo->width >> dst_lod ) : 1; + src_width_lod = (srcImageInfo->width >> src_lod) + ? (srcImageInfo->width >> src_lod) + : 1; + dst_width_lod = (dstImageInfo->width >> dst_lod) + ? (dstImageInfo->width >> dst_lod) + : 1; width_lod = ( src_width_lod > dst_width_lod ) ? dst_width_lod : src_width_lod; sourcePos[ 1 ] = src_lod; destPos[ 1 ] = dst_lod; @@ -83,7 +98,9 @@ int test_copy_image_size_1D( cl_context context, cl_command_queue queue, image_d // Go for it! - retCode = test_copy_image_generic( context, queue, imageInfo, imageInfo, sourcePos, destPos, regionSize, d ); + retCode = + test_copy_image_generic(context, queue, srcImageInfo, dstImageInfo, + sourcePos, destPos, regionSize, d); if( retCode < 0 ) return retCode; else @@ -93,18 +110,25 @@ int test_copy_image_size_1D( cl_context context, cl_command_queue queue, image_d return ret; } -int test_copy_image_set_1D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format ) +int test_copy_image_set_1D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_mem_flags src_flags, + cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format) { + assert(dst_type == src_type); // This test expects to copy 1D -> 1D images size_t maxWidth; cl_ulong maxAllocSize, memSize; - image_descriptor imageInfo = { 0 }; + image_descriptor srcImageInfo = { 0 }; + image_descriptor dstImageInfo = { 0 }; RandomSeed seed(gRandomSeed); size_t pixelSize; - imageInfo.format = format; - imageInfo.height = imageInfo.depth = imageInfo.arraySize = imageInfo.slicePitch = 0; - imageInfo.type = CL_MEM_OBJECT_IMAGE1D; - pixelSize = get_pixel_size( imageInfo.format ); + srcImageInfo.format = format; + srcImageInfo.height = srcImageInfo.depth = srcImageInfo.arraySize = + srcImageInfo.slicePitch = 0; + srcImageInfo.type = src_type; + srcImageInfo.mem_flags = src_flags; + pixelSize = get_pixel_size(srcImageInfo.format); int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL ); @@ -118,28 +142,33 @@ int test_copy_image_set_1D( cl_device_id device, cl_context context, cl_command_ if( gTestSmallImages ) { - for( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ ) + for (srcImageInfo.width = 1; srcImageInfo.width < 13; + srcImageInfo.width++) { size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; - if (gTestMipmaps) - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, 0, 0), seed); + if (gTestMipmaps) + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, (int)compute_max_mip_levels(srcImageInfo.width, 0, 0), seed); - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } - if( gDebugTrace ) - log_info( " at size %d\n", (int)imageInfo.width ); + if (gDebugTrace) log_info(" at size %d\n", (int)srcImageInfo.width); - int ret = test_copy_image_size_1D( context, queue, &imageInfo, seed ); - if( ret ) - return -1; + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_size_1D(context, queue, &srcImageInfo, + &dstImageInfo, seed); + if (ret) return -1; } } else if( gTestMaxImages ) @@ -148,29 +177,37 @@ int test_copy_image_set_1D( cl_device_id device, cl_context context, cl_command_ size_t numbeOfSizes; size_t sizes[100][3]; - get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, 1, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE1D, imageInfo.format); + get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, 1, + maxAllocSize, memSize, src_type, srcImageInfo.format); for( size_t idx = 0; idx < numbeOfSizes; idx++ ) { size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.width = sizes[ idx ][ 0 ]; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.width = sizes[idx][0]; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; - if (gTestMipmaps) - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, 0, 0), seed); + if (gTestMipmaps) + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, (int)compute_max_mip_levels(srcImageInfo.width, 0, 0), seed); - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } log_info( "Testing %d\n", (int)sizes[ idx ][ 0 ] ); if( gDebugTrace ) log_info( " at max size %d\n", (int)sizes[ idx ][ 0 ] ); - if( test_copy_image_size_1D( context, queue, &imageInfo, seed ) ) + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + if (test_copy_image_size_1D(context, queue, &srcImageInfo, + &dstImageInfo, seed)) return -1; } } @@ -184,41 +221,52 @@ int test_copy_image_set_1D( cl_device_id device, cl_context context, cl_command_ // image, the result array, plus offset arrays, will fit in the global ram space do { - imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed ); + srcImageInfo.width = + (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); - if (gTestMipmaps) - { - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, 0, 0), seed); - imageInfo.rowPitch = imageInfo.width * get_pixel_size( imageInfo.format ); - size = compute_mipmapped_image_size( imageInfo ); - size = size*4; - } + if (gTestMipmaps) + { + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, 0, 0), + seed); + srcImageInfo.rowPitch = srcImageInfo.width + * get_pixel_size(srcImageInfo.format); + size = compute_mipmapped_image_size(srcImageInfo); + size = size * 4; + } else { - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } - size = (size_t)imageInfo.rowPitch * 4; + size = (size_t)srcImageInfo.rowPitch * 4; } } while( size > maxAllocSize || ( size * 3 ) > memSize ); if( gDebugTrace ) { - log_info( " at size %d (row pitch %d) out of %d\n", (int)imageInfo.width, (int)imageInfo.rowPitch, (int)maxWidth ); - if ( gTestMipmaps ) - log_info(" and %u mip levels\n", imageInfo.num_mip_levels); + log_info(" at size %d (row pitch %d) out of %d\n", + (int)srcImageInfo.width, (int)srcImageInfo.rowPitch, + (int)maxWidth); + if (gTestMipmaps) + log_info(" and %zu mip levels\n", + (size_t)srcImageInfo.num_mip_levels); } - - int ret = test_copy_image_size_1D( context, queue, &imageInfo, seed ); - if( ret ) - return -1; + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_size_1D(context, queue, &srcImageInfo, + &dstImageInfo, seed); + if (ret) return -1; } } diff --git a/test_conformance/images/clCopyImage/test_copy_1D_array.cpp b/test_conformance/images/clCopyImage/test_copy_1D_array.cpp index d94ba8ef..78ab903e 100644 --- a/test_conformance/images/clCopyImage/test_copy_1D_array.cpp +++ b/test_conformance/images/clCopyImage/test_copy_1D_array.cpp @@ -18,33 +18,41 @@ extern int test_copy_image_generic( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d ); -int test_copy_image_size_1D_array( cl_context context, cl_command_queue queue, image_descriptor *imageInfo, MTdata d ) +int test_copy_image_size_1D_array(cl_context context, cl_command_queue queue, + image_descriptor *srcImageInfo, + image_descriptor *dstImageInfo, MTdata d) { size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ]; int ret = 0, retCode; - size_t src_lod = 0, src_width_lod = imageInfo->width, src_row_pitch_lod; - size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_row_pitch_lod; - size_t width_lod = imageInfo->width; + size_t src_lod = 0, src_width_lod = srcImageInfo->width, src_row_pitch_lod; + size_t dst_lod = 0, dst_width_lod = dstImageInfo->width, dst_row_pitch_lod; + size_t width_lod = srcImageInfo->width; size_t max_mip_level = 0; if( gTestMipmaps ) { - max_mip_level = imageInfo->num_mip_levels; + max_mip_level = srcImageInfo->num_mip_levels; // Work at a random mip level src_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); dst_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); - src_width_lod = ( imageInfo->width >> src_lod )? ( imageInfo->width >> src_lod ) : 1; - dst_width_lod = ( imageInfo->width >> dst_lod )? ( imageInfo->width >> dst_lod ) : 1; + src_width_lod = (srcImageInfo->width >> src_lod) + ? (srcImageInfo->width >> src_lod) + : 1; + dst_width_lod = (dstImageInfo->width >> dst_lod) + ? (dstImageInfo->width >> dst_lod) + : 1; width_lod = ( src_width_lod > dst_width_lod ) ? dst_width_lod : src_width_lod; - src_row_pitch_lod = src_width_lod * get_pixel_size( imageInfo->format ); - dst_row_pitch_lod = dst_width_lod * get_pixel_size( imageInfo->format ); + src_row_pitch_lod = + src_width_lod * get_pixel_size(srcImageInfo->format); + dst_row_pitch_lod = + dst_width_lod * get_pixel_size(dstImageInfo->format); } // First, try just a full covering region sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0; destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0; - regionSize[ 0 ] = imageInfo->width; - regionSize[ 1 ] = imageInfo->arraySize; + regionSize[0] = srcImageInfo->width; + regionSize[1] = srcImageInfo->arraySize; regionSize[ 2 ] = 1; if(gTestMipmaps) @@ -54,7 +62,9 @@ int test_copy_image_size_1D_array( cl_context context, cl_command_queue queue, i regionSize[ 0 ] = width_lod; } - retCode = test_copy_image_generic( context, queue, imageInfo, imageInfo, sourcePos, destPos, regionSize, d ); + retCode = + test_copy_image_generic(context, queue, srcImageInfo, dstImageInfo, + sourcePos, destPos, regionSize, d); if( retCode < 0 ) return retCode; else @@ -68,27 +78,41 @@ int test_copy_image_size_1D_array( cl_context context, cl_command_queue queue, i // Work at a random mip level src_lod = (size_t) ( max_mip_level > 1 )? random_in_range( 0, max_mip_level - 1 , d ) : 0; dst_lod = (size_t) ( max_mip_level > 1 )? random_in_range( 0, max_mip_level - 1 , d ) : 0; - src_width_lod = ( imageInfo->width >> src_lod )? ( imageInfo->width >> src_lod ) : 1; - dst_width_lod = ( imageInfo->width >> dst_lod )? ( imageInfo->width >> dst_lod ) : 1; + src_width_lod = (srcImageInfo->width >> src_lod) + ? (srcImageInfo->width >> src_lod) + : 1; + dst_width_lod = (dstImageInfo->width >> dst_lod) + ? (dstImageInfo->width >> dst_lod) + : 1; width_lod = ( src_width_lod > dst_width_lod ) ? dst_width_lod : src_width_lod; sourcePos[ 2 ] = src_lod; destPos[ 2 ] = dst_lod; } // Pick a random size regionSize[ 0 ] = ( width_lod > 8 ) ? (size_t)random_in_range( 8, (int)width_lod - 1, d ) : (int)width_lod; - regionSize[ 1 ] = ( imageInfo->arraySize > 8 ) ? (size_t)random_in_range( 8, (int)imageInfo->arraySize - 1, d ) : imageInfo->arraySize; + regionSize[1] = (srcImageInfo->arraySize > 8) + ? (size_t)random_in_range(8, (int)srcImageInfo->arraySize - 1, d) + : srcImageInfo->arraySize; // Now pick positions within valid ranges sourcePos[ 0 ] = ( width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( width_lod - regionSize[ 0 ] - 1 ), d ) : 0; - sourcePos[ 1 ] = ( imageInfo->arraySize > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->arraySize - regionSize[ 1 ] - 1 ), d ) : 0; + sourcePos[1] = (srcImageInfo->arraySize > regionSize[1]) + ? (size_t)random_in_range( + 0, (int)(srcImageInfo->arraySize - regionSize[1] - 1), d) + : 0; destPos[ 0 ] = ( width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( width_lod - regionSize[ 0 ] - 1 ), d ) : 0; - destPos[ 1 ] = ( imageInfo->arraySize > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( imageInfo->arraySize - regionSize[ 1 ] - 1 ), d ) : 0; + destPos[1] = (dstImageInfo->arraySize > regionSize[1]) + ? (size_t)random_in_range( + 0, (int)(dstImageInfo->arraySize - regionSize[1] - 1), d) + : 0; // Go for it! - retCode = test_copy_image_generic( context, queue, imageInfo, imageInfo, sourcePos, destPos, regionSize, d ); + retCode = + test_copy_image_generic(context, queue, srcImageInfo, dstImageInfo, + sourcePos, destPos, regionSize, d); if( retCode < 0 ) return retCode; else @@ -98,17 +122,27 @@ int test_copy_image_size_1D_array( cl_context context, cl_command_queue queue, i return ret; } -int test_copy_image_set_1D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format ) +int test_copy_image_set_1D_array(cl_device_id device, cl_context context, + cl_command_queue queue, cl_mem_flags src_flags, + cl_mem_object_type src_type, + cl_mem_flags dst_flags, + cl_mem_object_type dst_type, + cl_image_format *format) { + assert( + dst_type + == src_type); // This test expects to copy 1D array -> 1D array images size_t maxWidth, maxArraySize; cl_ulong maxAllocSize, memSize; - image_descriptor imageInfo = { 0 }; + image_descriptor srcImageInfo = { 0 }; + image_descriptor dstImageInfo = { 0 }; RandomSeed seed(gRandomSeed); size_t pixelSize; - imageInfo.format = format; - imageInfo.type = CL_MEM_OBJECT_IMAGE1D_ARRAY; - pixelSize = get_pixel_size( imageInfo.format ); + srcImageInfo.format = format; + srcImageInfo.type = src_type; + srcImageInfo.mem_flags = src_flags; + pixelSize = get_pixel_size(srcImageInfo.format); int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, NULL ); @@ -123,33 +157,41 @@ int test_copy_image_set_1D_array( cl_device_id device, cl_context context, cl_co if( gTestSmallImages ) { - for( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ ) + for (srcImageInfo.width = 1; srcImageInfo.width < 13; + srcImageInfo.width++) { size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; - if (gTestMipmaps) - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, 0, 0), seed); + if (gTestMipmaps) + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, (int)compute_max_mip_levels(srcImageInfo.width, 0, 0), seed); - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } - imageInfo.slicePitch = imageInfo.rowPitch; - for( imageInfo.arraySize = 2; imageInfo.arraySize < 9; imageInfo.arraySize++ ) - { - if( gDebugTrace ) - log_info( " at size %d,%d\n", (int)imageInfo.width, (int)imageInfo.arraySize ); + srcImageInfo.slicePitch = srcImageInfo.rowPitch; + for (srcImageInfo.arraySize = 2; srcImageInfo.arraySize < 9; + srcImageInfo.arraySize++) + { + if (gDebugTrace) + log_info(" at size %d,%d\n", (int)srcImageInfo.width, + (int)srcImageInfo.arraySize); - int ret = test_copy_image_size_1D_array( context, queue, &imageInfo, seed ); - if( ret ) - return -1; - } + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_size_1D_array(context, queue, &srcImageInfo, + &dstImageInfo, seed); + if (ret) return -1; + } } } else if( gTestMaxImages ) @@ -158,33 +200,42 @@ int test_copy_image_set_1D_array( cl_device_id device, cl_context context, cl_co size_t numbeOfSizes; size_t sizes[100][3]; - get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, maxArraySize, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE1D_ARRAY, imageInfo.format); + get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, maxArraySize, + maxAllocSize, memSize, src_type, srcImageInfo.format); for( size_t idx = 0; idx < numbeOfSizes; idx++ ) { size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.width = sizes[ idx ][ 0 ]; - imageInfo.arraySize = sizes[ idx ][ 2 ]; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.width = sizes[idx][0]; + srcImageInfo.arraySize = sizes[idx][2]; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; - if (gTestMipmaps) - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, 0, 0), seed); + if (gTestMipmaps) + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, (int)compute_max_mip_levels(srcImageInfo.width, 0, 0), seed); - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } - imageInfo.slicePitch = imageInfo.rowPitch; - log_info( "Testing %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 2 ] ); - if( gDebugTrace ) - log_info( " at max size %d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 2 ] ); - if( test_copy_image_size_1D_array( context, queue, &imageInfo, seed ) ) - return -1; + srcImageInfo.slicePitch = srcImageInfo.rowPitch; + log_info("Testing %d x %d\n", (int)sizes[idx][0], (int)sizes[idx][2]); + if (gDebugTrace) + log_info(" at max size %d,%d\n", (int)sizes[idx][0], + (int)sizes[idx][2]); + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + if (test_copy_image_size_1D_array(context, queue, &srcImageInfo, + &dstImageInfo, seed)) + return -1; } } else @@ -197,39 +248,55 @@ int test_copy_image_set_1D_array( cl_device_id device, cl_context context, cl_co // image, the result array, plus offset arrays, will fit in the global ram space do { - imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed ); - imageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed ); - imageInfo.height = imageInfo.depth = 0; + srcImageInfo.width = + (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + srcImageInfo.arraySize = (size_t)random_log_in_range( + 16, (int)maxArraySize / 32, seed); + srcImageInfo.height = srcImageInfo.depth = 0; - if (gTestMipmaps) - { - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, 0, 0), seed); - imageInfo.rowPitch = imageInfo.width * get_pixel_size( imageInfo.format ); - imageInfo.slicePitch = imageInfo.rowPitch; - size = compute_mipmapped_image_size( imageInfo ); - size = size*4; - } + if (gTestMipmaps) + { + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, 0, 0), + seed); + srcImageInfo.rowPitch = srcImageInfo.width + * get_pixel_size(srcImageInfo.format); + srcImageInfo.slicePitch = srcImageInfo.rowPitch; + size = compute_mipmapped_image_size(srcImageInfo); + size = size * 4; + } else { - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } - imageInfo.slicePitch = imageInfo.rowPitch; + srcImageInfo.slicePitch = srcImageInfo.rowPitch; - size = (size_t)imageInfo.rowPitch * (size_t)imageInfo.arraySize * 4; + size = (size_t)srcImageInfo.rowPitch + * (size_t)srcImageInfo.arraySize * 4; } } while( size > maxAllocSize || ( size * 3 ) > memSize ); if( gDebugTrace ) - log_info( " at size %d,%d (row pitch %d) out of %d,%d\n", (int)imageInfo.width, (int)imageInfo.arraySize, (int)imageInfo.rowPitch, (int)maxWidth, (int)maxArraySize ); - int ret = test_copy_image_size_1D_array( context, queue, &imageInfo, seed ); + log_info(" at size %d,%d (row pitch %d) out of %d,%d\n", + (int)srcImageInfo.width, (int)srcImageInfo.arraySize, + (int)srcImageInfo.rowPitch, (int)maxWidth, + (int)maxArraySize); + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_size_1D_array(context, queue, &srcImageInfo, + &dstImageInfo, seed); if( ret ) return -1; } diff --git a/test_conformance/images/clCopyImage/test_copy_1D_buffer.cpp b/test_conformance/images/clCopyImage/test_copy_1D_buffer.cpp index f74e60a9..07c86ccc 100644 --- a/test_conformance/images/clCopyImage/test_copy_1D_buffer.cpp +++ b/test_conformance/images/clCopyImage/test_copy_1D_buffer.cpp @@ -75,13 +75,18 @@ int test_copy_image_size_1D_buffer(cl_context context, cl_command_queue queue, return ret; } -int test_copy_image_set_1D_buffer(cl_device_id device, cl_context context, - cl_command_queue queue, - cl_image_format *format) +int test_copy_image_set_1D_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + cl_mem_flags src_flags, cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format) { + assert( + dst_type + == src_type); // This test expects to copy 1D buffer -> 1D buffer images size_t maxWidth; cl_ulong maxAllocSize, memSize; - image_descriptor imageInfo = { 0 }; + image_descriptor srcImageInfo = { 0 }; + image_descriptor dstImageInfo = { 0 }; RandomSeed seed(gRandomSeed); size_t pixelSize; @@ -92,11 +97,12 @@ int test_copy_image_set_1D_buffer(cl_device_id device, cl_context context, return 0; } - imageInfo.format = format; - imageInfo.height = imageInfo.depth = imageInfo.arraySize = - imageInfo.slicePitch = 0; - imageInfo.type = CL_MEM_OBJECT_IMAGE1D_BUFFER; - pixelSize = get_pixel_size(imageInfo.format); + srcImageInfo.format = format; + srcImageInfo.height = srcImageInfo.depth = srcImageInfo.arraySize = + srcImageInfo.slicePitch = 0; + srcImageInfo.type = src_type; + srcImageInfo.mem_flags = src_flags; + pixelSize = get_pixel_size(srcImageInfo.format); int error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, sizeof(maxWidth), &maxWidth, NULL); @@ -114,168 +120,29 @@ int test_copy_image_set_1D_buffer(cl_device_id device, cl_context context, if (gTestSmallImages) { - for (imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++) + for (srcImageInfo.width = 1; srcImageInfo.width < 13; + srcImageInfo.width++) { size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; if (gEnablePitch) { do { rowPadding++; - imageInfo.rowPitch = - imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); } - if (gDebugTrace) log_info(" at size %d\n", (int)imageInfo.width); - - int ret = test_copy_image_size_1D_buffer(context, queue, &imageInfo, - &imageInfo, seed); - if (ret) return -1; - } - } - else if (gTestMaxImages) - { - // Try a specific set of maximum sizes - size_t numbeOfSizes; - size_t sizes[100][3]; - - get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, 1, - maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE1D_BUFFER, - imageInfo.format); - - for (size_t idx = 0; idx < numbeOfSizes; idx++) - { - size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.width = sizes[idx][0]; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - - if (gEnablePitch) - { - do - { - rowPadding++; - imageInfo.rowPitch = - imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } - - log_info("Testing %d\n", (int)sizes[idx][0]); - if (gDebugTrace) - log_info(" at max size %d\n", (int)sizes[idx][0]); - if (test_copy_image_size_1D_buffer(context, queue, &imageInfo, - &imageInfo, seed)) - return -1; - } - } - else - { - for (int i = 0; i < NUM_IMAGE_ITERATIONS; i++) - { - cl_ulong size; - size_t rowPadding = gEnablePitch ? 48 : 0; - // Loop until we get a size that a) will fit in the max alloc size - // and b) that an allocation of that image, the result array, plus - // offset arrays, will fit in the global ram space - do - { - imageInfo.width = - (size_t)random_log_in_range(16, (int)(maxWidth / 32), seed); - - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - - if (gEnablePitch) - { - do - { - rowPadding++; - imageInfo.rowPitch = - imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } - - size = (size_t)imageInfo.rowPitch * 4; - } while (size > maxAllocSize || (size * 3) > memSize); - if (gDebugTrace) - { - log_info(" at size %d (row pitch %d) out of %d\n", - (int)imageInfo.width, (int)imageInfo.rowPitch, - (int)maxWidth); - } - - int ret = test_copy_image_size_1D_buffer(context, queue, &imageInfo, - &imageInfo, seed); - if (ret) return -1; - } - } - - return 0; -} - -int test_copy_image_set_1D_1D_buffer(cl_device_id device, cl_context context, - cl_command_queue queue, - cl_image_format *format) -{ - size_t maxWidth; - cl_ulong maxAllocSize, memSize; - image_descriptor imageInfo = { 0 }; - RandomSeed seed(gRandomSeed); - size_t pixelSize; - - if (gTestMipmaps) - { - // 1D image buffers don't support mipmaps - // https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_mipmap_image - return 0; - } - - imageInfo.format = format; - imageInfo.height = imageInfo.depth = imageInfo.arraySize = - imageInfo.slicePitch = 0; - imageInfo.type = CL_MEM_OBJECT_IMAGE1D_BUFFER; - pixelSize = get_pixel_size(imageInfo.format); - - int error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH, - sizeof(maxWidth), &maxWidth, NULL); - error |= clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, - sizeof(maxAllocSize), &maxAllocSize, NULL); - error |= clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(memSize), - &memSize, NULL); - test_error(error, "Unable to get max image 1D buffer size from device"); - - if (memSize > (cl_ulong)SIZE_MAX) - { - memSize = (cl_ulong)SIZE_MAX; - maxAllocSize = (cl_ulong)SIZE_MAX; - } - - if (gTestSmallImages) - { - for (imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++) - { - size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - - if (gEnablePitch) - { - do - { - rowPadding++; - imageInfo.rowPitch = - imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } - - if (gDebugTrace) log_info(" at size %d\n", (int)imageInfo.width); - - image_descriptor srcImageInfo = imageInfo; - srcImageInfo.type = CL_MEM_OBJECT_IMAGE1D; + log_info(" at size %d\n", (int)srcImageInfo.width); + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; int ret = test_copy_image_size_1D_buffer( - context, queue, &srcImageInfo, &imageInfo, seed); + context, queue, &srcImageInfo, &dstImageInfo, seed); if (ret) return -1; } } @@ -286,183 +153,31 @@ int test_copy_image_set_1D_1D_buffer(cl_device_id device, cl_context context, size_t sizes[100][3]; get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, 1, - maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE1D_BUFFER, - imageInfo.format); + maxAllocSize, memSize, src_type, srcImageInfo.format); for (size_t idx = 0; idx < numbeOfSizes; idx++) { size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.width = sizes[idx][0]; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.width = sizes[idx][0]; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; if (gEnablePitch) { do { rowPadding++; - imageInfo.rowPitch = - imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); } log_info("Testing %d\n", (int)sizes[idx][0]); if (gDebugTrace) log_info(" at max size %d\n", (int)sizes[idx][0]); - image_descriptor srcImageInfo = imageInfo; - srcImageInfo.type = CL_MEM_OBJECT_IMAGE1D; - + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; if (test_copy_image_size_1D_buffer(context, queue, &srcImageInfo, - &imageInfo, seed)) - return -1; - } - } - else - { - for (int i = 0; i < NUM_IMAGE_ITERATIONS; i++) - { - cl_ulong size; - size_t rowPadding = gEnablePitch ? 48 : 0; - // Loop until we get a size that a) will fit in the max alloc size - // and b) that an allocation of that image, the result array, plus - // offset arrays, will fit in the global ram space - do - { - imageInfo.width = - (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); - - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - - if (gEnablePitch) - { - do - { - rowPadding++; - imageInfo.rowPitch = - imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } - - size = (size_t)imageInfo.rowPitch * 4; - } while (size > maxAllocSize || (size * 3) > memSize); - - if (gDebugTrace) - { - log_info(" at size %d (row pitch %d) out of %d\n", - (int)imageInfo.width, (int)imageInfo.rowPitch, - (int)maxWidth); - } - - image_descriptor srcImageInfo = imageInfo; - srcImageInfo.type = CL_MEM_OBJECT_IMAGE1D; - - int ret = test_copy_image_size_1D_buffer( - context, queue, &srcImageInfo, &imageInfo, seed); - if (ret) return -1; - } - } - - return 0; -} - -int test_copy_image_set_1D_buffer_1D(cl_device_id device, cl_context context, - cl_command_queue queue, - cl_image_format *format) -{ - size_t maxWidth; - cl_ulong maxAllocSize, memSize; - image_descriptor imageInfo = { 0 }; - RandomSeed seed(gRandomSeed); - size_t pixelSize; - - if (gTestMipmaps) - { - // 1D image buffers don't support mipmaps - // https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_mipmap_image - return 0; - } - - imageInfo.format = format; - imageInfo.height = imageInfo.depth = imageInfo.arraySize = - imageInfo.slicePitch = 0; - imageInfo.type = CL_MEM_OBJECT_IMAGE1D_BUFFER; - pixelSize = get_pixel_size(imageInfo.format); - - int error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH, - sizeof(maxWidth), &maxWidth, NULL); - error |= clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, - sizeof(maxAllocSize), &maxAllocSize, NULL); - error |= clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(memSize), - &memSize, NULL); - test_error(error, "Unable to get max image 1D buffer size from device"); - - if (memSize > (cl_ulong)SIZE_MAX) - { - memSize = (cl_ulong)SIZE_MAX; - maxAllocSize = (cl_ulong)SIZE_MAX; - } - - if (gTestSmallImages) - { - for (imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++) - { - size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - - if (gEnablePitch) - { - do - { - rowPadding++; - imageInfo.rowPitch = - imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } - - if (gDebugTrace) log_info(" at size %d\n", (int)imageInfo.width); - - image_descriptor dstImageInfo = imageInfo; - dstImageInfo.type = CL_MEM_OBJECT_IMAGE1D; - - int ret = test_copy_image_size_1D_buffer(context, queue, &imageInfo, - &dstImageInfo, seed); - if (ret) return -1; - } - } - else if (gTestMaxImages) - { - // Try a specific set of maximum sizes - size_t numbeOfSizes; - size_t sizes[100][3]; - - get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, 1, - maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE1D_BUFFER, - imageInfo.format); - - for (size_t idx = 0; idx < numbeOfSizes; idx++) - { - size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.width = sizes[idx][0]; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - - if (gEnablePitch) - { - do - { - rowPadding++; - imageInfo.rowPitch = - imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } - - log_info("Testing %d\n", (int)sizes[idx][0]); - if (gDebugTrace) - log_info(" at max size %d\n", (int)sizes[idx][0]); - - image_descriptor dstImageInfo = imageInfo; - dstImageInfo.type = CL_MEM_OBJECT_IMAGE1D; - - if (test_copy_image_size_1D_buffer(context, queue, &imageInfo, &dstImageInfo, seed)) return -1; } @@ -478,36 +193,194 @@ int test_copy_image_set_1D_buffer_1D(cl_device_id device, cl_context context, // offset arrays, will fit in the global ram space do { - imageInfo.width = + srcImageInfo.width = (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; if (gEnablePitch) { do { rowPadding++; - imageInfo.rowPitch = - imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); } - size = (size_t)imageInfo.rowPitch * 4; + size = (size_t)srcImageInfo.rowPitch * 4; } while (size > maxAllocSize || (size * 3) > memSize); if (gDebugTrace) { log_info(" at size %d (row pitch %d) out of %d\n", - (int)imageInfo.width, (int)imageInfo.rowPitch, + (int)srcImageInfo.width, (int)srcImageInfo.rowPitch, (int)maxWidth); } - image_descriptor dstImageInfo = imageInfo; - dstImageInfo.type = CL_MEM_OBJECT_IMAGE1D; - - int ret = test_copy_image_size_1D_buffer(context, queue, &imageInfo, - &dstImageInfo, seed); + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_size_1D_buffer( + context, queue, &srcImageInfo, &dstImageInfo, seed); + if (ret) return -1; + } + } + + return 0; +} + +int test_copy_image_set_1D_1D_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + cl_mem_flags src_flags, cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format) +{ + size_t maxWidth; + cl_ulong maxAllocSize, memSize; + image_descriptor srcImageInfo = { 0 }; + image_descriptor dstImageInfo = { 0 }; + RandomSeed seed(gRandomSeed); + size_t pixelSize; + + if (gTestMipmaps) + { + // 1D image buffers don't support mipmaps + // https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_mipmap_image + return 0; + } + + srcImageInfo.format = format; + srcImageInfo.height = srcImageInfo.depth = srcImageInfo.arraySize = + srcImageInfo.slicePitch = 0; + srcImageInfo.type = src_type; + srcImageInfo.mem_flags = src_flags; + pixelSize = get_pixel_size(srcImageInfo.format); + + int error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH, + sizeof(maxWidth), &maxWidth, NULL); + error |= clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, + sizeof(maxAllocSize), &maxAllocSize, NULL); + error |= clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(memSize), + &memSize, NULL); + test_error(error, "Unable to get max image 1D buffer size from device"); + + if (memSize > (cl_ulong)SIZE_MAX) + { + memSize = (cl_ulong)SIZE_MAX; + maxAllocSize = (cl_ulong)SIZE_MAX; + } + + if (gTestSmallImages) + { + for (srcImageInfo.width = 1; srcImageInfo.width < 13; + srcImageInfo.width++) + { + size_t rowPadding = gEnablePitch ? 48 : 0; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; + + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } + + if (gDebugTrace) + log_info(" at size %d\n", (int)srcImageInfo.width); + + dstImageInfo = srcImageInfo; + dstImageInfo.type = dst_type; + dstImageInfo.mem_flags = dst_flags; + + int ret = test_copy_image_size_1D_buffer( + context, queue, &srcImageInfo, &dstImageInfo, seed); + if (ret) return -1; + } + } + else if (gTestMaxImages) + { + // Try a specific set of maximum sizes + size_t numbeOfSizes; + size_t sizes[100][3]; + + get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, 1, 1, 1, + maxAllocSize, memSize, src_type, srcImageInfo.format); + + for (size_t idx = 0; idx < numbeOfSizes; idx++) + { + size_t rowPadding = gEnablePitch ? 48 : 0; + srcImageInfo.width = sizes[idx][0]; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; + + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } + + log_info("Testing %d\n", (int)sizes[idx][0]); + if (gDebugTrace) + log_info(" at max size %d\n", (int)sizes[idx][0]); + + dstImageInfo = srcImageInfo; + dstImageInfo.type = dst_type; + dstImageInfo.mem_flags = dst_flags; + + if (test_copy_image_size_1D_buffer(context, queue, &srcImageInfo, + &dstImageInfo, seed)) + return -1; + } + } + else + { + for (int i = 0; i < NUM_IMAGE_ITERATIONS; i++) + { + cl_ulong size; + size_t rowPadding = gEnablePitch ? 48 : 0; + // Loop until we get a size that a) will fit in the max alloc size + // and b) that an allocation of that image, the result array, plus + // offset arrays, will fit in the global ram space + do + { + srcImageInfo.width = + (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } + + size = (size_t)srcImageInfo.rowPitch * 4; + } while (size > maxAllocSize || (size * 3) > memSize); + + if (gDebugTrace) + { + log_info(" at size %d (row pitch %d) out of %d\n", + (int)srcImageInfo.width, (int)srcImageInfo.rowPitch, + (int)maxWidth); + } + + dstImageInfo = srcImageInfo; + dstImageInfo.type = dst_type; + dstImageInfo.mem_flags = dst_flags; + + int ret = test_copy_image_size_1D_buffer( + context, queue, &srcImageInfo, &dstImageInfo, seed); if (ret) return -1; } } diff --git a/test_conformance/images/clCopyImage/test_copy_2D.cpp b/test_conformance/images/clCopyImage/test_copy_2D.cpp index 97cca26c..b7808b80 100644 --- a/test_conformance/images/clCopyImage/test_copy_2D.cpp +++ b/test_conformance/images/clCopyImage/test_copy_2D.cpp @@ -18,38 +18,50 @@ extern int test_copy_image_generic( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d ); -int test_copy_image_size_2D( cl_context context, cl_command_queue queue, image_descriptor *imageInfo, MTdata d ) +int test_copy_image_size_2D(cl_context context, cl_command_queue queue, + image_descriptor *srcImageInfo, + image_descriptor *dstImageInfo, MTdata d) { size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ]; int ret = 0, retCode; - size_t src_lod = 0, src_width_lod = imageInfo->width, src_row_pitch_lod; - size_t src_height_lod = imageInfo->height; - size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_row_pitch_lod; - size_t dst_height_lod = imageInfo->height; - size_t width_lod = imageInfo->width, height_lod = imageInfo->height; + size_t src_lod = 0, src_width_lod = srcImageInfo->width, src_row_pitch_lod; + size_t src_height_lod = srcImageInfo->height; + size_t dst_lod = 0, dst_width_lod = dstImageInfo->width, dst_row_pitch_lod; + size_t dst_height_lod = dstImageInfo->height; + size_t width_lod = srcImageInfo->width, height_lod = srcImageInfo->height; size_t max_mip_level = 0; if( gTestMipmaps ) { - max_mip_level = imageInfo->num_mip_levels; + max_mip_level = srcImageInfo->num_mip_levels; // Work at a random mip level src_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); dst_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); - src_width_lod = ( imageInfo->width >> src_lod )? ( imageInfo->width >> src_lod ) : 1; - dst_width_lod = ( imageInfo->width >> dst_lod )? ( imageInfo->width >> dst_lod ) : 1; - src_height_lod = ( imageInfo->height >> src_lod )? ( imageInfo->height >> src_lod ) : 1; - dst_height_lod = ( imageInfo->height >> dst_lod )? ( imageInfo->height >> dst_lod ) : 1; + src_width_lod = (srcImageInfo->width >> src_lod) + ? (srcImageInfo->width >> src_lod) + : 1; + dst_width_lod = (dstImageInfo->width >> dst_lod) + ? (dstImageInfo->width >> dst_lod) + : 1; + src_height_lod = (srcImageInfo->height >> src_lod) + ? (srcImageInfo->height >> src_lod) + : 1; + dst_height_lod = (dstImageInfo->height >> dst_lod) + ? (dstImageInfo->height >> dst_lod) + : 1; width_lod = ( src_width_lod > dst_width_lod ) ? dst_width_lod : src_width_lod; height_lod = ( src_height_lod > dst_height_lod ) ? dst_height_lod : src_height_lod; - src_row_pitch_lod = src_width_lod * get_pixel_size( imageInfo->format ); - dst_row_pitch_lod = dst_width_lod * get_pixel_size( imageInfo->format ); + src_row_pitch_lod = + src_width_lod * get_pixel_size(srcImageInfo->format); + dst_row_pitch_lod = + dst_width_lod * get_pixel_size(srcImageInfo->format); } // First, try just a full covering region sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0; destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0; - regionSize[ 0 ] = imageInfo->width; - regionSize[ 1 ] = imageInfo->height; + regionSize[0] = srcImageInfo->width; + regionSize[1] = srcImageInfo->height; regionSize[ 2 ] = 1; if(gTestMipmaps) @@ -60,7 +72,9 @@ int test_copy_image_size_2D( cl_context context, cl_command_queue queue, image_d regionSize[ 1 ] = height_lod; } - retCode = test_copy_image_generic( context, queue, imageInfo, imageInfo, sourcePos, destPos, regionSize, d ); + retCode = + test_copy_image_generic(context, queue, srcImageInfo, dstImageInfo, + sourcePos, destPos, regionSize, d); if( retCode < 0 ) return retCode; else @@ -74,10 +88,18 @@ int test_copy_image_size_2D( cl_context context, cl_command_queue queue, image_d // Work at a random mip level src_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); dst_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); - src_width_lod = ( imageInfo->width >> src_lod )? ( imageInfo->width >> src_lod ) : 1; - dst_width_lod = ( imageInfo->width >> dst_lod )? ( imageInfo->width >> dst_lod ) : 1; - src_height_lod = ( imageInfo->height >> src_lod )? ( imageInfo->height >> src_lod ) : 1; - dst_height_lod = ( imageInfo->height >> dst_lod )? ( imageInfo->height >> dst_lod ) : 1; + src_width_lod = (srcImageInfo->width >> src_lod) + ? (srcImageInfo->width >> src_lod) + : 1; + dst_width_lod = (dstImageInfo->width >> dst_lod) + ? (dstImageInfo->width >> dst_lod) + : 1; + src_height_lod = (srcImageInfo->height >> src_lod) + ? (srcImageInfo->height >> src_lod) + : 1; + dst_height_lod = (dstImageInfo->height >> dst_lod) + ? (dstImageInfo->height >> dst_lod) + : 1; width_lod = ( src_width_lod > dst_width_lod ) ? dst_width_lod : src_width_lod; height_lod = ( src_height_lod > dst_height_lod ) ? dst_height_lod : src_height_lod; sourcePos[ 2 ] = src_lod; @@ -95,7 +117,9 @@ int test_copy_image_size_2D( cl_context context, cl_command_queue queue, image_d destPos[ 1 ] = ( height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( height_lod - regionSize[ 1 ] - 1 ), d ) : 0; // Go for it! - retCode = test_copy_image_generic( context, queue, imageInfo, imageInfo, sourcePos, destPos, regionSize, d ); + retCode = + test_copy_image_generic(context, queue, srcImageInfo, dstImageInfo, + sourcePos, destPos, regionSize, d); if( retCode < 0 ) return retCode; else @@ -105,17 +129,23 @@ int test_copy_image_size_2D( cl_context context, cl_command_queue queue, image_d return ret; } -int test_copy_image_set_2D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format ) +int test_copy_image_set_2D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_mem_flags src_flags, + cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format) { + assert(dst_type == src_type); // This test expects to copy 2D -> 2D images size_t maxWidth, maxHeight; cl_ulong maxAllocSize, memSize; - image_descriptor imageInfo = { 0 }; + image_descriptor srcImageInfo = { 0 }; + image_descriptor dstImageInfo = { 0 }; RandomSeed seed(gRandomSeed); size_t pixelSize; - imageInfo.format = format; - imageInfo.type = CL_MEM_OBJECT_IMAGE2D; - pixelSize = get_pixel_size( imageInfo.format ); + srcImageInfo.format = format; + srcImageInfo.type = src_type; + srcImageInfo.mem_flags = src_flags; + pixelSize = get_pixel_size(srcImageInfo.format); int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL ); @@ -130,32 +160,43 @@ int test_copy_image_set_2D( cl_device_id device, cl_context context, cl_command_ if( gTestSmallImages ) { - for( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ ) + for (srcImageInfo.width = 1; srcImageInfo.width < 13; + srcImageInfo.width++) { size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; - if (gTestMipmaps) - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, 0), seed); + if (gTestMipmaps) + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, + srcImageInfo.height, 0), + seed); - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } - for( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ ) - { - if( gDebugTrace ) - log_info( " at size %d,%d\n", (int)imageInfo.width, (int)imageInfo.height ); + for (srcImageInfo.height = 1; srcImageInfo.height < 9; + srcImageInfo.height++) + { + if (gDebugTrace) + log_info(" at size %d,%d\n", (int)srcImageInfo.width, + (int)srcImageInfo.height); - int ret = test_copy_image_size_2D( context, queue, &imageInfo, seed ); - if( ret ) - return -1; - } + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_size_2D(context, queue, &srcImageInfo, + &dstImageInfo, seed); + if (ret) return -1; + } } } else if( gTestMaxImages ) @@ -164,31 +205,42 @@ int test_copy_image_set_2D( cl_device_id device, cl_context context, cl_command_ size_t numbeOfSizes; size_t sizes[100][3]; - get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, 1, 1, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE2D, imageInfo.format); + get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, 1, 1, + maxAllocSize, memSize, src_type, srcImageInfo.format); for( size_t idx = 0; idx < numbeOfSizes; idx++ ) { size_t rowPadding = gEnablePitch ? 48 : 0; - imageInfo.width = sizes[ idx ][ 0 ]; - imageInfo.height = sizes[ idx ][ 1 ]; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.width = sizes[idx][0]; + srcImageInfo.height = sizes[idx][1]; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; - if (gTestMipmaps) - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, 0), seed); + if (gTestMipmaps) + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, + srcImageInfo.height, 0), + seed); - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } log_info( "Testing %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ] ); if( gDebugTrace ) log_info( " at max size %d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ] ); - if( test_copy_image_size_2D( context, queue, &imageInfo, seed ) ) + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + if (test_copy_image_size_2D(context, queue, &srcImageInfo, + &dstImageInfo, seed)) return -1; } } @@ -202,34 +254,51 @@ int test_copy_image_set_2D( cl_device_id device, cl_context context, cl_command_ // image, the result array, plus offset arrays, will fit in the global ram space do { - imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed ); - imageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed ); + srcImageInfo.width = + (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + srcImageInfo.height = + (size_t)random_log_in_range(16, (int)maxHeight / 32, seed); - if (gTestMipmaps) - { - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, 0), seed); - imageInfo.rowPitch = imageInfo.width * get_pixel_size( imageInfo.format ); - size = compute_mipmapped_image_size( imageInfo ); - size = size*4; - } + if (gTestMipmaps) + { + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, + srcImageInfo.height, 0), + seed); + srcImageInfo.rowPitch = srcImageInfo.width + * get_pixel_size(srcImageInfo.format); + size = compute_mipmapped_image_size(srcImageInfo); + size = size * 4; + } else { - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } - size = (size_t)imageInfo.rowPitch * (size_t)imageInfo.height * 4; + size = + (size_t)srcImageInfo.rowPitch * (size_t)srcImageInfo.height * 4; } } while( size > maxAllocSize || ( size * 3 ) > memSize ); if( gDebugTrace ) - log_info( " at size %d,%d (row pitch %d) out of %d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.rowPitch, (int)maxWidth, (int)maxHeight ); - int ret = test_copy_image_size_2D( context, queue, &imageInfo, seed ); + log_info(" at size %d,%d (row pitch %d) out of %d,%d\n", + (int)srcImageInfo.width, (int)srcImageInfo.height, + (int)srcImageInfo.rowPitch, (int)maxWidth, + (int)maxHeight); + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_size_2D(context, queue, &srcImageInfo, + &dstImageInfo, seed); if( ret ) return -1; } diff --git a/test_conformance/images/clCopyImage/test_copy_2D_2D_array.cpp b/test_conformance/images/clCopyImage/test_copy_2D_2D_array.cpp index 9ba8718a..6fc9bc76 100644 --- a/test_conformance/images/clCopyImage/test_copy_2D_2D_array.cpp +++ b/test_conformance/images/clCopyImage/test_copy_2D_2D_array.cpp @@ -36,14 +36,12 @@ static void set_image_dimensions( image_descriptor *imageInfo, size_t width, siz } while ((imageInfo->rowPitch % pixelSize) != 0); } - if (arraySize == 0) + if (imageInfo->type == CL_MEM_OBJECT_IMAGE2D) { - imageInfo->type = CL_MEM_OBJECT_IMAGE2D; imageInfo->slicePitch = 0; } else { - imageInfo->type = CL_MEM_OBJECT_IMAGE2D_ARRAY; imageInfo->slicePitch = imageInfo->rowPitch * (imageInfo->height + slicePadding); } } @@ -205,15 +203,31 @@ int test_copy_image_size_2D_2D_array( cl_context context, cl_command_queue queue } -int test_copy_image_set_2D_2D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, bool reverse = false ) +int test_copy_image_set_2D_2D_array( + cl_device_id device, cl_context context, cl_command_queue queue, + cl_mem_flags src_flags, cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format) { size_t maxWidth, maxHeight, maxArraySize; cl_ulong maxAllocSize, memSize; - image_descriptor srcImageInfo = { 0 }; - image_descriptor dstImageInfo = { 0 }; + const bool reverse = (src_type == CL_MEM_OBJECT_IMAGE2D_ARRAY); + image_descriptor imageInfo2D = { 0 }; + image_descriptor imageInfo2Darray = { 0 }; RandomSeed seed( gRandomSeed ); - srcImageInfo.format = dstImageInfo.format = format; + imageInfo2D.format = imageInfo2Darray.format = format; + imageInfo2D.type = CL_MEM_OBJECT_IMAGE2D; + imageInfo2Darray.type = CL_MEM_OBJECT_IMAGE2D_ARRAY; + if (reverse) + { + imageInfo2Darray.mem_flags = src_flags; + imageInfo2D.mem_flags = dst_flags; + } + else + { + imageInfo2D.mem_flags = src_flags; + imageInfo2Darray.mem_flags = dst_flags; + } int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL ); @@ -229,42 +243,77 @@ int test_copy_image_set_2D_2D_array( cl_device_id device, cl_context context, cl if( gTestSmallImages ) { - for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ ) + for (imageInfo2Darray.width = 4; imageInfo2Darray.width < 17; + imageInfo2Darray.width++) { - for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ ) + for (imageInfo2Darray.height = 4; imageInfo2Darray.height < 13; + imageInfo2Darray.height++) { - for( dstImageInfo.arraySize = 4; dstImageInfo.arraySize < 9; dstImageInfo.arraySize++ ) + for (imageInfo2Darray.arraySize = 4; + imageInfo2Darray.arraySize < 9; + imageInfo2Darray.arraySize++) { size_t rowPadding = gEnablePitch ? 256 : 0; size_t slicePadding = gEnablePitch ? 3 : 0; - set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, rowPadding, slicePadding ); - set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, 0, rowPadding, slicePadding ); + set_image_dimensions( + &imageInfo2Darray, imageInfo2Darray.width, + imageInfo2Darray.height, imageInfo2Darray.arraySize, + rowPadding, slicePadding); + set_image_dimensions(&imageInfo2D, imageInfo2Darray.width, + imageInfo2Darray.height, 0, rowPadding, + slicePadding); if (gTestMipmaps) { - srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed); - srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D; - dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, 0), seed); - dstImageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY; - srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format ); - srcImageInfo.slicePitch = 0; - dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format ); - dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height; + imageInfo2D.num_mip_levels = + (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels( + imageInfo2D.width, imageInfo2D.height, 0), + seed); + imageInfo2Darray.num_mip_levels = + (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels( + imageInfo2Darray.width, + imageInfo2Darray.height, 0), + seed); + imageInfo2D.rowPitch = imageInfo2D.width + * get_pixel_size(imageInfo2D.format); + imageInfo2D.slicePitch = 0; + imageInfo2Darray.rowPitch = imageInfo2Darray.width + * get_pixel_size(imageInfo2Darray.format); + imageInfo2Darray.slicePitch = + imageInfo2Darray.rowPitch * imageInfo2Darray.height; } if( gDebugTrace ) { if (reverse) - log_info( " at size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height ); + log_info(" at size %d,%d,%d to %d,%d\n", + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize, + (int)imageInfo2D.width, + (int)imageInfo2D.height); else - 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.arraySize ); + log_info(" at size %d,%d to %d,%d,%d\n", + (int)imageInfo2D.width, + (int)imageInfo2D.height, + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize); } int ret; if( reverse ) - ret = test_copy_image_size_2D_2D_array( context, queue, &dstImageInfo, &srcImageInfo, seed ); + ret = test_copy_image_size_2D_2D_array( + context, queue, &imageInfo2Darray, &imageInfo2D, + seed); else - ret = test_copy_image_size_2D_2D_array( context, queue, &srcImageInfo, &dstImageInfo, seed ); + ret = test_copy_image_size_2D_2D_array( + context, queue, &imageInfo2D, &imageInfo2Darray, + seed); if( ret ) return -1; } @@ -278,8 +327,12 @@ int test_copy_image_set_2D_2D_array( cl_device_id device, cl_context context, cl size_t sizes2DArray[100][3], sizes2D[100][3]; // Try to allocate a bit smaller images because we need the 2D ones as well for the copy. - get_max_sizes(&numberOfSizes2DArray, 100, sizes2DArray, maxWidth, maxHeight, 1, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D_ARRAY, dstImageInfo.format); - get_max_sizes(&numberOfSizes2D, 100, sizes2D, maxWidth, maxHeight, 1, 1, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D, dstImageInfo.format); + get_max_sizes(&numberOfSizes2DArray, 100, sizes2DArray, maxWidth, + maxHeight, 1, maxArraySize, maxAllocSize / 2, memSize / 2, + CL_MEM_OBJECT_IMAGE2D_ARRAY, imageInfo2Darray.format); + get_max_sizes(&numberOfSizes2D, 100, sizes2D, maxWidth, maxHeight, 1, 1, + maxAllocSize / 2, memSize / 2, CL_MEM_OBJECT_IMAGE2D, + imageInfo2Darray.format); for( size_t i = 0; i < numberOfSizes2D; i++ ) { @@ -288,56 +341,94 @@ int test_copy_image_set_2D_2D_array( cl_device_id device, cl_context context, cl size_t rowPadding = gEnablePitch ? 256 : 0; size_t slicePadding = gEnablePitch ? 3 : 0; - set_image_dimensions( &dstImageInfo, sizes2DArray[ j ][ 0 ], sizes2DArray[ j ][ 1 ], sizes2DArray[ j ][ 2 ], rowPadding, slicePadding ); - set_image_dimensions( &srcImageInfo, sizes2D[ i ][ 0 ], sizes2D[ i ][ 1 ], 0, rowPadding, slicePadding ); + set_image_dimensions(&imageInfo2Darray, sizes2DArray[j][0], + sizes2DArray[j][1], sizes2DArray[j][2], + rowPadding, slicePadding); + set_image_dimensions(&imageInfo2D, sizes2D[i][0], sizes2D[i][1], 0, + rowPadding, slicePadding); - cl_ulong dstSize = get_image_size(&dstImageInfo); - cl_ulong srcSize = get_image_size(&srcImageInfo); + cl_ulong dstSize = get_image_size(&imageInfo2Darray); + cl_ulong srcSize = get_image_size(&imageInfo2D); if (gTestMipmaps) { - srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed); - srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D; - dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, 0), seed); - dstImageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY; - srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format ); - srcImageInfo.slicePitch = 0; - dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format ); - dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height; - dstSize = 4 * compute_mipmapped_image_size( dstImageInfo ); - srcSize = 4 * compute_mipmapped_image_size( srcImageInfo ); + imageInfo2D.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo2D.width, + imageInfo2D.height, 0), + seed); + imageInfo2Darray.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo2Darray.width, + imageInfo2Darray.height, 0), + seed); + imageInfo2D.rowPitch = + imageInfo2D.width * get_pixel_size(imageInfo2D.format); + imageInfo2D.slicePitch = 0; + imageInfo2Darray.rowPitch = imageInfo2Darray.width + * get_pixel_size(imageInfo2Darray.format); + imageInfo2Darray.slicePitch = + imageInfo2Darray.rowPitch * imageInfo2Darray.height; + dstSize = 4 * compute_mipmapped_image_size(imageInfo2Darray); + srcSize = 4 * compute_mipmapped_image_size(imageInfo2D); } if( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) && srcSize < maxAllocSize && srcSize < ( memSize / 3 ) ) { if (reverse) - log_info( "Testing %d x %d x %d to %d x %d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height ); + log_info("Testing %d x %d x %d to %d x %d\n", + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize, + (int)imageInfo2D.width, (int)imageInfo2D.height); else - 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.arraySize ); + log_info("Testing %d x %d to %d x %d x %d\n", + (int)imageInfo2D.width, (int)imageInfo2D.height, + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize); if( gDebugTrace ) { if (reverse) - log_info( " at max size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height ); + log_info(" at max size %d,%d,%d to %d,%d\n", + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize, + (int)imageInfo2D.width, (int)imageInfo2D.height); else - 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.arraySize ); + log_info(" at max size %d,%d to %d,%d,%d\n", + (int)imageInfo2D.width, (int)imageInfo2D.height, + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize); } int ret; if( reverse ) - ret = test_copy_image_size_2D_2D_array( context, queue, &dstImageInfo, &srcImageInfo, seed ); + ret = test_copy_image_size_2D_2D_array( + context, queue, &imageInfo2Darray, &imageInfo2D, seed); else - ret = test_copy_image_size_2D_2D_array( context, queue, &srcImageInfo, &dstImageInfo, seed ); + ret = test_copy_image_size_2D_2D_array( + context, queue, &imageInfo2D, &imageInfo2Darray, seed); if( ret ) return -1; } else { if (reverse) - log_info("Not testing max size %d x %d x %d to %d x %d due to memory constraints.\n", - (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height); + log_info("Not testing max size %d x %d x %d to %d x %d due " + "to memory constraints.\n", + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize, + (int)imageInfo2D.width, (int)imageInfo2D.height); else - log_info("Not testing max size %d x %d to %d x %d x %d due to memory constraints.\n", - (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize); + log_info("Not testing max size %d x %d to %d x %d x %d due " + "to memory constraints.\n", + (int)imageInfo2D.width, (int)imageInfo2D.height, + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize); } } @@ -354,47 +445,81 @@ int test_copy_image_set_2D_2D_array( cl_device_id device, cl_context context, cl // image, the result array, plus offset arrays, will fit in the global ram space do { - dstImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed ); - dstImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed ); - dstImageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed ); - srcImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed ); - srcImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed ); + imageInfo2Darray.width = + (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + imageInfo2Darray.height = + (size_t)random_log_in_range(16, (int)maxHeight / 32, seed); + imageInfo2Darray.arraySize = (size_t)random_log_in_range( + 16, (int)maxArraySize / 32, seed); + imageInfo2D.width = + (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + imageInfo2D.height = + (size_t)random_log_in_range(16, (int)maxHeight / 32, seed); if (gTestMipmaps) { - srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed); - srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D; - dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, 0), seed); - dstImageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY; - srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format ); - srcImageInfo.slicePitch = 0; - dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format ); - dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height; - srcSize = 4 * compute_mipmapped_image_size( srcImageInfo ); - dstSize = 4 * compute_mipmapped_image_size( dstImageInfo ); + imageInfo2D.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo2D.width, + imageInfo2D.height, 0), + seed); + imageInfo2Darray.num_mip_levels = + (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo2Darray.width, + imageInfo2Darray.height, + 0), + seed); + imageInfo2D.rowPitch = + imageInfo2D.width * get_pixel_size(imageInfo2D.format); + imageInfo2D.slicePitch = 0; + imageInfo2Darray.rowPitch = imageInfo2Darray.width + * get_pixel_size(imageInfo2Darray.format); + imageInfo2Darray.slicePitch = + imageInfo2Darray.rowPitch * imageInfo2Darray.height; + srcSize = 4 * compute_mipmapped_image_size(imageInfo2D); + dstSize = + 4 * compute_mipmapped_image_size(imageInfo2Darray); } else { - set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, 0, rowPadding, slicePadding ); - set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, rowPadding, slicePadding ); + set_image_dimensions(&imageInfo2D, imageInfo2D.width, + imageInfo2D.height, 0, rowPadding, + slicePadding); + set_image_dimensions( + &imageInfo2Darray, imageInfo2Darray.width, + imageInfo2Darray.height, imageInfo2Darray.arraySize, + rowPadding, slicePadding); - srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4; - dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize * 4; + srcSize = (cl_ulong)imageInfo2D.rowPitch + * (cl_ulong)imageInfo2D.height * 4; + dstSize = (cl_ulong)imageInfo2Darray.slicePitch + * (cl_ulong)imageInfo2Darray.arraySize * 4; } } while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize); if( gDebugTrace ) { if (reverse) - log_info( " at size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height ); + log_info(" at size %d,%d,%d to %d,%d\n", + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize, + (int)imageInfo2D.width, (int)imageInfo2D.height); else - 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.arraySize ); + log_info(" at size %d,%d to %d,%d,%d\n", + (int)imageInfo2D.width, (int)imageInfo2D.height, + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize); } int ret; if( reverse ) - ret = test_copy_image_size_2D_2D_array( context, queue, &dstImageInfo, &srcImageInfo, seed ); + ret = test_copy_image_size_2D_2D_array( + context, queue, &imageInfo2Darray, &imageInfo2D, seed); else - ret = test_copy_image_size_2D_2D_array( context, queue, &srcImageInfo, &dstImageInfo, seed ); + ret = test_copy_image_size_2D_2D_array( + context, queue, &imageInfo2D, &imageInfo2Darray, seed); if( ret ) return -1; } diff --git a/test_conformance/images/clCopyImage/test_copy_2D_3D.cpp b/test_conformance/images/clCopyImage/test_copy_2D_3D.cpp index 5f522e3e..d04356c5 100644 --- a/test_conformance/images/clCopyImage/test_copy_2D_3D.cpp +++ b/test_conformance/images/clCopyImage/test_copy_2D_3D.cpp @@ -36,12 +36,8 @@ static void set_image_dimensions( image_descriptor *imageInfo, size_t width, siz } while ((imageInfo->rowPitch % pixelSize) != 0); } - imageInfo->slicePitch = imageInfo->rowPitch * (imageInfo->height + slicePadding); - - if (depth == 0) - imageInfo->type = CL_MEM_OBJECT_IMAGE2D; - else - imageInfo->type = CL_MEM_OBJECT_IMAGE3D; + imageInfo->slicePitch = + imageInfo->rowPitch * (imageInfo->height + slicePadding); } @@ -209,15 +205,33 @@ int test_copy_image_size_2D_3D( cl_context context, cl_command_queue queue, imag } -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 ) +int test_copy_image_set_2D_3D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_mem_flags src_flags, + cl_mem_object_type src_type, + cl_mem_flags dst_flags, + cl_mem_object_type dst_type, + cl_image_format *format) { size_t maxWidth, maxHeight, max3DWidth, max3DHeight, max3DDepth; cl_ulong maxAllocSize, memSize; - image_descriptor srcImageInfo = { 0 }; - image_descriptor dstImageInfo = { 0 }; + const bool reverse = (dst_type == CL_MEM_OBJECT_IMAGE2D); + image_descriptor imageInfo2D = { 0 }; + image_descriptor imageInfo3D = { 0 }; RandomSeed seed( gRandomSeed ); - srcImageInfo.format = dstImageInfo.format = format; + imageInfo2D.format = imageInfo3D.format = format; + imageInfo2D.type = CL_MEM_OBJECT_IMAGE2D; + imageInfo3D.type = CL_MEM_OBJECT_IMAGE3D; + if (reverse) + { + imageInfo3D.mem_flags = src_flags; + imageInfo2D.mem_flags = dst_flags; + } + else + { + imageInfo2D.mem_flags = src_flags; + imageInfo3D.mem_flags = dst_flags; + } int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL ); @@ -235,38 +249,62 @@ int test_copy_image_set_2D_3D( cl_device_id device, cl_context context, cl_comma if( gTestSmallImages ) { - for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ ) + for (imageInfo3D.width = 4; imageInfo3D.width < 17; imageInfo3D.width++) { - for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ ) + for (imageInfo3D.height = 4; imageInfo3D.height < 13; + imageInfo3D.height++) { - for( dstImageInfo.depth = 4; dstImageInfo.depth < 9; dstImageInfo.depth++ ) + for (imageInfo3D.depth = 4; imageInfo3D.depth < 9; + imageInfo3D.depth++) { size_t rowPadding = gEnablePitch ? 256 : 0; size_t slicePadding = gEnablePitch ? 3 : 0; - set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth, rowPadding, slicePadding ); - set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, 0, rowPadding, slicePadding ); + set_image_dimensions(&imageInfo3D, imageInfo3D.width, + imageInfo3D.height, imageInfo3D.depth, + rowPadding, slicePadding); + set_image_dimensions(&imageInfo2D, imageInfo3D.width, + imageInfo3D.height, 0, rowPadding, + slicePadding); if (gTestMipmaps) { - srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed); - srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D; - dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth), seed); - dstImageInfo.type = CL_MEM_OBJECT_IMAGE3D; - srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format ); - srcImageInfo.slicePitch = 0; - dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format ); - dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height; + imageInfo2D.num_mip_levels = + (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels( + imageInfo2D.width, imageInfo2D.height, 0), + seed); + imageInfo3D.num_mip_levels = + (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo3D.width, + imageInfo3D.height, + imageInfo3D.depth), + seed); + imageInfo2D.rowPitch = imageInfo2D.width + * get_pixel_size(imageInfo2D.format); + imageInfo2D.slicePitch = 0; + imageInfo3D.rowPitch = imageInfo3D.width + * get_pixel_size(imageInfo3D.format); + imageInfo3D.slicePitch = + imageInfo3D.rowPitch * imageInfo3D.height; } if( gDebugTrace ) - 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 ); + log_info( + " at size %d,%d to %d,%d,%d\n", + (int)imageInfo2D.width, (int)imageInfo2D.height, + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth); int ret; if( reverse ) - ret = test_copy_image_size_2D_3D( context, queue, &dstImageInfo, &srcImageInfo, seed ); + ret = test_copy_image_size_2D_3D( + context, queue, &imageInfo3D, &imageInfo2D, seed); else - ret = test_copy_image_size_2D_3D( context, queue, &srcImageInfo, &dstImageInfo, seed ); + ret = test_copy_image_size_2D_3D( + context, queue, &imageInfo2D, &imageInfo3D, seed); if( ret ) return -1; } @@ -280,8 +318,12 @@ int test_copy_image_set_2D_3D( cl_device_id device, cl_context context, cl_comma size_t sizes3D[100][3], sizes2D[100][3]; // Try to allocate a bit smaller images because we need the 2D ones as well for the copy. - get_max_sizes(&numberOfSizes3D, 100, sizes3D, max3DWidth, max3DHeight, max3DDepth, 1, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE3D, dstImageInfo.format); - get_max_sizes(&numberOfSizes2D, 100, sizes2D, maxWidth, maxHeight, 1, 1, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D, srcImageInfo.format); + get_max_sizes(&numberOfSizes3D, 100, sizes3D, max3DWidth, max3DHeight, + max3DDepth, 1, maxAllocSize / 2, memSize / 2, + CL_MEM_OBJECT_IMAGE3D, imageInfo3D.format); + get_max_sizes(&numberOfSizes2D, 100, sizes2D, maxWidth, maxHeight, 1, 1, + maxAllocSize / 2, memSize / 2, CL_MEM_OBJECT_IMAGE2D, + imageInfo2D.format); for( size_t i = 0; i < numberOfSizes2D; i++ ) for( size_t j = 0; j < numberOfSizes3D; j++ ) @@ -289,42 +331,65 @@ int test_copy_image_set_2D_3D( cl_device_id device, cl_context context, cl_comma size_t rowPadding = gEnablePitch ? 256 : 0; size_t slicePadding = gEnablePitch ? 3 : 0; - set_image_dimensions( &dstImageInfo, sizes3D[ j ][ 0 ], sizes3D[ j ][ 1 ], sizes3D[ j ][ 2 ], rowPadding, slicePadding ); - set_image_dimensions( &srcImageInfo, sizes2D[ i ][ 0 ], sizes2D[ i ][ 1 ], 0, rowPadding, slicePadding ); - cl_ulong dstSize = get_image_size(&dstImageInfo); - cl_ulong srcSize = get_image_size(&srcImageInfo); + set_image_dimensions(&imageInfo3D, sizes3D[j][0], sizes3D[j][1], + sizes3D[j][2], rowPadding, slicePadding); + set_image_dimensions(&imageInfo2D, sizes2D[i][0], sizes2D[i][1], 0, + rowPadding, slicePadding); + cl_ulong dstSize = get_image_size(&imageInfo3D); + cl_ulong srcSize = get_image_size(&imageInfo2D); if (gTestMipmaps) { - srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed); - srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D; - dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth), seed); - dstImageInfo.type = CL_MEM_OBJECT_IMAGE3D; - srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format ); - srcImageInfo.slicePitch = 0; - dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format ); - dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height; - dstSize = 4 * compute_mipmapped_image_size( dstImageInfo ); - srcSize = 4 * compute_mipmapped_image_size( srcImageInfo ); + imageInfo2D.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo2D.width, + imageInfo2D.height, 0), + seed); + imageInfo3D.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo3D.width, + imageInfo3D.height, + imageInfo3D.depth), + seed); + imageInfo2D.rowPitch = + imageInfo2D.width * get_pixel_size(imageInfo2D.format); + imageInfo2D.slicePitch = 0; + imageInfo3D.rowPitch = + imageInfo3D.width * get_pixel_size(imageInfo3D.format); + imageInfo3D.slicePitch = + imageInfo3D.rowPitch * imageInfo3D.height; + dstSize = 4 * compute_mipmapped_image_size(imageInfo3D); + srcSize = 4 * compute_mipmapped_image_size(imageInfo2D); } if( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) && srcSize < maxAllocSize && srcSize < ( memSize / 3 ) ) { - 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 ); + log_info("Testing %d x %d to %d x %d x %d\n", + (int)imageInfo2D.width, (int)imageInfo2D.height, + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth); if( gDebugTrace ) - 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 ); + log_info(" at max size %d,%d to %d,%d,%d\n", + (int)imageInfo2D.width, (int)imageInfo2D.height, + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth); int ret; if( reverse ) - ret = test_copy_image_size_2D_3D( context, queue, &dstImageInfo, &srcImageInfo, seed ); + ret = test_copy_image_size_2D_3D( + context, queue, &imageInfo3D, &imageInfo2D, seed); else - ret = test_copy_image_size_2D_3D( context, queue, &srcImageInfo, &dstImageInfo, seed ); + ret = test_copy_image_size_2D_3D( + context, queue, &imageInfo2D, &imageInfo3D, seed); if( ret ) return -1; } else { - log_info("Not testing max size %d x %d to %d x %d x %d due to memory constraints.\n", - (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.depth); + log_info("Not testing max size %d x %d to %d x %d x %d due to " + "memory constraints.\n", + (int)imageInfo2D.width, (int)imageInfo2D.height, + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth); } } @@ -341,42 +406,68 @@ int test_copy_image_set_2D_3D( cl_device_id device, cl_context context, cl_comma // image, the result array, plus offset arrays, will fit in the global ram space do { - dstImageInfo.width = (size_t)random_log_in_range( 16, (int)max3DWidth / 32, seed ); - dstImageInfo.height = (size_t)random_log_in_range( 16, (int)max3DHeight / 32, seed ); - dstImageInfo.depth = (size_t)random_log_in_range( 16, (int)max3DDepth / 32, seed ); - srcImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed ); - srcImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed ); + imageInfo3D.width = + (size_t)random_log_in_range(16, (int)max3DWidth / 32, seed); + imageInfo3D.height = (size_t)random_log_in_range( + 16, (int)max3DHeight / 32, seed); + imageInfo3D.depth = + (size_t)random_log_in_range(16, (int)max3DDepth / 32, seed); + imageInfo2D.width = + (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + imageInfo2D.height = + (size_t)random_log_in_range(16, (int)maxHeight / 32, seed); if (gTestMipmaps) { - srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed); - srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D; - dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth), seed); - dstImageInfo.type = CL_MEM_OBJECT_IMAGE3D; - srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format ); - srcImageInfo.slicePitch = 0; - dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format ); - dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height; - srcSize = 4 * compute_mipmapped_image_size( srcImageInfo ); - dstSize = 4 * compute_mipmapped_image_size( dstImageInfo ); + imageInfo2D.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo2D.width, + imageInfo2D.height, 0), + seed); + imageInfo3D.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo3D.width, + imageInfo3D.height, + imageInfo3D.depth), + seed); + imageInfo2D.rowPitch = + imageInfo2D.width * get_pixel_size(imageInfo2D.format); + imageInfo2D.slicePitch = 0; + imageInfo3D.rowPitch = + imageInfo3D.width * get_pixel_size(imageInfo3D.format); + imageInfo3D.slicePitch = + imageInfo3D.rowPitch * imageInfo3D.height; + srcSize = 4 * compute_mipmapped_image_size(imageInfo2D); + dstSize = 4 * compute_mipmapped_image_size(imageInfo3D); } else { - set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, 0, rowPadding, slicePadding ); - set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth, rowPadding, slicePadding ); + set_image_dimensions(&imageInfo2D, imageInfo2D.width, + imageInfo2D.height, 0, rowPadding, + slicePadding); + set_image_dimensions(&imageInfo3D, imageInfo3D.width, + imageInfo3D.height, imageInfo3D.depth, + rowPadding, slicePadding); - srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4; - dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.depth * 4; + srcSize = (cl_ulong)imageInfo2D.rowPitch + * (cl_ulong)imageInfo2D.height * 4; + dstSize = (cl_ulong)imageInfo3D.slicePitch + * (cl_ulong)imageInfo3D.depth * 4; } } while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize); if( gDebugTrace ) - 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 ); + log_info(" at size %d,%d to %d,%d,%d\n", + (int)imageInfo2D.width, (int)imageInfo2D.height, + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth); int ret; if( reverse ) - ret = test_copy_image_size_2D_3D( context, queue, &dstImageInfo, &srcImageInfo, seed ); + ret = test_copy_image_size_2D_3D(context, queue, &imageInfo3D, + &imageInfo2D, seed); else - ret = test_copy_image_size_2D_3D( context, queue, &srcImageInfo, &dstImageInfo, seed ); + ret = test_copy_image_size_2D_3D(context, queue, &imageInfo2D, + &imageInfo3D, seed); if( ret ) return -1; } diff --git a/test_conformance/images/clCopyImage/test_copy_2D_array.cpp b/test_conformance/images/clCopyImage/test_copy_2D_array.cpp index 3376bf9a..72fc19ba 100644 --- a/test_conformance/images/clCopyImage/test_copy_2D_array.cpp +++ b/test_conformance/images/clCopyImage/test_copy_2D_array.cpp @@ -19,26 +19,39 @@ extern int test_copy_image_generic( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d ); -int test_copy_image_2D_array( cl_context context, cl_command_queue queue, image_descriptor *imageInfo, MTdata d ) +int test_copy_image_2D_array(cl_context context, cl_command_queue queue, + image_descriptor *srcImageInfo, + image_descriptor *dstImageInfo, MTdata d) { size_t srcPos[] = { 0, 0, 0, 0}, dstPos[] = {0, 0, 0, 0}; - size_t region[] = { imageInfo->width, imageInfo->height, imageInfo->arraySize }; + size_t region[] = { srcImageInfo->width, srcImageInfo->height, + srcImageInfo->arraySize }; - size_t src_lod = 0, src_width_lod = imageInfo->width, src_height_lod = imageInfo->height; - size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_height_lod = imageInfo->height; - size_t width_lod = imageInfo->width, height_lod = imageInfo->height; + size_t src_lod = 0, src_width_lod = srcImageInfo->width, + src_height_lod = srcImageInfo->height; + size_t dst_lod = 0, dst_width_lod = dstImageInfo->width, + dst_height_lod = dstImageInfo->height; + size_t width_lod = srcImageInfo->width, height_lod = srcImageInfo->height; size_t max_mip_level; if( gTestMipmaps ) { - max_mip_level = imageInfo->num_mip_levels; + max_mip_level = srcImageInfo->num_mip_levels; // Work at a random mip level src_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); dst_lod = (size_t)random_in_range( 0, max_mip_level ? max_mip_level - 1 : 0, d ); - src_width_lod = ( imageInfo->width >> src_lod )? ( imageInfo->width >> src_lod ) : 1; - dst_width_lod = ( imageInfo->width >> dst_lod )? ( imageInfo->width >> dst_lod ) : 1; - src_height_lod = ( imageInfo->height >> src_lod )? ( imageInfo->height >> src_lod ) : 1; - dst_height_lod = ( imageInfo->height >> dst_lod )? ( imageInfo->height >> dst_lod ) : 1; + src_width_lod = (srcImageInfo->width >> src_lod) + ? (srcImageInfo->width >> src_lod) + : 1; + dst_width_lod = (dstImageInfo->width >> dst_lod) + ? (dstImageInfo->width >> dst_lod) + : 1; + src_height_lod = (srcImageInfo->height >> src_lod) + ? (srcImageInfo->height >> src_lod) + : 1; + dst_height_lod = (dstImageInfo->height >> dst_lod) + ? (dstImageInfo->height >> dst_lod) + : 1; width_lod = ( src_width_lod > dst_width_lod ) ? dst_width_lod : src_width_lod; height_lod = ( src_height_lod > dst_height_lod ) ? dst_height_lod : src_height_lod; @@ -47,20 +60,31 @@ int test_copy_image_2D_array( cl_context context, cl_command_queue queue, image_ srcPos[ 3 ] = src_lod; dstPos[ 3 ] = dst_lod; } - return test_copy_image_generic( context, queue, imageInfo, imageInfo, srcPos, dstPos, region, d ); +return test_copy_image_generic(context, queue, srcImageInfo, dstImageInfo, + srcPos, dstPos, region, d); } -int test_copy_image_set_2D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format ) +int test_copy_image_set_2D_array(cl_device_id device, cl_context context, + cl_command_queue queue, cl_mem_flags src_flags, + cl_mem_object_type src_type, + cl_mem_flags dst_flags, + cl_mem_object_type dst_type, + cl_image_format *format) { + assert( + dst_type + == src_type); // This test expects to copy 2D array -> 2D array images size_t maxWidth, maxHeight, maxArraySize; cl_ulong maxAllocSize, memSize; - image_descriptor imageInfo = { 0 }; + image_descriptor srcImageInfo = { 0 }; + image_descriptor dstImageInfo = { 0 }; RandomSeed seed( gRandomSeed ); size_t pixelSize; - imageInfo.format = format; - imageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY; - pixelSize = get_pixel_size( imageInfo.format ); + srcImageInfo.format = format; + srcImageInfo.type = src_type; + srcImageInfo.mem_flags = src_flags; + pixelSize = get_pixel_size(srcImageInfo.format); int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL ); @@ -76,33 +100,49 @@ int test_copy_image_set_2D_array( cl_device_id device, cl_context context, cl_co if( gTestSmallImages ) { - for( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ ) + for (srcImageInfo.width = 1; srcImageInfo.width < 13; + srcImageInfo.width++) { size_t rowPadding = gEnablePitch ? 80 : 0; size_t slicePadding = gEnablePitch ? 3 : 0; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; if (gTestMipmaps) - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, 0), seed); + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, + srcImageInfo.height, 0), + seed); if (gEnablePitch) { do { rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); } - for( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ ) + for (srcImageInfo.height = 1; srcImageInfo.height < 9; + srcImageInfo.height++) { - imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding); + srcImageInfo.slicePitch = srcImageInfo.rowPitch + * (srcImageInfo.height + slicePadding); - for( imageInfo.arraySize = 2; imageInfo.arraySize < 9; imageInfo.arraySize++ ) + for (srcImageInfo.arraySize = 2; srcImageInfo.arraySize < 9; + srcImageInfo.arraySize++) { if( gDebugTrace ) - log_info( " at size %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.arraySize ); - int ret = test_copy_image_2D_array( context, queue, &imageInfo, seed ); + log_info(" at size %d,%d,%d\n", + (int)srcImageInfo.width, + (int)srcImageInfo.height, + (int)srcImageInfo.arraySize); + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_2D_array( + context, queue, &srcImageInfo, &dstImageInfo, seed); if( ret ) return -1; } @@ -114,34 +154,46 @@ int test_copy_image_set_2D_array( cl_device_id device, cl_context context, cl_co // Try a specific set of maximum sizes size_t numbeOfSizes; size_t sizes[100][3]; - get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, 1, maxArraySize, maxAllocSize, memSize, imageInfo.type, imageInfo.format); + get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, 1, + maxArraySize, maxAllocSize, memSize, srcImageInfo.type, + srcImageInfo.format); for( size_t idx = 0; idx < numbeOfSizes; idx++ ) { size_t rowPadding = gEnablePitch ? 80 : 0; size_t slicePadding = gEnablePitch ? 3 : 0; - imageInfo.width = sizes[ idx ][ 0 ]; - imageInfo.height = sizes[ idx ][ 1 ]; - imageInfo.arraySize = sizes[ idx ][ 2 ]; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.width = sizes[idx][0]; + srcImageInfo.height = sizes[idx][1]; + srcImageInfo.arraySize = sizes[idx][2]; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; if (gTestMipmaps) - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, 0), seed); + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, + srcImageInfo.height, 0), + seed); if (gEnablePitch) { do { rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); } - imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding); + srcImageInfo.slicePitch = + srcImageInfo.rowPitch * (srcImageInfo.height + slicePadding); log_info( "Testing %d x %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] ); if( gDebugTrace ) log_info( " at max size %d,%d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] ); - if( test_copy_image_2D_array( context, queue, &imageInfo, seed ) ) + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + if (test_copy_image_2D_array(context, queue, &srcImageInfo, + &dstImageInfo, seed)) return -1; } } @@ -156,38 +208,61 @@ int test_copy_image_set_2D_array( cl_device_id device, cl_context context, cl_co // image, the result array, plus offset arrays, will fit in the global ram space do { - imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed ); - imageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed ); - imageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed ); + srcImageInfo.width = + (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + srcImageInfo.height = + (size_t)random_log_in_range(16, (int)maxHeight / 32, seed); + srcImageInfo.arraySize = (size_t)random_log_in_range( + 16, (int)maxArraySize / 32, seed); if (gTestMipmaps) { - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, 0), seed); - imageInfo.rowPitch = imageInfo.width * get_pixel_size( imageInfo.format ); - imageInfo.slicePitch = imageInfo.rowPitch * imageInfo.height; - size = compute_mipmapped_image_size( imageInfo ); + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, + srcImageInfo.height, 0), + seed); + srcImageInfo.rowPitch = srcImageInfo.width + * get_pixel_size(srcImageInfo.format); + srcImageInfo.slicePitch = + srcImageInfo.rowPitch * srcImageInfo.height; + size = compute_mipmapped_image_size(srcImageInfo); size = size*4; } else { - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } - imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding); + srcImageInfo.slicePitch = srcImageInfo.rowPitch + * (srcImageInfo.height + slicePadding); - size = (cl_ulong)imageInfo.slicePitch * (cl_ulong)imageInfo.arraySize * 4 * 4; + size = (cl_ulong)srcImageInfo.slicePitch + * (cl_ulong)srcImageInfo.arraySize * 4 * 4; } } while( size > maxAllocSize || ( size * 3 ) > memSize ); if( gDebugTrace ) - log_info( " at size %d,%d,%d (pitch %d,%d) out of %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.arraySize, (int)imageInfo.rowPitch, (int)imageInfo.slicePitch, (int)maxWidth, (int)maxHeight, (int)maxArraySize ); - int ret = test_copy_image_2D_array( context, queue, &imageInfo,seed ); + log_info(" at size %d,%d,%d (pitch %d,%d) out of %d,%d,%d\n", + (int)srcImageInfo.width, (int)srcImageInfo.height, + (int)srcImageInfo.arraySize, + (int)srcImageInfo.rowPitch, + (int)srcImageInfo.slicePitch, (int)maxWidth, + (int)maxHeight, (int)maxArraySize); + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_2D_array(context, queue, &srcImageInfo, + &dstImageInfo, seed); if( ret ) return -1; } diff --git a/test_conformance/images/clCopyImage/test_copy_3D.cpp b/test_conformance/images/clCopyImage/test_copy_3D.cpp index cdfdccec..f7e7706e 100644 --- a/test_conformance/images/clCopyImage/test_copy_3D.cpp +++ b/test_conformance/images/clCopyImage/test_copy_3D.cpp @@ -19,34 +19,49 @@ extern int test_copy_image_generic( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d ); -int test_copy_image_3D( cl_context context, cl_command_queue queue, image_descriptor *imageInfo, MTdata d ) +int test_copy_image_3D(cl_context context, cl_command_queue queue, + image_descriptor *srcImageInfo, + image_descriptor *dstImageInfo, MTdata d) { size_t origin[] = { 0, 0, 0, 0}; - size_t region[] = { imageInfo->width, imageInfo->height, imageInfo->depth }; + size_t region[] = { srcImageInfo->width, srcImageInfo->height, + srcImageInfo->depth }; if( gTestMipmaps ) { - size_t lod = (imageInfo->num_mip_levels > 1 )? (size_t)random_in_range( 0, imageInfo->num_mip_levels - 1, d ) : 0 ; + size_t lod = (srcImageInfo->num_mip_levels > 1) + ? (size_t)random_in_range(0, srcImageInfo->num_mip_levels - 1, d) + : 0; origin[ 3 ] = lod; - region[ 0 ] = ( imageInfo->width >> lod ) ? ( imageInfo->width >> lod ) : 1; - region[ 1 ] = ( imageInfo->height >> lod ) ? ( imageInfo->height >> lod ) : 1; - region[ 2 ] = ( imageInfo->depth >> lod ) ? ( imageInfo->depth >> lod ) : 1; + region[0] = + (srcImageInfo->width >> lod) ? (srcImageInfo->width >> lod) : 1; + region[1] = + (srcImageInfo->height >> lod) ? (srcImageInfo->height >> lod) : 1; + region[2] = + (srcImageInfo->depth >> lod) ? (srcImageInfo->depth >> lod) : 1; } - return test_copy_image_generic( context, queue, imageInfo, imageInfo, origin, origin, region, d ); + return test_copy_image_generic(context, queue, srcImageInfo, dstImageInfo, + origin, origin, region, d); } -int test_copy_image_set_3D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format ) +int test_copy_image_set_3D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_mem_flags src_flags, + cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format) { + assert(dst_type == src_type); // This test expects to copy 3D -> 3D images size_t maxWidth, maxHeight, maxDepth; cl_ulong maxAllocSize, memSize; - image_descriptor imageInfo = { 0 }; + image_descriptor srcImageInfo = { 0 }; + image_descriptor dstImageInfo = { 0 }; RandomSeed seed( gRandomSeed ); size_t pixelSize; - imageInfo.format = format; - imageInfo.type = CL_MEM_OBJECT_IMAGE3D; - pixelSize = get_pixel_size( imageInfo.format ); + srcImageInfo.format = format; + srcImageInfo.type = src_type; + srcImageInfo.mem_flags = src_flags; + pixelSize = get_pixel_size(srcImageInfo.format); int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL ); @@ -62,32 +77,48 @@ int test_copy_image_set_3D( cl_device_id device, cl_context context, cl_command_ if( gTestSmallImages ) { - for( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ ) + for (srcImageInfo.width = 1; srcImageInfo.width < 13; + srcImageInfo.width++) { size_t rowPadding = gEnablePitch ? 80 : 0; size_t slicePadding = gEnablePitch ? 3 : 0; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; if (gTestMipmaps) - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, imageInfo.depth), seed); + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, + srcImageInfo.height, + srcImageInfo.depth), + seed); if (gEnablePitch) { do { rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); } - for( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ ) + for (srcImageInfo.height = 1; srcImageInfo.height < 9; + srcImageInfo.height++) { - imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding); - for( imageInfo.depth = 2; imageInfo.depth < 9; imageInfo.depth++ ) + srcImageInfo.slicePitch = srcImageInfo.rowPitch + * (srcImageInfo.height + slicePadding); + for (srcImageInfo.depth = 2; srcImageInfo.depth < 9; + srcImageInfo.depth++) { if( gDebugTrace ) - log_info( " at size %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.depth ); - int ret = test_copy_image_3D( context, queue, &imageInfo, seed ); + log_info( + " at size %d,%d,%d\n", (int)srcImageInfo.width, + (int)srcImageInfo.height, (int)srcImageInfo.depth); + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_3D(context, queue, &srcImageInfo, + &dstImageInfo, seed); if( ret ) return -1; } @@ -99,34 +130,47 @@ int test_copy_image_set_3D( cl_device_id device, cl_context context, cl_command_ // Try a specific set of maximum sizes size_t numbeOfSizes; size_t sizes[100][3]; - get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, maxDepth, 1, maxAllocSize, memSize, imageInfo.type, imageInfo.format); + get_max_sizes(&numbeOfSizes, 100, sizes, maxWidth, maxHeight, maxDepth, + 1, maxAllocSize, memSize, srcImageInfo.type, + srcImageInfo.format); for( size_t idx = 0; idx < numbeOfSizes; idx++ ) { size_t rowPadding = gEnablePitch ? 80 : 0; size_t slicePadding = gEnablePitch ? 3 : 0; - imageInfo.width = sizes[ idx ][ 0 ]; - imageInfo.height = sizes[ idx ][ 1 ]; - imageInfo.depth = sizes[ idx ][ 2 ]; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.width = sizes[idx][0]; + srcImageInfo.height = sizes[idx][1]; + srcImageInfo.depth = sizes[idx][2]; + srcImageInfo.rowPitch = srcImageInfo.width * pixelSize + rowPadding; if (gTestMipmaps) - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, imageInfo.depth), seed); + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, + srcImageInfo.height, + srcImageInfo.depth), + seed); if (gEnablePitch) { do { rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); } - imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding); + srcImageInfo.slicePitch = + srcImageInfo.rowPitch * (srcImageInfo.height + slicePadding); log_info( "Testing %d x %d x %d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] ); if( gDebugTrace ) log_info( " at max size %d,%d,%d\n", (int)sizes[ idx ][ 0 ], (int)sizes[ idx ][ 1 ], (int)sizes[ idx ][ 2 ] ); - if( test_copy_image_3D( context, queue, &imageInfo, seed ) ) + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + if (test_copy_image_3D(context, queue, &srcImageInfo, &dstImageInfo, + seed)) return -1; } } @@ -142,39 +186,62 @@ int test_copy_image_set_3D( cl_device_id device, cl_context context, cl_command_ // image, the result array, plus offset arrays, will fit in the global ram space do { - imageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed ); - imageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed ); - imageInfo.depth = (size_t)random_log_in_range( 16, (int)maxDepth / 32,seed ); + srcImageInfo.width = + (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + srcImageInfo.height = + (size_t)random_log_in_range(16, (int)maxHeight / 32, seed); + srcImageInfo.depth = + (size_t)random_log_in_range(16, (int)maxDepth / 32, seed); if (gTestMipmaps) { - imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, imageInfo.depth), seed); - imageInfo.rowPitch = imageInfo.width * get_pixel_size( imageInfo.format ); - imageInfo.slicePitch = imageInfo.height * imageInfo.rowPitch; - size = compute_mipmapped_image_size( imageInfo ); + srcImageInfo.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(srcImageInfo.width, + srcImageInfo.height, + srcImageInfo.depth), + seed); + srcImageInfo.rowPitch = srcImageInfo.width + * get_pixel_size(srcImageInfo.format); + srcImageInfo.slicePitch = + srcImageInfo.height * srcImageInfo.rowPitch; + size = compute_mipmapped_image_size(srcImageInfo); size = size*4; } else { - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; - if (gEnablePitch) - { - do { - rowPadding++; - imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; - } while ((imageInfo.rowPitch % pixelSize) != 0); - } + if (gEnablePitch) + { + do + { + rowPadding++; + srcImageInfo.rowPitch = + srcImageInfo.width * pixelSize + rowPadding; + } while ((srcImageInfo.rowPitch % pixelSize) != 0); + } - imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding); + srcImageInfo.slicePitch = srcImageInfo.rowPitch + * (srcImageInfo.height + slicePadding); - size = (cl_ulong)imageInfo.slicePitch * (cl_ulong)imageInfo.depth * 4 * 4; + size = (cl_ulong)srcImageInfo.slicePitch + * (cl_ulong)srcImageInfo.depth * 4 * 4; } } while( size > maxAllocSize || ( size * 3 ) > memSize ); if( gDebugTrace ) - log_info( " at size %d,%d,%d (pitch %d,%d) out of %d,%d,%d\n", (int)imageInfo.width, (int)imageInfo.height, (int)imageInfo.depth, (int)imageInfo.rowPitch, (int)imageInfo.slicePitch, (int)maxWidth, (int)maxHeight, (int)maxDepth ); - int ret = test_copy_image_3D( context, queue, &imageInfo,seed ); + log_info(" at size %d,%d,%d (pitch %d,%d) out of %d,%d,%d\n", + (int)srcImageInfo.width, (int)srcImageInfo.height, + (int)srcImageInfo.depth, (int)srcImageInfo.rowPitch, + (int)srcImageInfo.slicePitch, (int)maxWidth, + (int)maxHeight, (int)maxDepth); + + dstImageInfo = srcImageInfo; + dstImageInfo.mem_flags = dst_flags; + int ret = test_copy_image_3D(context, queue, &srcImageInfo, + &dstImageInfo, seed); if( ret ) return -1; } diff --git a/test_conformance/images/clCopyImage/test_copy_3D_2D_array.cpp b/test_conformance/images/clCopyImage/test_copy_3D_2D_array.cpp index 1da1e477..e135af5d 100644 --- a/test_conformance/images/clCopyImage/test_copy_3D_2D_array.cpp +++ b/test_conformance/images/clCopyImage/test_copy_3D_2D_array.cpp @@ -37,12 +37,8 @@ static void set_image_dimensions( image_descriptor *imageInfo, size_t width, siz } while ((imageInfo->rowPitch % pixelSize) != 0); } - imageInfo->slicePitch = imageInfo->rowPitch * (imageInfo->height + slicePadding); - - if (arraySize == 0) - imageInfo->type = CL_MEM_OBJECT_IMAGE3D; - else - imageInfo->type = CL_MEM_OBJECT_IMAGE2D_ARRAY; + imageInfo->slicePitch = + imageInfo->rowPitch * (imageInfo->height + slicePadding); } @@ -227,17 +223,33 @@ int test_copy_image_size_3D_2D_array( cl_context context, cl_command_queue queue } -int test_copy_image_set_3D_2D_array(cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, bool reverse = false ) +int test_copy_image_set_3D_2D_array( + cl_device_id device, cl_context context, cl_command_queue queue, + cl_mem_flags src_flags, cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format) { size_t maxWidth, maxHeight, max3DWidth, max3DHeight, maxDepth, maxArraySize; cl_ulong maxAllocSize, memSize; - image_descriptor srcImageInfo = { 0 }; - image_descriptor dstImageInfo = { 0 }; + const bool reverse = (src_type == CL_MEM_OBJECT_IMAGE2D_ARRAY); + image_descriptor imageInfo3D = { 0 }; + image_descriptor imageInfo2Darray = { 0 }; RandomSeed seed( gRandomSeed ); size_t rowPadding = gEnablePitch ? 256 : 0; size_t slicePadding = gEnablePitch ? 3 : 0; - srcImageInfo.format = dstImageInfo.format = format; + imageInfo3D.format = imageInfo2Darray.format = format; + imageInfo3D.type = CL_MEM_OBJECT_IMAGE3D; + imageInfo2Darray.type = CL_MEM_OBJECT_IMAGE2D_ARRAY; + if (reverse) + { + imageInfo2Darray.mem_flags = src_flags; + imageInfo3D.mem_flags = dst_flags; + } + else + { + imageInfo3D.mem_flags = src_flags; + imageInfo2Darray.mem_flags = dst_flags; + } int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL ); @@ -256,39 +268,79 @@ int test_copy_image_set_3D_2D_array(cl_device_id device, cl_context context, cl_ if( gTestSmallImages ) { - for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ ) + for (imageInfo2Darray.width = 4; imageInfo2Darray.width < 17; + imageInfo2Darray.width++) { - for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ ) + for (imageInfo2Darray.height = 4; imageInfo2Darray.height < 13; + imageInfo2Darray.height++) { - for( dstImageInfo.arraySize = 4; dstImageInfo.arraySize < 9; dstImageInfo.arraySize++ ) + for (imageInfo2Darray.arraySize = 4; + imageInfo2Darray.arraySize < 9; + imageInfo2Darray.arraySize++) { - set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, 0, dstImageInfo.arraySize, rowPadding, slicePadding ); - set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, 0, rowPadding, slicePadding ); + set_image_dimensions( + &imageInfo2Darray, imageInfo2Darray.width, + imageInfo2Darray.height, 0, imageInfo2Darray.arraySize, + rowPadding, slicePadding); + set_image_dimensions(&imageInfo3D, imageInfo2Darray.width, + imageInfo2Darray.height, + imageInfo2Darray.arraySize, 0, + rowPadding, slicePadding); if (gTestMipmaps) { - dstImageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY; - dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, 0), seed); - srcImageInfo.type = CL_MEM_OBJECT_IMAGE3D; - srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, srcImageInfo.depth), seed); - srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format ); - srcImageInfo.slicePitch = srcImageInfo.rowPitch * srcImageInfo.height; - dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format ); - dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height; + imageInfo2Darray.num_mip_levels = + (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels( + imageInfo2Darray.width, + imageInfo2Darray.height, 0), + seed); + imageInfo3D.num_mip_levels = + (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo3D.width, + imageInfo3D.height, + imageInfo3D.depth), + seed); + imageInfo3D.rowPitch = imageInfo3D.width + * get_pixel_size(imageInfo3D.format); + imageInfo3D.slicePitch = + imageInfo3D.rowPitch * imageInfo3D.height; + imageInfo2Darray.rowPitch = imageInfo2Darray.width + * get_pixel_size(imageInfo2Darray.format); + imageInfo2Darray.slicePitch = + imageInfo2Darray.rowPitch * imageInfo2Darray.height; } if( gDebugTrace ) { if (reverse) - log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth ); + log_info(" at size %d,%d,%d to %d,%d,%d\n", + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize, + (int)imageInfo3D.width, + (int)imageInfo3D.height, + (int)imageInfo3D.depth); else - log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize ); + log_info(" at size %d,%d,%d to %d,%d,%d\n", + (int)imageInfo3D.width, + (int)imageInfo3D.height, + (int)imageInfo3D.depth, + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize); } int ret; if( reverse ) - ret = test_copy_image_size_3D_2D_array( context, queue, &dstImageInfo, &srcImageInfo, seed ); + ret = test_copy_image_size_3D_2D_array( + context, queue, &imageInfo2Darray, &imageInfo3D, + seed); else - ret = test_copy_image_size_3D_2D_array( context, queue, &srcImageInfo, &dstImageInfo, seed ); + ret = test_copy_image_size_3D_2D_array( + context, queue, &imageInfo3D, &imageInfo2Darray, + seed); if( ret ) return -1; } @@ -303,62 +355,115 @@ int test_copy_image_set_3D_2D_array(cl_device_id device, cl_context context, cl_ size_t sizes2Darray[100][3]; // Try to allocate a bit smaller images because we need the 3D ones as well for the copy. - get_max_sizes(&numbeOfSizes, 100, sizes2Darray, maxWidth, maxHeight, maxDepth, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D_ARRAY, srcImageInfo.format); - get_max_sizes(&numbeOfSizes, 100, sizes3D, max3DWidth, max3DHeight, maxDepth, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE3D, dstImageInfo.format); + get_max_sizes(&numbeOfSizes, 100, sizes2Darray, maxWidth, maxHeight, + maxDepth, maxArraySize, maxAllocSize / 2, memSize / 2, + CL_MEM_OBJECT_IMAGE2D_ARRAY, imageInfo3D.format); + get_max_sizes(&numbeOfSizes, 100, sizes3D, max3DWidth, max3DHeight, + maxDepth, maxArraySize, maxAllocSize / 2, memSize / 2, + CL_MEM_OBJECT_IMAGE3D, imageInfo2Darray.format); for( size_t idx = 0; idx < numbeOfSizes; idx++ ) { - set_image_dimensions( &srcImageInfo, sizes3D[ idx ][ 0 ], sizes3D[ idx ][ 1 ], sizes3D[ idx ][ 2 ], 0, rowPadding, slicePadding ); - set_image_dimensions( &dstImageInfo, sizes2Darray[ idx ][ 0 ], sizes2Darray[ idx ][ 1 ], 0, sizes2Darray[ idx ][ 2 ], rowPadding, slicePadding ); + set_image_dimensions(&imageInfo3D, sizes3D[idx][0], sizes3D[idx][1], + sizes3D[idx][2], 0, rowPadding, slicePadding); + set_image_dimensions(&imageInfo2Darray, sizes2Darray[idx][0], + sizes2Darray[idx][1], 0, sizes2Darray[idx][2], + rowPadding, slicePadding); - cl_ulong dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize; - cl_ulong srcSize = (cl_ulong)srcImageInfo.slicePitch * (cl_ulong)srcImageInfo.depth; + cl_ulong dstSize = (cl_ulong)imageInfo2Darray.slicePitch + * (cl_ulong)imageInfo2Darray.arraySize; + cl_ulong srcSize = + (cl_ulong)imageInfo3D.slicePitch * (cl_ulong)imageInfo3D.depth; if (gTestMipmaps) { - dstImageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY; - dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, 0), seed); - srcImageInfo.type = CL_MEM_OBJECT_IMAGE3D; - srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, srcImageInfo.depth), seed); - srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format ); - srcImageInfo.slicePitch = srcImageInfo.rowPitch * srcImageInfo.height; - dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format ); - dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height; - srcSize = 4 * compute_mipmapped_image_size( srcImageInfo ); - dstSize = 4 * compute_mipmapped_image_size( dstImageInfo ); + imageInfo2Darray.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo2Darray.width, + imageInfo2Darray.height, 0), + seed); + imageInfo3D.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo3D.width, + imageInfo3D.height, + imageInfo3D.depth), + seed); + imageInfo3D.rowPitch = + imageInfo3D.width * get_pixel_size(imageInfo3D.format); + imageInfo3D.slicePitch = + imageInfo3D.rowPitch * imageInfo3D.height; + imageInfo2Darray.rowPitch = imageInfo2Darray.width + * get_pixel_size(imageInfo2Darray.format); + imageInfo2Darray.slicePitch = + imageInfo2Darray.rowPitch * imageInfo2Darray.height; + srcSize = 4 * compute_mipmapped_image_size(imageInfo3D); + dstSize = 4 * compute_mipmapped_image_size(imageInfo2Darray); } if ( ( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) ) && ( srcSize < maxAllocSize && srcSize < ( memSize / 3 ) ) ) { if (reverse) - log_info( "Testing %d x %d x %d to %d x %d x %d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth ); + log_info("Testing %d x %d x %d to %d x %d x %d\n", + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize, + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth); else - log_info( "Testing %d x %d x %d to %d x %d x %d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize ); + log_info("Testing %d x %d x %d to %d x %d x %d\n", + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth, + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize); if( gDebugTrace ) { if (reverse) - log_info( " at max size %d,%d,%d to %d,%d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth ); + log_info(" at max size %d,%d,%d to %d,%d,%d\n", + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize, + (int)imageInfo3D.width, + (int)imageInfo3D.height, + (int)imageInfo3D.depth); else - log_info( " at max size %d,%d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize ); + log_info( + " at max size %d,%d,%d to %d,%d,%d\n", + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth, (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize); } int ret; if( reverse ) - ret = test_copy_image_size_3D_2D_array( context, queue, &dstImageInfo, &srcImageInfo, seed ); + ret = test_copy_image_size_3D_2D_array( + context, queue, &imageInfo2Darray, &imageInfo3D, seed); else - ret = test_copy_image_size_3D_2D_array( context, queue, &srcImageInfo, &dstImageInfo, seed ); + ret = test_copy_image_size_3D_2D_array( + context, queue, &imageInfo3D, &imageInfo2Darray, seed); if( ret ) return -1; } else { if (reverse) - log_info("Not testing max size %d x %d x %d x %d to %d x %d due to memory constraints.\n", - (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth); + log_info("Not testing max size %d x %d x %d x %d to %d x " + "%d due to memory constraints.\n", + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize, + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth); else - log_info("Not testing max size %d x %d x %d to %d x %d x %d due to memory constraints.\n", - (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize); + log_info("Not testing max size %d x %d x %d to %d x %d x " + "%d due to memory constraints.\n", + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth, + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize); } } @@ -372,48 +477,87 @@ int test_copy_image_set_3D_2D_array(cl_device_id device, cl_context context, cl_ // image, the result array, plus offset arrays, will fit in the global ram space do { - dstImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed ); - dstImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed ); - dstImageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed ); - srcImageInfo.width = (size_t)random_log_in_range( 16, (int)max3DWidth / 32, seed ); - srcImageInfo.height = (size_t)random_log_in_range( 16, (int)max3DHeight / 32, seed ); - srcImageInfo.depth = (size_t)random_log_in_range( 16, (int)maxDepth / 32, seed ); + imageInfo2Darray.width = + (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + imageInfo2Darray.height = + (size_t)random_log_in_range(16, (int)maxHeight / 32, seed); + imageInfo2Darray.arraySize = (size_t)random_log_in_range( + 16, (int)maxArraySize / 32, seed); + imageInfo3D.width = + (size_t)random_log_in_range(16, (int)max3DWidth / 32, seed); + imageInfo3D.height = (size_t)random_log_in_range( + 16, (int)max3DHeight / 32, seed); + imageInfo3D.depth = + (size_t)random_log_in_range(16, (int)maxDepth / 128, seed); if (gTestMipmaps) { - dstImageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY; - dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, 0), seed); - srcImageInfo.type = CL_MEM_OBJECT_IMAGE3D; - srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, srcImageInfo.depth), seed); - srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format ); - srcImageInfo.slicePitch = srcImageInfo.rowPitch * srcImageInfo.height; - dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format ); - dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height; - srcSize = 4 * compute_mipmapped_image_size( srcImageInfo ); - dstSize = 4 * compute_mipmapped_image_size( dstImageInfo ); + imageInfo2Darray.num_mip_levels = + (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo2Darray.width, + imageInfo2Darray.height, + 0), + seed); + imageInfo3D.num_mip_levels = (cl_uint)random_log_in_range( + 2, + (int)compute_max_mip_levels(imageInfo3D.width, + imageInfo3D.height, + imageInfo3D.depth), + seed); + imageInfo3D.rowPitch = + imageInfo3D.width * get_pixel_size(imageInfo3D.format); + imageInfo3D.slicePitch = + imageInfo3D.rowPitch * imageInfo3D.height; + imageInfo2Darray.rowPitch = imageInfo2Darray.width + * get_pixel_size(imageInfo2Darray.format); + imageInfo2Darray.slicePitch = + imageInfo2Darray.rowPitch * imageInfo2Darray.height; + srcSize = 4 * compute_mipmapped_image_size(imageInfo3D); + dstSize = + 4 * compute_mipmapped_image_size(imageInfo2Darray); } else { - set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, srcImageInfo.depth, 0, rowPadding, slicePadding ); - set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, 0, dstImageInfo.arraySize, rowPadding, slicePadding ); + set_image_dimensions(&imageInfo3D, imageInfo3D.width, + imageInfo3D.height, imageInfo3D.depth, + 0, rowPadding, slicePadding); + set_image_dimensions( + &imageInfo2Darray, imageInfo2Darray.width, + imageInfo2Darray.height, 0, imageInfo2Darray.arraySize, + rowPadding, slicePadding); - srcSize = (cl_ulong)srcImageInfo.slicePitch * (cl_ulong)srcImageInfo.depth * 4; - dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize * 4; + srcSize = (cl_ulong)imageInfo3D.slicePitch + * (cl_ulong)imageInfo3D.depth * 4; + dstSize = (cl_ulong)imageInfo2Darray.slicePitch + * (cl_ulong)imageInfo2Darray.arraySize * 4; } } while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize); if( gDebugTrace ) { if (reverse) - log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth ); + log_info(" at size %d,%d,%d to %d,%d,%d\n", + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize, + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth); else - log_info( " at size %d,%d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)srcImageInfo.depth, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize ); + log_info(" at size %d,%d,%d to %d,%d,%d\n", + (int)imageInfo3D.width, (int)imageInfo3D.height, + (int)imageInfo3D.depth, + (int)imageInfo2Darray.width, + (int)imageInfo2Darray.height, + (int)imageInfo2Darray.arraySize); } int ret; if( reverse ) - ret = test_copy_image_size_3D_2D_array( context, queue, &dstImageInfo, &srcImageInfo, seed ); + ret = test_copy_image_size_3D_2D_array( + context, queue, &imageInfo2Darray, &imageInfo3D, seed); else - ret = test_copy_image_size_3D_2D_array( context, queue, &srcImageInfo, &dstImageInfo, seed ); + ret = test_copy_image_size_3D_2D_array( + context, queue, &imageInfo3D, &imageInfo2Darray, seed); if( ret ) return -1; } diff --git a/test_conformance/images/clCopyImage/test_loops.cpp b/test_conformance/images/clCopyImage/test_loops.cpp index d9c54854..c5a1ed29 100644 --- a/test_conformance/images/clCopyImage/test_loops.cpp +++ b/test_conformance/images/clCopyImage/test_loops.cpp @@ -15,32 +15,77 @@ // #include "../testBase.h" #include "../common.h" +#include -extern int test_copy_image_set_1D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format ); -extern int test_copy_image_set_2D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format ); -extern int test_copy_image_set_3D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format ); -extern int test_copy_image_set_1D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format ); -extern int test_copy_image_set_2D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format ); -extern int test_copy_image_set_2D_3D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, bool reverse ); -extern int test_copy_image_set_2D_2D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, bool reverse ); -extern int test_copy_image_set_3D_2D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, bool reverse ); -extern int test_copy_image_set_1D_buffer(cl_device_id device, - cl_context context, - cl_command_queue queue, - cl_image_format *format); -extern int test_copy_image_set_1D_1D_buffer(cl_device_id device, - cl_context context, - cl_command_queue queue, - cl_image_format *format); -extern int test_copy_image_set_1D_buffer_1D(cl_device_id device, - cl_context context, - cl_command_queue queue, - cl_image_format *format); +extern int +test_copy_image_set_1D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_mem_flags src_flags, + cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format); +extern int +test_copy_image_set_2D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_mem_flags src_flags, + cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format); +extern int +test_copy_image_set_3D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_mem_flags src_flags, + cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format); +extern int test_copy_image_set_1D_array( + cl_device_id device, cl_context context, cl_command_queue queue, + cl_mem_flags src_flags, cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format); +extern int test_copy_image_set_2D_array( + cl_device_id device, cl_context context, cl_command_queue queue, + cl_mem_flags src_flags, cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format); +extern int +test_copy_image_set_2D_3D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_mem_flags src_flags, + cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format); +extern int test_copy_image_set_2D_2D_array( + cl_device_id device, cl_context context, cl_command_queue queue, + cl_mem_flags src_flags, cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format); +extern int test_copy_image_set_3D_2D_array( + cl_device_id device, cl_context context, cl_command_queue queue, + cl_mem_flags src_flags, cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format); +extern int test_copy_image_set_1D_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + cl_mem_flags src_flags, cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format); +extern int test_copy_image_set_1D_1D_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + cl_mem_flags src_flags, cl_mem_object_type src_type, cl_mem_flags dst_flags, + cl_mem_object_type dst_type, cl_image_format *format); -int test_image_type( cl_device_id device, cl_context context, cl_command_queue queue, MethodsToTest testMethod, cl_mem_flags flags ) +using test_function_t = int (*)(cl_device_id, cl_context, cl_command_queue, + cl_mem_flags, cl_mem_object_type, cl_mem_flags, + cl_mem_object_type, cl_image_format *); + +struct TestConfigs { - const char *name = nullptr; - cl_mem_object_type imageType = 0; + const char *name; + cl_mem_object_type src_type; + cl_mem_flags src_flags; + cl_mem_object_type dst_type; + cl_mem_flags dst_flags; + + TestConfigs(const char *name_, cl_mem_object_type src_type_, + cl_mem_flags src_flags_, cl_mem_object_type dst_type_, + cl_mem_flags dst_flags_) + : name(name_), src_type(src_type_), src_flags(src_flags_), + dst_type(dst_type_), dst_flags(dst_flags_) + {} +}; + +int test_image_type(cl_device_id device, cl_context context, + cl_command_queue queue, MethodsToTest testMethod) +{ + test_function_t test_fn = nullptr; if ( gTestMipmaps ) { @@ -49,138 +94,217 @@ int test_image_type( cl_device_id device, cl_context context, cl_command_queue q log_info( "-----------------------------------------------------\n" ); log_info( "This device does not support cl_khr_mipmap_image.\nSkipping mipmapped image test. \n" ); log_info( "-----------------------------------------------------\n\n" ); - return 0; + return TEST_SKIPPED_ITSELF; } } + std::vector test_configs; switch (testMethod) { case k1D: - name = "1D -> 1D"; - imageType = CL_MEM_OBJECT_IMAGE1D; + test_configs.emplace_back( + "1D -> 1D", CL_MEM_OBJECT_IMAGE1D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE1D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_1D; break; case k2D: - name = "2D -> 2D"; - imageType = CL_MEM_OBJECT_IMAGE2D; + test_configs.emplace_back( + "2D -> 2D", CL_MEM_OBJECT_IMAGE2D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE2D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_2D; break; case k3D: - name = "3D -> 3D"; - imageType = CL_MEM_OBJECT_IMAGE3D; + test_configs.emplace_back( + "3D -> 3D", CL_MEM_OBJECT_IMAGE3D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE3D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_3D; break; case k1DArray: - name = "1D array -> 1D array"; - imageType = CL_MEM_OBJECT_IMAGE1D_ARRAY; + test_configs.emplace_back( + "1D array -> 1D array", CL_MEM_OBJECT_IMAGE1D_ARRAY, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE1D_ARRAY, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_1D_array; break; case k2DArray: - name = "2D array -> 2D array"; - imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY; + test_configs.emplace_back( + "2D array -> 2D array", CL_MEM_OBJECT_IMAGE2D_ARRAY, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE2D_ARRAY, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_2D_array; break; case k2DTo3D: - name = "2D -> 3D"; - imageType = CL_MEM_OBJECT_IMAGE3D; + test_configs.emplace_back( + "2D -> 3D", CL_MEM_OBJECT_IMAGE2D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE3D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_2D_3D; break; case k3DTo2D: - name = "3D -> 2D"; - imageType = CL_MEM_OBJECT_IMAGE3D; + test_configs.emplace_back( + "3D -> 2D", CL_MEM_OBJECT_IMAGE3D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE2D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_2D_3D; break; case k2DArrayTo2D: - name = "2D array -> 2D"; - imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY; + test_configs.emplace_back( + "2D array -> 2D", CL_MEM_OBJECT_IMAGE2D_ARRAY, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE2D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_2D_2D_array; break; case k2DTo2DArray: - name = "2D -> 2D array"; - imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY; + test_configs.emplace_back( + "2D -> 2D array", CL_MEM_OBJECT_IMAGE2D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE2D_ARRAY, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_2D_2D_array; break; case k2DArrayTo3D: - name = "2D array -> 3D"; - imageType = CL_MEM_OBJECT_IMAGE3D; + test_configs.emplace_back( + "2D array -> 3D", CL_MEM_OBJECT_IMAGE2D_ARRAY, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE3D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_3D_2D_array; break; case k3DTo2DArray: - name = "3D -> 2D array"; - imageType = CL_MEM_OBJECT_IMAGE3D; + test_configs.emplace_back( + "3D -> 2D array", CL_MEM_OBJECT_IMAGE3D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE2D_ARRAY, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_3D_2D_array; break; case k1DBuffer: - name = "1D buffer -> 1D buffer"; - imageType = CL_MEM_OBJECT_IMAGE1D_BUFFER; + test_configs.emplace_back( + "1D buffer -> 1D buffer", CL_MEM_OBJECT_IMAGE1D_BUFFER, + CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE1D_BUFFER, + CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_1D_buffer; break; case k1DTo1DBuffer: - name = "1D -> 1D buffer"; - imageType = CL_MEM_OBJECT_IMAGE1D_BUFFER; + test_configs.emplace_back( + "1D -> 1D buffer", CL_MEM_OBJECT_IMAGE1D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY, + CL_MEM_OBJECT_IMAGE1D_BUFFER, CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_1D_1D_buffer; break; case k1DBufferTo1D: - name = "1D buffer -> 1D"; - imageType = CL_MEM_OBJECT_IMAGE1D_BUFFER; + test_configs.emplace_back( + "1D buffer -> 1D", CL_MEM_OBJECT_IMAGE1D_BUFFER, + CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE1D, + gEnablePitch ? CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY + : CL_MEM_READ_ONLY); + test_fn = test_copy_image_set_1D_1D_buffer; break; } - if(gTestMipmaps) - log_info( "Running mipmapped %s tests...\n", name ); - else - log_info( "Running %s tests...\n", name ); int ret = 0; - - // Grab the list of supported image formats for integer reads - std::vector formatList; - if (get_format_list(context, imageType, formatList, flags)) return -1; - - std::vector filterFlags(formatList.size(), false); - filter_formats(formatList, filterFlags, nullptr); - - // Run the format list - for (unsigned int i = 0; i < formatList.size(); i++) + for (const auto &test_config : test_configs) { - int test_return = 0; - if( filterFlags[i] ) + if (gTestMipmaps) + log_info("Running mipmapped %s tests...\n", test_config.name); + else + log_info("Running %s tests...\n", test_config.name); + + // Grab the list of supported image formats for integer reads + std::vector formatList; { - continue; + std::vector srcFormatList; + std::vector dstFormatList; + if (get_format_list(context, test_config.src_type, srcFormatList, + test_config.src_flags)) + return TEST_FAIL; + if (get_format_list(context, test_config.dst_type, dstFormatList, + test_config.dst_flags)) + return TEST_FAIL; + + for (auto src_format : srcFormatList) + { + const bool src_format_in_dst = + std::find_if(dstFormatList.begin(), dstFormatList.end(), + [src_format](cl_image_format fmt) { + return src_format.image_channel_data_type + == fmt.image_channel_data_type + && src_format.image_channel_order + == fmt.image_channel_order; + }) + != dstFormatList.end(); + if (src_format_in_dst) + { + formatList.push_back(src_format); + } + } } - print_header( &formatList[ i ], false ); + std::vector filterFlags(formatList.size(), false); + filter_formats(formatList, filterFlags, nullptr); - gTestCount++; + // Run the format list + for (unsigned int i = 0; i < formatList.size(); i++) + { + int test_return = 0; + if (filterFlags[i]) + { + continue; + } - if( testMethod == k1D ) - test_return = test_copy_image_set_1D( device, context, queue, &formatList[ i ] ); - else if( testMethod == k2D ) - test_return = test_copy_image_set_2D( device, context, queue, &formatList[ i ] ); - else if( testMethod == k3D ) - test_return = test_copy_image_set_3D( device, context, queue,&formatList[ i ] ); - else if( testMethod == k1DArray ) - test_return = test_copy_image_set_1D_array( device, context, queue, &formatList[ i ] ); - else if( testMethod == k2DArray ) - test_return = test_copy_image_set_2D_array( device, context, queue, &formatList[ i ] ); - else if( testMethod == k2DTo3D ) - test_return = test_copy_image_set_2D_3D( device, context, queue, &formatList[ i ], false ); - else if( testMethod == k3DTo2D ) - test_return = test_copy_image_set_2D_3D( device, context, queue, &formatList[ i ], true ); - else if( testMethod == k2DArrayTo2D) - test_return = test_copy_image_set_2D_2D_array( device, context, queue, &formatList[ i ], true); - else if( testMethod == k2DTo2DArray) - test_return = test_copy_image_set_2D_2D_array( device, context, queue, &formatList[ i ], false); - else if( testMethod == k2DArrayTo3D) - test_return = test_copy_image_set_3D_2D_array( device, context, queue, &formatList[ i ], true); - else if( testMethod == k3DTo2DArray) - test_return = test_copy_image_set_3D_2D_array( device, context, queue, &formatList[ i ], false); - else if (testMethod == k1DBuffer) - test_return = test_copy_image_set_1D_buffer(device, context, queue, - &formatList[i]); - else if (testMethod == k1DBufferTo1D) - test_return = test_copy_image_set_1D_buffer_1D( - device, context, queue, &formatList[i]); - else if (testMethod == k1DTo1DBuffer) - test_return = test_copy_image_set_1D_1D_buffer( - device, context, queue, &formatList[i]); + print_header(&formatList[i], false); + gTestCount++; - if (test_return) { - gFailCount++; - log_error( "FAILED: " ); - print_header( &formatList[ i ], true ); - log_info( "\n" ); + test_return = test_fn(device, context, queue, test_config.src_flags, + test_config.src_type, test_config.dst_flags, + test_config.dst_type, &formatList[i]); + + if (test_return) + { + gFailCount++; + log_error("FAILED: "); + print_header(&formatList[i], true); + log_info("\n"); + } + + ret += test_return; } - - ret += test_return; } return ret; @@ -188,11 +312,7 @@ int test_image_type( cl_device_id device, cl_context context, cl_command_queue q int test_image_set( cl_device_id device, cl_context context, cl_command_queue queue, MethodsToTest testMethod ) { - int ret = 0; - - ret += test_image_type( device, context, queue, testMethod, CL_MEM_READ_ONLY ); - - return ret; + return test_image_type(device, context, queue, testMethod); } diff --git a/test_conformance/images/clFillImage/test_fill_1D.cpp b/test_conformance/images/clFillImage/test_fill_1D.cpp index b1550bf3..ad19b52d 100644 --- a/test_conformance/images/clFillImage/test_fill_1D.cpp +++ b/test_conformance/images/clFillImage/test_fill_1D.cpp @@ -58,7 +58,9 @@ int test_fill_image_size_1D( cl_context context, cl_command_queue queue, image_d } -int test_fill_image_set_1D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType outputType ) +int test_fill_image_set_1D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_image_format *format, + cl_mem_flags mem_flags, ExplicitType outputType) { size_t maxWidth; cl_ulong maxAllocSize, memSize; @@ -71,6 +73,7 @@ int test_fill_image_set_1D( cl_device_id device, cl_context context, cl_command_ memset(&imageInfo, 0x0, sizeof(image_descriptor)); imageInfo.type = CL_MEM_OBJECT_IMAGE1D; imageInfo.format = format; + imageInfo.mem_flags = mem_flags; pixelSize = get_pixel_size( imageInfo.format ); int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); diff --git a/test_conformance/images/clFillImage/test_fill_1D_array.cpp b/test_conformance/images/clFillImage/test_fill_1D_array.cpp index be32ec6a..1c88f3da 100644 --- a/test_conformance/images/clFillImage/test_fill_1D_array.cpp +++ b/test_conformance/images/clFillImage/test_fill_1D_array.cpp @@ -60,7 +60,11 @@ int test_fill_image_size_1D_array( cl_context context, cl_command_queue queue, i } -int test_fill_image_set_1D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType outputType ) +int test_fill_image_set_1D_array(cl_device_id device, cl_context context, + cl_command_queue queue, + cl_image_format *format, + cl_mem_flags mem_flags, + ExplicitType outputType) { size_t maxWidth, maxArraySize; cl_ulong maxAllocSize, memSize; @@ -73,6 +77,7 @@ int test_fill_image_set_1D_array( cl_device_id device, cl_context context, cl_co memset(&imageInfo, 0x0, sizeof(image_descriptor)); imageInfo.type = CL_MEM_OBJECT_IMAGE1D_ARRAY; imageInfo.format = format; + imageInfo.mem_flags = mem_flags; pixelSize = get_pixel_size( imageInfo.format ); int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); diff --git a/test_conformance/images/clFillImage/test_fill_1D_buffer.cpp b/test_conformance/images/clFillImage/test_fill_1D_buffer.cpp index dad389ae..2e8790c1 100644 --- a/test_conformance/images/clFillImage/test_fill_1D_buffer.cpp +++ b/test_conformance/images/clFillImage/test_fill_1D_buffer.cpp @@ -71,6 +71,7 @@ int test_fill_image_size_1D_buffer(cl_context context, cl_command_queue queue, int test_fill_image_set_1D_buffer(cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, + cl_mem_flags mem_flags, ExplicitType outputType) { size_t maxWidth; @@ -84,6 +85,7 @@ int test_fill_image_set_1D_buffer(cl_device_id device, cl_context context, memset(&imageInfo, 0x0, sizeof(image_descriptor)); imageInfo.type = CL_MEM_OBJECT_IMAGE1D_BUFFER; imageInfo.format = format; + imageInfo.mem_flags = mem_flags; pixelSize = get_pixel_size(imageInfo.format); int error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, diff --git a/test_conformance/images/clFillImage/test_fill_2D.cpp b/test_conformance/images/clFillImage/test_fill_2D.cpp index e941abcf..93675485 100644 --- a/test_conformance/images/clFillImage/test_fill_2D.cpp +++ b/test_conformance/images/clFillImage/test_fill_2D.cpp @@ -60,7 +60,9 @@ int test_fill_image_size_2D( cl_context context, cl_command_queue queue, image_d } -int test_fill_image_set_2D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType outputType ) +int test_fill_image_set_2D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_image_format *format, + cl_mem_flags mem_flags, ExplicitType outputType) { size_t maxWidth, maxHeight; cl_ulong maxAllocSize, memSize; @@ -73,6 +75,7 @@ int test_fill_image_set_2D( cl_device_id device, cl_context context, cl_command_ memset(&imageInfo, 0x0, sizeof(image_descriptor)); imageInfo.type = CL_MEM_OBJECT_IMAGE2D; imageInfo.format = format; + imageInfo.mem_flags = mem_flags; pixelSize = get_pixel_size( imageInfo.format ); int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); diff --git a/test_conformance/images/clFillImage/test_fill_2D_array.cpp b/test_conformance/images/clFillImage/test_fill_2D_array.cpp index 38196cfc..12024e6e 100644 --- a/test_conformance/images/clFillImage/test_fill_2D_array.cpp +++ b/test_conformance/images/clFillImage/test_fill_2D_array.cpp @@ -62,7 +62,11 @@ static int test_fill_image_2D_array( cl_context context, cl_command_queue queue, } -int test_fill_image_set_2D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType outputType ) +int test_fill_image_set_2D_array(cl_device_id device, cl_context context, + cl_command_queue queue, + cl_image_format *format, + cl_mem_flags mem_flags, + ExplicitType outputType) { size_t maxWidth, maxHeight, maxArraySize; cl_ulong maxAllocSize, memSize; @@ -76,6 +80,7 @@ int test_fill_image_set_2D_array( cl_device_id device, cl_context context, cl_co memset(&imageInfo, 0x0, sizeof(image_descriptor)); imageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY; imageInfo.format = format; + imageInfo.mem_flags = mem_flags; pixelSize = get_pixel_size( imageInfo.format ); int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); diff --git a/test_conformance/images/clFillImage/test_fill_3D.cpp b/test_conformance/images/clFillImage/test_fill_3D.cpp index 0b8e4e58..75067e14 100644 --- a/test_conformance/images/clFillImage/test_fill_3D.cpp +++ b/test_conformance/images/clFillImage/test_fill_3D.cpp @@ -62,7 +62,9 @@ int test_fill_image_3D( cl_context context, cl_command_queue queue, image_descri } -int test_fill_image_set_3D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType outputType ) +int test_fill_image_set_3D(cl_device_id device, cl_context context, + cl_command_queue queue, cl_image_format *format, + cl_mem_flags mem_flags, ExplicitType outputType) { size_t maxWidth, maxHeight, maxDepth; cl_ulong maxAllocSize, memSize; @@ -76,6 +78,7 @@ int test_fill_image_set_3D( cl_device_id device, cl_context context, cl_command_ memset(&imageInfo, 0x0, sizeof(image_descriptor)); imageInfo.type = CL_MEM_OBJECT_IMAGE3D; imageInfo.format = format; + imageInfo.mem_flags = mem_flags; pixelSize = get_pixel_size( imageInfo.format ); int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL ); diff --git a/test_conformance/images/clFillImage/test_loops.cpp b/test_conformance/images/clFillImage/test_loops.cpp index 95677aec..cb1e1a3e 100644 --- a/test_conformance/images/clFillImage/test_loops.cpp +++ b/test_conformance/images/clFillImage/test_loops.cpp @@ -18,19 +18,38 @@ extern int gTypesToTest; -extern int test_fill_image_set_1D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType outputType ); -extern int test_fill_image_set_2D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType outputType ); -extern int test_fill_image_set_3D( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType outputType ); -extern int test_fill_image_set_1D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType outputType ); -extern int test_fill_image_set_2D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, ExplicitType outputType ); -extern int test_fill_image_set_1D_buffer(cl_device_id device, - cl_context context, - cl_command_queue queue, - cl_image_format *format, - ExplicitType outputType); +extern int test_fill_image_set_1D(cl_device_id device, cl_context context, + cl_command_queue queue, + cl_image_format *format, + cl_mem_flags mem_flags, + ExplicitType outputType); +extern int test_fill_image_set_2D(cl_device_id device, cl_context context, + cl_command_queue queue, + cl_image_format *format, + cl_mem_flags mem_flags, + ExplicitType outputType); +extern int test_fill_image_set_3D(cl_device_id device, cl_context context, + cl_command_queue queue, + cl_image_format *format, + cl_mem_flags mem_flags, + ExplicitType outputType); +extern int test_fill_image_set_1D_array(cl_device_id device, cl_context context, + cl_command_queue queue, + cl_image_format *format, + cl_mem_flags mem_flags, + ExplicitType outputType); +extern int test_fill_image_set_2D_array(cl_device_id device, cl_context context, + cl_command_queue queue, + cl_image_format *format, + cl_mem_flags mem_flags, + ExplicitType outputType); +extern int +test_fill_image_set_1D_buffer(cl_device_id device, cl_context context, + cl_command_queue queue, cl_image_format *format, + cl_mem_flags mem_flags, ExplicitType outputType); typedef int (*test_func)(cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, - ExplicitType outputType); + cl_mem_flags mem_flags, ExplicitType outputType); int test_image_type( cl_device_id device, cl_context context, cl_command_queue queue, MethodsToTest testMethod, cl_mem_flags flags ) { @@ -105,7 +124,7 @@ int test_image_type( cl_device_id device, cl_context context, cl_command_queue q gTestCount++; int test_return = - test_fn(device, context, queue, &formatList[i], + test_fn(device, context, queue, &formatList[i], flags, test.explicitType); if (test_return) { @@ -128,8 +147,12 @@ int test_image_type( cl_device_id device, cl_context context, cl_command_queue q int test_image_set( cl_device_id device, cl_context context, cl_command_queue queue, MethodsToTest testMethod ) { int ret = 0; - - ret += test_image_type( device, context, queue, testMethod, CL_MEM_READ_ONLY ); + cl_mem_flags flags = CL_MEM_READ_ONLY; + if (gEnablePitch && testMethod != k1DBuffer) + { + flags |= CL_MEM_USE_HOST_PTR; + } + ret += test_image_type(device, context, queue, testMethod, flags); return ret; } diff --git a/test_conformance/images/common.cpp b/test_conformance/images/common.cpp index f11a0215..84254e77 100644 --- a/test_conformance/images/common.cpp +++ b/test_conformance/images/common.cpp @@ -173,7 +173,6 @@ clMemWrapper create_image(cl_context context, cl_command_queue queue, { cl_mem img; cl_image_desc imageDesc; - cl_mem_flags mem_flags = CL_MEM_READ_ONLY; void *host_ptr = nullptr; bool is_host_ptr_aligned = false; @@ -310,21 +309,17 @@ clMemWrapper create_image(cl_context context, cl_command_queue queue, imageInfo->depth * imageInfo->slicePitch); return nullptr; } - if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) - { - mem_flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR; - } } if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) { - img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, - host_ptr, error); + img = clCreateImage(context, imageInfo->mem_flags, imageInfo->format, + &imageDesc, host_ptr, error); } else { - img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, - nullptr, error); + img = clCreateImage(context, imageInfo->mem_flags, imageInfo->format, + &imageDesc, nullptr, error); } if (enable_pitch)