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