1*35238bceSAndroid Build Coastguard Worker# -*- coding: utf-8 -*- 2*35238bceSAndroid Build Coastguard Worker 3*35238bceSAndroid Build Coastguard Worker#------------------------------------------------------------------------- 4*35238bceSAndroid Build Coastguard Worker# drawElements Quality Program utilities 5*35238bceSAndroid Build Coastguard Worker# -------------------------------------- 6*35238bceSAndroid Build Coastguard Worker# 7*35238bceSAndroid Build Coastguard Worker# Copyright 2015-2017 The Android Open Source Project 8*35238bceSAndroid Build Coastguard Worker# 9*35238bceSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 10*35238bceSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 11*35238bceSAndroid Build Coastguard Worker# You may obtain a copy of the License at 12*35238bceSAndroid Build Coastguard Worker# 13*35238bceSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 14*35238bceSAndroid Build Coastguard Worker# 15*35238bceSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 16*35238bceSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 17*35238bceSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18*35238bceSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 19*35238bceSAndroid Build Coastguard Worker# limitations under the License. 20*35238bceSAndroid Build Coastguard Worker# 21*35238bceSAndroid Build Coastguard Worker#------------------------------------------------------------------------- 22*35238bceSAndroid Build Coastguard Worker 23*35238bceSAndroid Build Coastguard Workerimport os 24*35238bceSAndroid Build Coastguard Workerimport re 25*35238bceSAndroid Build Coastguard Workerimport sys 26*35238bceSAndroid Build Coastguard Worker 27*35238bceSAndroid Build Coastguard Workerdef registerPaths(): 28*35238bceSAndroid Build Coastguard Worker sys.path.append(os.path.dirname(os.path.dirname(__file__))) 29*35238bceSAndroid Build Coastguard Worker 30*35238bceSAndroid Build Coastguard WorkerregisterPaths() 31*35238bceSAndroid Build Coastguard Worker 32*35238bceSAndroid Build Coastguard Workerimport khr_util.format 33*35238bceSAndroid Build Coastguard Workerimport khr_util.registry 34*35238bceSAndroid Build Coastguard Workerimport khr_util.registry_cache 35*35238bceSAndroid Build Coastguard Worker 36*35238bceSAndroid Build Coastguard WorkerSCRIPTS_DIR = os.path.dirname(__file__) 37*35238bceSAndroid Build Coastguard WorkerEGL_DIR = os.path.normpath(os.path.join(SCRIPTS_DIR, "..", "..", "framework", "egl")) 38*35238bceSAndroid Build Coastguard WorkerEGL_WRAPPER_DIR = os.path.normpath(os.path.join(EGL_DIR, "wrapper")) 39*35238bceSAndroid Build Coastguard Worker 40*35238bceSAndroid Build Coastguard WorkerEGL_SOURCE = khr_util.registry_cache.RegistrySource( 41*35238bceSAndroid Build Coastguard Worker "https://raw.githubusercontent.com/KhronosGroup/EGL-Registry", 42*35238bceSAndroid Build Coastguard Worker "api/egl.xml", 43*35238bceSAndroid Build Coastguard Worker "6550e9b12e0b4f11182bda30ae2a8dd56d0b02c8", 44*35238bceSAndroid Build Coastguard Worker "cb965fcee1335723beb11e2e174a5cf69d2f896e459cc25be8074356eb59871c") 45*35238bceSAndroid Build Coastguard Worker 46*35238bceSAndroid Build Coastguard WorkerVERSION = '1.5' 47*35238bceSAndroid Build Coastguard Worker 48*35238bceSAndroid Build Coastguard WorkerEXTENSIONS = [ 49*35238bceSAndroid Build Coastguard Worker # \todo [2014-12-05 pyry] Use 1.5 core functions/enums instead 50*35238bceSAndroid Build Coastguard Worker "EGL_KHR_create_context", 51*35238bceSAndroid Build Coastguard Worker "EGL_KHR_create_context_no_error", 52*35238bceSAndroid Build Coastguard Worker "EGL_KHR_lock_surface", 53*35238bceSAndroid Build Coastguard Worker "EGL_KHR_image_base", 54*35238bceSAndroid Build Coastguard Worker "EGL_KHR_fence_sync", 55*35238bceSAndroid Build Coastguard Worker "EGL_KHR_reusable_sync", 56*35238bceSAndroid Build Coastguard Worker "EGL_KHR_wait_sync", 57*35238bceSAndroid Build Coastguard Worker "EGL_KHR_gl_texture_2D_image", 58*35238bceSAndroid Build Coastguard Worker "EGL_KHR_gl_texture_cubemap_image", 59*35238bceSAndroid Build Coastguard Worker "EGL_KHR_gl_renderbuffer_image", 60*35238bceSAndroid Build Coastguard Worker "EGL_KHR_gl_texture_3D_image", 61*35238bceSAndroid Build Coastguard Worker "EGL_EXT_create_context_robustness", 62*35238bceSAndroid Build Coastguard Worker "EGL_EXT_platform_base", 63*35238bceSAndroid Build Coastguard Worker "EGL_EXT_platform_x11", 64*35238bceSAndroid Build Coastguard Worker "EGL_KHR_platform_wayland", 65*35238bceSAndroid Build Coastguard Worker "EGL_ANDROID_image_native_buffer", 66*35238bceSAndroid Build Coastguard Worker "EGL_EXT_yuv_surface", 67*35238bceSAndroid Build Coastguard Worker "EGL_EXT_buffer_age", 68*35238bceSAndroid Build Coastguard Worker "EGL_KHR_partial_update", 69*35238bceSAndroid Build Coastguard Worker "EGL_KHR_swap_buffers_with_damage", 70*35238bceSAndroid Build Coastguard Worker "EGL_KHR_mutable_render_buffer", 71*35238bceSAndroid Build Coastguard Worker "EGL_EXT_pixel_format_float", 72*35238bceSAndroid Build Coastguard Worker "EGL_KHR_gl_colorspace", 73*35238bceSAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_bt2020_linear", 74*35238bceSAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_bt2020_pq", 75*35238bceSAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_bt2020_hlg", 76*35238bceSAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_display_p3", 77*35238bceSAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_display_p3_linear", 78*35238bceSAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_display_p3_passthrough", 79*35238bceSAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_scrgb", 80*35238bceSAndroid Build Coastguard Worker "EGL_EXT_gl_colorspace_scrgb_linear", 81*35238bceSAndroid Build Coastguard Worker "EGL_EXT_surface_SMPTE2086_metadata", 82*35238bceSAndroid Build Coastguard Worker "EGL_EXT_surface_CTA861_3_metadata", 83*35238bceSAndroid Build Coastguard Worker "EGL_ANDROID_recordable" 84*35238bceSAndroid Build Coastguard Worker] 85*35238bceSAndroid Build Coastguard WorkerPROTECTS = [ 86*35238bceSAndroid Build Coastguard Worker "KHRONOS_SUPPORT_INT64" 87*35238bceSAndroid Build Coastguard Worker] 88*35238bceSAndroid Build Coastguard Worker 89*35238bceSAndroid Build Coastguard Workerdef getEGLRegistry (): 90*35238bceSAndroid Build Coastguard Worker return khr_util.registry_cache.getRegistry(EGL_SOURCE) 91*35238bceSAndroid Build Coastguard Worker 92*35238bceSAndroid Build Coastguard Workerdef getInterface (registry, api, version=None, profile=None, **kwargs): 93*35238bceSAndroid Build Coastguard Worker spec = khr_util.registry.spec(registry, api, version, profile, **kwargs) 94*35238bceSAndroid Build Coastguard Worker return khr_util.registry.createInterface(registry, spec, api) 95*35238bceSAndroid Build Coastguard Worker 96*35238bceSAndroid Build Coastguard Workerdef getDefaultInterface (): 97*35238bceSAndroid Build Coastguard Worker return getInterface(getEGLRegistry(), 'egl', VERSION, extensionNames = EXTENSIONS, protects = PROTECTS) 98*35238bceSAndroid Build Coastguard Worker 99*35238bceSAndroid Build Coastguard Workerdef getFunctionTypeName (funcName): 100*35238bceSAndroid Build Coastguard Worker return "%sFunc" % funcName 101*35238bceSAndroid Build Coastguard Worker 102*35238bceSAndroid Build Coastguard Workerdef getFunctionMemberName (funcName): 103*35238bceSAndroid Build Coastguard Worker assert funcName[:3] == "egl" 104*35238bceSAndroid Build Coastguard Worker return "%c%s" % (funcName[3].lower(), funcName[4:]) 105*35238bceSAndroid Build Coastguard Worker 106*35238bceSAndroid Build Coastguard Workerdef genCommandList (iface, renderCommand, directory, filename, align=False): 107*35238bceSAndroid Build Coastguard Worker lines = map(renderCommand, iface.commands) 108*35238bceSAndroid Build Coastguard Worker if align: 109*35238bceSAndroid Build Coastguard Worker lines = khr_util.format.indentLines(lines) 110*35238bceSAndroid Build Coastguard Worker writeInlFile(os.path.join(directory, filename), lines) 111*35238bceSAndroid Build Coastguard Worker 112*35238bceSAndroid Build Coastguard Workerdef getVersionToken (version): 113*35238bceSAndroid Build Coastguard Worker return version.replace(".", "") 114*35238bceSAndroid Build Coastguard Worker 115*35238bceSAndroid Build Coastguard Workerdef genCommandLists (registry, renderCommand, check, directory, filePattern, align=False): 116*35238bceSAndroid Build Coastguard Worker for eFeature in registry.features: 117*35238bceSAndroid Build Coastguard Worker api = eFeature.get('api') 118*35238bceSAndroid Build Coastguard Worker version = eFeature.get('number') 119*35238bceSAndroid Build Coastguard Worker profile = check(api, version) 120*35238bceSAndroid Build Coastguard Worker if profile is True: 121*35238bceSAndroid Build Coastguard Worker profile = None 122*35238bceSAndroid Build Coastguard Worker elif profile is False: 123*35238bceSAndroid Build Coastguard Worker continue 124*35238bceSAndroid Build Coastguard Worker iface = getInterface(registry, api, version=version, profile=profile) 125*35238bceSAndroid Build Coastguard Worker filename = filePattern % getVersionToken(version) 126*35238bceSAndroid Build Coastguard Worker genCommandList(iface, renderCommand, directory, filename, align) 127*35238bceSAndroid Build Coastguard Worker 128*35238bceSAndroid Build Coastguard WorkerINL_HEADER = khr_util.format.genInlHeader("Khronos EGL API description (egl.xml)", EGL_SOURCE.getRevision()) 129*35238bceSAndroid Build Coastguard Worker 130*35238bceSAndroid Build Coastguard Workerdef writeInlFile (filename, source): 131*35238bceSAndroid Build Coastguard Worker khr_util.format.writeInlFile(filename, INL_HEADER, source) 132