From 3bb7ebfc7504af0e85596f3ad4b72a2ede10d227 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 16 Oct 2020 16:17:54 -0400 Subject: [PATCH] glx: move __glXGetUST into the DRI1 code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is only used from the __DRI_SYSTEM_TIME loader extension, which only the DRI1 drivers ever looked for. Reviewed-by: Michel Dänzer Part-of: --- src/glx/dri_common.c | 17 ----------------- src/glx/dri_common.h | 2 -- src/glx/dri_glx.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/glx/glxclient.h | 3 --- src/glx/glxcmds.c | 35 ----------------------------------- 5 files changed, 50 insertions(+), 57 deletions(-) diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index a5fae27..bcab5f6 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -114,23 +114,6 @@ driOpenDriver(const char *driverName, void **out_driver_handle) return extensions; } -static GLboolean -__driGetMSCRate(__DRIdrawable *draw, - int32_t * numerator, int32_t * denominator, - void *loaderPrivate) -{ - __GLXDRIdrawable *glxDraw = loaderPrivate; - - return __glxGetMscRate(glxDraw->psc, numerator, denominator); -} - -_X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = { - .base = {__DRI_SYSTEM_TIME, 1 }, - - .getUST = __glXGetUST, - .getMSCRate = __driGetMSCRate -}; - #define __ATTRIB(attrib, field) \ { attrib, offsetof(struct glx_config, field) } diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h index 6c634d8..24af8a9 100644 --- a/src/glx/dri_common.h +++ b/src/glx/dri_common.h @@ -63,8 +63,6 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable); extern void driReleaseDrawables(struct glx_context *gc); -extern const __DRIsystemTimeExtension systemTimeExtension; - extern void dri_message(int level, const char *f, ...) PRINTFLIKE(2, 3); #define InfoMessageF(...) dri_message(_LOADER_INFO, __VA_ARGS__) diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c index 3e08735..53de8f0 100644 --- a/src/glx/dri_glx.c +++ b/src/glx/dri_glx.c @@ -42,6 +42,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "dri2.h" #include "dri_sarea.h" #include +#include #include #include #include "xf86drm.h" @@ -278,6 +279,55 @@ out: return e ? e->config : NULL; } +/** + * Get the unadjusted system time (UST). Currently, the UST is measured in + * microseconds since Epoc. The actual resolution of the UST may vary from + * system to system, and the units may vary from release to release. + * Drivers should not call this function directly. They should instead use + * \c glXGetProcAddress to obtain a pointer to the function. + * + * \param ust Location to store the 64-bit UST + * \returns Zero on success or a negative errno value on failure. + * + * \sa glXGetProcAddress, PFNGLXGETUSTPROC + * + * \since Internal API version 20030317. + */ +static int +__glXGetUST(int64_t * ust) +{ + struct timeval tv; + + if (ust == NULL) { + return -EFAULT; + } + + if (gettimeofday(&tv, NULL) == 0) { + ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec; + return 0; + } + else { + return -errno; + } +} + +static GLboolean +__driGetMSCRate(__DRIdrawable *draw, + int32_t * numerator, int32_t * denominator, + void *loaderPrivate) +{ + __GLXDRIdrawable *glxDraw = loaderPrivate; + + return __glxGetMscRate(glxDraw->psc, numerator, denominator); +} + +static const __DRIsystemTimeExtension systemTimeExtension = { + .base = {__DRI_SYSTEM_TIME, 1 }, + + .getUST = __glXGetUST, + .getMSCRate = __driGetMSCRate +}; + static GLboolean has_damage_post(Display * dpy) { diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 41edf17..ea7668f 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -775,9 +775,6 @@ extern char *__glXGetString(Display * dpy, int opcode, extern const char __glXGLClientVersion[]; extern const char __glXGLClientExtensions[]; -/* Get the unadjusted system time */ -extern int __glXGetUST(int64_t * ust); - extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, int32_t * numerator, int32_t * denominator); diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index a8c51cb..4b96b38 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -45,7 +45,6 @@ #include "apple/apple_glx.h" #include "util/debug.h" #else -#include #ifndef GLX_USE_WINDOWSGL #include #endif /* GLX_USE_WINDOWSGL */ @@ -2650,40 +2649,6 @@ GLX_ALIAS(__GLXextFuncPtr, glXGetProcAddress, (procName), glXGetProcAddressARB) #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) -/** - * Get the unadjusted system time (UST). Currently, the UST is measured in - * microseconds since Epoc. The actual resolution of the UST may vary from - * system to system, and the units may vary from release to release. - * Drivers should not call this function directly. They should instead use - * \c glXGetProcAddress to obtain a pointer to the function. - * - * \param ust Location to store the 64-bit UST - * \returns Zero on success or a negative errno value on failure. - * - * \sa glXGetProcAddress, PFNGLXGETUSTPROC - * - * \since Internal API version 20030317. - */ -_X_HIDDEN int -__glXGetUST(int64_t * ust) -{ - struct timeval tv; - - if (ust == NULL) { - return -EFAULT; - } - - if (gettimeofday(&tv, NULL) == 0) { - ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec; - return 0; - } - else { - return -errno; - } -} -#endif /* GLX_DIRECT_RENDERING */ - -#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) PUBLIC int MesaGLInteropGLXQueryDeviceInfo(Display *dpy, GLXContext context, -- 2.7.4