Pyry Haulos | a017863 | 2014-11-21 14:56:21 -0800 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
Jarkko Pöyry | 3c77ed4 | 2015-01-06 12:54:34 -0800 | [diff] [blame] | 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 | |
Pyry Haulos | a017863 | 2014-11-21 14:56:21 -0800 | [diff] [blame] | 23 | import os |
| 24 | import re |
| 25 | import sys |
| 26 | |
| 27 | def registerPaths(): |
| 28 | sys.path.append(os.path.dirname(os.path.dirname(__file__))) |
| 29 | |
| 30 | registerPaths() |
| 31 | |
| 32 | import khr_util.format |
| 33 | import khr_util.registry |
| 34 | import khr_util.registry_cache |
| 35 | |
| 36 | SCRIPTS_DIR = os.path.dirname(__file__) |
| 37 | EGL_DIR = os.path.normpath(os.path.join(SCRIPTS_DIR, "..", "..", "framework", "egl")) |
Pyry Haulos | 3c67e4f | 2014-12-19 15:45:39 -0800 | [diff] [blame] | 38 | EGL_WRAPPER_DIR = os.path.normpath(os.path.join(EGL_DIR, "wrapper")) |
Pyry Haulos | a017863 | 2014-11-21 14:56:21 -0800 | [diff] [blame] | 39 | |
| 40 | EGL_SOURCE = khr_util.registry_cache.RegistrySource( |
| 41 | "egl.xml", |
Mark Adams | 521bf8a | 2016-12-14 17:02:52 -0500 | [diff] [blame] | 42 | 33315, |
| 43 | "19f3b517f0dede56a6a94b820d08149ef5e1726f58202f47d69fa27f6f483bd2") |
Pyry Haulos | a017863 | 2014-11-21 14:56:21 -0800 | [diff] [blame] | 44 | |
Pyry Haulos | 3c67e4f | 2014-12-19 15:45:39 -0800 | [diff] [blame] | 45 | VERSION = '1.5' |
| 46 | |
Pyry Haulos | a017863 | 2014-11-21 14:56:21 -0800 | [diff] [blame] | 47 | EXTENSIONS = [ |
Pyry Haulos | 3c67e4f | 2014-12-19 15:45:39 -0800 | [diff] [blame] | 48 | # \todo [2014-12-05 pyry] Use 1.5 core functions/enums instead |
Pyry Haulos | a017863 | 2014-11-21 14:56:21 -0800 | [diff] [blame] | 49 | "EGL_KHR_create_context", |
Pyry Haulos | 3c67e4f | 2014-12-19 15:45:39 -0800 | [diff] [blame] | 50 | "EGL_KHR_lock_surface", |
| 51 | "EGL_KHR_image_base", |
| 52 | "EGL_KHR_fence_sync", |
| 53 | "EGL_KHR_reusable_sync", |
| 54 | "EGL_KHR_wait_sync", |
| 55 | "EGL_KHR_gl_texture_2D_image", |
| 56 | "EGL_KHR_gl_texture_cubemap_image", |
| 57 | "EGL_KHR_gl_renderbuffer_image", |
| 58 | "EGL_KHR_gl_texture_3D_image", |
| 59 | "EGL_EXT_create_context_robustness", |
| 60 | "EGL_EXT_platform_base", |
| 61 | "EGL_EXT_platform_x11", |
| 62 | "EGL_ANDROID_image_native_buffer", |
Hengyuan Hu | 59248e2 | 2015-06-11 17:48:52 -0700 | [diff] [blame] | 63 | "EGL_EXT_yuv_surface", |
| 64 | "EGL_EXT_buffer_age", |
| 65 | "EGL_KHR_partial_update", |
Mark Adams | 521bf8a | 2016-12-14 17:02:52 -0500 | [diff] [blame] | 66 | "EGL_KHR_swap_buffers_with_damage", |
| 67 | "EGL_EXT_pixel_format_float" |
Pyry Haulos | 3c67e4f | 2014-12-19 15:45:39 -0800 | [diff] [blame] | 68 | ] |
| 69 | PROTECTS = [ |
| 70 | "KHRONOS_SUPPORT_INT64" |
Pyry Haulos | a017863 | 2014-11-21 14:56:21 -0800 | [diff] [blame] | 71 | ] |
| 72 | |
| 73 | def getEGLRegistry (): |
| 74 | return khr_util.registry_cache.getRegistry(EGL_SOURCE) |
| 75 | |
| 76 | def getInterface (registry, api, version=None, profile=None, **kwargs): |
| 77 | spec = khr_util.registry.spec(registry, api, version, profile, **kwargs) |
| 78 | return khr_util.registry.createInterface(registry, spec, api) |
| 79 | |
| 80 | def getDefaultInterface (): |
Pyry Haulos | 3c67e4f | 2014-12-19 15:45:39 -0800 | [diff] [blame] | 81 | return getInterface(getEGLRegistry(), 'egl', VERSION, extensionNames = EXTENSIONS, protects = PROTECTS) |
| 82 | |
| 83 | def getFunctionTypeName (funcName): |
| 84 | return "%sFunc" % funcName |
| 85 | |
| 86 | def getFunctionMemberName (funcName): |
| 87 | assert funcName[:3] == "egl" |
| 88 | return "%c%s" % (funcName[3].lower(), funcName[4:]) |
| 89 | |
| 90 | def genCommandList (iface, renderCommand, directory, filename, align=False): |
| 91 | lines = map(renderCommand, iface.commands) |
| 92 | if align: |
| 93 | lines = khr_util.format.indentLines(lines) |
| 94 | writeInlFile(os.path.join(directory, filename), lines) |
| 95 | |
| 96 | def getVersionToken (version): |
| 97 | return version.replace(".", "") |
| 98 | |
| 99 | def genCommandLists (registry, renderCommand, check, directory, filePattern, align=False): |
| 100 | for eFeature in registry.features: |
| 101 | api = eFeature.get('api') |
| 102 | version = eFeature.get('number') |
| 103 | profile = check(api, version) |
| 104 | if profile is True: |
| 105 | profile = None |
| 106 | elif profile is False: |
| 107 | continue |
| 108 | iface = getInterface(registry, api, version=version, profile=profile) |
| 109 | filename = filePattern % getVersionToken(version) |
| 110 | genCommandList(iface, renderCommand, directory, filename, align) |
Pyry Haulos | a017863 | 2014-11-21 14:56:21 -0800 | [diff] [blame] | 111 | |
| 112 | INL_HEADER = khr_util.format.genInlHeader("Khronos EGL API description (egl.xml)", EGL_SOURCE.getRevision()) |
| 113 | |
| 114 | def writeInlFile (filename, source): |
| 115 | khr_util.format.writeInlFile(filename, INL_HEADER, source) |