Creating common functions for image/kernel_read_write read tests (#1141)

* Make InitFloatCoords suitable for all image types

Contributes #616

* Create common functions neutral for image types

Remove 3D specific code from common test_read_image so using
it for other image types is simpler in following patches

Contributes #616

* Removing unused code

Tidying commented out or unnecessary code

Contributes #616

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>

* Restoring 'lod' variable name

Contributes #616

* Default cases to handle unsupported image types

Contributes #616

* Resolving build issues

Contributes #616

* Fix formatting

Contributes #616

* Using TEST_FAIL as an error code.

Contributes #616

* Add static keyword, improve error handling

Contributes #616

* Fix build errors with least disruption

Contributes #616

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
This commit is contained in:
ellnor01
2022-09-26 12:57:42 +01:00
committed by GitHub
parent 2012c6cadd
commit c014122742
2 changed files with 345 additions and 265 deletions

View File

@@ -42,12 +42,8 @@ extern int test_read_image(cl_context context, cl_command_queue queue,
bool useFloatCoords, ExplicitType outputType,
MTdata d);
extern void InitFloatCoordsCommon(image_descriptor *imageInfo,
image_sampler_data *imageSampler,
float *xOffsets, float *yOffsets,
float *zOffsets, float xfract, float yfract,
float zfract, int normalized_coords, MTdata d,
int lod);
extern bool get_image_dimensions(image_descriptor *imageInfo, size_t &width,
size_t &height, size_t &depth);
template <class T>
int determine_validation_error_offset(
@@ -63,8 +59,12 @@ int determine_validation_error_offset(
bool clampingErr = false, clamped = false, otherClampingBug = false;
int clampedX, clampedY, clampedZ;
size_t imageWidth = imageInfo->width, imageHeight = imageInfo->height,
imageDepth = imageInfo->depth;
size_t imageWidth, imageHeight, imageDepth;
if (get_image_dimensions(imageInfo, imageWidth, imageHeight, imageDepth))
{
log_error("ERROR: invalid image dimensions");
return TEST_FAIL;
}
clamped = get_integer_coords_offset(x, y, z, xAddressOffset, yAddressOffset,
zAddressOffset, imageWidth, imageHeight,
@@ -147,82 +147,67 @@ int determine_validation_error_offset(
}
if (!clampingErr)
{
/* if( clamped && ( (int)x + (int)xOffsetValues[ j ] < 0 ||
(int)y + (int)yOffsetValues[ j ] < 0 ) )
{
log_error( "NEGATIVE COORDINATE ERROR\n" );
return -1;
}
*/
if (true) // gExtraValidateInfo )
if (printAsFloat)
{
if (printAsFloat)
{
log_error("Sample %ld: coord {%f(%a),%f(%a),%f(%a)} did not "
"validate!\n\tExpected (%g,%g,%g,%g),\n\t got "
"(%g,%g,%g,%g), error of %g\n",
j, x, x, y, y, z, z, (float)expected[0],
(float)expected[1], (float)expected[2],
(float)expected[3], (float)resultPtr[0],
(float)resultPtr[1], (float)resultPtr[2],
(float)resultPtr[3], error);
}
else
{
log_error("Sample %ld: coord {%f(%a),%f(%a),%f(%a)} did not "
"validate!\n\tExpected (%x,%x,%x,%x),\n\t got "
"(%x,%x,%x,%x)\n",
j, x, x, y, y, z, z, (int)expected[0],
(int)expected[1], (int)expected[2], (int)expected[3],
(int)resultPtr[0], (int)resultPtr[1],
(int)resultPtr[2], (int)resultPtr[3]);
}
log_error(
"Integer coords resolve to %d,%d,%d with img size %d,%d,%d\n",
clampedX, clampedY, clampedZ, (int)imageWidth, (int)imageHeight,
(int)imageDepth);
log_error("Sample %ld: coord {%f(%a),%f(%a),%f(%a)} did not "
"validate!\n\tExpected (%g,%g,%g,%g),\n\t got "
"(%g,%g,%g,%g), error of %g\n",
j, x, x, y, y, z, z, (float)expected[0],
(float)expected[1], (float)expected[2],
(float)expected[3], (float)resultPtr[0],
(float)resultPtr[1], (float)resultPtr[2],
(float)resultPtr[3], error);
}
else
{
log_error("Sample %ld: coord {%f(%a),%f(%a),%f(%a)} did not "
"validate!\n\tExpected (%x,%x,%x,%x),\n\t got "
"(%x,%x,%x,%x)\n",
j, x, x, y, y, z, z, (int)expected[0], (int)expected[1],
(int)expected[2], (int)expected[3], (int)resultPtr[0],
(int)resultPtr[1], (int)resultPtr[2], (int)resultPtr[3]);
}
log_error(
"Integer coords resolve to %d,%d,%d with img size %d,%d,%d\n",
clampedX, clampedY, clampedZ, (int)imageWidth, (int)imageHeight,
(int)imageDepth);
if (printAsFloat && gExtraValidateInfo)
if (printAsFloat && gExtraValidateInfo)
{
log_error("\nNearby values:\n");
for (int zOff = -1; zOff <= 1; zOff++)
{
log_error("\nNearby values:\n");
for (int zOff = -1; zOff <= 1; zOff++)
for (int yOff = -1; yOff <= 1; yOff++)
{
for (int yOff = -1; yOff <= 1; yOff++)
{
float top[4], real[4], bot[4];
read_image_pixel_float(imagePtr, imageInfo,
clampedX - 1, clampedY + yOff,
clampedZ + zOff, top);
read_image_pixel_float(imagePtr, imageInfo, clampedX,
clampedY + yOff, clampedZ + zOff,
real);
read_image_pixel_float(imagePtr, imageInfo,
clampedX + 1, clampedY + yOff,
clampedZ + zOff, bot);
log_error("\t(%g,%g,%g,%g)", top[0], top[1], top[2],
top[3]);
log_error(" (%g,%g,%g,%g)", real[0], real[1], real[2],
real[3]);
log_error(" (%g,%g,%g,%g)\n", bot[0], bot[1], bot[2],
bot[3]);
}
float top[4], real[4], bot[4];
read_image_pixel_float(imagePtr, imageInfo, clampedX - 1,
clampedY + yOff, clampedZ + zOff,
top);
read_image_pixel_float(imagePtr, imageInfo, clampedX,
clampedY + yOff, clampedZ + zOff,
real);
read_image_pixel_float(imagePtr, imageInfo, clampedX + 1,
clampedY + yOff, clampedZ + zOff,
bot);
log_error("\t(%g,%g,%g,%g)", top[0], top[1], top[2],
top[3]);
log_error(" (%g,%g,%g,%g)", real[0], real[1], real[2],
real[3]);
log_error(" (%g,%g,%g,%g)\n", bot[0], bot[1], bot[2],
bot[3]);
}
}
// }
// else
// log_error( "\n" );
if (imageSampler->filter_mode != CL_FILTER_LINEAR)
{
if (found)
log_error(
"\tValue really found in image at %d,%d,%d (%s)\n",
actualX, actualY, actualZ,
(found > 1) ? "NOT unique!!" : "unique");
else
log_error("\tValue not actually found in image\n");
}
log_error("\n");
}
if (imageSampler->filter_mode != CL_FILTER_LINEAR)
{
if (found)
log_error("\tValue really found in image at %d,%d,%d (%s)\n",
actualX, actualY, actualZ,
(found > 1) ? "NOT unique!!" : "unique");
else
log_error("\tValue not actually found in image\n");
}
log_error("\n");
numClamped = -1; // We force the clamped counter to never work
if ((--numTries) == 0) return -1;