• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 extern int test_get_image_info_1D(cl_device_id device, cl_context context,
21                                   cl_command_queue queue,
22                                   cl_image_format *format, cl_mem_flags flags);
23 extern int test_get_image_info_2D(cl_device_id device, cl_context context,
24                                   cl_command_queue queue,
25                                   cl_image_format *format, cl_mem_flags flags);
26 extern int test_get_image_info_3D(cl_device_id device, cl_context context,
27                                   cl_command_queue queue,
28                                   cl_image_format *format, cl_mem_flags flags);
29 extern int test_get_image_info_1D_array(cl_device_id device, cl_context context,
30                                         cl_command_queue queue,
31                                         cl_image_format *format,
32                                         cl_mem_flags flags);
33 extern int test_get_image_info_2D_array(cl_device_id device, cl_context context,
34                                         cl_command_queue queue,
35                                         cl_image_format *format,
36                                         cl_mem_flags flags);
37 
test_image_type(cl_device_id device,cl_context context,cl_command_queue queue,cl_mem_object_type imageType,cl_mem_flags flags)38 int test_image_type( cl_device_id device, cl_context context, cl_command_queue queue, cl_mem_object_type imageType, cl_mem_flags flags )
39 {
40     log_info( "Running %s %s-only tests...\n", convert_image_type_to_string(imageType), flags == CL_MEM_READ_ONLY ? "read" : "write" );
41 
42     int ret = 0;
43 
44     // Grab the list of supported image formats for integer reads
45     std::vector<cl_image_format> formatList;
46     if (get_format_list(context, imageType, formatList, flags)) return -1;
47 
48     std::vector<bool> filterFlags(formatList.size(), false);
49     filter_formats(formatList, filterFlags, nullptr);
50 
51     // Run the format list
52     for (unsigned int i = 0; i < formatList.size(); i++)
53     {
54         int test_return = 0;
55         if( filterFlags[i] )
56         {
57             log_info( "NOT RUNNING: " );
58             print_header( &formatList[ i ], false );
59             continue;
60         }
61 
62         print_header( &formatList[ i ], false );
63 
64         gTestCount++;
65 
66         switch (imageType) {
67             case CL_MEM_OBJECT_IMAGE1D:
68                 test_return = test_get_image_info_1D(device, context, queue,
69                                                      &formatList[i], flags);
70                 break;
71             case CL_MEM_OBJECT_IMAGE2D:
72                 test_return = test_get_image_info_2D(device, context, queue,
73                                                      &formatList[i], flags);
74                 break;
75             case CL_MEM_OBJECT_IMAGE3D:
76                 test_return = test_get_image_info_3D(device, context, queue,
77                                                      &formatList[i], flags);
78                 break;
79             case CL_MEM_OBJECT_IMAGE1D_ARRAY:
80                 test_return = test_get_image_info_1D_array(
81                     device, context, queue, &formatList[i], flags);
82                 break;
83             case CL_MEM_OBJECT_IMAGE2D_ARRAY:
84                 test_return = test_get_image_info_2D_array(
85                     device, context, queue, &formatList[i], flags);
86                 break;
87         }
88 
89         if (test_return) {
90             gFailCount++;
91             log_error( "FAILED: " );
92             print_header( &formatList[ i ], true );
93             log_info( "\n" );
94         }
95 
96         ret += test_return;
97     }
98 
99     return ret;
100 }
101 
test_image_set(cl_device_id device,cl_context context,cl_command_queue queue,cl_mem_object_type imageType)102 int test_image_set( cl_device_id device, cl_context context, cl_command_queue queue, cl_mem_object_type imageType )
103 {
104     int version_check;
105     auto version = get_device_cl_version(device);
106 
107     if ((version_check = (version < Version(1, 2))))
108     {
109         switch (imageType) {
110             case CL_MEM_OBJECT_IMAGE1D:
111             test_missing_feature(version_check, "image_1D");
112             case CL_MEM_OBJECT_IMAGE1D_ARRAY:
113             test_missing_feature(version_check, "image_1D_array");
114             case CL_MEM_OBJECT_IMAGE2D_ARRAY:
115             test_missing_feature(version_check, "image_2D_array");
116     }
117     }
118 
119   int ret = 0;
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