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_read_image_set_1D(cl_device_id device, cl_context context,
20 cl_command_queue queue,
21 cl_image_format *format, cl_mem_flags flags);
22 extern int test_read_image_set_2D(cl_device_id device, cl_context context,
23 cl_command_queue queue,
24 cl_image_format *format, cl_mem_flags flags);
25 extern int test_read_image_set_3D(cl_device_id device, cl_context context,
26 cl_command_queue queue,
27 cl_image_format *format, cl_mem_flags flags);
28 extern int test_read_image_set_1D_array(cl_device_id device, cl_context context,
29 cl_command_queue queue,
30 cl_image_format *format,
31 cl_mem_flags flags);
32 extern int test_read_image_set_2D_array(cl_device_id device, cl_context context,
33 cl_command_queue queue,
34 cl_image_format *format,
35 cl_mem_flags flags);
36
test_image_type(cl_device_id device,cl_context context,cl_command_queue queue,cl_mem_object_type imageType,cl_mem_flags flags)37 int test_image_type( cl_device_id device, cl_context context, cl_command_queue queue, cl_mem_object_type imageType, cl_mem_flags flags )
38 {
39 log_info( "Running %s %s %s-only tests...\n", gTestMipmaps?"mipmapped":"",convert_image_type_to_string(imageType), flags == CL_MEM_READ_ONLY ? "read" : "write" );
40
41 int ret = 0;
42
43 if (gTestMipmaps)
44 {
45 if (0 == is_extension_available(device, "cl_khr_mipmap_image"))
46 {
47 log_info("-----------------------------------------------------\n");
48 log_info("This device does not support "
49 "cl_khr_mipmap_image.\nSkipping mipmapped image test. \n");
50 log_info(
51 "-----------------------------------------------------\n\n");
52 return 0;
53 }
54 }
55
56 // Grab the list of supported image formats for integer reads
57 std::vector<cl_image_format> formatList;
58 if (get_format_list(context, imageType, formatList, flags)) return -1;
59
60 std::vector<bool> filterFlags(formatList.size(), false);
61 filter_formats(formatList, filterFlags, nullptr);
62
63 // Run the format list
64 for (unsigned int i = 0; i < formatList.size(); i++)
65 {
66 int test_return = 0;
67 if (filterFlags[i])
68 {
69 log_info("NOT RUNNING: ");
70 print_header(&formatList[i], false);
71 continue;
72 }
73
74 print_header(&formatList[i], false);
75
76 gTestCount++;
77
78 switch (imageType)
79 {
80 case CL_MEM_OBJECT_IMAGE1D:
81 test_return = test_read_image_set_1D(device, context, queue,
82 &formatList[i], flags);
83 break;
84 case CL_MEM_OBJECT_IMAGE2D:
85 test_return = test_read_image_set_2D(device, context, queue,
86 &formatList[i], flags);
87 break;
88 case CL_MEM_OBJECT_IMAGE3D:
89 test_return = test_read_image_set_3D(device, context, queue,
90 &formatList[i], flags);
91 break;
92 case CL_MEM_OBJECT_IMAGE1D_ARRAY:
93 test_return = test_read_image_set_1D_array(
94 device, context, queue, &formatList[i], flags);
95 break;
96 case CL_MEM_OBJECT_IMAGE2D_ARRAY:
97 test_return = test_read_image_set_2D_array(
98 device, context, queue, &formatList[i], flags);
99 break;
100 }
101
102 if (test_return)
103 {
104 gFailCount++;
105 log_error("FAILED: ");
106 print_header(&formatList[i], true);
107 log_info("\n");
108 }
109
110 ret += test_return;
111 }
112
113 return ret;
114 }
115
test_image_set(cl_device_id device,cl_context context,cl_command_queue queue,cl_mem_object_type imageType)116 int test_image_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_mem_object_type imageType )
117 {
118 int ret = 0;
119
120 ret += test_image_type( device, context, queue, imageType, CL_MEM_READ_ONLY );
121 ret += test_image_type( device, context, queue, imageType, CL_MEM_WRITE_ONLY );
122
123 return ret;
124 }
125
126
127
128
129