Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / scripts / egl / library.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 from egl.common import *
24 from khr_util.format import indentLines, commandParams, commandArgs
25 import khr_util.registry
26 from itertools import chain
27
28 try:
29         from itertools import imap
30 except ImportError:
31         imap=map
32
33 def virtualMemberDecl (command):
34         return "virtual %s\t%s\t(%s) const\t= 0;" % (
35                 command.type,
36                 getFunctionMemberName(command.name),
37                 commandParams(command))
38
39 def concreteMemberDecl (command):
40         return "%s\t%s\t(%s) const;" % (
41                 command.type,
42                 getFunctionMemberName(command.name),
43                 commandParams(command))
44
45 def memberImpl (command):
46         template = """
47 {returnType} FuncPtrLibrary::{memberName} ({paramDecls}) const
48 {{
49         {maybeReturn}m_egl.{memberName}({arguments});
50 }}"""
51         return template.format(
52                 returnType              = command.type,
53                 mangledName             = getFunctionMemberName(command.name),
54                 paramDecls              = commandParams(command),
55                 maybeReturn             = "return " if command.type != 'void' else "",
56                 memberName              = getFunctionMemberName(command.name),
57                 arguments               = commandArgs(command))
58
59 def initFunctionEntry (command):
60         return "dst->%s\t= (%sFunc)\tloader->get(\"%s\");" % (
61                 getFunctionMemberName(command.name),
62                 command.name,
63                 command.name)
64
65 def getExtOnlyIface (registry, api, extensions):
66         spec = khr_util.registry.InterfaceSpec()
67
68         for extension in registry.extensions:
69                 if not khr_util.registry.getExtensionName(extension) in extensions:
70                         continue
71
72                 if not khr_util.registry.extensionSupports(extension, api):
73                         continue
74
75                 spec.addExtension(extension, api)
76
77         return khr_util.registry.createInterface(registry, spec, api)
78
79 def commandLibraryEntry (command):
80         return "\t{ \"%s\",\t(deFunctionPtr)%s }," % (command.name, command.name)
81
82 def genStaticLibrary (registry):
83         genCommandLists(registry, commandLibraryEntry,
84                                         check           = lambda api, version: api == 'egl' and version in set(["1.4", "1.5"]),
85                                         directory       = EGL_WRAPPER_DIR,
86                                         filePattern     = "eglwStaticLibrary%s.inl",
87                                         align           = True)
88
89 def gen (registry):
90         defaultIface    = getDefaultInterface()
91         noExtIface              = getInterface(registry, 'egl', VERSION)
92         extOnlyIface    = getExtOnlyIface(registry, 'egl', EXTENSIONS)
93
94         genCommandList(defaultIface,    virtualMemberDecl,      EGL_WRAPPER_DIR, "eglwLibrary.inl", True)
95         genCommandList(defaultIface,    concreteMemberDecl,     EGL_WRAPPER_DIR, "eglwFuncPtrLibraryDecl.inl", True)
96         genCommandList(defaultIface,    memberImpl,                     EGL_WRAPPER_DIR, "eglwFuncPtrLibraryImpl.inl")
97
98         genCommandList(noExtIface,              initFunctionEntry,      EGL_WRAPPER_DIR, "eglwInitCore.inl", True)
99         genCommandList(extOnlyIface,    initFunctionEntry,      EGL_WRAPPER_DIR, "eglwInitExtensions.inl", True)
100
101         genStaticLibrary(registry)