1. 21 Aug, 2020 1 commit
    • Adam Jackson's avatar
      GLdispatch: Export __glDispatchSetCurrentThreadState · 8ece1971
      Adam Jackson authored
      This seems to be the shortest path to getting Delay working. It's kind
      of playing with fire, hence the warning, but it does seem to work if
      you're careful.
      
      Another option that I considered was to use dlmopen() to put libEGL into
      its own link map (and thus own TLS scope). That doesn't work because of
      dlmopen bugs, and wouldn't be portable outside of glibc and Solaris.
      
      Another another option I consider was to add a new GLDISPATCH_API_BLAH
      enum and teach the frontend libraries to handle it. This got ugly
      quickly, in part because I think that ends up wanting additional API
      between the frontend and vendor library without having a good way to
      signal from the frontend that that API is available. So if we're adding
      API anyway, simply exporting one function we already have seems quite a
      bit simpler.
      8ece1971
  2. 24 Oct, 2016 1 commit
    • Kyle Brenneman's avatar
      Fix a crash in process termination when EGL and GLX are both loaded. · 61bd107c
      Kyle Brenneman authored
      Added a new function to libGLdispatch, __glDispatchForceUnpatch, which forces
      it to unpatch the OpenGL entrypoints before libEGL or libGLX can unload the
      vendor library that patched them.
      
      If a vendor patches the OpenGL entrypoints, libGLdispatch doesn't unpatch them
      when that vendor's context is no longer current, because that adds too much
      overhead to repeated MakeCurrent+LoseCurrent calls. But, that also means that
      the patch callbacks end up being dangling pointers after the vendor library is
      unloaded.
      
      This mainly shows up at process termination when a process loads both libEGL
      and libGLX, because __glxFini and __eglFini will both call the vendor's
      threadAttach callback.
      
      Fixes https://github.com/NVIDIA/libglvnd/issues/103
      61bd107c
  3. 24 Mar, 2016 1 commit
  4. 10 Mar, 2016 1 commit
  5. 13 Jan, 2016 1 commit
    • Kyle Brenneman's avatar
      Install the public header files. · ec97db77
      Kyle Brenneman authored
      Two header files (libglxabi.h and GLdispatchABI.h) are public -- intended to be
      used by vendor libraries, while the other headers are all internal to libglvnd.
      
      Move the public header files to a new directory, include/glvnd.
      
      Add a makefile so that the public headers are installed by make install.
      ec97db77
  6. 01 Oct, 2015 1 commit
  7. 10 Sep, 2015 1 commit
    • Kyle Brenneman's avatar
      libGLdispatch: Remove __glDispatchGetOffset and __glDispatchSetEntry. · b9aa37bd
      Kyle Brenneman authored
      Removed __glDispatchGetOffset and __glDispatchSetEntry from libGLdispatch.
      Neither one is used anywhere, and the dispatch offsets should be an internal
      detail of libGLdispatch.
      
      Removed the mutex from stub_find_dynamic. Anything that calls that function
      should already be holding the GLdispatch lock.
      
      Also removed the __GLdispatchGetOffsetHook, since nothing uses it anymore.
      b9aa37bd
  8. 23 Jul, 2015 2 commits
  9. 16 Jul, 2015 1 commit
  10. 10 Jul, 2015 1 commit
    • Kyle Brenneman's avatar
      libGLdispatch: Add an ABI version number. · 503f3474
      Kyle Brenneman authored
      Add a version number for the interface between libGLX and libGLdispatch, which
      libGLX checks during initialization.
      
      The interface between libGLX and libGLdispatch can and should be a stable ABI,
      so that it's more resiliant to version mismatches if they come from different
      packages or installers.
      
      The version number is mainly a sanity check in case some future version of
      libGLdispatch does change the interface.
      503f3474
  11. 23 Jun, 2015 1 commit
  12. 15 Jun, 2015 1 commit
  13. 13 Jun, 2015 1 commit
    • Kyle Brenneman's avatar
      Remove __GLdispatchAPIState::context. · 161f3f05
      Kyle Brenneman authored
      Remvoved the context member of __GLdispatchAPIState, and instead added a new
      currentContext member to __GLXAPIState.
      
      libGLdispatch only needs the API state pointer, not the window system's context
      handle.
      
      This also removes the ill-defined case where a thread could have a current API
      state but not a current context.
      161f3f05
  14. 12 Jun, 2015 1 commit
    • Kyle Brenneman's avatar
      Remove __GLdispatchAPIState::id. · d351b4c1
      Kyle Brenneman authored
      The "id" member of __GLdispatchAPIState isn't used anywhere in libGLdispatch,
      so it doesn't need to be part of libGLdispatch's interface.
      
      Instead, libGLX now stores the thread ID in __GLXAPIState::tid.
      d351b4c1
  15. 08 Jun, 2015 1 commit
    • Kyle Brenneman's avatar
      Remove the TSD key from libGLX. · 302595a5
      Kyle Brenneman authored
      Added a pointer to a callback function __GLdispatchAPIState to notify the
      window system library of thread termination.
      
      Removed tsdContextKey from libglx.c. It now uses the API state stored in
      libGLdispatch and the callback function in __GLdispatchAPIState instead.
      
      libGLX will now free the __GLXAPIState struct for a thread when the thread
      terminates, instead of waiting until __glXAPITeardown.
      
      Fixes issue #35
      302595a5
  16. 05 Jun, 2015 1 commit
    • Kyle Brenneman's avatar
      libGLdispatch: Add a TSD key for the current context. · d39c4006
      Kyle Brenneman authored
      Add a glvnd_key_t key to GLdispatch.c to hold the current API state.
      
      __glDispatchGetCurrentAPIState and __glDispatchGetCurrentContext are now normal
      exported functions instead of wrappers around _glapi_get_current.
      
      Removed _glapi_get_current, _glapi_set_current, _glapi_get_context,
      _glapi_set_context, and their associated functions in u_current.c.
      
      Removed the U_CURRENT_* constants and replaced them with the corresponding
      GLAPI_CURRENT_* constants.
      
      Removed the GLAPI_CURRENT_* enums except for GLAPI_CURRENT_DISPATCH.
      d39c4006
  17. 01 Apr, 2015 1 commit
  18. 28 Oct, 2014 1 commit
    • Brian Nguyen's avatar
      Add __glDispatch{Fini,Reset}() · 81523012
      Brian Nguyen authored
      
      
      __glDispatchFini() is called by a GLdispatch client to clean up
      GLdispatch-internal state when the client is done using GLdispatch
      functionality.
      
      __glDispatchReset() is called by a GLdispatch client to determine
      whether fork recovery is needed, and handle the fork if necessary.
      
      Signed-off-by: default avatarBrian Nguyen <brnguyen@nvidia.com>
      81523012
  19. 24 Jan, 2014 3 commits
    • Brian Nguyen's avatar
      [GLdispatch] Patch entrypoints on make current · 3fa81a5f
      Brian Nguyen authored
      Modify __glDispatchMakeCurrent() to take a pointer to the patch
      callbacks for the vendor library whose context is about to be current.
      
      Implement GLdispatch.c:PatchEntrypoints() and helpers.  This contains
      the logic for determining whether it is safe to patch entrypoints, and
      using the provided vendor callbacks to actually do the entrypoint
      patching.  Call this from __glDispatchMakeCurrent() with the provided
      patch callbacks.
      
      Also implement GLdispatch.c:CurrentEntrypointsSafeToUse(), which
      determines based on the current vendor ID whether the current top-level
      code is safe to use with that vendor.  If this check fails, the make
      current operation fails.
      
      Allow users to disable entrypoint rewriting functionality by setting the
      environment variable __GLVND_DISALLOW_PATCHING=1.
      
      When losing current, also attempt to restore the default libglvnd
      entrypoints so other vendors can potentially use them.
      3fa81a5f
    • Brian Nguyen's avatar
      [GLdispatch] Implement API for registering top-level dispatch stubs · 8225879a
      Brian Nguyen authored
      This allows vendor libraries to potentially overwrite the static
      entrypoints of wrapper libraries (such as libGL and libOpenGL) at make
      current time, in addition to the main GLdispatch entrypoints.
      8225879a
    • Brian Nguyen's avatar
      Register vendors with GLdispatch · a033f25b
      Brian Nguyen authored
      This implements the notion of a "vendor ID" that is unique to each
      vendor library instance loaded in a process.  When entrypoint rewriting
      is implemented, this will be used by libglvnd to determine whether a
      given entrypoint implementation is compatible with a given context, by
      comparing the vendor owning the context with the vendor owning the
      implementation.
      
      This changes the function prototype of __glDispatchMakeCurrent()
      to include the vendorID as an argument, which will be saved off in the
      API state, and return a boolean value to indicate whether make current
      succeeded.
      a033f25b
  20. 27 Nov, 2013 1 commit
    • Brian Nguyen's avatar
      Simplify vendor-library ABI for libglx · 7a25ae54
      Brian Nguyen authored
      
      
      - Pull GL dispatch callback typedefs into GLdispatchABI.h.  This is
        a common header which will be shared between the libGLX and libEGL
        ABIs.
      
      - Add extern "C" blocks to libglxabi.h and GLdispatchABI.h so these
        headers may be used with vendor libraries that are built C++.
      
      - Remove support for auxiliary dispatch table management
        (libglxgldispatch.[ch] and __GLdispatchExports).  This can be added
        back in later on if it proves useful.
      
      - In libglxmappings.c, replace static initialization of glxExportsTable
        with one-time runtime initialization of the table.
      
      - In libglxmappings.c, use __glDispatchCreateTable() directly to create
        the initial dispatch table.
      
      - In libglxnoopdefs.h, remove unnecessary includes of libglxabipriv.h
        and libglxnoop.h.
      
      - Add screen mapping functions to the GLX exports table.  Some extension
        functions not implemented by libglvnd, e.g. glXCreateContextAttribsARB()
        from GLX_ARB_create_context, may need to update the mappings from
        context or drawable to screen that are managed by libglvnd in order to
        work properly.  Additionally, dispatch functions implemented by vendor
        libraries for GLX extension functions may want to query these mappings
        in order to properly dispatch the call.
      
      - Remove the getDispatchProto() vendor callback.  This is not needed by
        libglvnd since libglvnd does not support mapping more than one
        entrypoint to a single dispatch stub.  See GLdispatch.c for the
        rationale behind this decision.
      
      - Remove redundant typedefs to prevent build errors.
      
      - Delete the vendorData parameter from the getProcAddress() vendor
        callback, which isn't useful if there is no support for more than one
        libglvnd dispatch table per context.  Add the isClientAPI parameter,
        which can be used to distinguish between getProcAddress() requests for
        GLX functions versus getProcAddress() requests for client API
        functions.
      
      - Remove the "screen" argument from Remove.*Mapping() functions.  This
        is unnecessary, as the hash key used to lookup the mapping object in
        libglvnd's hashtables doesn't depend on the screen (which is the hash
        value).  It's problematic since in some cases we don't actually know
        the value of the screen mapped to by a key.
      
      Signed-off-by: default avatarBrian Nguyen <brnguyen@nvidia.com>
      7a25ae54
  21. 25 Nov, 2013 1 commit
    • Brian Nguyen's avatar
      Add context, dispatch parameters to __glDispatchMakeCurrent() · 4628149a
      Brian Nguyen authored
      
      
      When making current, assign the API state's new context and dispatch table
      in GLdispatch rather than GLX.  This avoids consistency issues if the API state
      is unchanged but the current dispatch or context may have changed.
      
      Update the __glDispatchMakeCurrent() call in
      __glXMakeGLDispatchCurrent() to get libglvnd building for now; a later change
      will remove libglxgldispatch.c altogether.
      
      Signed-off-by: default avatarBrian Nguyen <brnguyen@nvidia.com>
      4628149a
  22. 26 Aug, 2013 4 commits
    • Brian Nguyen's avatar
      [mapi] Implement _glapi_{set,get}_current() · efa8ca15
      Brian Nguyen authored
      This replaces the _glapi_tls_{Dispatch,Context} symbols with a single
      symbol, _glapi_tls_Current, which references an array of type (void*).
      This allows us to easily extend mapi to accomodate additional TLS
      entries, which will be necessary for storing current API state and
      allowing vendors to utilize TLS entries for their own purposes.
      
      This change is rather messy. It requires modification to both the
      dispatch stub generation code and mapi's compatibility #defines in
      u_current.h. This could probably be cleaned up in later changes. It's
      not clear whether _glapi_{set,get}_{dispatch,context}() are even needed
      anymore, but they are kept in place for backwards compatibility and to
      keep this change as self-contained as possible.
      efa8ca15
    • Brian Nguyen's avatar
      [GLdispatch] Write pseudo-code implementations of API · 810c4343
      Brian Nguyen authored
      This adds comments and (incomplete) code to describe the general
      strategy which will be taken to implement the GLdispatch API. This
      is still a WIP.
      810c4343
    • Brian Nguyen's avatar
      Add GLdispatch DSO · 8b3953b2
      Brian Nguyen authored
      Move the GLdispatch header file to its own directory in src/GLdispatch,
      and build a real DSO that GLX will depend on. In GLdispatch.c, add stub
      functions which will later be fleshed out.
      8b3953b2
    • Brian Nguyen's avatar
      [GLX] Define GLdispatch API · b459d25c
      Brian Nguyen authored
      Add a new header file, GLdispatch.h, which defines an API for
      window-system libraries such as libGLX to manage core GL dispatch tables
      as well as TLS. Refactor the __GLXAPIState to be derived from
      __GLdispatchAPIState, make __GLXvendorInfo::glDispatch type
      __GLdispatchTable, and implement make current/get current functionality
      using this API.
      
      At some point this API will be implemented in a shared library used by
      both libGLX and libEGL.
      b459d25c