From f230f788a78d1f8fbfb99fad7e6b4d1f767975ba Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Tue, 16 Jan 2024 20:59:45 -0800 Subject: [PATCH] sort image formats before printing Sorting the queried image formats can make it easier to diff results across drivers and devices. --- samples/images/00_enumimageformats/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/samples/images/00_enumimageformats/main.cpp b/samples/images/00_enumimageformats/main.cpp index 57e8752..5f3ff8c 100644 --- a/samples/images/00_enumimageformats/main.cpp +++ b/samples/images/00_enumimageformats/main.cpp @@ -8,6 +8,8 @@ #include +#include + #define CASE_TO_STRING(_e) case _e: return #_e; const char* mem_object_type_to_string(cl_mem_object_type mem_object_type) @@ -200,6 +202,13 @@ int main( std::vector imageFormats; context.getSupportedImageFormats( imageAccess, imageType, &imageFormats ); + std::sort(std::begin(imageFormats), std::end(imageFormats), + [](cl::ImageFormat a, cl::ImageFormat b) { + return a.image_channel_order < b.image_channel_order || + (a.image_channel_order == b.image_channel_data_type && + a.image_channel_data_type < b.image_channel_data_type); + }); + printf("\nFor image access %s (%04X), image type %s (%04X):\n", mem_flags_to_string(imageAccess), (cl_uint)imageAccess,