Add eglChooseConfig() tests for EXT_pixel_format_float am: 54c090f981
[platform/upstream/VK-GL-CTS.git] / scripts / egl / str_util.py
1 # -*- coding: utf-8 -*-
2
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
6 #
7 # Copyright 2015 The Android Open Source Project
8 #
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12 #
13 #      http://www.apache.org/licenses/LICENSE-2.0
14 #
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 #
21 #-------------------------------------------------------------------------
22
23 import os
24 import string
25
26 from common import *
27 from khr_util.format import indentLines
28 from khr_util.gen_str_util import addValuePrefix, genStrUtilProtos, genStrUtilImpls
29
30 # Bitfield mapping
31 BITFIELD_GROUPS = [
32         ("APIBits", [
33                 "OPENGL_BIT",
34                 "OPENGL_ES_BIT",
35                 "OPENGL_ES2_BIT",
36                 "OPENGL_ES3_BIT_KHR",
37                 "OPENVG_BIT"
38                 ]),
39         ("SurfaceBits", [
40                 "PBUFFER_BIT",
41                 "PIXMAP_BIT",
42                 "WINDOW_BIT",
43                 "MULTISAMPLE_RESOLVE_BOX_BIT",
44                 "SWAP_BEHAVIOR_PRESERVED_BIT",
45                 "VG_ALPHA_FORMAT_PRE_BIT",
46                 "VG_COLORSPACE_LINEAR_BIT",
47                 "LOCK_SURFACE_BIT_KHR",
48                 "OPTIMAL_FORMAT_BIT_KHR"
49                 ])
50 ]
51
52 # Enum mapping
53 ENUM_GROUPS = [
54         ("Boolean",                     ["TRUE", "FALSE"]),
55         ("BoolDontCare",        ["TRUE", "FALSE", "DONT_CARE"]),
56         ("API",                         ["OPENGL_API", "OPENGL_ES_API", "OPENVG_API"]),
57         ("Error", [
58                 "SUCCESS",
59                 "NOT_INITIALIZED",
60                 "BAD_ACCESS",
61                 "BAD_ALLOC",
62                 "BAD_ATTRIBUTE",
63                 "BAD_CONFIG",
64                 "BAD_CONTEXT",
65                 "BAD_CURRENT_SURFACE",
66                 "BAD_DISPLAY",
67                 "BAD_MATCH",
68                 "BAD_NATIVE_PIXMAP",
69                 "BAD_NATIVE_WINDOW",
70                 "BAD_PARAMETER",
71                 "BAD_SURFACE",
72                 "CONTEXT_LOST"
73                 ]),
74         ("ContextAttrib", [
75                 "CONFIG_ID",
76                 "CONTEXT_CLIENT_TYPE",
77                 "CONTEXT_CLIENT_VERSION",
78                 "RENDER_BUFFER"
79                 ]),
80         ("ConfigAttrib", [
81                 "BUFFER_SIZE",
82                 "RED_SIZE",
83                 "GREEN_SIZE",
84                 "BLUE_SIZE",
85                 "LUMINANCE_SIZE",
86                 "ALPHA_SIZE",
87                 "ALPHA_MASK_SIZE",
88                 "BIND_TO_TEXTURE_RGB",
89                 "BIND_TO_TEXTURE_RGBA",
90                 "COLOR_BUFFER_TYPE",
91                 "CONFIG_CAVEAT",
92                 "CONFIG_ID",
93                 "CONFORMANT",
94                 "DEPTH_SIZE",
95                 "LEVEL",
96                 "MATCH_NATIVE_PIXMAP",
97                 "MAX_SWAP_INTERVAL",
98                 "MIN_SWAP_INTERVAL",
99                 "NATIVE_RENDERABLE",
100                 "NATIVE_VISUAL_TYPE",
101                 "RENDERABLE_TYPE",
102                 "SAMPLE_BUFFERS",
103                 "SAMPLES",
104                 "STENCIL_SIZE",
105                 "SURFACE_TYPE",
106                 "TRANSPARENT_TYPE",
107                 "TRANSPARENT_RED_VALUE",
108                 "TRANSPARENT_GREEN_VALUE",
109                 "TRANSPARENT_BLUE_VALUE",
110                 "COLOR_COMPONENT_TYPE_EXT"
111                 ]),
112         ("SurfaceAttrib", [
113                 "CONFIG_ID",
114                 "WIDTH",
115                 "HEIGHT",
116                 "HORIZONTAL_RESOLUTION",
117                 "VERTICAL_RESOLUTION",
118                 "LARGEST_PBUFFER",
119                 "MIPMAP_TEXTURE",
120                 "MIPMAP_LEVEL",
121                 "MULTISAMPLE_RESOLVE",
122                 "PIXEL_ASPECT_RATIO",
123                 "RENDER_BUFFER",
124                 "SWAP_BEHAVIOR",
125                 "TEXTURE_FORMAT",
126                 "TEXTURE_TARGET",
127                 "ALPHA_FORMAT",
128                 "COLORSPACE"
129                 ]),
130         ("YuvOrder", [
131                 "NONE",
132                 "YUV_ORDER_YUV_EXT",
133                 "YUV_ORDER_YVU_EXT",
134                 "YUV_ORDER_YUYV_EXT",
135                 "YUV_ORDER_UYVY_EXT",
136                 "YUV_ORDER_YVYU_EXT",
137                 "YUV_ORDER_VYUY_EXT",
138                 "YUV_ORDER_AYUV_EXT",
139                 ]),
140         ("YuvPlaneBpp", [
141                 "YUV_PLANE_BPP_0_EXT",
142                 "YUV_PLANE_BPP_8_EXT",
143                 "YUV_PLANE_BPP_10_EXT",
144                 ]),
145         ("ColorComponentType",  ["COLOR_COMPONENT_TYPE_FIXED_EXT", "COLOR_COMPONENT_TYPE_FLOAT_EXT"]),
146         ("SurfaceTarget",               ["READ", "DRAW"]),
147
148         # ConfigAttrib values
149         ("ColorBufferType",             ["RGB_BUFFER", "LUMINANCE_BUFFER"]),
150         ("ConfigCaveat",                ["NONE", "SLOW_CONFIG", "NON_CONFORMANT_CONFIG"]),
151         ("TransparentType",             ["NONE", "TRANSPARENT_RGB"]),
152
153         # SurfaceAttrib values
154         ("MultisampleResolve",  ["MULTISAMPLE_RESOLVE_DEFAULT", "MULTISAMPLE_RESOLVE_BOX"]),
155         ("RenderBuffer",                ["SINGLE_BUFFER", "BACK_BUFFER"]),
156         ("SwapBehavior",                ["BUFFER_DESTROYED", "BUFFER_PRESERVED"]),
157         ("TextureFormat",               ["NO_TEXTURE", "TEXTURE_RGB", "TEXTURE_RGBA"]),
158         ("TextureTarget",               ["NO_TEXTURE", "TEXTURE_2D"]),
159         ("AlphaFormat",                 ["ALPHA_FORMAT_NONPRE", "ALPHA_FORMAT_PRE"]),
160         ("Colorspace",                  ["COLORSPACE_sRGB", "COLORSPACE_LINEAR"])
161 ]
162
163 def gen (iface):
164         enumGroups              = addValuePrefix(ENUM_GROUPS, "EGL_")
165         bitfieldGroups  = addValuePrefix(BITFIELD_GROUPS, "EGL_")
166         prototypeFile   = os.path.join(EGL_DIR, "egluStrUtilPrototypes.inl")
167         implFile                = os.path.join(EGL_DIR, "egluStrUtil.inl")
168
169         writeInlFile(prototypeFile, indentLines(genStrUtilProtos(iface, enumGroups, bitfieldGroups)))
170         writeInlFile(implFile, genStrUtilImpls(iface, enumGroups, bitfieldGroups))