Use std::vector for format lists in images suite (#1105)

* Use std::vector for format lists in images suite

Avoids memory deallocation issues and generally simplifies the code.

* Fixup formatting with git-clang-format
This commit is contained in:
James Price
2021-01-14 08:27:59 -05:00
committed by GitHub
parent 0b6fbd15d1
commit 03a0989998
28 changed files with 280 additions and 289 deletions

View File

@@ -58,13 +58,13 @@ std::array<ImageTestTypes, 3> imageTestTypes = { {
{ kTestFloat, kFloat, floatFormats, "float" },
} };
int filter_formats(cl_image_format *formatList, bool *filterFlags,
unsigned int formatCount,
int filter_formats(const std::vector<cl_image_format> &formatList,
std::vector<bool> &filterFlags,
cl_channel_type *channelDataTypesToFilter,
bool testMipmaps /*=false*/)
{
int numSupported = 0;
for (unsigned int j = 0; j < formatCount; j++)
for (unsigned int j = 0; j < formatList.size(); j++)
{
// If this format has been previously filtered, remove the filter
if (filterFlags[j]) filterFlags[j] = false;
@@ -129,18 +129,18 @@ int filter_formats(cl_image_format *formatList, bool *filterFlags,
}
int get_format_list(cl_context context, cl_mem_object_type imageType,
cl_image_format *&outFormatList,
unsigned int &outFormatCount, cl_mem_flags flags)
std::vector<cl_image_format> &outFormatList,
cl_mem_flags flags)
{
cl_uint formatCount;
int error = clGetSupportedImageFormats(context, flags, imageType, 0, NULL,
&outFormatCount);
&formatCount);
test_error(error, "Unable to get count of supported image formats");
outFormatList =
(outFormatCount > 0) ? new cl_image_format[outFormatCount] : NULL;
outFormatList.resize(formatCount);
error = clGetSupportedImageFormats(context, flags, imageType,
outFormatCount, outFormatList, NULL);
error = clGetSupportedImageFormats(context, flags, imageType, formatCount,
outFormatList.data(), NULL);
test_error(error, "Unable to get list of supported image formats");
return 0;
}