1*38e8c45fSAndroid Build Coastguard Worker#!/usr/bin/env python 2*38e8c45fSAndroid Build Coastguard Worker# 3*38e8c45fSAndroid Build Coastguard Worker# Copyright 2014 The Android Open Source Project 4*38e8c45fSAndroid Build Coastguard Worker# 5*38e8c45fSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 6*38e8c45fSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 7*38e8c45fSAndroid Build Coastguard Worker# You may obtain a copy of the License at 8*38e8c45fSAndroid Build Coastguard Worker# 9*38e8c45fSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 10*38e8c45fSAndroid Build Coastguard Worker# 11*38e8c45fSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 12*38e8c45fSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 13*38e8c45fSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*38e8c45fSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 15*38e8c45fSAndroid Build Coastguard Worker# limitations under the License. 16*38e8c45fSAndroid Build Coastguard Worker 17*38e8c45fSAndroid Build Coastguard Workerfrom __future__ import print_function 18*38e8c45fSAndroid Build Coastguard Workerfrom operator import itemgetter 19*38e8c45fSAndroid Build Coastguard Workerimport collections 20*38e8c45fSAndroid Build Coastguard Workerimport os.path 21*38e8c45fSAndroid Build Coastguard Workerimport re 22*38e8c45fSAndroid Build Coastguard Workerimport sys 23*38e8c45fSAndroid Build Coastguard Worker 24*38e8c45fSAndroid Build Coastguard Worker 25*38e8c45fSAndroid Build Coastguard Worker# Avoid endlessly adding to the path if this module is imported multiple 26*38e8c45fSAndroid Build Coastguard Worker# times, e.g. in an interactive session 27*38e8c45fSAndroid Build Coastguard Workerregpath = os.path.join(sys.path[0], "registry") 28*38e8c45fSAndroid Build Coastguard Workerif sys.path[1] != regpath: 29*38e8c45fSAndroid Build Coastguard Worker sys.path.insert(1, regpath) 30*38e8c45fSAndroid Build Coastguard Workerimport reg 31*38e8c45fSAndroid Build Coastguard Worker 32*38e8c45fSAndroid Build Coastguard Worker 33*38e8c45fSAndroid Build Coastguard WorkerAEP_EXTENSIONS = [ 34*38e8c45fSAndroid Build Coastguard Worker 'GL_KHR_blend_equation_advanced', 35*38e8c45fSAndroid Build Coastguard Worker 'GL_KHR_debug', 36*38e8c45fSAndroid Build Coastguard Worker 'GL_KHR_texture_compression_astc_ldr', 37*38e8c45fSAndroid Build Coastguard Worker 'GL_OES_sample_shading', 38*38e8c45fSAndroid Build Coastguard Worker 'GL_OES_sample_variables', 39*38e8c45fSAndroid Build Coastguard Worker 'GL_OES_shader_image_atomic', 40*38e8c45fSAndroid Build Coastguard Worker 'GL_OES_shader_multisample_interpolation', 41*38e8c45fSAndroid Build Coastguard Worker 'GL_OES_texture_stencil8', 42*38e8c45fSAndroid Build Coastguard Worker 'GL_OES_texture_storage_multisample_2d_array', 43*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_copy_image', 44*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_draw_buffers_indexed', 45*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_geometry_shader', 46*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_gpu_shader5', 47*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_primitive_bounding_box', 48*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_shader_io_blocks', 49*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_tessellation_shader', 50*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_texture_border_clamp', 51*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_texture_buffer', 52*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_texture_cube_map_array', 53*38e8c45fSAndroid Build Coastguard Worker 'GL_EXT_texture_sRGB_decode'] 54*38e8c45fSAndroid Build Coastguard Worker 55*38e8c45fSAndroid Build Coastguard Worker 56*38e8c45fSAndroid Build Coastguard Workerdef nonestr(s): 57*38e8c45fSAndroid Build Coastguard Worker return s if s else "" 58*38e8c45fSAndroid Build Coastguard Worker 59*38e8c45fSAndroid Build Coastguard Workerdef parseProto(elem): 60*38e8c45fSAndroid Build Coastguard Worker type = nonestr(elem.text) 61*38e8c45fSAndroid Build Coastguard Worker name = None 62*38e8c45fSAndroid Build Coastguard Worker for subelem in elem: 63*38e8c45fSAndroid Build Coastguard Worker text = nonestr(subelem.text) 64*38e8c45fSAndroid Build Coastguard Worker if subelem.tag == 'name': 65*38e8c45fSAndroid Build Coastguard Worker name = text 66*38e8c45fSAndroid Build Coastguard Worker else: 67*38e8c45fSAndroid Build Coastguard Worker type += text 68*38e8c45fSAndroid Build Coastguard Worker type += nonestr(subelem.tail) 69*38e8c45fSAndroid Build Coastguard Worker return (type.strip(), name) 70*38e8c45fSAndroid Build Coastguard Worker 71*38e8c45fSAndroid Build Coastguard Workerdef parseParam(elem): 72*38e8c45fSAndroid Build Coastguard Worker name = elem.find('name').text 73*38e8c45fSAndroid Build Coastguard Worker declaration = ''.join(elem.itertext()) 74*38e8c45fSAndroid Build Coastguard Worker return (name, declaration) 75*38e8c45fSAndroid Build Coastguard Worker 76*38e8c45fSAndroid Build Coastguard Worker# Format a list of (type, declaration) tuples as a C-style parameter list 77*38e8c45fSAndroid Build Coastguard Workerdef fmtParams(params): 78*38e8c45fSAndroid Build Coastguard Worker if not params: 79*38e8c45fSAndroid Build Coastguard Worker return 'void' 80*38e8c45fSAndroid Build Coastguard Worker return ', '.join(p[1] for p in params) 81*38e8c45fSAndroid Build Coastguard Worker 82*38e8c45fSAndroid Build Coastguard Worker# Format a list of (type, declaration) tuples as a C-style argument list 83*38e8c45fSAndroid Build Coastguard Workerdef fmtArgs(params): 84*38e8c45fSAndroid Build Coastguard Worker return ', '.join(p[0] for p in params) 85*38e8c45fSAndroid Build Coastguard Worker 86*38e8c45fSAndroid Build Coastguard Workerdef overrideSymbolName(sym, apiname): 87*38e8c45fSAndroid Build Coastguard Worker # The wrapper intercepts various glGet and glGetString functions and 88*38e8c45fSAndroid Build Coastguard Worker # (sometimes) calls the generated thunk which dispatches to the 89*38e8c45fSAndroid Build Coastguard Worker # driver's implementation 90*38e8c45fSAndroid Build Coastguard Worker wrapped_get_syms = { 91*38e8c45fSAndroid Build Coastguard Worker 'gles1' : [ 92*38e8c45fSAndroid Build Coastguard Worker 'glGetString' 93*38e8c45fSAndroid Build Coastguard Worker ], 94*38e8c45fSAndroid Build Coastguard Worker 'gles2' : [ 95*38e8c45fSAndroid Build Coastguard Worker 'glGetString', 96*38e8c45fSAndroid Build Coastguard Worker 'glGetStringi', 97*38e8c45fSAndroid Build Coastguard Worker 'glGetBooleanv', 98*38e8c45fSAndroid Build Coastguard Worker 'glGetFloatv', 99*38e8c45fSAndroid Build Coastguard Worker 'glGetIntegerv', 100*38e8c45fSAndroid Build Coastguard Worker 'glGetInteger64v', 101*38e8c45fSAndroid Build Coastguard Worker ], 102*38e8c45fSAndroid Build Coastguard Worker } 103*38e8c45fSAndroid Build Coastguard Worker if sym in wrapped_get_syms.get(apiname): 104*38e8c45fSAndroid Build Coastguard Worker return '__' + sym 105*38e8c45fSAndroid Build Coastguard Worker else: 106*38e8c45fSAndroid Build Coastguard Worker return sym 107*38e8c45fSAndroid Build Coastguard Worker 108*38e8c45fSAndroid Build Coastguard Worker 109*38e8c45fSAndroid Build Coastguard Worker# Generate API trampoline templates: 110*38e8c45fSAndroid Build Coastguard Worker# <rtype> API_ENTRY(<name>)(<params>) { 111*38e8c45fSAndroid Build Coastguard Worker# CALL_GL_API(<name>, <args>); 112*38e8c45fSAndroid Build Coastguard Worker# // or 113*38e8c45fSAndroid Build Coastguard Worker# CALL_GL_API_RETURN(<name>, <args>); 114*38e8c45fSAndroid Build Coastguard Worker# } 115*38e8c45fSAndroid Build Coastguard Workerclass TrampolineGen(reg.OutputGenerator): 116*38e8c45fSAndroid Build Coastguard Worker def __init__(self): 117*38e8c45fSAndroid Build Coastguard Worker reg.OutputGenerator.__init__(self, sys.stderr, sys.stderr, None) 118*38e8c45fSAndroid Build Coastguard Worker 119*38e8c45fSAndroid Build Coastguard Worker def genCmd(self, cmd, name): 120*38e8c45fSAndroid Build Coastguard Worker if re.search('Win32', name): 121*38e8c45fSAndroid Build Coastguard Worker return 122*38e8c45fSAndroid Build Coastguard Worker reg.OutputGenerator.genCmd(self, cmd, name) 123*38e8c45fSAndroid Build Coastguard Worker 124*38e8c45fSAndroid Build Coastguard Worker rtype, fname = parseProto(cmd.elem.find('proto')) 125*38e8c45fSAndroid Build Coastguard Worker params = [parseParam(p) for p in cmd.elem.findall('param')] 126*38e8c45fSAndroid Build Coastguard Worker call = 'CALL_GL_API' if rtype == 'void' else 'CALL_GL_API_RETURN' 127*38e8c45fSAndroid Build Coastguard Worker print('%s API_ENTRY(%s)(%s) {\n' 128*38e8c45fSAndroid Build Coastguard Worker ' %s(%s%s%s);\n' 129*38e8c45fSAndroid Build Coastguard Worker '}' 130*38e8c45fSAndroid Build Coastguard Worker % (rtype, overrideSymbolName(fname, self.genOpts.apiname), 131*38e8c45fSAndroid Build Coastguard Worker fmtParams(params), call, fname, 132*38e8c45fSAndroid Build Coastguard Worker ', ' if len(params) > 0 else '', 133*38e8c45fSAndroid Build Coastguard Worker fmtArgs(params)), 134*38e8c45fSAndroid Build Coastguard Worker file=self.outFile) 135*38e8c45fSAndroid Build Coastguard Worker 136*38e8c45fSAndroid Build Coastguard Worker 137*38e8c45fSAndroid Build Coastguard Worker 138*38e8c45fSAndroid Build Coastguard Worker# Collect all API prototypes across all families, remove duplicates, 139*38e8c45fSAndroid Build Coastguard Worker# emit to entries.in and enums.in files. 140*38e8c45fSAndroid Build Coastguard Workerclass ApiGenerator(reg.OutputGenerator): 141*38e8c45fSAndroid Build Coastguard Worker def __init__(self): 142*38e8c45fSAndroid Build Coastguard Worker reg.OutputGenerator.__init__(self, sys.stderr, sys.stderr, None) 143*38e8c45fSAndroid Build Coastguard Worker self.cmds = [] 144*38e8c45fSAndroid Build Coastguard Worker self.enums = collections.OrderedDict() 145*38e8c45fSAndroid Build Coastguard Worker 146*38e8c45fSAndroid Build Coastguard Worker def genCmd(self, cmd, name): 147*38e8c45fSAndroid Build Coastguard Worker if re.search('Win32', name): 148*38e8c45fSAndroid Build Coastguard Worker return 149*38e8c45fSAndroid Build Coastguard Worker reg.OutputGenerator.genCmd(self, cmd, name) 150*38e8c45fSAndroid Build Coastguard Worker rtype, fname = parseProto(cmd.elem.find('proto')) 151*38e8c45fSAndroid Build Coastguard Worker params = [parseParam(p) for p in cmd.elem.findall('param')] 152*38e8c45fSAndroid Build Coastguard Worker self.cmds.append({'rtype': rtype, 'name': fname, 'params': params}) 153*38e8c45fSAndroid Build Coastguard Worker 154*38e8c45fSAndroid Build Coastguard Worker def genEnum(self, enuminfo, name): 155*38e8c45fSAndroid Build Coastguard Worker reg.OutputGenerator.genEnum(self, enuminfo, name) 156*38e8c45fSAndroid Build Coastguard Worker value = enuminfo.elem.get('value') 157*38e8c45fSAndroid Build Coastguard Worker 158*38e8c45fSAndroid Build Coastguard Worker # Skip bitmask enums. Pattern matches: 159*38e8c45fSAndroid Build Coastguard Worker # - GL_DEPTH_BUFFER_BIT 160*38e8c45fSAndroid Build Coastguard Worker # - GL_MAP_INVALIDATE_BUFFER_BIT_EXT 161*38e8c45fSAndroid Build Coastguard Worker # - GL_COLOR_BUFFER_BIT1_QCOM 162*38e8c45fSAndroid Build Coastguard Worker # but not 163*38e8c45fSAndroid Build Coastguard Worker # - GL_DEPTH_BITS 164*38e8c45fSAndroid Build Coastguard Worker # - GL_QUERY_COUNTER_BITS_EXT 165*38e8c45fSAndroid Build Coastguard Worker # 166*38e8c45fSAndroid Build Coastguard Worker # TODO: Assuming a naming pattern and using a regex is what the 167*38e8c45fSAndroid Build Coastguard Worker # old glenumsgen script did. But the registry XML knows which enums are 168*38e8c45fSAndroid Build Coastguard Worker # parts of bitmask groups, so we should just use that. I'm not sure how 169*38e8c45fSAndroid Build Coastguard Worker # to get the information out though, and it's not critical right now, 170*38e8c45fSAndroid Build Coastguard Worker # so leaving for later. 171*38e8c45fSAndroid Build Coastguard Worker if re.search('_BIT($|\d*_)', name): 172*38e8c45fSAndroid Build Coastguard Worker return 173*38e8c45fSAndroid Build Coastguard Worker if re.search('D3D|WIN32', name): 174*38e8c45fSAndroid Build Coastguard Worker return 175*38e8c45fSAndroid Build Coastguard Worker 176*38e8c45fSAndroid Build Coastguard Worker # Skip non-hex values (GL_TRUE, GL_FALSE, header guard junk) 177*38e8c45fSAndroid Build Coastguard Worker if not re.search('0x[0-9A-Fa-f]+', value): 178*38e8c45fSAndroid Build Coastguard Worker return 179*38e8c45fSAndroid Build Coastguard Worker 180*38e8c45fSAndroid Build Coastguard Worker # Append 'u' or 'ull' type suffix if present 181*38e8c45fSAndroid Build Coastguard Worker type = enuminfo.elem.get('type') 182*38e8c45fSAndroid Build Coastguard Worker if type and type != 'i': 183*38e8c45fSAndroid Build Coastguard Worker value += type 184*38e8c45fSAndroid Build Coastguard Worker 185*38e8c45fSAndroid Build Coastguard Worker if value not in self.enums: 186*38e8c45fSAndroid Build Coastguard Worker self.enums[value] = name 187*38e8c45fSAndroid Build Coastguard Worker 188*38e8c45fSAndroid Build Coastguard Worker def finish(self): 189*38e8c45fSAndroid Build Coastguard Worker # sort by function name, remove duplicates 190*38e8c45fSAndroid Build Coastguard Worker self.cmds.sort(key=itemgetter('name')) 191*38e8c45fSAndroid Build Coastguard Worker cmds = [] 192*38e8c45fSAndroid Build Coastguard Worker for cmd in self.cmds: 193*38e8c45fSAndroid Build Coastguard Worker if len(cmds) == 0 or cmd != cmds[-1]: 194*38e8c45fSAndroid Build Coastguard Worker cmds.append(cmd) 195*38e8c45fSAndroid Build Coastguard Worker self.cmds = cmds 196*38e8c45fSAndroid Build Coastguard Worker 197*38e8c45fSAndroid Build Coastguard Worker # Write entries.in 198*38e8c45fSAndroid Build Coastguard Worker def writeEntries(self, outfile): 199*38e8c45fSAndroid Build Coastguard Worker for cmd in self.cmds: 200*38e8c45fSAndroid Build Coastguard Worker print('GL_ENTRY(%s, %s, %s)' 201*38e8c45fSAndroid Build Coastguard Worker % (cmd['rtype'], cmd['name'], fmtParams(cmd['params'])), 202*38e8c45fSAndroid Build Coastguard Worker file=outfile) 203*38e8c45fSAndroid Build Coastguard Worker 204*38e8c45fSAndroid Build Coastguard Worker # Write enums.in 205*38e8c45fSAndroid Build Coastguard Worker def writeEnums(self, outfile): 206*38e8c45fSAndroid Build Coastguard Worker for enum in self.enums.iteritems(): 207*38e8c45fSAndroid Build Coastguard Worker print('GL_ENUM(%s,%s)' % (enum[0], enum[1]), file=outfile) 208*38e8c45fSAndroid Build Coastguard Worker 209*38e8c45fSAndroid Build Coastguard Worker 210*38e8c45fSAndroid Build Coastguard Worker# Generate .spec entries for use by legacy 'gen' script 211*38e8c45fSAndroid Build Coastguard Workerclass SpecGenerator(reg.OutputGenerator): 212*38e8c45fSAndroid Build Coastguard Worker def __init__(self): 213*38e8c45fSAndroid Build Coastguard Worker reg.OutputGenerator.__init__(self, sys.stderr, sys.stderr, None) 214*38e8c45fSAndroid Build Coastguard Worker 215*38e8c45fSAndroid Build Coastguard Worker def genCmd(self, cmd, name): 216*38e8c45fSAndroid Build Coastguard Worker reg.OutputGenerator.genCmd(self, cmd, name) 217*38e8c45fSAndroid Build Coastguard Worker rtype, fname = parseProto(cmd.elem.find('proto')) 218*38e8c45fSAndroid Build Coastguard Worker params = [parseParam(p) for p in cmd.elem.findall('param')] 219*38e8c45fSAndroid Build Coastguard Worker 220*38e8c45fSAndroid Build Coastguard Worker print('%s %s ( %s )' % (rtype, fname, fmtParams(params)), 221*38e8c45fSAndroid Build Coastguard Worker file=self.outFile) 222*38e8c45fSAndroid Build Coastguard Worker 223*38e8c45fSAndroid Build Coastguard Worker 224*38e8c45fSAndroid Build Coastguard Workerif __name__ == '__main__': 225*38e8c45fSAndroid Build Coastguard Worker registry = reg.Registry() 226*38e8c45fSAndroid Build Coastguard Worker registry.loadFile('registry/gl.xml') 227*38e8c45fSAndroid Build Coastguard Worker 228*38e8c45fSAndroid Build Coastguard Worker registry.setGenerator(TrampolineGen()) 229*38e8c45fSAndroid Build Coastguard Worker TRAMPOLINE_OPTIONS = [ 230*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 231*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles1', 232*38e8c45fSAndroid Build Coastguard Worker profile = 'common', 233*38e8c45fSAndroid Build Coastguard Worker filename = '../../libs/GLES_CM/gl_api.in'), 234*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 235*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles1', 236*38e8c45fSAndroid Build Coastguard Worker profile = 'common', 237*38e8c45fSAndroid Build Coastguard Worker emitversions = None, 238*38e8c45fSAndroid Build Coastguard Worker defaultExtensions = 'gles1', 239*38e8c45fSAndroid Build Coastguard Worker filename = '../../libs/GLES_CM/glext_api.in'), 240*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 241*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles2', 242*38e8c45fSAndroid Build Coastguard Worker profile = 'common', 243*38e8c45fSAndroid Build Coastguard Worker filename = '../../libs/GLES2/gl2_api.in'), 244*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 245*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles2', 246*38e8c45fSAndroid Build Coastguard Worker profile = 'common', 247*38e8c45fSAndroid Build Coastguard Worker emitversions = None, 248*38e8c45fSAndroid Build Coastguard Worker defaultExtensions = 'gles2', 249*38e8c45fSAndroid Build Coastguard Worker filename = '../../libs/GLES2/gl2ext_api.in')] 250*38e8c45fSAndroid Build Coastguard Worker for opts in TRAMPOLINE_OPTIONS: 251*38e8c45fSAndroid Build Coastguard Worker registry.apiGen(opts) 252*38e8c45fSAndroid Build Coastguard Worker 253*38e8c45fSAndroid Build Coastguard Worker # Generate a GLESv1_CM entries separately to avoid extra driver loading time 254*38e8c45fSAndroid Build Coastguard Worker apigen = ApiGenerator() 255*38e8c45fSAndroid Build Coastguard Worker registry.setGenerator(apigen) 256*38e8c45fSAndroid Build Coastguard Worker API_OPTIONS = [ 257*38e8c45fSAndroid Build Coastguard Worker # Generate non-extension versions of each API first, then extensions, 258*38e8c45fSAndroid Build Coastguard Worker # so that if an extension enum was later standardized, we see the non- 259*38e8c45fSAndroid Build Coastguard Worker # suffixed version first. 260*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 261*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles1', 262*38e8c45fSAndroid Build Coastguard Worker profile = 'common'), 263*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 264*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles1', 265*38e8c45fSAndroid Build Coastguard Worker profile = 'common', 266*38e8c45fSAndroid Build Coastguard Worker emitversions = None, 267*38e8c45fSAndroid Build Coastguard Worker defaultExtensions = 'gles1')] 268*38e8c45fSAndroid Build Coastguard Worker for opts in API_OPTIONS: 269*38e8c45fSAndroid Build Coastguard Worker registry.apiGen(opts) 270*38e8c45fSAndroid Build Coastguard Worker apigen.finish() 271*38e8c45fSAndroid Build Coastguard Worker with open('../../libs/entries_gles1.in', 'w') as f: 272*38e8c45fSAndroid Build Coastguard Worker apigen.writeEntries(f) 273*38e8c45fSAndroid Build Coastguard Worker 274*38e8c45fSAndroid Build Coastguard Worker apigen = ApiGenerator() 275*38e8c45fSAndroid Build Coastguard Worker registry.setGenerator(apigen) 276*38e8c45fSAndroid Build Coastguard Worker API_OPTIONS = [ 277*38e8c45fSAndroid Build Coastguard Worker # Generate non-extension versions of each API first, then extensions, 278*38e8c45fSAndroid Build Coastguard Worker # so that if an extension enum was later standardized, we see the non- 279*38e8c45fSAndroid Build Coastguard Worker # suffixed version first. 280*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 281*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles1', 282*38e8c45fSAndroid Build Coastguard Worker profile = 'common'), 283*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 284*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles2', 285*38e8c45fSAndroid Build Coastguard Worker profile = 'common'), 286*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 287*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles1', 288*38e8c45fSAndroid Build Coastguard Worker profile = 'common', 289*38e8c45fSAndroid Build Coastguard Worker emitversions = None, 290*38e8c45fSAndroid Build Coastguard Worker defaultExtensions = 'gles1'), 291*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 292*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles2', 293*38e8c45fSAndroid Build Coastguard Worker profile = 'common', 294*38e8c45fSAndroid Build Coastguard Worker emitversions = None, 295*38e8c45fSAndroid Build Coastguard Worker defaultExtensions = 'gles2')] 296*38e8c45fSAndroid Build Coastguard Worker for opts in API_OPTIONS: 297*38e8c45fSAndroid Build Coastguard Worker registry.apiGen(opts) 298*38e8c45fSAndroid Build Coastguard Worker apigen.finish() 299*38e8c45fSAndroid Build Coastguard Worker with open('../../libs/entries.in', 'w') as f: 300*38e8c45fSAndroid Build Coastguard Worker apigen.writeEntries(f) 301*38e8c45fSAndroid Build Coastguard Worker with open('../../libs/enums.in', 'w') as f: 302*38e8c45fSAndroid Build Coastguard Worker apigen.writeEnums(f) 303*38e8c45fSAndroid Build Coastguard Worker 304*38e8c45fSAndroid Build Coastguard Worker registry.setGenerator(SpecGenerator()) 305*38e8c45fSAndroid Build Coastguard Worker SPEC_OPTIONS = [ 306*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 307*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles2', 308*38e8c45fSAndroid Build Coastguard Worker profile = 'common', 309*38e8c45fSAndroid Build Coastguard Worker versions = '3\.1', 310*38e8c45fSAndroid Build Coastguard Worker filename = '../glgen/specs/gles11/GLES31.spec'), 311*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 312*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles2', 313*38e8c45fSAndroid Build Coastguard Worker profile = 'common', 314*38e8c45fSAndroid Build Coastguard Worker emitversions = None, 315*38e8c45fSAndroid Build Coastguard Worker defaultExtensions = None, 316*38e8c45fSAndroid Build Coastguard Worker addExtensions = '^({})$'.format('|'.join(AEP_EXTENSIONS)), 317*38e8c45fSAndroid Build Coastguard Worker filename = '../glgen/specs/gles11/GLES31Ext.spec'), 318*38e8c45fSAndroid Build Coastguard Worker reg.GeneratorOptions( 319*38e8c45fSAndroid Build Coastguard Worker apiname = 'gles2', 320*38e8c45fSAndroid Build Coastguard Worker profile = 'common', 321*38e8c45fSAndroid Build Coastguard Worker versions = '3\.2', 322*38e8c45fSAndroid Build Coastguard Worker filename = '../glgen/specs/gles11/GLES32.spec')] 323*38e8c45fSAndroid Build Coastguard Worker # SpecGenerator creates a good starting point, but the CFunc.java parser is 324*38e8c45fSAndroid Build Coastguard Worker # so terrible that the .spec file needs a lot of manual massaging before 325*38e8c45fSAndroid Build Coastguard Worker # it works. Commenting this out to avoid accidentally overwriting all the 326*38e8c45fSAndroid Build Coastguard Worker # manual modifications. 327*38e8c45fSAndroid Build Coastguard Worker # 328*38e8c45fSAndroid Build Coastguard Worker # Eventually this script should generate the Java and JNI code directly, 329*38e8c45fSAndroid Build Coastguard Worker # skipping the intermediate .spec step, and obsoleting the existing 330*38e8c45fSAndroid Build Coastguard Worker # ../glgen system. 331*38e8c45fSAndroid Build Coastguard Worker # 332*38e8c45fSAndroid Build Coastguard Worker # for opts in SPEC_OPTIONS: 333*38e8c45fSAndroid Build Coastguard Worker # registry.apiGen(opts) 334*38e8c45fSAndroid Build Coastguard Worker 335