1 //
2 // Copyright (c) 2017 The Khronos Group Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #include "../testBase.h"
17 #include "../common.h"
18
19 extern int test_get_image_info_1D( cl_device_id device, cl_context context, cl_image_format *format, cl_mem_flags flags );
20 extern int test_get_image_info_2D( cl_device_id device, cl_context context, cl_image_format *format, cl_mem_flags flags );
21 extern int test_get_image_info_3D( cl_device_id device, cl_context context, cl_image_format *format, cl_mem_flags flags );
22 extern int test_get_image_info_1D_array( cl_device_id device, cl_context context, cl_image_format *format, cl_mem_flags flags );
23 extern int test_get_image_info_2D_array( cl_device_id device, cl_context context, cl_image_format *format, cl_mem_flags flags );
24
test_image_type(cl_device_id device,cl_context context,cl_mem_object_type image_type,cl_mem_flags flags)25 int test_image_type( cl_device_id device, cl_context context, cl_mem_object_type image_type, cl_mem_flags flags )
26 {
27 log_info( "Running %s %s-only tests...\n", convert_image_type_to_string(image_type), flags == CL_MEM_READ_ONLY ? "read" : "write" );
28
29 int ret = 0;
30
31 // Grab the list of supported image formats for integer reads
32 std::vector<cl_image_format> formatList;
33 if (get_format_list(context, image_type, formatList, flags)) return -1;
34
35 std::vector<bool> filterFlags(formatList.size(), false);
36 filter_formats(formatList, filterFlags, nullptr);
37
38 // Run the format list
39 for (unsigned int i = 0; i < formatList.size(); i++)
40 {
41 int test_return = 0;
42 if( filterFlags[i] )
43 {
44 log_info( "NOT RUNNING: " );
45 print_header( &formatList[ i ], false );
46 continue;
47 }
48
49 print_header( &formatList[ i ], false );
50
51 gTestCount++;
52
53 switch (image_type) {
54 case CL_MEM_OBJECT_IMAGE1D:
55 test_return = test_get_image_info_1D( device, context, &formatList[ i ], flags );
56 break;
57 case CL_MEM_OBJECT_IMAGE2D:
58 test_return = test_get_image_info_2D( device, context,&formatList[ i ], flags );
59 break;
60 case CL_MEM_OBJECT_IMAGE3D:
61 test_return = test_get_image_info_3D( device, context, &formatList[ i ], flags );
62 break;
63 case CL_MEM_OBJECT_IMAGE1D_ARRAY:
64 test_return = test_get_image_info_1D_array( device, context, &formatList[ i ], flags );
65 break;
66 case CL_MEM_OBJECT_IMAGE2D_ARRAY:
67 test_return = test_get_image_info_2D_array( device, context, &formatList[ i ], flags );
68 break;
69 }
70
71 if (test_return) {
72 gFailCount++;
73 log_error( "FAILED: " );
74 print_header( &formatList[ i ], true );
75 log_info( "\n" );
76 }
77
78 ret += test_return;
79 }
80
81 return ret;
82 }
83
test_image_set(cl_device_id device,cl_context context,cl_mem_object_type image_type)84 int test_image_set( cl_device_id device, cl_context context, cl_mem_object_type image_type )
85 {
86 int ret = 0;
87
88 ret += test_image_type( device, context, image_type, CL_MEM_READ_ONLY );
89 ret += test_image_type( device, context, image_type, CL_MEM_WRITE_ONLY );
90
91 return ret;
92 }
93
94
95
96
97