mirror of
https://github.com/elwrcl/intel-hard-graphics.git
synced 2026-11-01 03:18:02 +03:00
init
This commit is contained in:
12511 files changed
+6156641
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,247 @@
|
||||
# (C) Copyright 2016, NVIDIA CORPORATION.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
# license, and/or sell copies of the Software, and to permit persons to whom
|
||||
# the Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice (including the next
|
||||
# paragraph) shall be included in all copies or substantial portions of the
|
||||
# Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
#
|
||||
# Authors:
|
||||
# Kyle Brenneman <[email protected]>
|
||||
|
||||
"""
|
||||
Contains a list of EGL functions to generate dispatch functions for.
|
||||
|
||||
This is used from gen_egl_dispatch.py.
|
||||
|
||||
EGL_FUNCTIONS is a sequence of (name, eglData) pairs, where name is the name
|
||||
of the function, and eglData is a dictionary containing data about that
|
||||
function.
|
||||
|
||||
The values in the eglData dictionary are:
|
||||
- method (string):
|
||||
How to select a vendor library. See "Method values" below.
|
||||
|
||||
- prefix (string):
|
||||
This string is prepended to the name of the dispatch function. If
|
||||
unspecified, the default is "" (an empty string).
|
||||
|
||||
- static (boolean)
|
||||
If True, this function should be declared static.
|
||||
|
||||
- "public" (boolean)
|
||||
If True, the function should be exported from the library. Vendor libraries
|
||||
generally should not use this.
|
||||
|
||||
- extension (string):
|
||||
If specified, this is the name of a macro to check for before defining a
|
||||
function. Used for checking for extension macros and such.
|
||||
|
||||
- retval (string):
|
||||
If specified, this is a C expression with the default value to return if we
|
||||
can't find a function to call. By default, it will try to guess from the
|
||||
return type: EGL_NO_whatever for the various handle types, NULL for
|
||||
pointers, and zero for everything else.
|
||||
|
||||
method values:
|
||||
- "custom"
|
||||
The dispatch stub will be hand-written instead of generated.
|
||||
|
||||
- "none"
|
||||
No dispatch function exists at all, but the function should still have an
|
||||
entry in the index array. This is for other functions that a stub may need
|
||||
to call that are implemented in libEGL itself.
|
||||
|
||||
- "display"
|
||||
Select a vendor from an EGLDisplay argument.
|
||||
|
||||
- "device"
|
||||
Select a vendor from an EGLDeviceEXT argument.
|
||||
|
||||
- "current"
|
||||
Select the vendor that owns the current context.
|
||||
"""
|
||||
|
||||
|
||||
def _eglFunc(name, method, static=None, public=False, inheader=None, prefix="dispatch_", extension=None, retval=None):
|
||||
"""
|
||||
A convenience function to define an entry in the EGL function list.
|
||||
"""
|
||||
if static is None:
|
||||
static = (not public and method != "custom")
|
||||
if inheader is None:
|
||||
inheader = (not static)
|
||||
values = {
|
||||
"method": method,
|
||||
"prefix": prefix,
|
||||
"extension": extension,
|
||||
"retval": retval,
|
||||
"static": static,
|
||||
"public": public,
|
||||
"inheader": inheader,
|
||||
}
|
||||
return (name, values)
|
||||
|
||||
|
||||
EGL_FUNCTIONS = (
|
||||
# EGL_VERSION_1_0
|
||||
_eglFunc("eglChooseConfig", "none"),
|
||||
_eglFunc("eglCopyBuffers", "none"),
|
||||
_eglFunc("eglCreateContext", "none"),
|
||||
_eglFunc("eglCreatePbufferSurface", "none"),
|
||||
_eglFunc("eglCreatePixmapSurface", "none"),
|
||||
_eglFunc("eglCreateWindowSurface", "none"),
|
||||
_eglFunc("eglDestroyContext", "none"),
|
||||
_eglFunc("eglDestroySurface", "none"),
|
||||
_eglFunc("eglGetConfigAttrib", "none"),
|
||||
_eglFunc("eglGetConfigs", "none"),
|
||||
_eglFunc("eglQueryContext", "none"),
|
||||
_eglFunc("eglQuerySurface", "none"),
|
||||
_eglFunc("eglSwapBuffers", "none"),
|
||||
_eglFunc("eglWaitGL", "none"),
|
||||
_eglFunc("eglWaitNative", "none"),
|
||||
_eglFunc("eglTerminate", "none"),
|
||||
_eglFunc("eglInitialize", "none"),
|
||||
|
||||
_eglFunc("eglGetCurrentDisplay", "none"),
|
||||
_eglFunc("eglGetCurrentSurface", "none"),
|
||||
_eglFunc("eglGetDisplay", "none"),
|
||||
_eglFunc("eglGetError", "none"),
|
||||
_eglFunc("eglGetProcAddress", "none"),
|
||||
_eglFunc("eglMakeCurrent", "none"),
|
||||
_eglFunc("eglQueryString", "none"),
|
||||
|
||||
# EGL_VERSION_1_1
|
||||
_eglFunc("eglBindTexImage", "none"),
|
||||
_eglFunc("eglReleaseTexImage", "none"),
|
||||
_eglFunc("eglSurfaceAttrib", "none"),
|
||||
_eglFunc("eglSwapInterval", "none"),
|
||||
|
||||
# EGL_VERSION_1_2
|
||||
_eglFunc("eglCreatePbufferFromClientBuffer", "none"),
|
||||
_eglFunc("eglWaitClient", "none"),
|
||||
_eglFunc("eglBindAPI", "none"),
|
||||
_eglFunc("eglQueryAPI", "none"),
|
||||
_eglFunc("eglReleaseThread", "none"),
|
||||
|
||||
# EGL_VERSION_1_4
|
||||
_eglFunc("eglGetCurrentContext", "none"),
|
||||
|
||||
# EGL_VERSION_1_5
|
||||
_eglFunc("eglCreateSync", "none"),
|
||||
_eglFunc("eglDestroySync", "none"),
|
||||
_eglFunc("eglClientWaitSync", "none"),
|
||||
_eglFunc("eglGetSyncAttrib", "none"),
|
||||
_eglFunc("eglCreateImage", "none"),
|
||||
_eglFunc("eglDestroyImage", "none"),
|
||||
_eglFunc("eglCreatePlatformWindowSurface", "none"),
|
||||
_eglFunc("eglCreatePlatformPixmapSurface", "none"),
|
||||
_eglFunc("eglWaitSync", "none"),
|
||||
_eglFunc("eglGetPlatformDisplay", "none"),
|
||||
|
||||
# EGL_EXT_platform_base
|
||||
_eglFunc("eglCreatePlatformWindowSurfaceEXT", "display"),
|
||||
_eglFunc("eglCreatePlatformPixmapSurfaceEXT", "display"),
|
||||
_eglFunc("eglGetPlatformDisplayEXT", "none"),
|
||||
|
||||
# TODO: Most of these extensions should be provided by the vendor
|
||||
# libraries, not by libEGL. They're here now to make testing everything
|
||||
# else easier.
|
||||
|
||||
# EGL_EXT_swap_buffers_with_damage
|
||||
_eglFunc("eglSwapBuffersWithDamageEXT", "display"),
|
||||
|
||||
# KHR_EXT_swap_buffers_with_damage
|
||||
_eglFunc("eglSwapBuffersWithDamageKHR", "display"),
|
||||
|
||||
# EGL_KHR_cl_event2
|
||||
_eglFunc("eglCreateSync64KHR", "display"),
|
||||
|
||||
# EGL_KHR_fence_sync
|
||||
_eglFunc("eglCreateSyncKHR", "display"),
|
||||
_eglFunc("eglDestroySyncKHR", "display"),
|
||||
_eglFunc("eglClientWaitSyncKHR", "display"),
|
||||
_eglFunc("eglGetSyncAttribKHR", "display"),
|
||||
|
||||
# EGL_KHR_image
|
||||
_eglFunc("eglCreateImageKHR", "display"),
|
||||
_eglFunc("eglDestroyImageKHR", "display"),
|
||||
|
||||
# EGL_KHR_image_base
|
||||
# eglCreateImageKHR already defined in EGL_KHR_image
|
||||
# eglDestroyImageKHR already defined in EGL_KHR_image
|
||||
|
||||
# EGL_KHR_reusable_sync
|
||||
_eglFunc("eglSignalSyncKHR", "display"),
|
||||
# eglCreateSyncKHR already defined in EGL_KHR_fence_sync
|
||||
# eglDestroySyncKHR already defined in EGL_KHR_fence_sync
|
||||
# eglClientWaitSyncKHR already defined in EGL_KHR_fence_sync
|
||||
# eglGetSyncAttribKHR already defined in EGL_KHR_fence_sync
|
||||
|
||||
# EGL_KHR_wait_sync
|
||||
_eglFunc("eglWaitSyncKHR", "display"),
|
||||
|
||||
# EGL_MESA_image_dma_buf_export
|
||||
_eglFunc("eglExportDMABUFImageQueryMESA", "display"),
|
||||
_eglFunc("eglExportDMABUFImageMESA", "display"),
|
||||
|
||||
# EGL_WL_bind_wayland_display
|
||||
_eglFunc("eglCreateWaylandBufferFromImageWL", "display"),
|
||||
_eglFunc("eglUnbindWaylandDisplayWL", "display"),
|
||||
_eglFunc("eglQueryWaylandBufferWL", "display"),
|
||||
_eglFunc("eglBindWaylandDisplayWL", "display"),
|
||||
|
||||
# EGL_CHROMIUM_get_sync_values
|
||||
_eglFunc("eglGetSyncValuesCHROMIUM", "display"),
|
||||
|
||||
# EGL_ANGLE_sync_control_rate
|
||||
_eglFunc("eglGetMscRateANGLE", "display"),
|
||||
|
||||
# EGL_ANDROID_native_fence_sync
|
||||
_eglFunc("eglDupNativeFenceFDANDROID", "display"),
|
||||
|
||||
# EGL_ANDROID_blob_cache
|
||||
_eglFunc("eglSetBlobCacheFuncsANDROID", "display"),
|
||||
|
||||
# EGL_EXT_image_dma_buf_import_modifiers
|
||||
_eglFunc("eglQueryDmaBufFormatsEXT", "display"),
|
||||
_eglFunc("eglQueryDmaBufModifiersEXT", "display"),
|
||||
|
||||
# EGL_EXT_device_base
|
||||
_eglFunc("eglQueryDeviceAttribEXT", "device"),
|
||||
_eglFunc("eglQueryDeviceStringEXT", "device"),
|
||||
_eglFunc("eglQueryDevicesEXT", "none"),
|
||||
_eglFunc("eglQueryDisplayAttribEXT", "display"),
|
||||
|
||||
# EGL_MESA_query_driver
|
||||
_eglFunc("eglGetDisplayDriverName", "display"),
|
||||
_eglFunc("eglGetDisplayDriverConfig", "display"),
|
||||
|
||||
# EGL_KHR_partial_update
|
||||
_eglFunc("eglSetDamageRegionKHR", "display"),
|
||||
|
||||
# EGL_MESA_gl_interop
|
||||
_eglFunc("eglGLInteropQueryDeviceInfoMESA", "display"),
|
||||
_eglFunc("eglGLInteropExportObjectMESA", "display"),
|
||||
_eglFunc("eglGLInteropFlushObjectsMESA", "display"),
|
||||
|
||||
# EGL_EXT_surface_compression
|
||||
_eglFunc("eglQuerySupportedCompressionRatesEXT", "display"),
|
||||
|
||||
# EGL_EXT_device_persistent_id
|
||||
_eglFunc("eglQueryDeviceBinaryEXT", "device"),
|
||||
)
|
||||
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<registry>
|
||||
<!--
|
||||
(C) Copyright 2016, NVIDIA CORPORATION.
|
||||
All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
license, and/or sell copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
|
||||
Authors:
|
||||
Kyle Brenneman <[email protected]>
|
||||
-->
|
||||
|
||||
<comment>
|
||||
This file contains any EGL extension functions that are missing from
|
||||
the normal egl.xml list.
|
||||
</comment>
|
||||
<types>
|
||||
<type>struct <name>mesa_glinterop_device_info</name>;</type>
|
||||
<type>struct <name>mesa_glinterop_export_in</name>;</type>
|
||||
<type>struct <name>mesa_glinterop_export_out</name>;</type>
|
||||
<type>struct <name>mesa_glinterop_flush_out</name>;</type>
|
||||
</types>
|
||||
<commands namespace="EGL">
|
||||
<!-- EGL_WL_bind_wayland_display -->
|
||||
<command>
|
||||
<proto>struct wl_buffer * <name>eglCreateWaylandBufferFromImageWL</name></proto>
|
||||
<param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
|
||||
<param><ptype>EGLImage</ptype> <name>image</name></param>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<proto>EGLBoolean <name>eglUnbindWaylandDisplayWL</name></proto>
|
||||
<param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
|
||||
<param><ptype>struct wl_display *</ptype> <name>display</name></param>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<proto>EGLBoolean <name>eglQueryWaylandBufferWL</name></proto>
|
||||
<param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
|
||||
<param><ptype>struct wl_resource *</ptype> <name>buffer</name></param>
|
||||
<param><ptype>EGLint</ptype> <name>attribute</name></param>
|
||||
<param><ptype>EGLint *</ptype> <name>value</name></param>
|
||||
</command>
|
||||
|
||||
<command>
|
||||
<proto>EGLBoolean <name>eglBindWaylandDisplayWL</name></proto>
|
||||
<param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
|
||||
<param><ptype>struct wl_display *</ptype> <name>display</name></param>
|
||||
</command>
|
||||
|
||||
<!-- EGL_CHROMIUM_get_sync_values -->
|
||||
<command>
|
||||
<proto>EGLBoolean <name>eglGetSyncValuesCHROMIUM</name></proto>
|
||||
<param><ptype>EGLDisplay</ptype> <name>display</name></param>
|
||||
<param><ptype>EGLSurface</ptype> <name>surface</name></param>
|
||||
<param><ptype>EGLuint64KHR *</ptype> <name>ust</name></param>
|
||||
<param><ptype>EGLuint64KHR *</ptype> <name>msc</name></param>
|
||||
<param><ptype>EGLuint64KHR *</ptype> <name>sbc</name></param>
|
||||
</command>
|
||||
|
||||
<!-- EGL_ANGLE_sync_control_rate -->
|
||||
<command>
|
||||
<proto>EGLBoolean <name>eglGetMscRateANGLE</name></proto>
|
||||
<param><ptype>EGLDisplay</ptype> <name>display</name></param>
|
||||
<param><ptype>EGLSurface</ptype> <name>surface</name></param>
|
||||
<param><ptype>EGLint *</ptype> <name>numerator</name></param>
|
||||
<param><ptype>EGLint *</ptype> <name>denominator</name></param>
|
||||
</command>
|
||||
|
||||
<!-- EGL_MESA_gl_interop -->
|
||||
<command>
|
||||
<proto><ptype>EGLint</ptype> <name>eglGLInteropQueryDeviceInfoMESA</name></proto>
|
||||
<param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
|
||||
<param><ptype>EGLContext</ptype> <name>ctx</name></param>
|
||||
<param>struct <ptype>mesa_glinterop_device_info</ptype> *<name>out</name></param>
|
||||
</command>
|
||||
<command>
|
||||
<proto><ptype>EGLint</ptype> <name>eglGLInteropExportObjectMESA</name></proto>
|
||||
<param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
|
||||
<param><ptype>EGLContext</ptype> <name>ctx</name></param>
|
||||
<param>struct <ptype>mesa_glinterop_export_in</ptype> *<name>in</name></param>
|
||||
<param>struct <ptype>mesa_glinterop_export_out</ptype> *<name>out</name></param>
|
||||
</command>
|
||||
<command>
|
||||
<proto><ptype>EGLint</ptype> <name>eglGLInteropFlushObjectsMESA</name></proto>
|
||||
<param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
|
||||
<param><ptype>EGLContext</ptype> <name>ctx</name></param>
|
||||
<param>unsigned <name>count</name></param>
|
||||
<param>struct <ptype>mesa_glinterop_export_in</ptype> *<name>objects</name></param>
|
||||
<param>struct <ptype>mesa_glinterop_flush_out</ptype> *<name>out</name></param>
|
||||
</command>
|
||||
</commands>
|
||||
</registry>
|
||||
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# (C) Copyright 2016, NVIDIA CORPORATION.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
# license, and/or sell copies of the Software, and to permit persons to whom
|
||||
# the Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice (including the next
|
||||
# paragraph) shall be included in all copies or substantial portions of the
|
||||
# Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
#
|
||||
# Authors:
|
||||
# Kyle Brenneman <[email protected]>
|
||||
|
||||
"""
|
||||
Generates dispatch functions for EGL.
|
||||
|
||||
The list of functions and arguments is read from the Khronos's XML files, with
|
||||
additional information defined in the module eglFunctionList.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import eglFunctionList
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
import os
|
||||
NEWAPI = os.path.join(os.path.dirname(__file__), "..", "..", "mesa", "glapi", "new")
|
||||
sys.path.insert(0, NEWAPI)
|
||||
import genCommon
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--bind-wl-display", action="store_true",
|
||||
help="Include EGL_WL_bind_wayland_display")
|
||||
parser.add_argument("target", choices=("header", "source"),
|
||||
help="Whether to build the source or header file.")
|
||||
parser.add_argument("xml_files", nargs="+",
|
||||
help="The XML files with the EGL function lists.")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
xmlFunctions = genCommon.getFunctions(args.xml_files)
|
||||
xmlByName = dict((f.name, f) for f in xmlFunctions)
|
||||
functions = []
|
||||
for (name, eglFunc) in eglFunctionList.EGL_FUNCTIONS:
|
||||
if not args.bind_wl_display and "Wayland" in name:
|
||||
continue
|
||||
func = xmlByName[name]
|
||||
eglFunc = fixupEglFunc(func, eglFunc)
|
||||
functions.append((func, eglFunc))
|
||||
|
||||
# Sort the function list by name.
|
||||
functions = sorted(functions, key=lambda f: f[0].name)
|
||||
|
||||
if args.target == "header":
|
||||
text = generateHeader(functions)
|
||||
elif args.target == "source":
|
||||
text = generateSource(functions)
|
||||
sys.stdout.write(text)
|
||||
|
||||
|
||||
def fixupEglFunc(func, eglFunc):
|
||||
result = dict(eglFunc)
|
||||
if result.get("prefix") is None:
|
||||
result["prefix"] = ""
|
||||
|
||||
if result.get("extension") is not None:
|
||||
text = "defined(" + result["extension"] + ")"
|
||||
result["extension"] = text
|
||||
|
||||
if result["method"] in ("none", "custom"):
|
||||
return result
|
||||
|
||||
if result["method"] not in ("display", "device", "current"):
|
||||
raise ValueError("Invalid dispatch method %r for function %r" %
|
||||
(result["method"], func.name))
|
||||
|
||||
if func.hasReturn():
|
||||
if result.get("retval") is None:
|
||||
result["retval"] = getDefaultReturnValue(func.rt)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def generateHeader(functions):
|
||||
text = textwrap.dedent(r"""
|
||||
#ifndef G_EGLDISPATCH_STUBS_H
|
||||
#define G_EGLDISPATCH_STUBS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <EGL/eglmesaext.h>
|
||||
#include <EGL/eglext_angle.h>
|
||||
#include <GL/mesa_glinterop.h>
|
||||
#include "glvnd/libeglabi.h"
|
||||
|
||||
""".lstrip("\n"))
|
||||
|
||||
text += "enum {\n"
|
||||
for (func, eglFunc) in functions:
|
||||
text += generateGuardBegin(func, eglFunc)
|
||||
text += " __EGL_DISPATCH_" + func.name + ",\n"
|
||||
text += generateGuardEnd(func, eglFunc)
|
||||
text += " __EGL_DISPATCH_COUNT\n"
|
||||
text += "};\n"
|
||||
|
||||
for (func, eglFunc) in functions:
|
||||
if eglFunc["inheader"]:
|
||||
text += generateGuardBegin(func, eglFunc)
|
||||
text += "{f.rt} EGLAPIENTRY {ex[prefix]}{f.name}({f.decArgs});\n".format(
|
||||
f=func, ex=eglFunc)
|
||||
text += generateGuardEnd(func, eglFunc)
|
||||
|
||||
text += textwrap.dedent(r"""
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // G_EGLDISPATCH_STUBS_H
|
||||
""")
|
||||
return text
|
||||
|
||||
|
||||
def generateSource(functions):
|
||||
# First, sort the function list by name.
|
||||
text = ""
|
||||
text += '#include "egldispatchstubs.h"\n'
|
||||
text += '#include "g_egldispatchstubs.h"\n'
|
||||
text += '#include <stddef.h>\n'
|
||||
text += "\n"
|
||||
|
||||
for (func, eglFunc) in functions:
|
||||
if eglFunc["method"] not in ("custom", "none"):
|
||||
text += generateGuardBegin(func, eglFunc)
|
||||
text += generateDispatchFunc(func, eglFunc)
|
||||
text += generateGuardEnd(func, eglFunc)
|
||||
|
||||
text += "\n"
|
||||
text += "const char * const __EGL_DISPATCH_FUNC_NAMES[__EGL_DISPATCH_COUNT + 1] = {\n"
|
||||
for (func, eglFunc) in functions:
|
||||
text += generateGuardBegin(func, eglFunc)
|
||||
text += ' "' + func.name + '",\n'
|
||||
text += generateGuardEnd(func, eglFunc)
|
||||
text += " NULL\n"
|
||||
text += "};\n"
|
||||
|
||||
text += "const __eglMustCastToProperFunctionPointerType __EGL_DISPATCH_FUNCS[__EGL_DISPATCH_COUNT + 1] = {\n"
|
||||
for (func, eglFunc) in functions:
|
||||
text += generateGuardBegin(func, eglFunc)
|
||||
if eglFunc["method"] != "none":
|
||||
text += " (__eglMustCastToProperFunctionPointerType) " + \
|
||||
eglFunc.get("prefix", "") + func.name + ",\n"
|
||||
else:
|
||||
text += " NULL, // " + func.name + "\n"
|
||||
text += generateGuardEnd(func, eglFunc)
|
||||
text += " NULL\n"
|
||||
text += "};\n"
|
||||
|
||||
return text
|
||||
|
||||
|
||||
def generateGuardBegin(func, eglFunc):
|
||||
ext = eglFunc.get("extension")
|
||||
if ext is not None:
|
||||
return "#if " + ext + "\n"
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def generateGuardEnd(func, eglFunc):
|
||||
if eglFunc.get("extension") is not None:
|
||||
return "#endif\n"
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def generateDispatchFunc(func, eglFunc):
|
||||
text = ""
|
||||
|
||||
if eglFunc.get("static"):
|
||||
text += "static "
|
||||
elif eglFunc.get("public"):
|
||||
text += "PUBLIC "
|
||||
text += textwrap.dedent(
|
||||
r"""
|
||||
{f.rt} EGLAPIENTRY {ef[prefix]}{f.name}({f.decArgs})
|
||||
{{
|
||||
typedef {f.rt} EGLAPIENTRY (* _pfn_{f.name})({f.decArgs});
|
||||
""").lstrip("\n").format(f=func, ef=eglFunc)
|
||||
|
||||
if func.hasReturn():
|
||||
text += " {f.rt} _ret = {ef[retval]};\n".format(f=func, ef=eglFunc)
|
||||
|
||||
text += " _pfn_{f.name} _ptr_{f.name} = (_pfn_{f.name}) ".format(f=func)
|
||||
if eglFunc["method"] == "current":
|
||||
text += "__eglDispatchFetchByCurrent(__EGL_DISPATCH_{f.name});\n".format(
|
||||
f=func)
|
||||
|
||||
elif eglFunc["method"] in ("display", "device"):
|
||||
if eglFunc["method"] == "display":
|
||||
lookupFunc = "__eglDispatchFetchByDisplay"
|
||||
lookupType = "EGLDisplay"
|
||||
else:
|
||||
assert eglFunc["method"] == "device"
|
||||
lookupFunc = "__eglDispatchFetchByDevice"
|
||||
lookupType = "EGLDeviceEXT"
|
||||
|
||||
lookupArg = None
|
||||
for arg in func.args:
|
||||
if arg.type == lookupType:
|
||||
lookupArg = arg.name
|
||||
break
|
||||
if lookupArg is None:
|
||||
raise ValueError("Can't find %s argument for function %s" %
|
||||
(lookupType, func.name,))
|
||||
|
||||
text += "{lookupFunc}({lookupArg}, __EGL_DISPATCH_{f.name});\n".format(
|
||||
f=func, lookupFunc=lookupFunc, lookupArg=lookupArg)
|
||||
else:
|
||||
raise ValueError("Unknown dispatch method: %r" % (eglFunc["method"],))
|
||||
|
||||
text += " if(_ptr_{f.name} != NULL) {{\n".format(f=func)
|
||||
text += " "
|
||||
if func.hasReturn():
|
||||
text += "_ret = "
|
||||
text += "_ptr_{f.name}({f.callArgs});\n".format(f=func)
|
||||
text += " }\n"
|
||||
|
||||
if func.hasReturn():
|
||||
text += " return _ret;\n"
|
||||
text += "}\n"
|
||||
return text
|
||||
|
||||
|
||||
def getDefaultReturnValue(typename):
|
||||
if typename.endswith("*"):
|
||||
return "NULL"
|
||||
elif typename == "EGLDisplay":
|
||||
return "EGL_NO_DISPLAY"
|
||||
elif typename == "EGLContext":
|
||||
return "EGL_NO_CONTEXT"
|
||||
elif typename == "EGLSurface":
|
||||
return "EGL_NO_SURFACE"
|
||||
elif typename == "EGLBoolean":
|
||||
return "EGL_FALSE"
|
||||
|
||||
return "0"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user