1. 31 May, 2016 1 commit
    • Kyle Brenneman's avatar
      GLdispatch: Don't unpatch entrypoints in __glDispatchLoseCurrent. · 1b30d153
      Kyle Brenneman authored
      
      
      In __glDispatchLoseCurrent, don't try to restore the default entrypoints.
      Instead, __glDispatchMakeCurrent will check if it's using a different vendor
      library, and if so, it will unpatch and repatch the entrypoints then. If it's
      using the same vendor library (which will usually be the case), then it can
      leave them patched and skip the patch overhead.
      
      Some applications will call glXMakeCurrent to release and bind the same context
      every frame, sometimes multiples times. Each patch and unpatch sequnce can chew
      up 1-2 milliseconds. That's enough to significantly reduce the framerate of
      some applications.
      
      Reviewed-by: James Jones's avatarJames Jones <jajones@nvidia.com>
      1b30d153
  2. 29 Mar, 2016 1 commit
    • Kyle Brenneman's avatar
      Add support for reporting application errors. · e2d44985
      Kyle Brenneman authored
      The libglvnd libraries will now check for a new environment variable,
      __GLVND_APP_ERROR_CHECKING. If it's set to a non-zero value, then libglvnd will
      check for and report some application errors.
      
      Many non-libglvnd implementations of libGL.so have been fairly tolerant of
      certain application bugs. Libglvnd has to be similarly tolerant to support
      existing apps that the developers can't or won't fix.
      
      The new __GLVND_APP_ERROR_CHECKING provides a way to check for some of those
      errors, so that hopefully there will be fewer broken apps in the future.
      
      In addition to the setting itself, this updates the no-op stubs in
      libGLdispatch to report an error when the app tries to call an OpenGL function
      without a current context. Later changes will likely add other error checks.
      e2d44985
  3. 24 Mar, 2016 1 commit
  4. 10 Mar, 2016 1 commit
  5. 29 Feb, 2016 2 commits
    • Kyle Brenneman's avatar
      Rename a couple of functions in the ABI's. · ba1c58a5
      Kyle Brenneman authored
      Renamed __GLdispatchPatchCallbacks::checkPatchSupported to isPatchSupported,
      and renamed __GLXapiImports::checkSupportsScreen to isScreenSupported.
      ba1c58a5
    • Kyle Brenneman's avatar
      Add a threadAttach callback for entrypoint patching. · 233b274b
      Kyle Brenneman authored
      The threadAttach callback is used so that a vendor library can go through any
      thread initialization it needs to in order to deal with any later OpenGL calls.
      
      This allows a vendor library to work around broken applications that try to
      call OpenGL functions without a current context.
      233b274b
  6. 25 Feb, 2016 1 commit
  7. 21 Jan, 2016 1 commit
    • Kyle Brenneman's avatar
      GLDispatch: Initialize the dispatch table from __glDispatchCheckMultithreaded. · ba0b05a5
      Kyle Brenneman authored
      __glDispatchCheckMultithreaded will now check if the thread's current dispatch
      table is NULL, and if it is, it will plug in the no-op table.
      
      This is a workaround for some broken applications which try to call OpenGL
      functions without a current context. As long as the thread calls a GLX function
      first, any OpenGL calls it makes later will call a no-op stub instead of just
      crashing.
      
      Added calls to __glXThreadInitialize to some of the functions in
      __GLXapiExports, so that GLX extension functions will still call
      __glXThreadInitialize.
      ba0b05a5
  8. 01 Oct, 2015 1 commit
  9. 23 Sep, 2015 1 commit
    • Kyle Brenneman's avatar
      GLdispatch: Rename _glapi_get_dispatch and _glapi_set_dispatch. · 3d430714
      Kyle Brenneman authored
      Rename the functions _glapi_get_dispatch and _glapi_set_dispatch to
      _glapi_get_current and _glapi_set_current.
      
      Aside from better consistency with _glapi_Current and _glapi_tls_Current, this
      should make it easier to avoid name clashes with Mesa's GLAPI functions.
      3d430714
  10. 10 Sep, 2015 2 commits
    • Kyle Brenneman's avatar
      libGLdispatch: Assign offsets to dynamic stubs up front. · a55324d5
      Kyle Brenneman authored
      _glapi_get_proc_address (and stub_add_dynamic) will now assign an offset to a
      new dynamic stub when it's first generated, instead of waiting until
      _glapi_add_dispatch.
      
      Deferring it until _glapi_add_dispatch is only useful for handling aliases
      (where multiple functions are assigned to the same dispatch table slot), but
      libGLdispatch does not use aliases.
      
      Removed the newProcList list in GLdispatch.c. It'll now add all functions
      directly to extProcList.
      
      Removed _glapi_add_dispatch and stub_fix_dynamic.
      a55324d5
    • 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
  11. 11 Aug, 2015 2 commits
  12. 24 Jul, 2015 1 commit
  13. 23 Jul, 2015 2 commits
  14. 16 Jul, 2015 1 commit
  15. 13 Jul, 2015 1 commit
    • Kyle Brenneman's avatar
      libGLX: Remove the isClientAPI flag. · 308f5506
      Kyle Brenneman authored
      Remove the isClientAPI parameter from __GLXvendorCallbacksRec::getProcAddress.
      
      The only thing that libGLX can use to determine the the isClientAPI flag is the
      function name, which a vendor library could implement just as easily. In
      addition, since it would be possible for a GL entrypoint to start with "glX",
      the isClientAPI flag isn't always reliable.
      308f5506
  16. 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
  17. 23 Jun, 2015 2 commits
    • Kyle Brenneman's avatar
      libGLdispatch: Rework the __GLdispatchPatchCallbacks interface. · c7091414
      Kyle Brenneman authored
      Reworked the __GLdispatchPatchCallbacks interface, mostly toward fixing issue
      37.
      
      __GLdispatchPatchCallbacks::initiatePatch now handles the entire patching
      process, instead of splitting it between initiatePatch, getOffsetHook, and
      finalizePatch.
      
      Added callbacks to __GLdispatchStubPatchCallbacks that are called before and
      after calling into the vendor library to patch the entrypoints.
      
      Changed the documentation to say that the vendor library can only change the
      entrypoints during the call to initiatePatch. That'll allow libGLdispatch to
      change the memory protection before and after the app is finished modifying
      the entrypoints.
      
      The callback that a vendor library calls to fetch an entrypoint now returns
      separate writable and executable addresses.
      c7091414
    • Kyle Brenneman's avatar
      libGLdispatch: Cleanup the internal patching interface. · 7eedc37e
      Kyle Brenneman authored
      Added a __GLdispatchStubPatchCallbacks struct to hold the callback functions
      that libGLdispatch uses to patch entrypoints in each DSO.
      7eedc37e
  18. 15 Jun, 2015 1 commit
  19. 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
  20. 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
  21. 05 Jun, 2015 2 commits
    • 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
    • Kyle Brenneman's avatar
      libGLdispatch: Clean up GLAPI initialization. · b4a45f4c
      Kyle Brenneman authored
      Add a _glapi_init function to perform any initialization for the GLAPI layer.
      
      u_current_init will now initialize the TSD keys, instead of trying to create
      them when they're first used.
      
      Moved the check to multiple threads to __glDispatchCheckMultithreaded. The
      GLAPI layer now just has a _glapi_set_multithread function to tell it to
      switch to multi-threaded mode.
      
      Removed glapi/glthread.h, since nothing in it was used anywhere.
      b4a45f4c
  22. 01 Apr, 2015 1 commit
  23. 27 Mar, 2015 1 commit
  24. 06 Feb, 2015 1 commit
    • Brian Nguyen's avatar
      [GLdispatch] Widen dispatchStubListGeneration to 64-bit · ec6969bf
      Brian Nguyen authored
      There is a theoretical problem of wrapping if an application frequently
      loads and unloads an API library which registers its entrypoints with
      GLdispatch.  Proactively prevent this from being an issue by widening
      dispatchStubListGeneration, and the corresponding stubGeneration
      argument in the __GLdispatchPatchCallbacks API in GLdispatchABI.h, to
      64-bit.
      ec6969bf
  25. 29 Jan, 2015 1 commit
  26. 28 Oct, 2014 3 commits
  27. 24 Jan, 2014 6 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
      Define driver ABI for patching libglvnd entrypoints · fdf67a7d
      Brian Nguyen authored
      This defines several callbacks to be used by vendor libraries for
      rewriting top-level entrypoints defined in libglvnd:
      
      - initiatePatch(): libglvnd calls into this function at make current
        time to determine whether entrypoint patching is possible with the
        given stub type and code size.  The vendor library will notify
        libglvnd whether offsets are needed based on a generation number.
      - getOffsetHook(): libglvnd calls into the vendor library with this hook
        for each loaded interface library so the vendor can lookup the stub
        locations for rewriting.
      - finalizePatch(): libglvnd calls into this function after the vendor
        library has updated its stub locations to complete the patch.
      fdf67a7d
    • 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
    • Brian Nguyen's avatar
      Export pthreads functions from libGLdispatch, rather than libGLX · ac9d4092
      Brian Nguyen authored
      GLdispatch previously relied on locking primitives retrieved from
      libGLX, but it may be loaded and used by other interface libraries (e.g.
      libOpenGL) prior to being loaded by libGLX.  Instead, statically link
      the glvnd_pthread wrapper library in libGLdispatch and import the
      wrapper functions into libGLX when it first initializes libGLdispatch.
      ac9d4092
    • Brian Nguyen's avatar
      [GLdispatch] Track the number of current contexts · b4bdc092
      Brian Nguyen authored
      This will be useful when determining whether contexts are current on
      threads other than the current thread, for the purposes of determining
      whether entrypoint re-writing is safe.
      b4bdc092