Re: [Mesa-dev] [PATCH 1/3] dri2: Implement a throttle dri extension.
- Original Message - The X server has limited throttle support on the server side, but doing this in the client has some benefits: 1) X server throttling is per client. Client side throttling can be done per drawable. 2) It's easier to control the throttling based on what client is run, for example using driconf. 3) X server throttling requires drm swap complete events. The patches in this series looks good. Again (in the right patch series) it makes it sound like you hooked up driconf but I can't see where this is done? Reviewed-by: Jakob Bornecrantz ja...@vmware.com Cheers, Jakob. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/3] dri2: Implement a throttle dri extension.
Thanks for reviewing, Michel. On 10/11/2011 05:29 PM, Michel Dänzer wrote: On Die, 2011-10-11 at 15:44 +0200, Thomas Hellstrom wrote: The X server has limited throttle support on the server side, but doing this in the client has some benefits: 1) X server throttling is per client. Client side throttling can be done per drawable. 2) It's easier to control the throttling based on what client is run, for example using driconf. 3) X server throttling requires drm swap complete events. So implement a dri2 throttling extension intended to be used by direct rendering clients. I'm on the fence about whether it's better to add a new extension for this or to add anything missing to the flush extension instead, as the callsites are basically the same. I agree. What made me favor a new extension was that we'd have to add a new function anyway, since we pass more argument. Also the throttling extension will most likely never be called from AIGLX, since that would stall the server. @@ -390,6 +393,15 @@ dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height) (*psc-f-flush) (priv-driDrawable); #endif + if (psc-throttle) { + struct glx_context *gc = __glXGetCurrentContext(); + struct dri2_context *dri2Ctx = (struct dri2_context *)gc; + __DRIcontext *ctx = +(dri2Ctx) ? dri2Ctx-driContext : NULL; + + psc-throttle-throttle(ctx, priv-driDrawable, reason); + } + Either way though, these blocks should probably be refactored into a helper function. Sure. I'll take care of that. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/3] dri2: Implement a throttle dri extension.
On Mit, 2011-10-12 at 11:35 +0200, Thomas Hellstrom wrote: Thanks for reviewing, Michel. On 10/11/2011 05:29 PM, Michel Dänzer wrote: On Die, 2011-10-11 at 15:44 +0200, Thomas Hellstrom wrote: The X server has limited throttle support on the server side, but doing this in the client has some benefits: 1) X server throttling is per client. Client side throttling can be done per drawable. 2) It's easier to control the throttling based on what client is run, for example using driconf. 3) X server throttling requires drm swap complete events. So implement a dri2 throttling extension intended to be used by direct rendering clients. I'm on the fence about whether it's better to add a new extension for this or to add anything missing to the flush extension instead, as the callsites are basically the same. I agree. What made me favor a new extension was that we'd have to add a new function anyway, since we pass more argument. Also the throttling extension will most likely never be called from AIGLX, since that would stall the server. Ah, right. I'm convinced. :) -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] dri2: Implement a throttle dri extension.
The X server has limited throttle support on the server side, but doing this in the client has some benefits: 1) X server throttling is per client. Client side throttling can be done per drawable. 2) It's easier to control the throttling based on what client is run, for example using driconf. 3) X server throttling requires drm swap complete events. So implement a dri2 throttling extension intended to be used by direct rendering clients. Signed-off-by: Thomas Hellstrom thellst...@vmware.com --- include/GL/internal/dri_interface.h | 22 ++ src/glx/dri2_glx.c | 54 +-- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 8a9ca19..4f768f0 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -84,6 +84,7 @@ typedef struct __DRIbufferRec __DRIbuffer; typedef struct __DRIdri2ExtensionRec __DRIdri2Extension; typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension; typedef struct __DRI2flushExtensionRec __DRI2flushExtension; +typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension; /*@}*/ @@ -284,6 +285,27 @@ struct __DRI2flushExtensionRec { /** + * Extension that the driver uses to request + * throttle callbacks. + */ + +#define __DRI2_THROTTLE DRI2_Throttle +#define __DRI2_THROTTLE_VERSION 1 + +enum __DRI2throttleReason { + __DRI2_THROTTLE_SWAPBUFFER, + __DRI2_THROTTLE_COPYSUBBUFFER, + __DRI2_THROTTLE_FLUSHFRONT +}; + +struct __DRI2throttleExtensionRec { + __DRIextension base; + void (*throttle)(__DRIcontext *ctx, + __DRIdrawable *drawable, + enum __DRI2throttleReason reason); +}; + +/** * XML document describing the configuration options supported by the * driver. */ diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 01e3fd6..37da073 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -85,6 +85,7 @@ struct dri2_screen { const __DRI2flushExtension *f; const __DRI2configQueryExtension *config; const __DRItexBufferExtension *texBuffer; + const __DRI2throttleExtension *throttle; const __DRIconfig **driver_configs; void *driver; @@ -369,7 +370,9 @@ dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, #endif /* X_DRI2WaitMSC */ static void -dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height) +__dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, + int width, int height, + enum __DRI2throttleReason reason) { struct dri2_drawable *priv = (struct dri2_drawable *) pdraw; struct dri2_screen *psc = (struct dri2_screen *) pdraw-psc; @@ -390,6 +393,15 @@ dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height) (*psc-f-flush) (priv-driDrawable); #endif + if (psc-throttle) { + struct glx_context *gc = __glXGetCurrentContext(); + struct dri2_context *dri2Ctx = (struct dri2_context *)gc; + __DRIcontext *ctx = +(dri2Ctx) ? dri2Ctx-driContext : NULL; + + psc-throttle-throttle(ctx, priv-driDrawable, reason); + } + region = XFixesCreateRegion(psc-base.dpy, xrect, 1); DRI2CopyRegion(psc-base.dpy, pdraw-xDrawable, region, DRI2BufferFrontLeft, DRI2BufferBackLeft); @@ -405,6 +417,15 @@ dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height) } static void +dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, + int width, int height) +{ + __dri2CopySubBuffer(pdraw, x, y, width, height, + __DRI2_THROTTLE_COPYSUBBUFFER); +} + + +static void dri2_copy_drawable(struct dri2_drawable *priv, int dest, int src) { XRectangle xrect; @@ -458,6 +479,7 @@ dri2FlushFrontBuffer(__DRIdrawable *driDrawable, void *loaderPrivate) struct dri2_display *pdp; struct glx_context *gc; struct dri2_drawable *pdraw = loaderPrivate; + struct dri2_screen *psc; if (!pdraw) return; @@ -465,10 +487,22 @@ dri2FlushFrontBuffer(__DRIdrawable *driDrawable, void *loaderPrivate) if (!pdraw-base.psc) return; - priv = __glXInitialize(pdraw-base.psc-dpy); + psc = (struct dri2_screen *) pdraw-base.psc; + + priv = __glXInitialize(psc-base.dpy); pdp = (struct dri2_display *) priv-dri2Display; gc = __glXGetCurrentContext(); + if (psc-throttle) { + struct glx_context *gc = __glXGetCurrentContext(); + struct dri2_context *dri2Ctx = (struct dri2_context *)gc; + __DRIcontext *ctx = (dri2Ctx) ? dri2Ctx-driContext : NULL; + + psc-throttle-throttle(ctx, + pdraw-driDrawable, + __DRI2_THROTTLE_FLUSHFRONT); + } + /* Old servers don't send invalidate events */ if (!pdp-invalidateAvailable)
Re: [Mesa-dev] [PATCH 1/3] dri2: Implement a throttle dri extension.
On Die, 2011-10-11 at 15:44 +0200, Thomas Hellstrom wrote: The X server has limited throttle support on the server side, but doing this in the client has some benefits: 1) X server throttling is per client. Client side throttling can be done per drawable. 2) It's easier to control the throttling based on what client is run, for example using driconf. 3) X server throttling requires drm swap complete events. So implement a dri2 throttling extension intended to be used by direct rendering clients. I'm on the fence about whether it's better to add a new extension for this or to add anything missing to the flush extension instead, as the callsites are basically the same. @@ -390,6 +393,15 @@ dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height) (*psc-f-flush) (priv-driDrawable); #endif + if (psc-throttle) { + struct glx_context *gc = __glXGetCurrentContext(); + struct dri2_context *dri2Ctx = (struct dri2_context *)gc; + __DRIcontext *ctx = + (dri2Ctx) ? dri2Ctx-driContext : NULL; + + psc-throttle-throttle(ctx, priv-driDrawable, reason); + } + Either way though, these blocks should probably be refactored into a helper function. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev