xref: /aosp_15_r20/external/OpenCL-CTS/test_conformance/gl/testBase.h (revision 6467f958c7de8070b317fc65bcb0f6472e388d82)
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 #ifndef _testBase_h
17 #define _testBase_h
18 
19 #include "harness/compat.h"
20 
21 #include <stdio.h>
22 #include <string.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 
26 #if !defined(__APPLE__)
27 #include <CL/cl.h>
28 #include "gl/gl_headers.h"
29 #include <CL/cl_gl.h>
30 #else
31 #include "gl/gl_headers.h"
32 #endif
33 
34 #include "harness/imageHelpers.h"
35 #include "harness/errorHelpers.h"
36 #include "harness/kernelHelpers.h"
37 #include "harness/typeWrappers.h"
38 #include "harness/conversions.h"
39 #include "harness/mt19937.h"
40 
41 #include "gl/helpers.h"
42 
43 extern const char *get_kernel_suffix(cl_image_format *format);
44 extern const char *get_write_conversion(cl_image_format *format,
45                                         ExplicitType type);
46 extern ExplicitType get_read_kernel_type(cl_image_format *format);
47 extern ExplicitType get_write_kernel_type(cl_image_format *format);
48 
49 extern char *convert_to_expected(void *inputBuffer, size_t numPixels,
50                                  ExplicitType inType, ExplicitType outType,
51                                  size_t channelNum, GLenum glDataType = 0);
52 extern int validate_integer_results(void *expectedResults, void *actualResults,
53                                     size_t width, size_t height,
54                                     size_t sampleNum, size_t typeSize);
55 extern int validate_integer_results(void *expectedResults, void *actualResults,
56                                     size_t width, size_t height, size_t depth,
57                                     size_t sampleNum, size_t typeSize);
58 extern int validate_float_results(void *expectedResults, void *actualResults,
59                                   size_t width, size_t height, size_t sampleNum,
60                                   size_t channelNum);
61 extern int validate_float_results(void *expectedResults, void *actualResults,
62                                   size_t width, size_t height, size_t depth,
63                                   size_t sampleNum, size_t channelNum);
64 extern int validate_float_results_rgb_101010(void *expectedResults,
65                                              void *actualResults, size_t width,
66                                              size_t height, size_t sampleNum);
67 extern int validate_float_results_rgb_101010(void *expectedResults,
68                                              void *actualResults, size_t width,
69                                              size_t height, size_t depth,
70                                              size_t sampleNum);
71 
72 extern int CheckGLObjectInfo(cl_mem mem, cl_gl_object_type expected_cl_gl_type,
73                              GLuint expected_gl_name,
74                              GLenum expected_cl_gl_texture_target,
75                              GLint expected_cl_gl_mipmap_level);
76 
77 extern bool CheckGLIntegerExtensionSupport();
78 
79 #endif // _testBase_h
80