xref: /aosp_15_r20/external/deqp/scripts/opengl/gen_ext_init.py (revision 35238bce31c2a825756842865a792f8cf7f89930)
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 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 Workerfrom src_util import *
24*35238bceSAndroid Build Coastguard Worker
25*35238bceSAndroid Build Coastguard Workerdef getExtensionCommands (registry, iface, api, extension):
26*35238bceSAndroid Build Coastguard Worker    commands = []
27*35238bceSAndroid Build Coastguard Worker
28*35238bceSAndroid Build Coastguard Worker    # Build interface with just the single extension and no core APIs.
29*35238bceSAndroid Build Coastguard Worker    # Aliases will not be set in this iface so we will use it only for
30*35238bceSAndroid Build Coastguard Worker    # slicing the complete (hybrid) iface.
31*35238bceSAndroid Build Coastguard Worker    extIface = getInterface(registry, api, version=False, profile='core', extensionNames=[extension])
32*35238bceSAndroid Build Coastguard Worker    if not extIface.commands:
33*35238bceSAndroid Build Coastguard Worker        return commands
34*35238bceSAndroid Build Coastguard Worker
35*35238bceSAndroid Build Coastguard Worker    cmdMap = {}
36*35238bceSAndroid Build Coastguard Worker    for command in iface.commands:
37*35238bceSAndroid Build Coastguard Worker        cmdMap[command.name] = command
38*35238bceSAndroid Build Coastguard Worker
39*35238bceSAndroid Build Coastguard Worker    for extCommand in extIface.commands:
40*35238bceSAndroid Build Coastguard Worker        assert extCommand.name in cmdMap
41*35238bceSAndroid Build Coastguard Worker        commands.append(cmdMap[extCommand.name])
42*35238bceSAndroid Build Coastguard Worker
43*35238bceSAndroid Build Coastguard Worker    return commands
44*35238bceSAndroid Build Coastguard Worker
45*35238bceSAndroid Build Coastguard Workerdef genExtensions (registry, iface, api):
46*35238bceSAndroid Build Coastguard Worker    for extName in EXTENSIONS:
47*35238bceSAndroid Build Coastguard Worker        extCommands = getExtensionCommands(registry, iface, api, extName)
48*35238bceSAndroid Build Coastguard Worker        if len(extCommands) == 0:
49*35238bceSAndroid Build Coastguard Worker            continue # Not applicable for this api
50*35238bceSAndroid Build Coastguard Worker
51*35238bceSAndroid Build Coastguard Worker        yield ""
52*35238bceSAndroid Build Coastguard Worker        yield "if (de::contains(extSet, \"%s\"))" % extName
53*35238bceSAndroid Build Coastguard Worker        yield "{"
54*35238bceSAndroid Build Coastguard Worker
55*35238bceSAndroid Build Coastguard Worker        def genInit (command):
56*35238bceSAndroid Build Coastguard Worker            ifaceName = command.alias.name if command.alias and command.name not in ALIASING_EXCEPTIONS else command.name
57*35238bceSAndroid Build Coastguard Worker            return "gl->%s\t= (%s)\tloader->get(\"%s\");" % (
58*35238bceSAndroid Build Coastguard Worker                getFunctionMemberName(ifaceName),
59*35238bceSAndroid Build Coastguard Worker                getFunctionTypeName(ifaceName),
60*35238bceSAndroid Build Coastguard Worker                command.name)
61*35238bceSAndroid Build Coastguard Worker
62*35238bceSAndroid Build Coastguard Worker        for line in indentLines(genInit(command) for command in extCommands):
63*35238bceSAndroid Build Coastguard Worker            yield "\t" + line
64*35238bceSAndroid Build Coastguard Worker
65*35238bceSAndroid Build Coastguard Worker        yield "}"
66*35238bceSAndroid Build Coastguard Worker
67*35238bceSAndroid Build Coastguard Workerdef genExtInit (registry, iface):
68*35238bceSAndroid Build Coastguard Worker    nonStrippedIface = getHybridInterface(stripAliasedExtCommands = False)
69*35238bceSAndroid Build Coastguard Worker
70*35238bceSAndroid Build Coastguard Worker    writeInlFile(os.path.join(OPENGL_INC_DIR, "glwInitExtES.inl"), genExtensions(registry, nonStrippedIface, 'gles2'))
71*35238bceSAndroid Build Coastguard Worker    writeInlFile(os.path.join(OPENGL_INC_DIR, "glwInitExtGL.inl"), genExtensions(registry, nonStrippedIface, 'gl'))
72*35238bceSAndroid Build Coastguard Worker
73*35238bceSAndroid Build Coastguard Workerif __name__ == '__main__':
74*35238bceSAndroid Build Coastguard Worker    genExtInit(getGLRegistry(), getHybridInterface())
75