mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Initial open source release of OpenCL 2.2 CTS.
This commit is contained in:
28
test_conformance/images/clCopyImage/CMakeLists.txt
Normal file
28
test_conformance/images/clCopyImage/CMakeLists.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
set(MODULE_NAME CL_COPY_IMAGES)
|
||||
|
||||
set(${MODULE_NAME}_SOURCES
|
||||
main.cpp
|
||||
test_copy_1D.cpp
|
||||
test_copy_1D_array.cpp
|
||||
test_copy_2D.cpp
|
||||
test_copy_2D_2D_array.cpp
|
||||
test_copy_2D_3D.cpp
|
||||
test_copy_2D_array.cpp
|
||||
test_copy_3D.cpp
|
||||
test_copy_3D_2D_array.cpp
|
||||
test_copy_generic.cpp
|
||||
test_loops.cpp
|
||||
../../../test_common/harness/testHarness.c
|
||||
../../../test_common/harness/errorHelpers.c
|
||||
../../../test_common/harness/threadTesting.c
|
||||
../../../test_common/harness/kernelHelpers.c
|
||||
../../../test_common/harness/imageHelpers.cpp
|
||||
../../../test_common/harness/mt19937.c
|
||||
../../../test_common/harness/conversions.c
|
||||
../../../test_common/harness/typeWrappers.cpp
|
||||
../../../test_common/harness/msvc9.c
|
||||
../../../test_common/harness/parseParameters.cpp
|
||||
)
|
||||
|
||||
include(../../CMakeCommon.txt)
|
||||
|
||||
19
test_conformance/images/clCopyImage/Jamfile
Normal file
19
test_conformance/images/clCopyImage/Jamfile
Normal file
@@ -0,0 +1,19 @@
|
||||
project
|
||||
: requirements
|
||||
# <toolset>gcc:<cflags>-xc++
|
||||
# <toolset>msvc:<cflags>"/TP"
|
||||
;
|
||||
|
||||
exe test_cl_copy_images
|
||||
: main.cpp
|
||||
test_copy_2D_3D.cpp
|
||||
test_copy_2D.cpp
|
||||
test_copy_3D.cpp
|
||||
test_loops.cpp
|
||||
;
|
||||
|
||||
install dist
|
||||
: test_cl_copy_images
|
||||
: <variant>debug:<location>$(DIST)/debug/tests/test_conformance/images/clCopyImage
|
||||
<variant>release:<location>$(DIST)/release/tests/test_conformance/images/clCopyImage
|
||||
;
|
||||
56
test_conformance/images/clCopyImage/Makefile
Normal file
56
test_conformance/images/clCopyImage/Makefile
Normal file
@@ -0,0 +1,56 @@
|
||||
ifdef BUILD_WITH_ATF
|
||||
ATF = -framework ATF
|
||||
USE_ATF = -DUSE_ATF
|
||||
endif
|
||||
|
||||
SRCS = main.cpp \
|
||||
test_copy_generic.cpp \
|
||||
test_copy_1D.cpp \
|
||||
test_copy_2D.cpp \
|
||||
test_loops.cpp \
|
||||
test_copy_3D.cpp \
|
||||
test_copy_1D_array.cpp \
|
||||
test_copy_2D_array.cpp \
|
||||
test_copy_2D_3D.cpp \
|
||||
test_copy_2D_2D_array.cpp \
|
||||
test_copy_3D_2D_array.cpp \
|
||||
../../../test_common/harness/errorHelpers.c \
|
||||
../../../test_common/harness/threadTesting.c \
|
||||
../../../test_common/harness/kernelHelpers.c \
|
||||
../../../test_common/harness/imageHelpers.cpp \
|
||||
../../../test_common/harness/conversions.c \
|
||||
../../../test_common/harness/testHarness.c \
|
||||
../../../test_common/harness/typeWrappers.cpp \
|
||||
../../../test_common/harness/mt19937.c
|
||||
|
||||
|
||||
DEFINES = DONT_TEST_GARBAGE_POINTERS
|
||||
|
||||
SOURCES = $(abspath $(SRCS))
|
||||
LIBPATH += -L/System/Library/Frameworks/OpenCL.framework/Libraries
|
||||
LIBPATH += -L.
|
||||
FRAMEWORK =
|
||||
HEADERS =
|
||||
TARGET = test_cl_copy_images
|
||||
INCLUDE =
|
||||
COMPILERFLAGS = -c -Wall -g -Wshorten-64-to-32 -Os
|
||||
CC = c++
|
||||
CXX = c++
|
||||
CFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
|
||||
CXXFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
|
||||
LIBRARIES = -framework OpenCL -framework OpenGL -framework GLUT -framework AppKit ${ATF}
|
||||
|
||||
OBJECTS := ${SOURCES:.c=.o}
|
||||
OBJECTS := ${OBJECTS:.cpp=.o}
|
||||
|
||||
TARGETOBJECT =
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CC) $(RC_CFLAGS) $(OBJECTS) -o $@ $(LIBPATH) $(LIBRARIES)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJECTS)
|
||||
|
||||
.DEFAULT:
|
||||
@echo The target \"$@\" does not exist in Makefile.
|
||||
265
test_conformance/images/clCopyImage/main.cpp
Normal file
265
test_conformance/images/clCopyImage/main.cpp
Normal file
@@ -0,0 +1,265 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../../../test_common/harness/compat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "../testBase.h"
|
||||
|
||||
bool gDebugTrace = false, gTestSmallImages = false, gTestMaxImages = false, gUseRamp = false, gTestRounding = false, gEnablePitch = false, gTestMipmaps = false;
|
||||
int gTypesToTest = 0;
|
||||
cl_channel_type gChannelTypeToUse = (cl_channel_type)-1;
|
||||
cl_channel_order gChannelOrderToUse = (cl_channel_order)-1;
|
||||
cl_device_type gDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
||||
cl_context context;
|
||||
cl_command_queue queue;
|
||||
|
||||
extern int test_image_set( cl_device_id device, MethodsToTest testMethod );
|
||||
|
||||
#define MAX_ALLOWED_STD_DEVIATION_IN_MB 8.0
|
||||
|
||||
void printUsage( const char *execName )
|
||||
{
|
||||
const char *p = strrchr( execName, '/' );
|
||||
if( p != NULL )
|
||||
execName = p + 1;
|
||||
|
||||
log_info( "Usage: %s [debug_trace] [small_images]\n", execName );
|
||||
log_info( "Where:\n" );
|
||||
log_info( "\t1D - Only test 1D images\n" );
|
||||
log_info( "\t2D - Only test 2D images\n" );
|
||||
log_info( "\t3D - Only test 3D images\n" );
|
||||
log_info( "\t1Darray - Only test 1D image arrays\n" );
|
||||
log_info( "\t2Darray - Only test 2D image arrays\n" );
|
||||
log_info( "\t2Dto3D - Only test 2D -> 3D images\n" );
|
||||
log_info( "\t3Dto2D - Only test 3D -> 2D images\n" );
|
||||
log_info( "\t2Darrayto2D - Only test 2D image arrays -> 2D images\n" );
|
||||
log_info( "\t2Dto2Darray - Only test 2D images -> 2D image arrays\n" );
|
||||
log_info( "\t2Darrayto3D - Only test 2D image arrays -> 3D images\n" );
|
||||
log_info( "\t3Dto2Darray - Only test 3D images -> 2D image arrays\n" );
|
||||
log_info( "\n" );
|
||||
log_info( "\ttest_mipmaps - Test with mipmapped images\n" );
|
||||
log_info( "\tdebug_trace - Enables additional debug info logging\n" );
|
||||
log_info( "\tsmall_images - Runs every format through a loop of widths 1-13 and heights 1-9, instead of random sizes\n" );
|
||||
log_info( "\tmax_images - Runs every format through a set of size combinations with the max values, max values - 1, and max values / 128\n" );
|
||||
log_info( "\trounding - Runs every format through a single image filled with every possible value for that image format, to verify rounding works properly\n" );
|
||||
//log_info( "\tuse_pitches - Enables row and slice pitches\n" );
|
||||
log_info( "\tuse_ramp - Instead of random data, uses images filled with ramps (and 0xff on any padding pixels) to ease debugging\n" );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
cl_platform_id platform;
|
||||
cl_device_id device;
|
||||
cl_channel_type chanType;
|
||||
cl_channel_order chanOrder;
|
||||
char str[ 128 ];
|
||||
int testMethods = 0;
|
||||
bool randomize = false;
|
||||
|
||||
test_start();
|
||||
|
||||
checkDeviceTypeOverride( &gDeviceType );
|
||||
|
||||
// Parse arguments
|
||||
for( int i = 1; i < argc; i++ )
|
||||
{
|
||||
strncpy( str, argv[ i ], sizeof( str ) - 1 );
|
||||
|
||||
if( strcmp( str, "cpu" ) == 0 || strcmp( str, "CL_DEVICE_TYPE_CPU" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_CPU;
|
||||
else if( strcmp( str, "gpu" ) == 0 || strcmp( str, "CL_DEVICE_TYPE_GPU" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_GPU;
|
||||
else if( strcmp( str, "accelerator" ) == 0 || strcmp( str, "CL_DEVICE_TYPE_ACCELERATOR" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_ACCELERATOR;
|
||||
else if( strcmp( str, "CL_DEVICE_TYPE_DEFAULT" ) == 0 )
|
||||
gDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
||||
|
||||
else if( strcmp( str, "test_mipmaps" ) == 0 )
|
||||
{
|
||||
gTestMipmaps = true;
|
||||
// Don't test pitches with mipmaps, at least currently.
|
||||
gEnablePitch = false;
|
||||
}
|
||||
else if( strcmp( str, "debug_trace" ) == 0 )
|
||||
gDebugTrace = true;
|
||||
|
||||
else if( strcmp( str, "small_images" ) == 0 )
|
||||
gTestSmallImages = true;
|
||||
else if( strcmp( str, "max_images" ) == 0 )
|
||||
gTestMaxImages = true;
|
||||
else if( strcmp( str, "use_ramps" ) == 0 )
|
||||
gUseRamp = true;
|
||||
|
||||
else if( strcmp( str, "use_pitches" ) == 0 )
|
||||
gEnablePitch = true;
|
||||
|
||||
else if( strcmp( str, "randomize" ) == 0 )
|
||||
randomize = true;
|
||||
|
||||
else if( strcmp( str, "1D" ) == 0 )
|
||||
testMethods |= k1D;
|
||||
else if( strcmp( str, "2D" ) == 0 )
|
||||
testMethods |= k2D;
|
||||
else if( strcmp( str, "3D" ) == 0 )
|
||||
testMethods |= k3D;
|
||||
else if( strcmp( str, "1Darray" ) == 0 )
|
||||
testMethods |= k1DArray;
|
||||
else if( strcmp( str, "2Darray" ) == 0 )
|
||||
testMethods |= k2DArray;
|
||||
else if( strcmp( str, "2Dto3D" ) == 0 )
|
||||
testMethods |= k2DTo3D;
|
||||
else if( strcmp( str, "3Dto2D" ) == 0 )
|
||||
testMethods |= k3DTo2D;
|
||||
else if( strcmp( str, "2Darrayto2D" ) == 0 )
|
||||
testMethods |= k2DArrayTo2D;
|
||||
else if( strcmp( str, "2Dto2Darray" ) == 0 )
|
||||
testMethods |= k2DTo2DArray;
|
||||
else if( strcmp( str, "2Darrayto3D" ) == 0 )
|
||||
testMethods |= k2DArrayTo3D;
|
||||
else if( strcmp( str, "3Dto2Darray" ) == 0 )
|
||||
testMethods |= k3DTo2DArray;
|
||||
|
||||
else if( strcmp( str, "help" ) == 0 || strcmp( str, "?" ) == 0 )
|
||||
{
|
||||
printUsage( argv[ 0 ] );
|
||||
return -1;
|
||||
}
|
||||
|
||||
else if( ( chanType = get_channel_type_from_name( str ) ) != (cl_channel_type)-1 )
|
||||
gChannelTypeToUse = chanType;
|
||||
|
||||
else if( ( chanOrder = get_channel_order_from_name( str ) ) != (cl_channel_order)-1 )
|
||||
gChannelOrderToUse = chanOrder;
|
||||
else
|
||||
{
|
||||
log_error( "ERROR: Unknown argument %d: %s. Exiting....\n", i, str );
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( testMethods == 0 )
|
||||
testMethods = k1D | k2D | k3D | k1DArray | k2DArray | k2DTo3D | k3DTo2D | k2DArrayTo2D | k2DTo2DArray | k2DArrayTo3D | k3DTo2DArray;
|
||||
|
||||
// Seed the random # generators
|
||||
if( randomize )
|
||||
{
|
||||
gRandomSeed = (cl_uint) time( NULL );
|
||||
log_info( "Random seed: %u.\n", gRandomSeed );
|
||||
gReSeed = 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
// Get our platform
|
||||
error = clGetPlatformIDs(1, &platform, NULL);
|
||||
if( error )
|
||||
{
|
||||
print_error( error, "Unable to get platform" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get our device
|
||||
error = clGetDeviceIDs(platform, gDeviceType, 1, &device, NULL );
|
||||
if( error )
|
||||
{
|
||||
print_error( error, "Unable to get specified device" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
char deviceName[ 128 ], deviceVendor[ 128 ], deviceVersion[ 128 ];
|
||||
error = clGetDeviceInfo( device, CL_DEVICE_NAME, sizeof( deviceName ), deviceName, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_VENDOR, sizeof( deviceVendor ), deviceVendor, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_VERSION, sizeof( deviceVersion ), deviceVersion, NULL );
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to get device information" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
log_info("Using compute device: Name = %s, Vendor = %s, Version = %s\n", deviceName, deviceVendor, deviceVersion );
|
||||
|
||||
// Check for image support
|
||||
if(checkForImageSupport( device ) == CL_IMAGE_FORMAT_NOT_SUPPORTED) {
|
||||
log_info("Device does not support images. Skipping test.\n");
|
||||
test_finish();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create a context to test with
|
||||
context = clCreateContext( NULL, 1, &device, notify_callback, NULL, &error );
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create testing context" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create a queue against the context
|
||||
queue = clCreateCommandQueueWithProperties( context, device, 0, &error );
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create testing command queue" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( gTestSmallImages )
|
||||
log_info( "Note: Using small test images\n" );
|
||||
|
||||
// Run the test now
|
||||
int ret = 0;
|
||||
for( int test = k1D; test <= k3DTo2DArray; test <<= 1 )
|
||||
{
|
||||
if( testMethods & test )
|
||||
ret += test_image_set( device, (MethodsToTest)test );
|
||||
}
|
||||
|
||||
error = clFinish(queue);
|
||||
if (error)
|
||||
print_error(error, "clFinish failed.");
|
||||
|
||||
if (gTestFailure == 0) {
|
||||
if (gTestCount > 1)
|
||||
log_info("PASSED %d of %d tests.\n", gTestCount, gTestCount);
|
||||
else
|
||||
log_info("PASSED test.\n");
|
||||
} else if (gTestFailure > 0) {
|
||||
if (gTestCount > 1)
|
||||
log_error("FAILED %d of %d tests.\n", gTestFailure, gTestCount);
|
||||
else
|
||||
log_error("FAILED test.\n");
|
||||
}
|
||||
|
||||
// Clean up
|
||||
clReleaseCommandQueue(queue);
|
||||
clReleaseContext(context);
|
||||
test_finish();
|
||||
|
||||
if (gTestFailure > 0)
|
||||
return gTestFailure;
|
||||
|
||||
return ret;
|
||||
}
|
||||
235
test_conformance/images/clCopyImage/test_copy_1D.cpp
Normal file
235
test_conformance/images/clCopyImage/test_copy_1D.cpp
Normal file
@@ -0,0 +1,235 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gEnablePitch, gTestMaxImages, gTestRounding, gTestMipmaps;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, 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_device_id device, image_descriptor *imageInfo, 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;
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
// 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 ] = 1;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
sourcePos[ 1 ] = src_lod;
|
||||
destPos[ 1 ] = dst_lod;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
}
|
||||
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
// 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;
|
||||
sourcePos[ 1 ] = src_lod;
|
||||
destPos[ 1 ] = dst_lod;
|
||||
}
|
||||
// Pick a random size
|
||||
regionSize[ 0 ] = ( width_lod > 8 ) ? (size_t)random_in_range( 8, (int)width_lod - 1, d ) : width_lod;
|
||||
|
||||
// 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;
|
||||
destPos[ 0 ] = ( width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_copy_image_set_1D( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 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 );
|
||||
|
||||
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 2D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (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 (gTestMipmaps)
|
||||
imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, 0, 0), seed);
|
||||
|
||||
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 );
|
||||
|
||||
int ret = test_copy_image_size_1D( device, &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, 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 (gTestMipmaps)
|
||||
imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, 0, 0), seed);
|
||||
|
||||
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( device, &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 );
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
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 );
|
||||
if ( gTestMipmaps )
|
||||
log_info( " and %llu mip levels\n", (size_t) imageInfo.num_mip_levels );
|
||||
}
|
||||
|
||||
int ret = test_copy_image_size_1D( device, &imageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
248
test_conformance/images/clCopyImage/test_copy_1D_array.cpp
Normal file
248
test_conformance/images/clCopyImage/test_copy_1D_array.cpp
Normal file
@@ -0,0 +1,248 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gEnablePitch, gTestMaxImages, gTestRounding, gTestMipmaps;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, 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_device_id device, image_descriptor *imageInfo, 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;
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
// 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[ 2 ] = 1;
|
||||
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
sourcePos[ 2 ] = src_lod;
|
||||
destPos[ 2 ] = dst_lod;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
}
|
||||
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
// 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;
|
||||
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;
|
||||
|
||||
// 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;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_copy_image_set_1D_array( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
pixelSize = get_pixel_size( imageInfo.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 );
|
||||
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 array size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (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 (gTestMipmaps)
|
||||
imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, 0, 0), seed);
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.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 );
|
||||
|
||||
int ret = test_copy_image_size_1D_array( device, &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, maxArraySize, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE1D_ARRAY, imageInfo.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;
|
||||
|
||||
if (gTestMipmaps)
|
||||
imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, 0, 0), seed);
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.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( device, &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.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed );
|
||||
imageInfo.height = imageInfo.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;
|
||||
}
|
||||
else
|
||||
{
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch;
|
||||
|
||||
size = (size_t)imageInfo.rowPitch * (size_t)imageInfo.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( device, &imageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
248
test_conformance/images/clCopyImage/test_copy_2D.cpp
Normal file
248
test_conformance/images/clCopyImage/test_copy_2D.cpp
Normal file
@@ -0,0 +1,248 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gEnablePitch, gTestMaxImages, gTestRounding, gTestMipmaps;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, 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_device_id device, image_descriptor *imageInfo, 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 max_mip_level;
|
||||
|
||||
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;
|
||||
src_height_lod = ( imageInfo->height >> src_lod )? ( imageInfo->height >> src_lod ) : 1;
|
||||
dst_height_lod = ( imageInfo->height >> dst_lod )? ( imageInfo->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 );
|
||||
}
|
||||
|
||||
// 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[ 2 ] = 1;
|
||||
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
sourcePos[ 2 ] = src_lod;
|
||||
destPos[ 2 ] = dst_lod;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
regionSize[ 1 ] = height_lod;
|
||||
}
|
||||
|
||||
retCode = test_copy_image_generic( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
// 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;
|
||||
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;
|
||||
destPos[ 2 ] = dst_lod;
|
||||
}
|
||||
// Pick a random size
|
||||
regionSize[ 0 ] = ( width_lod > 8 ) ? (size_t)random_in_range( 8, (int)width_lod - 1, d ) : width_lod;
|
||||
regionSize[ 1 ] = ( height_lod > 8 ) ? (size_t)random_in_range( 8, (int)height_lod - 1, d ) : height_lod;
|
||||
|
||||
// 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 ] = ( height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( height_lod - 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 ] = ( 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( device, imageInfo, imageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_copy_image_set_2D( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxHeight;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed(gRandomSeed);
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE2D;
|
||||
pixelSize = get_pixel_size( imageInfo.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 );
|
||||
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 2D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (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 (gTestMipmaps)
|
||||
imageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(imageInfo.width, imageInfo.height, 0), seed);
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.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 );
|
||||
|
||||
int ret = test_copy_image_size_2D( device, &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, maxHeight, 1, 1, maxAllocSize, memSize, CL_MEM_OBJECT_IMAGE2D, imageInfo.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;
|
||||
|
||||
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 (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.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( device, &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.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;
|
||||
}
|
||||
else
|
||||
{
|
||||
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 * (size_t)imageInfo.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( device, &imageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
419
test_conformance/images/clCopyImage/test_copy_2D_2D_array.cpp
Normal file
419
test_conformance/images/clCopyImage/test_copy_2D_2D_array.cpp
Normal file
@@ -0,0 +1,419 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gTestMaxImages, gTestRounding, gEnablePitch, gTestMipmaps;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
|
||||
static size_t random_in_ranges( size_t minimum, size_t rangeA, size_t rangeB, MTdata d )
|
||||
{
|
||||
if( rangeB < rangeA )
|
||||
rangeA = rangeB;
|
||||
if( rangeA < minimum )
|
||||
return rangeA;
|
||||
return (size_t)random_in_range( (int)minimum, (int)rangeA - 1, d );
|
||||
}
|
||||
|
||||
|
||||
static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t arraySize, size_t rowPadding, size_t slicePadding )
|
||||
{
|
||||
size_t pixelSize = get_pixel_size( imageInfo->format );
|
||||
|
||||
imageInfo->width = width;
|
||||
imageInfo->height = height;
|
||||
imageInfo->arraySize = arraySize;
|
||||
imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
|
||||
} while ((imageInfo->rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
if (arraySize == 0)
|
||||
{
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imageInfo->slicePitch = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
imageInfo->type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
imageInfo->slicePitch = imageInfo->rowPitch * (imageInfo->height + slicePadding);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_size_2D_2D_array( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 4 ] = { 0 }, destPos[ 4 ] = { 0 }, regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
image_descriptor *threeImage, *twoImage;
|
||||
|
||||
if( srcImageInfo->arraySize > 0 )
|
||||
{
|
||||
threeImage = srcImageInfo;
|
||||
twoImage = dstImageInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
threeImage = dstImageInfo;
|
||||
twoImage = srcImageInfo;
|
||||
}
|
||||
|
||||
size_t twoImage_lod = 0, twoImage_width_lod = twoImage->width, twoImage_row_pitch_lod;
|
||||
size_t twoImage_height_lod = twoImage->height;
|
||||
size_t threeImage_lod = 0, threeImage_width_lod = threeImage->width, threeImage_row_pitch_lod, threeImage_slice_pitch_lod;
|
||||
size_t threeImage_height_lod = threeImage->height;
|
||||
size_t width_lod, height_lod;
|
||||
size_t twoImage_max_mip_level,threeImage_max_mip_level;
|
||||
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
twoImage_max_mip_level = twoImage->num_mip_levels;
|
||||
threeImage_max_mip_level = threeImage->num_mip_levels;
|
||||
// Work at random mip levels
|
||||
twoImage_lod = (size_t)random_in_range( 0, twoImage_max_mip_level ? twoImage_max_mip_level - 1 : 0, d );
|
||||
threeImage_lod = (size_t)random_in_range( 0, threeImage_max_mip_level ? threeImage_max_mip_level - 1 : 0, d );
|
||||
twoImage_width_lod = ( twoImage->width >> twoImage_lod )? ( twoImage->width >> twoImage_lod ) : 1;
|
||||
threeImage_width_lod = ( threeImage->width >> threeImage_lod )? ( threeImage->width >> threeImage_lod ) : 1;
|
||||
twoImage_height_lod = ( twoImage->height >> twoImage_lod )? ( twoImage->height >> twoImage_lod ) : 1;
|
||||
threeImage_height_lod = ( threeImage->height >> threeImage_lod )? ( threeImage->height >> threeImage_lod ) : 1;
|
||||
twoImage_row_pitch_lod = twoImage_width_lod * get_pixel_size( twoImage->format );
|
||||
threeImage_row_pitch_lod = threeImage_width_lod * get_pixel_size( threeImage->format );
|
||||
threeImage_slice_pitch_lod = threeImage_height_lod * threeImage_row_pitch_lod;
|
||||
}
|
||||
width_lod = ( twoImage_width_lod > threeImage_width_lod ) ? threeImage_width_lod : twoImage_width_lod;
|
||||
height_lod = ( twoImage_height_lod > threeImage_height_lod ) ? threeImage_height_lod : twoImage_height_lod;
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = sourcePos[ 3 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = destPos[ 3 ] = 0;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
regionSize[ 1 ] = height_lod;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
if( srcImageInfo->arraySize == 0 )
|
||||
{
|
||||
// 2D to 2D array
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->arraySize - 1, d );
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
sourcePos[ 2 ] = twoImage_lod;
|
||||
destPos[ 3 ] = threeImage_lod;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
regionSize[ 1 ] = height_lod;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 2D array to 2D
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->arraySize - 1, d );
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
sourcePos[ 3 ] = threeImage_lod;
|
||||
destPos[ 2 ] = twoImage_lod;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
regionSize[ 1 ] = height_lod;
|
||||
}
|
||||
}
|
||||
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
// Work at a random mip level
|
||||
twoImage_lod = (size_t)random_in_range( 0, twoImage_max_mip_level ? twoImage_max_mip_level - 1 : 0, d );
|
||||
threeImage_lod = (size_t)random_in_range( 0, threeImage_max_mip_level ? threeImage_max_mip_level - 1 : 0, d );
|
||||
twoImage_width_lod = ( twoImage->width >> twoImage_lod )? ( twoImage->width >> twoImage_lod ) : 1;
|
||||
threeImage_width_lod = ( threeImage->width >> threeImage_lod )? ( threeImage->width >> threeImage_lod ) : 1;
|
||||
twoImage_height_lod = ( twoImage->height >> twoImage_lod )? ( twoImage->height >> twoImage_lod ) : 1;
|
||||
threeImage_height_lod = ( threeImage->height >> threeImage_lod )? ( threeImage->height >> threeImage_lod ) : 1;
|
||||
width_lod = ( twoImage_width_lod > threeImage_width_lod ) ? threeImage_width_lod : twoImage_width_lod;
|
||||
height_lod = ( twoImage_height_lod > threeImage_height_lod ) ? threeImage_height_lod : twoImage_height_lod;
|
||||
}
|
||||
// Pick a random size
|
||||
regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
|
||||
regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
regionSize[ 0 ] = ( width_lod > 8 ) ? random_in_range( 8, width_lod, d ) : width_lod;
|
||||
regionSize[ 1 ] = ( height_lod > 8) ? random_in_range( 8, height_lod, d ): height_lod;
|
||||
}
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 2 ] = ( srcImageInfo->arraySize > 0 ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->arraySize - 1 ), d ) : gTestMipmaps ? twoImage_lod : 0;
|
||||
if ( gTestMipmaps )
|
||||
if( srcImageInfo->arraySize > 0 )
|
||||
{
|
||||
sourcePos[ 0 ] = ( threeImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( threeImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 3 ] = threeImage_lod;
|
||||
}
|
||||
else
|
||||
{
|
||||
sourcePos[ 0 ] = ( twoImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( twoImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
}
|
||||
|
||||
destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
destPos[ 2 ] = ( dstImageInfo->arraySize > 0 ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->arraySize - 1 ), d ) : gTestMipmaps ? twoImage_lod : 0;
|
||||
if ( gTestMipmaps )
|
||||
if( dstImageInfo->arraySize > 0 )
|
||||
{
|
||||
destPos[ 0 ] = ( threeImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( threeImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
destPos[ 3 ] = threeImage_lod;
|
||||
}
|
||||
else
|
||||
{
|
||||
destPos[ 0 ] = ( twoImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( twoImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
}
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_set_2D_2D_array( cl_device_id device, cl_image_format *format, bool reverse = false )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor srcImageInfo = { 0 };
|
||||
image_descriptor dstImageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
srcImageInfo.format = dstImageInfo.format = 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 );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, 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 2D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
|
||||
{
|
||||
for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
|
||||
{
|
||||
for( dstImageInfo.arraySize = 4; dstImageInfo.arraySize < 9; dstImageInfo.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 );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numberOfSizes2DArray, numberOfSizes2D;
|
||||
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);
|
||||
|
||||
for( size_t i = 0; i < numberOfSizes2D; i++ )
|
||||
{
|
||||
for( size_t j = 0; j < numberOfSizes2DArray; j++ )
|
||||
{
|
||||
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 );
|
||||
|
||||
cl_ulong dstSize = get_image_size(&dstImageInfo);
|
||||
cl_ulong srcSize = get_image_size(&srcImageInfo);
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
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 );
|
||||
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 );
|
||||
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_2D_array( device, &srcImageInfo, &dstImageInfo, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong srcSize, dstSize;
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 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
|
||||
{
|
||||
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 );
|
||||
|
||||
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 );
|
||||
}
|
||||
else
|
||||
{
|
||||
set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, 0, rowPadding, slicePadding );
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, rowPadding, slicePadding );
|
||||
|
||||
srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4;
|
||||
dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.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 );
|
||||
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 );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
401
test_conformance/images/clCopyImage/test_copy_2D_3D.cpp
Normal file
401
test_conformance/images/clCopyImage/test_copy_2D_3D.cpp
Normal file
@@ -0,0 +1,401 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gTestMaxImages, gTestRounding, gEnablePitch, gTestMipmaps;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
|
||||
static size_t random_in_ranges( size_t minimum, size_t rangeA, size_t rangeB, MTdata d )
|
||||
{
|
||||
if( rangeB < rangeA )
|
||||
rangeA = rangeB;
|
||||
if( rangeA < minimum )
|
||||
return rangeA;
|
||||
return (size_t)random_in_range( (int)minimum, (int)rangeA - 1, d );
|
||||
}
|
||||
|
||||
|
||||
static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t depth, size_t rowPadding, size_t slicePadding )
|
||||
{
|
||||
size_t pixelSize = get_pixel_size( imageInfo->format );
|
||||
|
||||
imageInfo->width = width;
|
||||
imageInfo->height = height;
|
||||
imageInfo->depth = depth;
|
||||
imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_size_2D_3D( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 4 ] = { 0 }, destPos[ 4 ] = { 0 }, regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
image_descriptor *threeImage, *twoImage;
|
||||
|
||||
if( srcImageInfo->depth > 0 )
|
||||
{
|
||||
threeImage = srcImageInfo;
|
||||
twoImage = dstImageInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
threeImage = dstImageInfo;
|
||||
twoImage = srcImageInfo;
|
||||
}
|
||||
|
||||
size_t twoImage_lod = 0, twoImage_width_lod = twoImage->width, twoImage_row_pitch_lod;
|
||||
size_t twoImage_height_lod = twoImage->height;
|
||||
size_t threeImage_lod = 0, threeImage_width_lod = threeImage->width, threeImage_row_pitch_lod, threeImage_slice_pitch_lod;
|
||||
size_t threeImage_height_lod = threeImage->height, depth_lod = threeImage->depth;
|
||||
size_t width_lod, height_lod;
|
||||
size_t twoImage_max_mip_level,threeImage_max_mip_level;
|
||||
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
twoImage_max_mip_level = twoImage->num_mip_levels;
|
||||
threeImage_max_mip_level = threeImage->num_mip_levels;
|
||||
// Work at random mip levels
|
||||
twoImage_lod = (size_t)random_in_range( 0, twoImage_max_mip_level ? twoImage_max_mip_level - 1 : 0, d );
|
||||
threeImage_lod = (size_t)random_in_range( 0, threeImage_max_mip_level ? threeImage_max_mip_level - 1 : 0, d );
|
||||
twoImage_width_lod = ( twoImage->width >> twoImage_lod )? ( twoImage->width >> twoImage_lod ) : 1;
|
||||
threeImage_width_lod = ( threeImage->width >> threeImage_lod )? ( threeImage->width >> threeImage_lod ) : 1;
|
||||
twoImage_height_lod = ( twoImage->height >> twoImage_lod )? ( twoImage->height >> twoImage_lod ) : 1;
|
||||
threeImage_height_lod = ( threeImage->height >> threeImage_lod )? ( threeImage->height >> threeImage_lod ) : 1;
|
||||
depth_lod = ( threeImage->depth >> threeImage_lod )? ( threeImage->depth >> threeImage_lod ) : 1;
|
||||
twoImage_row_pitch_lod = twoImage_width_lod * get_pixel_size( twoImage->format );
|
||||
threeImage_row_pitch_lod = threeImage_width_lod * get_pixel_size( threeImage->format );
|
||||
threeImage_slice_pitch_lod = threeImage_height_lod * threeImage_row_pitch_lod;
|
||||
}
|
||||
width_lod = ( twoImage_width_lod > threeImage_width_lod ) ? threeImage_width_lod : twoImage_width_lod;
|
||||
height_lod = ( twoImage_height_lod > threeImage_height_lod ) ? threeImage_height_lod : twoImage_height_lod;
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = sourcePos[ 3 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = destPos[ 3 ] = 0;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
regionSize[ 1 ] = height_lod;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
if( srcImageInfo->depth == 0 )
|
||||
{
|
||||
// 2D to 3D
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->depth - 1, d );
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)depth_lod - 1, d );
|
||||
sourcePos[ 2 ] = twoImage_lod;
|
||||
destPos[ 3 ] = threeImage_lod;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
regionSize[ 1 ] = height_lod;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 3D to 2D
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->depth - 1, d );
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)depth_lod - 1, d );
|
||||
sourcePos[ 3 ] = threeImage_lod;
|
||||
destPos[ 2 ] = twoImage_lod;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
regionSize[ 1 ] = height_lod;
|
||||
}
|
||||
}
|
||||
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
// Work at a random mip level
|
||||
twoImage_lod = (size_t)random_in_range( 0, twoImage_max_mip_level ? twoImage_max_mip_level - 1 : 0, d );
|
||||
threeImage_lod = (size_t)random_in_range( 0, threeImage_max_mip_level ? threeImage_max_mip_level - 1 : 0, d );
|
||||
twoImage_width_lod = ( twoImage->width >> twoImage_lod )? ( twoImage->width >> twoImage_lod ) : 1;
|
||||
threeImage_width_lod = ( threeImage->width >> threeImage_lod )? ( threeImage->width >> threeImage_lod ) : 1;
|
||||
twoImage_height_lod = ( twoImage->height >> twoImage_lod )? ( twoImage->height >> twoImage_lod ) : 1;
|
||||
threeImage_height_lod = ( threeImage->height >> threeImage_lod )? ( threeImage->height >> threeImage_lod ) : 1;
|
||||
width_lod = ( twoImage_width_lod > threeImage_width_lod ) ? threeImage_width_lod : twoImage_width_lod;
|
||||
height_lod = ( twoImage_height_lod > threeImage_height_lod ) ? threeImage_height_lod : twoImage_height_lod;
|
||||
depth_lod = ( threeImage->depth >> threeImage_lod )? ( threeImage->depth >> threeImage_lod ) : 1;
|
||||
}
|
||||
// Pick a random size
|
||||
regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
|
||||
regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
regionSize[ 0 ] = ( width_lod > 8 ) ? random_in_range( 8, width_lod, d ) : width_lod;
|
||||
regionSize[ 1 ] = ( height_lod > 8) ? random_in_range( 8, height_lod, d ): height_lod;
|
||||
}
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 2 ] = ( srcImageInfo->depth > 0 ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->depth - 1 ), d ) : 0;
|
||||
|
||||
if ( gTestMipmaps )
|
||||
if( srcImageInfo->depth > 0 )
|
||||
{
|
||||
sourcePos[ 0 ] = ( threeImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( threeImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)( depth_lod - 1 ), d );
|
||||
sourcePos[ 3 ] = threeImage_lod;
|
||||
}
|
||||
else
|
||||
{
|
||||
sourcePos[ 0 ] = ( twoImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( twoImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
}
|
||||
|
||||
destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
destPos[ 2 ] = ( dstImageInfo->depth > 0 ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->depth - 1 ), d ) : 0;
|
||||
|
||||
if ( gTestMipmaps )
|
||||
if( dstImageInfo->depth > 0 )
|
||||
{
|
||||
destPos[ 0 ] = ( threeImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( threeImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)( depth_lod - 1 ), d );
|
||||
destPos[ 3 ] = threeImage_lod;
|
||||
}
|
||||
else
|
||||
{
|
||||
destPos[ 0 ] = ( twoImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( twoImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
}
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_set_2D_3D( cl_device_id device, cl_image_format *format, bool reverse = false )
|
||||
{
|
||||
size_t maxWidth, maxHeight, max3DWidth, max3DHeight, max3DDepth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor srcImageInfo = { 0 };
|
||||
image_descriptor dstImageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
srcImageInfo.format = dstImageInfo.format = 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 );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( max3DWidth ), &max3DWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( max3DHeight ), &max3DHeight, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof( max3DDepth ), &max3DDepth, 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 2D or 3D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
|
||||
{
|
||||
for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
|
||||
{
|
||||
for( dstImageInfo.depth = 4; dstImageInfo.depth < 9; dstImageInfo.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 );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_3D( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_3D( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numberOfSizes3D, numberOfSizes2D;
|
||||
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);
|
||||
|
||||
for( size_t i = 0; i < numberOfSizes2D; i++ )
|
||||
for( size_t j = 0; j < numberOfSizes3D; j++ )
|
||||
{
|
||||
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);
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
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 );
|
||||
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 );
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_3D( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_3D( device, &srcImageInfo, &dstImageInfo, 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong srcSize, dstSize;
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 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
|
||||
{
|
||||
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 );
|
||||
|
||||
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 );
|
||||
}
|
||||
else
|
||||
{
|
||||
set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, 0, rowPadding, slicePadding );
|
||||
set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.depth, rowPadding, slicePadding );
|
||||
|
||||
srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4;
|
||||
dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.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 );
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_2D_3D( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_2D_3D( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
205
test_conformance/images/clCopyImage/test_copy_2D_array.cpp
Normal file
205
test_conformance/images/clCopyImage/test_copy_2D_array.cpp
Normal file
@@ -0,0 +1,205 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gTestMaxImages, gEnablePitch, gTestRounding, gTestMipmaps;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_copy_generic.cpp
|
||||
extern int test_copy_image_generic( cl_device_id device, 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_device_id device, image_descriptor *imageInfo, 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 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 max_mip_level;
|
||||
|
||||
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;
|
||||
src_height_lod = ( imageInfo->height >> src_lod )? ( imageInfo->height >> src_lod ) : 1;
|
||||
dst_height_lod = ( imageInfo->height >> dst_lod )? ( imageInfo->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;
|
||||
|
||||
region[ 0 ] = width_lod;
|
||||
region[ 1 ] = height_lod;
|
||||
srcPos[ 3 ] = src_lod;
|
||||
dstPos[ 3 ] = dst_lod;
|
||||
}
|
||||
return test_copy_image_generic( device, imageInfo, imageInfo, srcPos, dstPos, region, d );
|
||||
}
|
||||
|
||||
int test_copy_image_set_2D_array( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
pixelSize = get_pixel_size( imageInfo.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 );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, 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 2D array size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
imageInfo.rowPitch = imageInfo.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 (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
for( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ )
|
||||
{
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
|
||||
for( imageInfo.arraySize = 2; imageInfo.arraySize < 9; imageInfo.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( device, &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, maxHeight, 1, maxArraySize, maxAllocSize, memSize, imageInfo.type, imageInfo.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;
|
||||
|
||||
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 (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.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( device, &imageInfo, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 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.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 );
|
||||
|
||||
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 );
|
||||
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);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
|
||||
size = (cl_ulong)imageInfo.slicePitch * (cl_ulong)imageInfo.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( device, &imageInfo,seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
192
test_conformance/images/clCopyImage/test_copy_3D.cpp
Normal file
192
test_conformance/images/clCopyImage/test_copy_3D.cpp
Normal file
@@ -0,0 +1,192 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gTestMaxImages, gEnablePitch, gTestRounding, gTestMipmaps;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
// Defined in test_copy_generic.cpp
|
||||
extern int test_copy_image_generic( cl_device_id device, 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_device_id device, image_descriptor *imageInfo, MTdata d )
|
||||
{
|
||||
size_t origin[] = { 0, 0, 0, 0};
|
||||
size_t region[] = { imageInfo->width, imageInfo->height, imageInfo->depth };
|
||||
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
size_t lod = (imageInfo->num_mip_levels > 1 )? (size_t)random_in_range( 0, imageInfo->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;
|
||||
}
|
||||
|
||||
return test_copy_image_generic( device, imageInfo, imageInfo, origin, origin, region, d );
|
||||
}
|
||||
|
||||
int test_copy_image_set_3D( cl_device_id device, cl_image_format *format )
|
||||
{
|
||||
size_t maxWidth, maxHeight, maxDepth;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor imageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t pixelSize;
|
||||
|
||||
imageInfo.format = format;
|
||||
imageInfo.type = CL_MEM_OBJECT_IMAGE3D;
|
||||
pixelSize = get_pixel_size( imageInfo.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 );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof( maxDepth ), &maxDepth, 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 3D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( imageInfo.width = 1; imageInfo.width < 13; imageInfo.width++ )
|
||||
{
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
imageInfo.rowPitch = imageInfo.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);
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
for( imageInfo.height = 1; imageInfo.height < 9; imageInfo.height++ )
|
||||
{
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
for( imageInfo.depth = 2; imageInfo.depth < 9; imageInfo.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( device, &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, maxHeight, maxDepth, 1, maxAllocSize, memSize, imageInfo.type, imageInfo.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;
|
||||
|
||||
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);
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding;
|
||||
} while ((imageInfo.rowPitch % pixelSize) != 0);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.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( device, &imageInfo, seed ) )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong size;
|
||||
size_t rowPadding = gEnablePitch ? 80 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 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.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 );
|
||||
|
||||
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 );
|
||||
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);
|
||||
}
|
||||
|
||||
imageInfo.slicePitch = imageInfo.rowPitch * (imageInfo.height + slicePadding);
|
||||
|
||||
size = (cl_ulong)imageInfo.slicePitch * (cl_ulong)imageInfo.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( device, &imageInfo,seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
442
test_conformance/images/clCopyImage/test_copy_3D_2D_array.cpp
Normal file
442
test_conformance/images/clCopyImage/test_copy_3D_2D_array.cpp
Normal file
@@ -0,0 +1,442 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gTestMaxImages, gTestRounding, gEnablePitch, gTestMipmaps;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
extern int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
|
||||
|
||||
|
||||
static size_t random_in_ranges( size_t minimum, size_t rangeA, size_t rangeB, MTdata d )
|
||||
{
|
||||
if( rangeB < rangeA )
|
||||
rangeA = rangeB;
|
||||
if( rangeA < minimum )
|
||||
return rangeA;
|
||||
return (size_t)random_in_range( (int)minimum, (int)rangeA - 1, d );
|
||||
}
|
||||
|
||||
|
||||
static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t depth, size_t arraySize, size_t rowPadding, size_t slicePadding )
|
||||
{
|
||||
size_t pixelSize = get_pixel_size( imageInfo->format );
|
||||
|
||||
imageInfo->width = width;
|
||||
imageInfo->height = height;
|
||||
imageInfo->depth = depth;
|
||||
imageInfo->arraySize = arraySize;
|
||||
imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
do {
|
||||
rowPadding++;
|
||||
imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_size_3D_2D_array( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 4 ], destPos[ 4 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
image_descriptor *threeImage, *twoImage;
|
||||
|
||||
if( srcImageInfo->arraySize == 0 )
|
||||
{
|
||||
threeImage = srcImageInfo;
|
||||
twoImage = dstImageInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
threeImage = dstImageInfo;
|
||||
twoImage = srcImageInfo;
|
||||
}
|
||||
|
||||
size_t twoImage_width_lod = twoImage->width, twoImage_height_lod = twoImage->height;
|
||||
size_t threeImage_width_lod = threeImage->width, threeImage_height_lod = threeImage->height;
|
||||
size_t twoImage_lod = 0, threeImage_lod = 0;
|
||||
size_t width_lod = 0, height_lod = 0, depth_lod = 0;
|
||||
size_t twoImage_max_mip_level,threeImage_max_mip_level;
|
||||
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
twoImage_max_mip_level = twoImage->num_mip_levels;
|
||||
threeImage_max_mip_level = threeImage->num_mip_levels;
|
||||
// Work at random mip levels
|
||||
twoImage_lod = (size_t)random_in_range( 0, twoImage_max_mip_level ? twoImage_max_mip_level - 1 : 0, d );
|
||||
threeImage_lod = (size_t)random_in_range( 0, threeImage_max_mip_level ? threeImage_max_mip_level - 1 : 0, d );
|
||||
twoImage_width_lod = ( twoImage->width >> twoImage_lod )? ( twoImage->width >> twoImage_lod ) : 1;
|
||||
threeImage_width_lod = ( threeImage->width >> threeImage_lod )? ( threeImage->width >> threeImage_lod ) : 1;
|
||||
twoImage_height_lod = ( twoImage->height >> twoImage_lod )? ( twoImage->height >> twoImage_lod ) : 1;
|
||||
threeImage_height_lod = ( threeImage->height >> threeImage_lod )? ( threeImage->height >> threeImage_lod ) : 1;
|
||||
depth_lod = ( threeImage->depth >> threeImage_lod )? ( threeImage->depth >> threeImage_lod ) : 1;
|
||||
}
|
||||
width_lod = ( twoImage_width_lod > threeImage_width_lod ) ? threeImage_width_lod : twoImage_width_lod;
|
||||
height_lod = ( twoImage_height_lod > threeImage_height_lod ) ? threeImage_height_lod : twoImage_height_lod;
|
||||
depth_lod = ( depth_lod > twoImage->arraySize ) ? twoImage->arraySize : depth_lod;
|
||||
|
||||
// First, try just a full covering region
|
||||
sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = 0;
|
||||
destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = 0;
|
||||
regionSize[ 0 ] = ( threeImage->width < twoImage->width ) ? threeImage->width : twoImage->width;
|
||||
regionSize[ 1 ] = ( threeImage->height < twoImage->height ) ? threeImage->height : twoImage->height;
|
||||
regionSize[ 2 ] = 1;
|
||||
|
||||
if( srcImageInfo->type == CL_MEM_OBJECT_IMAGE3D )
|
||||
{
|
||||
// 3D to 2D array
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->depth - 1, d );
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->arraySize - 1, d );
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
sourcePos[ 2 ] = 0/*(size_t)random_in_range( 0, (int)depth_lod - 1, d )*/;
|
||||
destPos[ 2 ] = ( twoImage->arraySize > depth_lod ) ? (size_t)random_in_range( 0, twoImage->arraySize - depth_lod, d) : 0;
|
||||
sourcePos[ 3 ] = threeImage_lod;
|
||||
destPos[ 3 ] = twoImage_lod;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
regionSize[ 1 ] = height_lod;
|
||||
regionSize[ 2 ] = depth_lod;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 2D array to 3D
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->arraySize - 1, d );
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->depth - 1, d );
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
destPos[ 2 ] = 0 /*(size_t)random_in_range( 0, (int)depth_lod - 1, d )*/;
|
||||
sourcePos[ 2 ] = ( twoImage->arraySize > depth_lod ) ? (size_t)random_in_range( 0, twoImage->arraySize - depth_lod, d) : 0;
|
||||
sourcePos[ 3 ] = twoImage_lod;
|
||||
destPos[ 3 ] = threeImage_lod;
|
||||
regionSize[ 0 ] = width_lod;
|
||||
regionSize[ 1 ] = height_lod;
|
||||
regionSize[ 2 ] = depth_lod;
|
||||
}
|
||||
}
|
||||
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
|
||||
// Now try a sampling of different random regions
|
||||
for( int i = 0; i < 8; i++ )
|
||||
{
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
twoImage_max_mip_level = twoImage->num_mip_levels;
|
||||
threeImage_max_mip_level = threeImage->num_mip_levels;
|
||||
// Work at random mip levels
|
||||
twoImage_lod = (size_t)random_in_range( 0, twoImage_max_mip_level ? twoImage_max_mip_level - 1 : 0, d );
|
||||
threeImage_lod = (size_t)random_in_range( 0, threeImage_max_mip_level ? threeImage_max_mip_level - 1 : 0, d );
|
||||
twoImage_width_lod = ( twoImage->width >> twoImage_lod )? ( twoImage->width >> twoImage_lod ) : 1;
|
||||
threeImage_width_lod = ( threeImage->width >> threeImage_lod )? ( threeImage->width >> threeImage_lod ) : 1;
|
||||
twoImage_height_lod = ( twoImage->height >> twoImage_lod )? ( twoImage->height >> twoImage_lod ) : 1;
|
||||
threeImage_height_lod = ( threeImage->height >> threeImage_lod )? ( threeImage->height >> threeImage_lod ) : 1;
|
||||
depth_lod = ( threeImage->depth >> threeImage_lod )? ( threeImage->depth >> threeImage_lod ) : 1;
|
||||
width_lod = ( twoImage_width_lod > threeImage_width_lod ) ? threeImage_width_lod : twoImage_width_lod;
|
||||
height_lod = ( twoImage_height_lod > threeImage_height_lod ) ? threeImage_height_lod : twoImage_height_lod;
|
||||
depth_lod = ( twoImage->arraySize > depth_lod ) ? depth_lod : twoImage->arraySize;
|
||||
}
|
||||
// Pick a random size
|
||||
regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
|
||||
regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
regionSize[ 0 ] = random_in_range( 1, width_lod, d );
|
||||
regionSize[ 1 ] = random_in_range( 1, height_lod, d );
|
||||
regionSize[ 2 ] = depth_lod/*random_in_range( 0, depth_lod, d )*/;
|
||||
}
|
||||
|
||||
// Now pick positions within valid ranges
|
||||
sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
|
||||
if (srcImageInfo->type == CL_MEM_OBJECT_IMAGE3D)
|
||||
{
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)( srcImageInfo->depth - 1 ), d );
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
sourcePos[ 0 ] = ( threeImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( threeImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 2 ] = 0 /*( depth_lod > regionSize[ 2 ] ) ? (size_t)random_in_range( 0, (int)( depth_lod - regionSize[ 2 ] - 1 ), d ) : 0*/;
|
||||
sourcePos[ 3 ] = threeImage_lod;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)( srcImageInfo->arraySize - 1 ), d );
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
sourcePos[ 0 ] = ( twoImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 1 ] = ( twoImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 2 ] = ( twoImage->arraySize > regionSize[ 2 ] ) ? (size_t)random_in_range( 0, (int)( twoImage->arraySize - regionSize[ 2 ] - 1 ), d ) : 0;
|
||||
sourcePos[ 3 ] = twoImage_lod;
|
||||
}
|
||||
}
|
||||
|
||||
destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
if (dstImageInfo->type == CL_MEM_OBJECT_IMAGE3D)
|
||||
{
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)( dstImageInfo->depth - 1 ), d );
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
destPos[ 0 ] = ( threeImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( threeImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
destPos[ 2 ] = 0/*( depth_lod > regionSize[ 2 ] ) ? (size_t)random_in_range( 0, (int)( depth_lod - regionSize[ 2 ] - 1 ), d ) : 0*/;
|
||||
destPos[ 3 ] = threeImage_lod;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
destPos[ 2 ] = (size_t)random_in_range( 0, (int)( dstImageInfo->arraySize - 1 ), d );
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
destPos[ 0 ] = ( twoImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
|
||||
destPos[ 1 ] = ( twoImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
|
||||
destPos[ 2 ] = ( twoImage->arraySize > regionSize[ 2 ] ) ? (size_t)random_in_range( 0, (int)( twoImage->arraySize - regionSize[ 2 ] - 1 ), d ) : 0;
|
||||
destPos[ 3 ] = twoImage_lod;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int test_copy_image_set_3D_2D_array( cl_device_id device, cl_image_format *format, bool reverse = false )
|
||||
{
|
||||
size_t maxWidth, maxHeight, max3DWidth, max3DHeight, maxDepth, maxArraySize;
|
||||
cl_ulong maxAllocSize, memSize;
|
||||
image_descriptor srcImageInfo = { 0 };
|
||||
image_descriptor dstImageInfo = { 0 };
|
||||
RandomSeed seed( gRandomSeed );
|
||||
size_t rowPadding = gEnablePitch ? 256 : 0;
|
||||
size_t slicePadding = gEnablePitch ? 3 : 0;
|
||||
|
||||
srcImageInfo.format = dstImageInfo.format = 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 );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( max3DWidth ), &max3DWidth, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( max3DHeight ), &max3DHeight, NULL );
|
||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof( maxDepth ), &maxDepth, 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 2D image array or 3D size from device" );
|
||||
|
||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
||||
memSize = (cl_ulong)SIZE_MAX;
|
||||
}
|
||||
|
||||
if( gTestSmallImages )
|
||||
{
|
||||
for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
|
||||
{
|
||||
for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
|
||||
{
|
||||
for( dstImageInfo.arraySize = 4; dstImageInfo.arraySize < 9; dstImageInfo.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 );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_3D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_3D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( gTestMaxImages )
|
||||
{
|
||||
// Try a specific set of maximum sizes
|
||||
size_t numbeOfSizes;
|
||||
size_t sizes3D[100][3];
|
||||
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_IMAGE3D, srcImageInfo.format);
|
||||
get_max_sizes(&numbeOfSizes, 100, sizes3D, max3DWidth, max3DHeight, maxDepth, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE3D, dstImageInfo.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 );
|
||||
|
||||
cl_ulong dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize;
|
||||
cl_ulong srcSize = (cl_ulong)srcImageInfo.slicePitch * (cl_ulong)srcImageInfo.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 );
|
||||
}
|
||||
|
||||
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 );
|
||||
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 );
|
||||
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_3D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_3D_2D_array( device, &srcImageInfo, &dstImageInfo, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
|
||||
{
|
||||
cl_ulong srcSize, dstSize;
|
||||
// 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
|
||||
{
|
||||
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 );
|
||||
|
||||
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 );
|
||||
}
|
||||
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 );
|
||||
|
||||
srcSize = (cl_ulong)srcImageInfo.slicePitch * (cl_ulong)srcImageInfo.depth * 4;
|
||||
dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.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 );
|
||||
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 );
|
||||
}
|
||||
int ret;
|
||||
if( reverse )
|
||||
ret = test_copy_image_size_3D_2D_array( device, &dstImageInfo, &srcImageInfo, seed );
|
||||
else
|
||||
ret = test_copy_image_size_3D_2D_array( device, &srcImageInfo, &dstImageInfo, seed );
|
||||
if( ret )
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
763
test_conformance/images/clCopyImage/test_copy_generic.cpp
Normal file
763
test_conformance/images/clCopyImage/test_copy_generic.cpp
Normal file
@@ -0,0 +1,763 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
#define MAX_ERR 0.005f
|
||||
#define MAX_HALF_LINEAR_ERR 0.3f
|
||||
|
||||
extern bool gDebugTrace, gDisableOffsets, gTestSmallImages, gTestMaxImages, gTestRounding, gEnablePitch, gTestMipmaps;
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern uint64_t gRoundingStartValue;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
|
||||
size_t random_in_ranges( size_t minimum, size_t rangeA, size_t rangeB, MTdata d )
|
||||
{
|
||||
if( rangeB < rangeA )
|
||||
rangeA = rangeB;
|
||||
if( rangeA < minimum )
|
||||
return rangeA;
|
||||
return (size_t)random_in_range( (int)minimum, (int)rangeA - 1, d );
|
||||
}
|
||||
|
||||
static void CL_CALLBACK free_pitch_buffer( cl_mem image, void *buf )
|
||||
{
|
||||
free( buf );
|
||||
}
|
||||
|
||||
cl_mem create_image( cl_context context, BufferOwningPtr<char>& data, image_descriptor *imageInfo, int *error )
|
||||
{
|
||||
cl_mem img;
|
||||
cl_image_desc imageDesc;
|
||||
cl_mem_flags mem_flags = CL_MEM_READ_ONLY;
|
||||
void *host_ptr = NULL;
|
||||
|
||||
memset(&imageDesc, 0x0, sizeof(cl_image_desc));
|
||||
imageDesc.image_type = imageInfo->type;
|
||||
imageDesc.image_width = imageInfo->width;
|
||||
imageDesc.image_height = imageInfo->height;
|
||||
imageDesc.image_depth = imageInfo->depth;
|
||||
imageDesc.image_array_size = imageInfo->arraySize;
|
||||
imageDesc.image_row_pitch = gEnablePitch ? imageInfo->rowPitch : 0;
|
||||
imageDesc.image_slice_pitch = gEnablePitch ? imageInfo->slicePitch : 0;
|
||||
imageDesc.num_mip_levels = gTestMipmaps ? imageInfo->num_mip_levels : 0;
|
||||
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 1D image %d ...\n", (int)imageInfo->width );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->rowPitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 2D image %d by %d ...\n", (int)imageInfo->width, (int)imageInfo->height );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->height * imageInfo->rowPitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 3D image %d by %d by %d...\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->depth );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->depth * imageInfo->slicePitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 1D image array %d by %d...\n", (int)imageInfo->width, (int)imageInfo->arraySize );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->arraySize * imageInfo->slicePitch );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
if ( gDebugTrace )
|
||||
log_info( " - Creating 2D image array %d by %d by %d...\n", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->arraySize );
|
||||
if ( gEnablePitch )
|
||||
host_ptr = malloc( imageInfo->arraySize * imageInfo->slicePitch );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( gDebugTrace && gTestMipmaps )
|
||||
log_info(" - with %llu mip levels\n", (unsigned long long) imageInfo->num_mip_levels);
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
if ( NULL == host_ptr )
|
||||
{
|
||||
log_error( "ERROR: Unable to create backing store for pitched 3D image. %ld bytes\n", imageInfo->depth * imageInfo->slicePitch );
|
||||
return NULL;
|
||||
}
|
||||
mem_flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR;
|
||||
}
|
||||
|
||||
img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, host_ptr, error);
|
||||
|
||||
if (gEnablePitch)
|
||||
{
|
||||
if ( *error == CL_SUCCESS )
|
||||
{
|
||||
int callbackError = clSetMemObjectDestructorCallback( img, free_pitch_buffer, host_ptr );
|
||||
if ( CL_SUCCESS != callbackError )
|
||||
{
|
||||
free( host_ptr );
|
||||
log_error( "ERROR: Unable to attach destructor callback to pitched 3D image. Err: %d\n", callbackError );
|
||||
clReleaseMemObject( img );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
free(host_ptr);
|
||||
}
|
||||
|
||||
if ( *error != CL_SUCCESS )
|
||||
{
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
log_error( "ERROR: Unable to create 1D image of size %d (%s)", (int)imageInfo->width, IGetErrorString( *error ) );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
log_error( "ERROR: Unable to create 2D image of size %d x %d (%s)", (int)imageInfo->width, (int)imageInfo->height, IGetErrorString( *error ) );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
log_error( "ERROR: Unable to create 3D image of size %d x %d x %d (%s)", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->depth, IGetErrorString( *error ) );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
log_error( "ERROR: Unable to create 1D image array of size %d x %d (%s)", (int)imageInfo->width, (int)imageInfo->arraySize, IGetErrorString( *error ) );
|
||||
break;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
log_error( "ERROR: Unable to create 2D image array of size %d x %d x %d (%s)", (int)imageInfo->width, (int)imageInfo->height, (int)imageInfo->arraySize, IGetErrorString( *error ) );
|
||||
break;
|
||||
}
|
||||
log_error("ERROR: and %llu mip levels\n", (unsigned long long) imageInfo->num_mip_levels);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Copy the specified data to the image via a Map operation.
|
||||
size_t mappedRow, mappedSlice;
|
||||
size_t width = imageInfo->width;
|
||||
size_t height = 1;
|
||||
size_t depth = 1;
|
||||
size_t row_pitch_lod, slice_pitch_lod;
|
||||
row_pitch_lod = imageInfo->rowPitch;
|
||||
slice_pitch_lod = imageInfo->slicePitch;
|
||||
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
height = imageInfo->arraySize;
|
||||
depth = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
height = depth = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
height = imageInfo->height;
|
||||
depth = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
height = imageInfo->height;
|
||||
depth = imageInfo->arraySize;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
height = imageInfo->height;
|
||||
depth = imageInfo->depth;
|
||||
break;
|
||||
}
|
||||
|
||||
size_t origin[ 4 ] = { 0, 0, 0, 0 };
|
||||
size_t region[ 3 ] = { imageInfo->width, height, depth };
|
||||
|
||||
for ( size_t lod = 0; (gTestMipmaps && (lod < imageInfo->num_mip_levels)) || (!gTestMipmaps && (lod < 1)); lod++)
|
||||
{
|
||||
// Map the appropriate miplevel to copy the specified data.
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
origin[ 3 ] = lod;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
origin[ 2 ] = lod;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
origin[ 1 ] = lod;
|
||||
break;
|
||||
}
|
||||
|
||||
//Adjust image dimensions as per miplevel
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
depth = ( imageInfo->depth >> lod ) ? (imageInfo->depth >> lod) : 1;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
height = ( imageInfo->height >> lod ) ? (imageInfo->height >> lod) : 1;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
width = ( imageInfo->width >> lod ) ? (imageInfo->width >> lod) : 1;
|
||||
}
|
||||
row_pitch_lod = width * get_pixel_size(imageInfo->format);
|
||||
slice_pitch_lod = row_pitch_lod * height;
|
||||
region[0] = width;
|
||||
region[1] = height;
|
||||
region[2] = depth;
|
||||
}
|
||||
|
||||
void* mapped = (char*)clEnqueueMapImage(queue, img, CL_TRUE, CL_MAP_WRITE, origin, region, &mappedRow, &mappedSlice, 0, NULL, NULL, error);
|
||||
if (*error != CL_SUCCESS)
|
||||
{
|
||||
log_error( "ERROR: Unable to map image for writing: %s\n", IGetErrorString( *error ) );
|
||||
return NULL;
|
||||
}
|
||||
size_t mappedSlicePad = mappedSlice - (mappedRow * height);
|
||||
|
||||
// Copy the image.
|
||||
size_t scanlineSize = row_pitch_lod;
|
||||
size_t sliceSize = slice_pitch_lod - scanlineSize * height;
|
||||
size_t imageSize = scanlineSize * height * depth;
|
||||
size_t data_lod_offset = 0;
|
||||
if( gTestMipmaps )
|
||||
data_lod_offset = compute_mip_level_offset(imageInfo, lod);
|
||||
|
||||
char* src = (char*)data + data_lod_offset;
|
||||
char* dst = (char*)mapped;
|
||||
|
||||
if ((mappedRow == scanlineSize) && (mappedSlicePad==0 || (imageInfo->depth==0 && imageInfo->arraySize==0))) {
|
||||
// Copy the whole image.
|
||||
memcpy( dst, src, imageSize );
|
||||
}
|
||||
else {
|
||||
// Else copy one scan line at a time.
|
||||
size_t dstPitch2D = 0;
|
||||
switch (imageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
dstPitch2D = mappedRow;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
dstPitch2D = mappedSlice;
|
||||
break;
|
||||
}
|
||||
for ( size_t z = 0; z < depth; z++ )
|
||||
{
|
||||
for ( size_t y = 0; y < height; y++ )
|
||||
{
|
||||
memcpy( dst, src, scanlineSize );
|
||||
dst += dstPitch2D;
|
||||
src += scanlineSize;
|
||||
}
|
||||
|
||||
// mappedSlicePad is incorrect for 2D images here, but we will exit the z loop before this is a problem.
|
||||
dst += mappedSlicePad;
|
||||
src += sliceSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Unmap the image.
|
||||
*error = clEnqueueUnmapMemObject(queue, img, mapped, 0, NULL, NULL);
|
||||
if (*error != CL_SUCCESS)
|
||||
{
|
||||
log_error( "ERROR: Unable to unmap image after writing: %s\n", IGetErrorString( *error ) );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
// WARNING -- not thread safe
|
||||
BufferOwningPtr<char> srcData;
|
||||
BufferOwningPtr<char> dstData;
|
||||
BufferOwningPtr<char> srcHost;
|
||||
BufferOwningPtr<char> dstHost;
|
||||
|
||||
int test_copy_image_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
|
||||
const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d )
|
||||
{
|
||||
int error;
|
||||
|
||||
clMemWrapper srcImage, dstImage;
|
||||
|
||||
if( gDebugTrace )
|
||||
log_info( " ++ Entering inner test loop...\n" );
|
||||
|
||||
// Generate some data to test against
|
||||
size_t srcBytes = 0;
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
srcBytes = (size_t)compute_mipmapped_image_size( *srcImageInfo );
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (srcImageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
srcBytes = srcImageInfo->rowPitch;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
srcBytes = srcImageInfo->height * srcImageInfo->rowPitch;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
srcBytes = srcImageInfo->depth * srcImageInfo->slicePitch;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
srcBytes = srcImageInfo->arraySize * srcImageInfo->slicePitch;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
srcBytes = srcImageInfo->arraySize * srcImageInfo->slicePitch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (srcBytes > srcData.getSize())
|
||||
{
|
||||
if( gDebugTrace )
|
||||
log_info( " - Resizing random image data...\n" );
|
||||
|
||||
generate_random_image_data( srcImageInfo, srcData, d );
|
||||
|
||||
// Update the host verification copy of the data.
|
||||
srcHost.reset(malloc(srcBytes),NULL,0,srcBytes);
|
||||
if (srcHost == NULL) {
|
||||
log_error( "ERROR: Unable to malloc %lu bytes for srcHost\n", srcBytes );
|
||||
return -1;
|
||||
}
|
||||
memcpy(srcHost,srcData,srcBytes);
|
||||
}
|
||||
|
||||
// Construct testing sources
|
||||
if( gDebugTrace )
|
||||
log_info( " - Writing source image...\n" );
|
||||
|
||||
srcImage = create_image( context, srcData, srcImageInfo, &error );
|
||||
if( srcImage == NULL )
|
||||
return error;
|
||||
|
||||
|
||||
// Initialize the destination to empty
|
||||
size_t destImageSize = 0;
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
destImageSize = (size_t)compute_mipmapped_image_size( *dstImageInfo );
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (dstImageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
destImageSize = dstImageInfo->rowPitch;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
destImageSize = dstImageInfo->height * dstImageInfo->rowPitch;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
destImageSize = dstImageInfo->depth * dstImageInfo->slicePitch;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
destImageSize = dstImageInfo->arraySize * dstImageInfo->slicePitch;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
destImageSize = dstImageInfo->arraySize * dstImageInfo->slicePitch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (destImageSize > dstData.getSize())
|
||||
{
|
||||
if( gDebugTrace )
|
||||
log_info( " - Resizing destination buffer...\n" );
|
||||
dstData.reset(malloc(destImageSize),NULL,0,destImageSize);
|
||||
if (dstData == NULL) {
|
||||
log_error( "ERROR: Unable to malloc %lu bytes for dstData\n", destImageSize );
|
||||
return -1;
|
||||
}
|
||||
|
||||
dstHost.reset(malloc(destImageSize),NULL,0,destImageSize);
|
||||
if (dstHost == NULL) {
|
||||
dstData.reset(NULL);
|
||||
log_error( "ERROR: Unable to malloc %lu bytes for dstHost\n", destImageSize );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
memset( dstData, 0xff, destImageSize );
|
||||
memset( dstHost, 0xff, destImageSize );
|
||||
|
||||
if( gDebugTrace )
|
||||
log_info( " - Writing destination image...\n" );
|
||||
|
||||
dstImage = create_image( context, dstData, dstImageInfo, &error );
|
||||
if( dstImage == NULL )
|
||||
return error;
|
||||
|
||||
size_t dstRegion[ 3 ] = { dstImageInfo->width, 1, 1};
|
||||
size_t dst_lod = 0;
|
||||
size_t origin[ 4 ] = { 0, 0, 0, 0 };
|
||||
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
switch(dstImageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
dst_lod = destPos[1];
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
dst_lod = destPos[2];
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
dst_lod = destPos[3];
|
||||
break;
|
||||
}
|
||||
|
||||
dstRegion[ 0 ] = (dstImageInfo->width >> dst_lod)?(dstImageInfo->width >> dst_lod) : 1;
|
||||
}
|
||||
switch (dstImageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
if( gTestMipmaps )
|
||||
origin[ 1 ] = dst_lod;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
dstRegion[ 1 ] = dstImageInfo->height;
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
dstRegion[ 1 ] = (dstImageInfo->height >> dst_lod) ?(dstImageInfo->height >> dst_lod): 1;
|
||||
origin[ 2 ] = dst_lod;
|
||||
}
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
dstRegion[ 1 ] = dstImageInfo->height;
|
||||
dstRegion[ 2 ] = dstImageInfo->depth;
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
dstRegion[ 1 ] = (dstImageInfo->height >> dst_lod) ?(dstImageInfo->height >> dst_lod): 1;
|
||||
dstRegion[ 2 ] = (dstImageInfo->depth >> dst_lod) ?(dstImageInfo->depth >> dst_lod): 1;
|
||||
origin[ 3 ] = dst_lod;
|
||||
}
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
dstRegion[ 1 ] = dstImageInfo->arraySize;
|
||||
if( gTestMipmaps )
|
||||
origin[ 2 ] = dst_lod;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
dstRegion[ 1 ] = dstImageInfo->height;
|
||||
dstRegion[ 2 ] = dstImageInfo->arraySize;
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
dstRegion[ 1 ] = (dstImageInfo->height >> dst_lod) ?(dstImageInfo->height >> dst_lod): 1;
|
||||
origin[ 3 ] = dst_lod;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
size_t region[ 3 ] = { dstRegion[ 0 ], dstRegion[ 1 ], dstRegion[ 2 ] };
|
||||
|
||||
// Now copy a subset to the destination image. This is the meat of what we're testing
|
||||
if( gDebugTrace )
|
||||
{
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
log_info( " - Copying from %d,%d,%d,%d to %d,%d,%d,%d size %d,%d,%d\n", (int)sourcePos[ 0 ], (int)sourcePos[ 1 ], (int)sourcePos[ 2 ],(int)sourcePos[ 3 ],
|
||||
(int)destPos[ 0 ], (int)destPos[ 1 ], (int)destPos[ 2 ],(int)destPos[ 3 ],
|
||||
(int)regionSize[ 0 ], (int)regionSize[ 1 ], (int)regionSize[ 2 ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info( " - Copying from %d,%d,%d to %d,%d,%d size %d,%d,%d\n", (int)sourcePos[ 0 ], (int)sourcePos[ 1 ], (int)sourcePos[ 2 ],
|
||||
(int)destPos[ 0 ], (int)destPos[ 1 ], (int)destPos[ 2 ],
|
||||
(int)regionSize[ 0 ], (int)regionSize[ 1 ], (int)regionSize[ 2 ] );
|
||||
}
|
||||
}
|
||||
|
||||
error = clEnqueueCopyImage( queue, srcImage, dstImage, sourcePos, destPos, regionSize, 0, NULL, NULL );
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
log_error( "ERROR: Unable to copy image from pos %d,%d,%d to %d,%d,%d size %d,%d,%d! (%s)\n",
|
||||
(int)sourcePos[ 0 ], (int)sourcePos[ 1 ], (int)sourcePos[ 2 ], (int)destPos[ 0 ], (int)destPos[ 1 ], (int)destPos[ 2 ],
|
||||
(int)regionSize[ 0 ], (int)regionSize[ 1 ], (int)regionSize[ 2 ], IGetErrorString( error ) );
|
||||
return error;
|
||||
}
|
||||
|
||||
// Construct the final dest image values to test against
|
||||
if( gDebugTrace )
|
||||
log_info( " - Host verification copy...\n" );
|
||||
|
||||
copy_image_data( srcImageInfo, dstImageInfo, srcHost, dstHost, sourcePos, destPos, regionSize );
|
||||
|
||||
// Map the destination image to verify the results with the host
|
||||
// copy. The contents of the entire buffer are compared.
|
||||
if( gDebugTrace )
|
||||
log_info( " - Mapping results...\n" );
|
||||
|
||||
size_t mappedRow, mappedSlice;
|
||||
void* mapped = (char*)clEnqueueMapImage(queue, dstImage, CL_TRUE, CL_MAP_READ, origin, region, &mappedRow, &mappedSlice, 0, NULL, NULL, &error);
|
||||
if (error != CL_SUCCESS)
|
||||
{
|
||||
log_error( "ERROR: Unable to map image for verification: %s\n", IGetErrorString( error ) );
|
||||
return error;
|
||||
}
|
||||
|
||||
// Verify scanline by scanline, since the pitches are different
|
||||
char *sourcePtr = dstHost;
|
||||
size_t cur_lod_offset = 0;
|
||||
char *destPtr = (char*)mapped;
|
||||
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
cur_lod_offset = compute_mip_level_offset(dstImageInfo, dst_lod);
|
||||
sourcePtr += cur_lod_offset;
|
||||
}
|
||||
|
||||
size_t scanlineSize = dstImageInfo->width * get_pixel_size( dstImageInfo->format );
|
||||
size_t rowPitch = dstImageInfo->rowPitch;
|
||||
size_t slicePitch = dstImageInfo->slicePitch;
|
||||
size_t dst_height_lod = dstImageInfo->height;
|
||||
if(gTestMipmaps)
|
||||
{
|
||||
size_t dst_width_lod = (dstImageInfo->width >> dst_lod)?(dstImageInfo->width >> dst_lod) : 1;
|
||||
dst_height_lod = (dstImageInfo->height >> dst_lod)?(dstImageInfo->height >> dst_lod) : 1;
|
||||
scanlineSize = dst_width_lod * get_pixel_size(dstImageInfo->format);
|
||||
rowPitch = scanlineSize;
|
||||
slicePitch = rowPitch * dst_height_lod;
|
||||
}
|
||||
|
||||
if( gDebugTrace )
|
||||
log_info( " - Scanline verification...\n" );
|
||||
|
||||
size_t thirdDim;
|
||||
size_t secondDim;
|
||||
if (dstImageInfo->type == CL_MEM_OBJECT_IMAGE1D_ARRAY)
|
||||
{
|
||||
secondDim = dstImageInfo->arraySize;
|
||||
thirdDim = 1;
|
||||
}
|
||||
else if (dstImageInfo->type == CL_MEM_OBJECT_IMAGE2D_ARRAY)
|
||||
{
|
||||
secondDim = dstImageInfo->height;
|
||||
if( gTestMipmaps )
|
||||
secondDim = (dstImageInfo->height >> dst_lod) ? (dstImageInfo->height >> dst_lod):1;
|
||||
thirdDim = dstImageInfo->arraySize;
|
||||
}
|
||||
else
|
||||
{
|
||||
secondDim = dstImageInfo->height;
|
||||
thirdDim = dstImageInfo->depth;
|
||||
if( gTestMipmaps )
|
||||
{
|
||||
secondDim = (dstImageInfo->height >> dst_lod) ? (dstImageInfo->height >> dst_lod):1;
|
||||
if(dstImageInfo->type == CL_MEM_OBJECT_IMAGE3D)
|
||||
thirdDim = (dstImageInfo->depth >> dst_lod) ? (dstImageInfo->depth >> dst_lod):1;
|
||||
}
|
||||
}
|
||||
|
||||
for( size_t z = 0; z < thirdDim; z++ )
|
||||
{
|
||||
for( size_t y = 0; y < secondDim; y++ )
|
||||
{
|
||||
if( memcmp( sourcePtr, destPtr, scanlineSize ) != 0 )
|
||||
{
|
||||
log_error( "ERROR: Scanline %d did not verify for image size %d,%d,%d pitch %d (extra %d bytes)\n", (int)y, (int)dstImageInfo->width, (int)dstImageInfo->height, (int)dstImageInfo->depth, (int)dstImageInfo->rowPitch, (int)dstImageInfo->rowPitch - (int)dstImageInfo->width * (int)get_pixel_size( dstImageInfo->format ) );
|
||||
|
||||
// Find the first missing pixel
|
||||
size_t pixel_size = get_pixel_size( dstImageInfo->format );
|
||||
size_t where = 0;
|
||||
for( where = 0; where < dstImageInfo->width; where++ )
|
||||
if( memcmp( sourcePtr + pixel_size * where, destPtr + pixel_size * where, pixel_size) )
|
||||
break;
|
||||
log_error( "Failed at column: %ld ", where );
|
||||
switch( pixel_size )
|
||||
{
|
||||
case 1:
|
||||
log_error( "*0x%2.2x vs. 0x%2.2x\n", ((cl_uchar*)(sourcePtr + pixel_size * where))[0], ((cl_uchar*)(destPtr + pixel_size * where))[0] );
|
||||
break;
|
||||
case 2:
|
||||
log_error( "*0x%4.4x vs. 0x%4.4x\n", ((cl_ushort*)(sourcePtr + pixel_size * where))[0], ((cl_ushort*)(destPtr + pixel_size * where))[0] );
|
||||
break;
|
||||
case 3:
|
||||
log_error( "*{0x%2.2x, 0x%2.2x, 0x%2.2x} vs. {0x%2.2x, 0x%2.2x, 0x%2.2x}\n",
|
||||
((cl_uchar*)(sourcePtr + pixel_size * where))[0], ((cl_uchar*)(sourcePtr + pixel_size * where))[1], ((cl_uchar*)(sourcePtr + pixel_size * where))[2],
|
||||
((cl_uchar*)(destPtr + pixel_size * where))[0], ((cl_uchar*)(destPtr + pixel_size * where))[1], ((cl_uchar*)(destPtr + pixel_size * where))[2]
|
||||
);
|
||||
break;
|
||||
case 4:
|
||||
log_error( "*0x%8.8x vs. 0x%8.8x\n", ((cl_uint*)(sourcePtr + pixel_size * where))[0], ((cl_uint*)(destPtr + pixel_size * where))[0] );
|
||||
break;
|
||||
case 6:
|
||||
log_error( "*{0x%4.4x, 0x%4.4x, 0x%4.4x} vs. {0x%4.4x, 0x%4.4x, 0x%4.4x}\n",
|
||||
((cl_ushort*)(sourcePtr + pixel_size * where))[0], ((cl_ushort*)(sourcePtr + pixel_size * where))[1], ((cl_ushort*)(sourcePtr + pixel_size * where))[2],
|
||||
((cl_ushort*)(destPtr + pixel_size * where))[0], ((cl_ushort*)(destPtr + pixel_size * where))[1], ((cl_ushort*)(destPtr + pixel_size * where))[2]
|
||||
);
|
||||
break;
|
||||
case 8:
|
||||
log_error( "*0x%16.16llx vs. 0x%16.16llx\n", ((cl_ulong*)(sourcePtr + pixel_size * where))[0], ((cl_ulong*)(destPtr + pixel_size * where))[0] );
|
||||
break;
|
||||
case 12:
|
||||
log_error( "*{0x%8.8x, 0x%8.8x, 0x%8.8x} vs. {0x%8.8x, 0x%8.8x, 0x%8.8x}\n",
|
||||
((cl_uint*)(sourcePtr + pixel_size * where))[0], ((cl_uint*)(sourcePtr + pixel_size * where))[1], ((cl_uint*)(sourcePtr + pixel_size * where))[2],
|
||||
((cl_uint*)(destPtr + pixel_size * where))[0], ((cl_uint*)(destPtr + pixel_size * where))[1], ((cl_uint*)(destPtr + pixel_size * where))[2]
|
||||
);
|
||||
break;
|
||||
case 16:
|
||||
log_error( "*{0x%8.8x, 0x%8.8x, 0x%8.8x, 0x%8.8x} vs. {0x%8.8x, 0x%8.8x, 0x%8.8x, 0x%8.8x}\n",
|
||||
((cl_uint*)(sourcePtr + pixel_size * where))[0], ((cl_uint*)(sourcePtr + pixel_size * where))[1], ((cl_uint*)(sourcePtr + pixel_size * where))[2], ((cl_uint*)(sourcePtr + pixel_size * where))[3],
|
||||
((cl_uint*)(destPtr + pixel_size * where))[0], ((cl_uint*)(destPtr + pixel_size * where))[1], ((cl_uint*)(destPtr + pixel_size * where))[2], ((cl_uint*)(destPtr + pixel_size * where))[3]
|
||||
);
|
||||
break;
|
||||
default:
|
||||
log_error( "Don't know how to print pixel size of %ld\n", pixel_size );
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
sourcePtr += rowPitch;
|
||||
if((dstImageInfo->type == CL_MEM_OBJECT_IMAGE1D_ARRAY || dstImageInfo->type == CL_MEM_OBJECT_IMAGE1D))
|
||||
destPtr += mappedSlice;
|
||||
else
|
||||
destPtr += mappedRow;
|
||||
}
|
||||
sourcePtr += slicePitch - rowPitch * dst_height_lod;
|
||||
destPtr += mappedSlice - mappedRow * dst_height_lod;
|
||||
}
|
||||
|
||||
// Unmap the image.
|
||||
error = clEnqueueUnmapMemObject(queue, dstImage, mapped, 0, NULL, NULL);
|
||||
if (error != CL_SUCCESS)
|
||||
{
|
||||
log_error( "ERROR: Unable to unmap image after verify: %s\n", IGetErrorString( error ) );
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_copy_image_size_generic( cl_device_id device, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
|
||||
{
|
||||
size_t sourcePos[ 3 ], destPos[ 3 ], regionSize[ 3 ];
|
||||
int ret = 0, retCode;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
switch (srcImageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
sourcePos[ 0 ] = random_in_range( 0, (int)(srcImageInfo->width - 4), d );
|
||||
sourcePos[ 1 ] = 1;
|
||||
sourcePos[ 2 ] = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
sourcePos[ 0 ] = random_in_range( 0, (int)(srcImageInfo->width - 4), d );
|
||||
sourcePos[ 1 ] = random_in_range( 0, (int)(srcImageInfo->height - 4), d );
|
||||
sourcePos[ 2 ] = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
sourcePos[ 0 ] = random_in_range( 0, (int)(srcImageInfo->width - 4), d );
|
||||
sourcePos[ 1 ] = random_in_range( 0, (int)(srcImageInfo->height - 4), d );
|
||||
sourcePos[ 2 ] = random_in_range( 0, (int)(srcImageInfo->depth - 4), d );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
sourcePos[ 0 ] = random_in_range( 0, (int)(srcImageInfo->width - 4), d );
|
||||
sourcePos[ 1 ] = random_in_range( 0, (int)(srcImageInfo->arraySize - 4), d );
|
||||
sourcePos[ 2 ] = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
sourcePos[ 0 ] = random_in_range( 0, (int)(srcImageInfo->width - 4), d );
|
||||
sourcePos[ 1 ] = random_in_range( 0, (int)(srcImageInfo->height - 4), d );
|
||||
sourcePos[ 2 ] = random_in_range( 0, (int)(srcImageInfo->arraySize - 4), d );
|
||||
break;
|
||||
}
|
||||
|
||||
switch (dstImageInfo->type)
|
||||
{
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
destPos[ 0 ] = random_in_range( 0, (int)(dstImageInfo->width - 4), d );
|
||||
destPos[ 1 ] = 1;
|
||||
destPos[ 2 ] = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
destPos[ 0 ] = random_in_range( 0, (int)(dstImageInfo->width - 4), d );
|
||||
destPos[ 1 ] = random_in_range( 0, (int)(dstImageInfo->height - 4), d );
|
||||
destPos[ 2 ] = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE3D:
|
||||
destPos[ 0 ] = random_in_range( 0, (int)(dstImageInfo->width - 4), d );
|
||||
destPos[ 1 ] = random_in_range( 0, (int)(dstImageInfo->height - 4), d );
|
||||
destPos[ 2 ] = random_in_range( 0, (int)(dstImageInfo->depth - 4), d );
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
destPos[ 0 ] = random_in_range( 0, (int)(dstImageInfo->width - 4), d );
|
||||
destPos[ 1 ] = random_in_range( 0, (int)(dstImageInfo->arraySize - 4), d );
|
||||
destPos[ 2 ] = 1;
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
destPos[ 0 ] = random_in_range( 0, (int)(dstImageInfo->width - 4), d );
|
||||
destPos[ 1 ] = random_in_range( 0, (int)(dstImageInfo->height - 4), d );
|
||||
destPos[ 2 ] = random_in_range( 0, (int)(dstImageInfo->arraySize - 4), d );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( (dstImageInfo->width - destPos[0]) < (srcImageInfo->width - sourcePos[0]) )
|
||||
regionSize[0] = random_in_range(1, (dstImageInfo->width - destPos[0]), d);
|
||||
else
|
||||
regionSize[0] = random_in_range(1, (srcImageInfo->width - sourcePos[0]), d);
|
||||
|
||||
if (srcImageInfo->type == CL_MEM_OBJECT_IMAGE1D || dstImageInfo->type == CL_MEM_OBJECT_IMAGE1D)
|
||||
regionSize[1] = 0;
|
||||
else
|
||||
{
|
||||
if ( (dstImageInfo->height - destPos[1]) < (srcImageInfo->height - sourcePos[1]) )
|
||||
regionSize[1] = random_in_range(1, (dstImageInfo->height - destPos[1]), d);
|
||||
else
|
||||
regionSize[1] = random_in_range(1, (srcImageInfo->height - sourcePos[1]), d);
|
||||
}
|
||||
|
||||
regionSize[2] = 0;
|
||||
if (dstImageInfo->type == CL_MEM_OBJECT_IMAGE3D && srcImageInfo->type == CL_MEM_OBJECT_IMAGE3D)
|
||||
{
|
||||
if ( (dstImageInfo->depth - destPos[2]) < (srcImageInfo->depth - sourcePos[2]) )
|
||||
regionSize[2] = random_in_range(1, (dstImageInfo->depth - destPos[2]), d);
|
||||
else
|
||||
regionSize[2] = random_in_range(1, (srcImageInfo->depth - sourcePos[2]), d);
|
||||
}
|
||||
else if ( (dstImageInfo->type == CL_MEM_OBJECT_IMAGE2D_ARRAY && srcImageInfo->type == CL_MEM_OBJECT_IMAGE2D_ARRAY) )
|
||||
{
|
||||
if ( (dstImageInfo->arraySize - destPos[2]) < (srcImageInfo->arraySize - sourcePos[2]) )
|
||||
regionSize[2] = random_in_range(1, (dstImageInfo->arraySize - destPos[2]), d);
|
||||
else
|
||||
regionSize[2] = random_in_range(1, (srcImageInfo->arraySize - sourcePos[2]), d);
|
||||
}
|
||||
|
||||
// Go for it!
|
||||
retCode = test_copy_image_generic( device, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
|
||||
if( retCode < 0 )
|
||||
return retCode;
|
||||
else
|
||||
ret += retCode;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
274
test_conformance/images/clCopyImage/test_loops.cpp
Normal file
274
test_conformance/images/clCopyImage/test_loops.cpp
Normal file
@@ -0,0 +1,274 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "../testBase.h"
|
||||
|
||||
extern cl_filter_mode gFilterModeToUse;
|
||||
extern cl_addressing_mode gAddressModeToUse;
|
||||
extern int gTypesToTest;
|
||||
extern int gNormalizedModeToUse;
|
||||
extern bool gTestMipmaps;
|
||||
extern cl_channel_type gChannelTypeToUse;
|
||||
extern cl_command_queue queue;
|
||||
extern cl_context context;
|
||||
extern cl_channel_type gChannelTypeToUse;
|
||||
extern cl_channel_order gChannelOrderToUse;
|
||||
|
||||
|
||||
extern bool gDebugTrace;
|
||||
|
||||
extern int test_copy_image_set_1D( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_2D( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_3D( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_1D_array( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_2D_array( cl_device_id device, cl_image_format *format );
|
||||
extern int test_copy_image_set_2D_3D( cl_device_id device, cl_image_format *format, bool reverse );
|
||||
extern int test_copy_image_set_2D_2D_array( cl_device_id device, cl_image_format *format, bool reverse );
|
||||
extern int test_copy_image_set_3D_2D_array( cl_device_id device, cl_image_format *format, bool reverse );
|
||||
|
||||
|
||||
int filter_formats( cl_image_format *formatList, bool *filterFlags, unsigned int formatCount, cl_channel_type *channelDataTypesToFilter )
|
||||
{
|
||||
int numSupported = 0;
|
||||
for( unsigned int j = 0; j < formatCount; j++ )
|
||||
{
|
||||
// If this format has been previously filtered, remove the filter
|
||||
if( filterFlags[ j ] )
|
||||
filterFlags[ j ] = false;
|
||||
|
||||
// Have we already discarded this via the command line?
|
||||
if( gChannelTypeToUse != (cl_channel_type)-1 && gChannelTypeToUse != formatList[ j ].image_channel_data_type )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Have we already discarded the channel order via the command line?
|
||||
if( gChannelOrderToUse != (cl_channel_order)-1 && gChannelOrderToUse != formatList[ j ].image_channel_order )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is given format standard channel order and type given by spec. We don't want to test it if this is vendor extension
|
||||
if( !IsChannelOrderSupported( formatList[ j ].image_channel_order ) || !IsChannelTypeSupported( formatList[ j ].image_channel_data_type ) )
|
||||
{
|
||||
filterFlags[ j ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// We don't filter by channel type
|
||||
if( !channelDataTypesToFilter )
|
||||
{
|
||||
numSupported++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is the format supported?
|
||||
int i;
|
||||
for( i = 0; channelDataTypesToFilter[ i ] != (cl_channel_type)-1; i++ )
|
||||
{
|
||||
if( formatList[ j ].image_channel_data_type == channelDataTypesToFilter[ i ] )
|
||||
{
|
||||
numSupported++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( channelDataTypesToFilter[ i ] == (cl_channel_type)-1 )
|
||||
{
|
||||
// Format is NOT supported, so mark it as such
|
||||
filterFlags[ j ] = true;
|
||||
}
|
||||
}
|
||||
return numSupported;
|
||||
}
|
||||
|
||||
int get_format_list( cl_device_id device, cl_mem_object_type imageType, cl_image_format * &outFormatList, unsigned int &outFormatCount, cl_mem_flags flags )
|
||||
{
|
||||
int error;
|
||||
|
||||
cl_image_format tempList[ 128 ];
|
||||
error = clGetSupportedImageFormats( context, (cl_mem_flags)flags,
|
||||
imageType, 128, tempList, &outFormatCount );
|
||||
test_error( error, "Unable to get count of supported image formats" );
|
||||
|
||||
outFormatList = new cl_image_format[ outFormatCount ];
|
||||
error = clGetSupportedImageFormats( context, (cl_mem_flags)flags,
|
||||
imageType, outFormatCount, outFormatList, NULL );
|
||||
test_error( error, "Unable to get list of supported image formats" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_image_type( cl_device_id device, MethodsToTest testMethod, cl_mem_flags flags )
|
||||
{
|
||||
const char *name;
|
||||
cl_mem_object_type imageType;
|
||||
|
||||
if ( gTestMipmaps )
|
||||
{
|
||||
if ( 0 == is_extension_available( device, "cl_khr_mipmap_image" ))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if( testMethod == k1D )
|
||||
{
|
||||
name = "1D -> 1D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE1D;
|
||||
}
|
||||
else if( testMethod == k2D )
|
||||
{
|
||||
name = "2D -> 2D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D;
|
||||
}
|
||||
else if( testMethod == k3D )
|
||||
{
|
||||
name = "3D -> 3D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k1DArray )
|
||||
{
|
||||
name = "1D array -> 1D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DArray )
|
||||
{
|
||||
name = "2D array -> 2D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DTo3D )
|
||||
{
|
||||
name = "2D -> 3D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k3DTo2D )
|
||||
{
|
||||
name = "3D -> 2D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k2DArrayTo2D )
|
||||
{
|
||||
name = "2D array -> 2D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DTo2DArray )
|
||||
{
|
||||
name = "2D -> 2D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
else if( testMethod == k2DArrayTo3D )
|
||||
{
|
||||
name = "2D array -> 3D";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
else if( testMethod == k3DTo2DArray )
|
||||
{
|
||||
name = "3D -> 2D array";
|
||||
imageType = CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
|
||||
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
|
||||
cl_image_format *formatList;
|
||||
bool *filterFlags;
|
||||
unsigned int numFormats;
|
||||
|
||||
if( get_format_list( device, imageType, formatList, numFormats, flags ) )
|
||||
return -1;
|
||||
|
||||
filterFlags = new bool[ numFormats ];
|
||||
if( filterFlags == NULL )
|
||||
{
|
||||
log_error( "ERROR: Out of memory allocating filter flags list!\n" );
|
||||
return -1;
|
||||
}
|
||||
memset( filterFlags, 0, sizeof( bool ) * numFormats );
|
||||
|
||||
filter_formats(formatList, filterFlags, numFormats, NULL);
|
||||
|
||||
// Run the format list
|
||||
for( unsigned int i = 0; i < numFormats; i++ )
|
||||
{
|
||||
int test_return = 0;
|
||||
if( filterFlags[i] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
print_header( &formatList[ i ], false );
|
||||
|
||||
gTestCount++;
|
||||
|
||||
if( testMethod == k1D )
|
||||
test_return = test_copy_image_set_1D( device, &formatList[ i ] );
|
||||
else if( testMethod == k2D )
|
||||
test_return = test_copy_image_set_2D( device, &formatList[ i ] );
|
||||
else if( testMethod == k3D )
|
||||
test_return = test_copy_image_set_3D( device, &formatList[ i ] );
|
||||
else if( testMethod == k1DArray )
|
||||
test_return = test_copy_image_set_1D_array( device, &formatList[ i ] );
|
||||
else if( testMethod == k2DArray )
|
||||
test_return = test_copy_image_set_2D_array( device, &formatList[ i ] );
|
||||
else if( testMethod == k2DTo3D )
|
||||
test_return = test_copy_image_set_2D_3D( device, &formatList[ i ], false );
|
||||
else if( testMethod == k3DTo2D )
|
||||
test_return = test_copy_image_set_2D_3D( device, &formatList[ i ], true );
|
||||
else if( testMethod == k2DArrayTo2D)
|
||||
test_return = test_copy_image_set_2D_2D_array( device, &formatList[ i ], true);
|
||||
else if( testMethod == k2DTo2DArray)
|
||||
test_return = test_copy_image_set_2D_2D_array( device, &formatList[ i ], false);
|
||||
else if( testMethod == k2DArrayTo3D)
|
||||
test_return = test_copy_image_set_3D_2D_array( device, &formatList[ i ], true);
|
||||
else if( testMethod == k3DTo2DArray)
|
||||
test_return = test_copy_image_set_3D_2D_array( device, &formatList[ i ], false);
|
||||
|
||||
if (test_return) {
|
||||
gTestFailure++;
|
||||
log_error( "FAILED: " );
|
||||
print_header( &formatList[ i ], true );
|
||||
log_info( "\n" );
|
||||
}
|
||||
|
||||
ret += test_return;
|
||||
}
|
||||
|
||||
delete filterFlags;
|
||||
delete formatList;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_image_set( cl_device_id device, MethodsToTest testMethod )
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret += test_image_type( device, testMethod, CL_MEM_READ_ONLY );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user