xref: /aosp_15_r20/external/OpenCL-CTS/test_conformance/gl/common.h (revision 6467f958c7de8070b317fc65bcb0f6472e388d82)
1*6467f958SSadaf Ebrahimi //
2*6467f958SSadaf Ebrahimi // Copyright (c) 2017 The Khronos Group Inc.
3*6467f958SSadaf Ebrahimi //
4*6467f958SSadaf Ebrahimi // Licensed under the Apache License, Version 2.0 (the "License");
5*6467f958SSadaf Ebrahimi // you may not use this file except in compliance with the License.
6*6467f958SSadaf Ebrahimi // You may obtain a copy of the License at
7*6467f958SSadaf Ebrahimi //
8*6467f958SSadaf Ebrahimi //    http://www.apache.org/licenses/LICENSE-2.0
9*6467f958SSadaf Ebrahimi //
10*6467f958SSadaf Ebrahimi // Unless required by applicable law or agreed to in writing, software
11*6467f958SSadaf Ebrahimi // distributed under the License is distributed on an "AS IS" BASIS,
12*6467f958SSadaf Ebrahimi // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*6467f958SSadaf Ebrahimi // See the License for the specific language governing permissions and
14*6467f958SSadaf Ebrahimi // limitations under the License.
15*6467f958SSadaf Ebrahimi //
16*6467f958SSadaf Ebrahimi #ifndef __COMMON_H__
17*6467f958SSadaf Ebrahimi #define __COMMON_H__
18*6467f958SSadaf Ebrahimi 
19*6467f958SSadaf Ebrahimi #include "testBase.h"
20*6467f958SSadaf Ebrahimi 
21*6467f958SSadaf Ebrahimi typedef struct
22*6467f958SSadaf Ebrahimi {
23*6467f958SSadaf Ebrahimi     size_t width;
24*6467f958SSadaf Ebrahimi     size_t height;
25*6467f958SSadaf Ebrahimi     size_t depth;
26*6467f958SSadaf Ebrahimi } sizevec_t;
27*6467f958SSadaf Ebrahimi 
28*6467f958SSadaf Ebrahimi struct format
29*6467f958SSadaf Ebrahimi {
30*6467f958SSadaf Ebrahimi     GLenum internal;
31*6467f958SSadaf Ebrahimi     GLenum formattype;
32*6467f958SSadaf Ebrahimi     GLenum datatype;
33*6467f958SSadaf Ebrahimi     ExplicitType type;
34*6467f958SSadaf Ebrahimi };
35*6467f958SSadaf Ebrahimi 
36*6467f958SSadaf Ebrahimi // These are the typically tested formats.
37*6467f958SSadaf Ebrahimi // clang-format off
38*6467f958SSadaf Ebrahimi static const format common_formats[] = {
39*6467f958SSadaf Ebrahimi #ifdef __APPLE__
40*6467f958SSadaf Ebrahimi   { GL_RGBA8,        GL_BGRA,             GL_UNSIGNED_INT_8_8_8_8,         kUChar },
41*6467f958SSadaf Ebrahimi   { GL_RGBA8,        GL_BGRA,             GL_UNSIGNED_INT_8_8_8_8_REV,     kUChar },
42*6467f958SSadaf Ebrahimi   { GL_RGBA8,        GL_RGBA,             GL_UNSIGNED_INT_8_8_8_8_REV,     kUChar },
43*6467f958SSadaf Ebrahimi   // { GL_RGB10,        GL_BGRA,             GL_UNSIGNED_INT_2_10_10_10_REV,  kFloat },
44*6467f958SSadaf Ebrahimi #endif
45*6467f958SSadaf Ebrahimi   { GL_RGBA8,        GL_RGBA,             GL_UNSIGNED_BYTE,                kUChar },
46*6467f958SSadaf Ebrahimi   { GL_RGBA16,       GL_RGBA,             GL_UNSIGNED_SHORT,               kUShort },
47*6467f958SSadaf Ebrahimi   { GL_RGBA8I_EXT,   GL_RGBA_INTEGER_EXT, GL_BYTE,                         kChar },
48*6467f958SSadaf Ebrahimi   { GL_RGBA16I_EXT,  GL_RGBA_INTEGER_EXT, GL_SHORT,                        kShort },
49*6467f958SSadaf Ebrahimi   { GL_RGBA32I_EXT,  GL_RGBA_INTEGER_EXT, GL_INT,                          kInt },
50*6467f958SSadaf Ebrahimi   { GL_RGBA8UI_EXT,  GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE,                kUChar },
51*6467f958SSadaf Ebrahimi   { GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT,               kUShort },
52*6467f958SSadaf Ebrahimi   { GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT,                 kUInt },
53*6467f958SSadaf Ebrahimi   { GL_RGBA32F_ARB,  GL_RGBA,             GL_FLOAT,                        kFloat },
54*6467f958SSadaf Ebrahimi   { GL_RGBA16F_ARB,  GL_RGBA,             GL_HALF_FLOAT,                   kHalf }
55*6467f958SSadaf Ebrahimi };
56*6467f958SSadaf Ebrahimi 
57*6467f958SSadaf Ebrahimi #ifdef GL_VERSION_3_2
58*6467f958SSadaf Ebrahimi static const format depth_formats[] = {
59*6467f958SSadaf Ebrahimi   { GL_DEPTH_COMPONENT16,  GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT,                 kUShort },
60*6467f958SSadaf Ebrahimi   { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT,                          kFloat },
61*6467f958SSadaf Ebrahimi   { GL_DEPTH24_STENCIL8,   GL_DEPTH_STENCIL,   GL_UNSIGNED_INT_24_8,              kUInt },
62*6467f958SSadaf Ebrahimi   { GL_DEPTH32F_STENCIL8,  GL_DEPTH_STENCIL,   GL_FLOAT_32_UNSIGNED_INT_24_8_REV, kFloat },
63*6467f958SSadaf Ebrahimi };
64*6467f958SSadaf Ebrahimi #endif
65*6467f958SSadaf Ebrahimi // clang-format on
66*6467f958SSadaf Ebrahimi 
67*6467f958SSadaf Ebrahimi int test_images_write_common(cl_device_id device, cl_context context,
68*6467f958SSadaf Ebrahimi                              cl_command_queue queue, const format *formats,
69*6467f958SSadaf Ebrahimi                              size_t nformats, GLenum *targets, size_t ntargets,
70*6467f958SSadaf Ebrahimi                              sizevec_t *sizes, size_t nsizes);
71*6467f958SSadaf Ebrahimi 
72*6467f958SSadaf Ebrahimi int test_images_read_common(cl_device_id device, cl_context context,
73*6467f958SSadaf Ebrahimi                             cl_command_queue queue, const format *formats,
74*6467f958SSadaf Ebrahimi                             size_t nformats, GLenum *targets, size_t ntargets,
75*6467f958SSadaf Ebrahimi                             sizevec_t *sizes, size_t nsizes);
76*6467f958SSadaf Ebrahimi 
77*6467f958SSadaf Ebrahimi int test_images_get_info_common(cl_device_id device, cl_context context,
78*6467f958SSadaf Ebrahimi                                 cl_command_queue queue, const format *formats,
79*6467f958SSadaf Ebrahimi                                 size_t nformats, GLenum *targets,
80*6467f958SSadaf Ebrahimi                                 size_t ntargets, sizevec_t *sizes,
81*6467f958SSadaf Ebrahimi                                 size_t nsizes);
82*6467f958SSadaf Ebrahimi 
83*6467f958SSadaf Ebrahimi int is_rgb_101010_supported(cl_context context, GLenum gl_target);
84*6467f958SSadaf Ebrahimi 
85*6467f958SSadaf Ebrahimi #endif // __COMMON_H__
86