xref: /aosp_15_r20/external/OpenCL-CTS/test_conformance/gl/common.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 __COMMON_H__
17 #define __COMMON_H__
18 
19 #include "testBase.h"
20 
21 typedef struct
22 {
23     size_t width;
24     size_t height;
25     size_t depth;
26 } sizevec_t;
27 
28 struct format
29 {
30     GLenum internal;
31     GLenum formattype;
32     GLenum datatype;
33     ExplicitType type;
34 };
35 
36 // These are the typically tested formats.
37 // clang-format off
38 static const format common_formats[] = {
39 #ifdef __APPLE__
40   { GL_RGBA8,        GL_BGRA,             GL_UNSIGNED_INT_8_8_8_8,         kUChar },
41   { GL_RGBA8,        GL_BGRA,             GL_UNSIGNED_INT_8_8_8_8_REV,     kUChar },
42   { GL_RGBA8,        GL_RGBA,             GL_UNSIGNED_INT_8_8_8_8_REV,     kUChar },
43   // { GL_RGB10,        GL_BGRA,             GL_UNSIGNED_INT_2_10_10_10_REV,  kFloat },
44 #endif
45   { GL_RGBA8,        GL_RGBA,             GL_UNSIGNED_BYTE,                kUChar },
46   { GL_RGBA16,       GL_RGBA,             GL_UNSIGNED_SHORT,               kUShort },
47   { GL_RGBA8I_EXT,   GL_RGBA_INTEGER_EXT, GL_BYTE,                         kChar },
48   { GL_RGBA16I_EXT,  GL_RGBA_INTEGER_EXT, GL_SHORT,                        kShort },
49   { GL_RGBA32I_EXT,  GL_RGBA_INTEGER_EXT, GL_INT,                          kInt },
50   { GL_RGBA8UI_EXT,  GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE,                kUChar },
51   { GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT,               kUShort },
52   { GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT,                 kUInt },
53   { GL_RGBA32F_ARB,  GL_RGBA,             GL_FLOAT,                        kFloat },
54   { GL_RGBA16F_ARB,  GL_RGBA,             GL_HALF_FLOAT,                   kHalf }
55 };
56 
57 #ifdef GL_VERSION_3_2
58 static const format depth_formats[] = {
59   { GL_DEPTH_COMPONENT16,  GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT,                 kUShort },
60   { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT,                          kFloat },
61   { GL_DEPTH24_STENCIL8,   GL_DEPTH_STENCIL,   GL_UNSIGNED_INT_24_8,              kUInt },
62   { GL_DEPTH32F_STENCIL8,  GL_DEPTH_STENCIL,   GL_FLOAT_32_UNSIGNED_INT_24_8_REV, kFloat },
63 };
64 #endif
65 // clang-format on
66 
67 int test_images_write_common(cl_device_id device, cl_context context,
68                              cl_command_queue queue, const format *formats,
69                              size_t nformats, GLenum *targets, size_t ntargets,
70                              sizevec_t *sizes, size_t nsizes);
71 
72 int test_images_read_common(cl_device_id device, cl_context context,
73                             cl_command_queue queue, const format *formats,
74                             size_t nformats, GLenum *targets, size_t ntargets,
75                             sizevec_t *sizes, size_t nsizes);
76 
77 int test_images_get_info_common(cl_device_id device, cl_context context,
78                                 cl_command_queue queue, const format *formats,
79                                 size_t nformats, GLenum *targets,
80                                 size_t ntargets, sizevec_t *sizes,
81                                 size_t nsizes);
82 
83 int is_rgb_101010_supported(cl_context context, GLenum gl_target);
84 
85 #endif // __COMMON_H__
86