Blame interface/eglexternalplatformversion.h

rpm-build 87357e
/*
rpm-build 87357e
 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
rpm-build 87357e
 *
rpm-build 87357e
 * Permission is hereby granted, free of charge, to any person obtaining a
rpm-build 87357e
 * copy of this software and associated documentation files (the "Software"),
rpm-build 87357e
 * to deal in the Software without restriction, including without limitation
rpm-build 87357e
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
rpm-build 87357e
 * and/or sell copies of the Software, and to permit persons to whom the
rpm-build 87357e
 * Software is furnished to do so, subject to the following conditions:
rpm-build 87357e
 *
rpm-build 87357e
 * The above copyright notice and this permission notice shall be included in
rpm-build 87357e
 * all copies or substantial portions of the Software.
rpm-build 87357e
 *
rpm-build 87357e
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
rpm-build 87357e
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
rpm-build 87357e
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
rpm-build 87357e
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
rpm-build 87357e
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
rpm-build 87357e
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
rpm-build 87357e
 * DEALINGS IN THE SOFTWARE.
rpm-build 87357e
 */
rpm-build 87357e
rpm-build 87357e
#ifndef EGL_EXTERNAL_PLATFORM_VERSION_H
rpm-build 87357e
#define EGL_EXTERNAL_PLATFORM_VERSION_H
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * <EGL_EXTERNAL_PLATFORM_VERSION_MAJOR>.<EGL_EXTERNAL_PLATFORM_VERSION_MINOR>
rpm-build 87357e
 * defines the EGL external platform interface version.
rpm-build 87357e
 *
rpm-build 87357e
 * The includer of this file can override either
rpm-build 87357e
 * EGL_EXTERNAL_PLATFORM_VERSION_MAJOR or EGL_EXTERNAL_PLATFORM_VERSION_MINOR in
rpm-build 87357e
 * order to build against a certain EGL external platform interface version.
rpm-build 87357e
 *
rpm-build 87357e
 * Note that, if only EGL_EXTERNAL_PLATFORM_VERSION_MAJOR is overridden, the
rpm-build 87357e
 * least possible value for EGL_EXTERNAL_PLATFORM_VERSION_MINOR is taken.
rpm-build 87357e
 *
rpm-build 87357e
 *
rpm-build 87357e
 * How to update these version numbers:
rpm-build 87357e
 *
rpm-build 87357e
 *  - If a backwards-compatible change is made to the interface, increase
rpm-build 87357e
 *    EGL_EXTERNAL_PLATFORM_VERSION_MINOR by 1
rpm-build 87357e
 *
rpm-build 87357e
 *  - If backwards-compatibility is broken by a change, increase
rpm-build 87357e
 *    EGL_EXTERNAL_PLATFORM_VERSION_MAJOR by 1 and set
rpm-build 87357e
 *    EGL_EXTERNAL_PLATFORM_VERSION_MINOR to 0 (keep these kind of changes to
rpm-build 87357e
 *    the minimum)
rpm-build 87357e
 */
rpm-build 87357e
#if !defined(EGL_EXTERNAL_PLATFORM_VERSION_MAJOR)
rpm-build 87357e
 #define EGL_EXTERNAL_PLATFORM_VERSION_MAJOR                      1
rpm-build 87357e
 #if !defined(EGL_EXTERNAL_PLATFORM_VERSION_MINOR)
rpm-build 87357e
  #define EGL_EXTERNAL_PLATFORM_VERSION_MINOR                     1
rpm-build 87357e
 #endif
rpm-build 87357e
#elif !defined(EGL_EXTERNAL_PLATFORM_VERSION_MINOR)
rpm-build 87357e
 #define EGL_EXTERNAL_PLATFORM_VERSION_MINOR                      0
rpm-build 87357e
#endif
rpm-build 87357e
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * EGL_EXTERNAL_PLATFORM_VERSION_CMP
rpm-build 87357e
 *
rpm-build 87357e
 * Helper macro to compare two different version numbers. It evaluates to true
rpm-build 87357e
 * if <_MAJOR1_>.<_MINOR1_> is compatible with <_MAJOR2_>.<_MINOR2_>
rpm-build 87357e
 */
rpm-build 87357e
#define EGL_EXTERNAL_PLATFORM_VERSION_CMP(_MAJOR1_, _MINOR1_, _MAJOR2_, _MINOR2_) \
rpm-build 87357e
    (((_MAJOR1_) == (_MAJOR2_)) && ((_MINOR1_) >= (_MINOR2_)))
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * EGL_EXTERNAL_PLATFORM_VERSION_CHECK
rpm-build 87357e
 *
rpm-build 87357e
 * Helper macro to check whether the current EGL external platform interface
rpm-build 87357e
 * version is compatible with the given version number <_MAJOR_>.<_MINOR_>
rpm-build 87357e
 */
rpm-build 87357e
#define EGL_EXTERNAL_PLATFORM_VERSION_CHECK(_MAJOR_, _MINOR_)              \
rpm-build 87357e
    EGL_EXTERNAL_PLATFORM_VERSION_CMP(EGL_EXTERNAL_PLATFORM_VERSION_MAJOR, \
rpm-build 87357e
                                      EGL_EXTERNAL_PLATFORM_VERSION_MINOR, \
rpm-build 87357e
                                      _MAJOR_, _MINOR_)
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * EGL_EXTERNAL_PLATFORM_HAS
rpm-build 87357e
 *
rpm-build 87357e
 * Helper macro to check whether the current EGL external platform interface
rpm-build 87357e
 * version implements the given feature <_FEATURE_>
rpm-build 87357e
 */
rpm-build 87357e
#define EGL_EXTERNAL_PLATFORM_HAS(_FEATURE_)                                                 \
rpm-build 87357e
    EGL_EXTERNAL_PLATFORM_VERSION_CHECK(EGL_EXTERNAL_PLATFORM_ ## _FEATURE_ ## _SINCE_MAJOR, \
rpm-build 87357e
                                        EGL_EXTERNAL_PLATFORM_ ## _FEATURE_ ## _SINCE_MINOR)
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * EGL_EXTERNAL_PLATFORM_SUPPORTS
rpm-build 87357e
 *
rpm-build 87357e
 * Helper macro to check whether the given EGL external platform interface
rpm-build 87357e
 * version number <_MAJOR_>.<_MINOR_> supports the given feature <_FEATURE_>
rpm-build 87357e
 */
rpm-build 87357e
#define EGL_EXTERNAL_PLATFORM_SUPPORTS(_MAJOR_, _MINOR_, _FEATURE_)                        \
rpm-build 87357e
    EGL_EXTERNAL_PLATFORM_VERSION_CMP(_MAJOR_, _MINOR_,                                    \
rpm-build 87357e
                                      EGL_EXTERNAL_PLATFORM_ ## _FEATURE_ ## _SINCE_MAJOR, \
rpm-build 87357e
                                      EGL_EXTERNAL_PLATFORM_ ## _FEATURE_ ## _SINCE_MINOR)
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * List of supported features
rpm-build 87357e
 *
rpm-build 87357e
 * Whenever a new feature/function is added to the EGL external platform
rpm-build 87357e
 * interface, along with the corresponding version number bump, a pair of
rpm-build 87357e
 * 
rpm-build 87357e
 * NAME"_SINCE_MAJOR>.<EGL_EXTERNAL_PLATFORM_"FEATURE NAME"_SINCE_MINOR> numbers
rpm-build 87357e
 * must be added.
rpm-build 87357e
 *
rpm-build 87357e
 * All new symbols and usages of the new feature/function must be protected with
rpm-build 87357e
 * EGL_EXTERNAL_PLATFORM_HAS(<feature-name>).
rpm-build 87357e
 *
rpm-build 87357e
 * Additionally, any external platform implementation that supports the new
rpm-build 87357e
 * feature/function, must also protect the corresponding export initialization
rpm-build 87357e
 * in function 'loadEGLExternalPlatform()' with
rpm-build 87357e
 * EGL_EXTERNAL_PLATFORM_SUPPORTS(<major>, <minor>, <feature-name>) using the
rpm-build 87357e
 * given version number.
rpm-build 87357e
 *
rpm-build 87357e
 * Example:
rpm-build 87357e
 *
rpm-build 87357e
 *    In eglexternalplatformversion.h:
rpm-build 87357e
 *
rpm-build 87357e
 *        #define EGL_EXTERNAL_PLATFORM_FOO_SINCE_MAJOR 1
rpm-build 87357e
 *        #define EGL_EXTERNAL_PLATFORM_FOO_SINCE_MINOR 0
rpm-build 87357e
 *
rpm-build 87357e
 *    In eglexternalplatform.h:
rpm-build 87357e
 *
rpm-build 87357e
 *        #if EGL_EXTERNAL_PLATFORM_HAS(FOO)
rpm-build 87357e
 *        typedef void* (*PEGLEXTFNFOO)(void *fooAttr);
rpm-build 87357e
 *        #endif
rpm-build 87357e
 *
rpm-build 87357e
 *        sitruct EGLExtPlatformExports {
rpm-build 87357e
 *            [...]
rpm-build 87357e
 *
rpm-build 87357e
 *        #if EGL_EXTERNAL_PLATFORM_HAS(FOO)
rpm-build 87357e
 *            PEGLEXTFNFOO foo;
rpm-build 87357e
 *        #endif
rpm-build 87357e
 *        };
rpm-build 87357e
 *
rpm-build 87357e
 *    In platform's loadEGLExternalPlatform() implementation:
rpm-build 87357e
 *
rpm-build 87357e
 *        EGLBoolean loadEGLExternalPlatform(int major, int minor,
rpm-build 87357e
 *                                           const EGLExtDriver *driver,
rpm-build 87357e
 *                                           EGLExtPlatform *platform)
rpm-build 87357e
 *        {
rpm-build 87357e
 *            if (!EGL_EXTERNAL_PLATFORM_VERSION_CHECK(major, minor)) {
rpm-build 87357e
 *                return EGL_FALSE;
rpm-build 87357e
 *            }
rpm-build 87357e
 *
rpm-build 87357e
 *            [...]
rpm-build 87357e
 *
rpm-build 87357e
 *        #if EGL_EXTERNAL_PLATFORM_HAS(FOO)
rpm-build 87357e
 *            if (EGL_EXTERNAL_PLATFORM_SUPPORTS(major, minor, FOO)) {
rpm-build 87357e
 *                platform->exports.foo = fooImpl;
rpm-build 87357e
 *            }
rpm-build 87357e
 *        #endif
rpm-build 87357e
 *
rpm-build 87357e
 *            [...]
rpm-build 87357e
 *        }
rpm-build 87357e
 */
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * DRIVER_VERSION
rpm-build 87357e
 *
rpm-build 87357e
 * <major> and <minor> fields added to EGLExtDriver for drivers to let the
rpm-build 87357e
 * external platform know the supported EGL version
rpm-build 87357e
 */
rpm-build 87357e
#define EGL_EXTERNAL_PLATFORM_DRIVER_VERSION_SINCE_MAJOR 1
rpm-build 87357e
#define EGL_EXTERNAL_PLATFORM_DRIVER_VERSION_SINCE_MINOR 1
rpm-build 87357e
rpm-build 87357e
#endif // EGL_EXTERNAL_PLATFORM_VERSION_H