Re: [Mesa-dev] [PATCH 08/11] GLX/DRI3: Add GPU offloading support.

2014-06-24 Thread Axel Davy

On 23/06/2014 04:48, Michel Dänzer wrote :

If X doesn't know anything about the secondary card, the secondary card
must use the server side GLX information from the driver of the primary
card, right? That seems rather hackish to me, and like it can only work
as long as the cards / drivers are 'similar enough'...


Patches 1, 2 and 10 look good to me though FWIW. The radeonsi piglit
multisampling regressions with DRI3 compared to DRI2 can be addressed
later as far as I'm concerned.



I've investigated this deeper, and apparently it shouldn't be a problem.
Mesa takes care of the driver capabilities for the GLX visuals and 
fbconfigs,

and you have an intersection of what the server advertises and what you can
actually have.

The only constraint in the spec seems to be that there must be a GLX 
fbconfig supporting

RGBA and some other constraints.

Axel Davy
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 08/11] GLX/DRI3: Add GPU offloading support.

2014-06-23 Thread Michel Dänzer
On 19.06.2014 12:27, Axel Davy wrote:
> The differences with DRI2 GPU offloading are:
> . There's no logic for GPU offloading needed in the Xserver
> . for DRI2, the card would render to a back buffer, and
> the content would be copied to the front buffer (the same buffers
> everytime). Here we can potentially use several back buffers and copy
> to buffers with no tiling to share with X. We send them with the
> Present extension.
> That means than the DRI2 solution is forced to have tearings with GPU
> offloading. In the ideal scenario, this DRI3 solution doesn't have this
> problem.
> However without dma-buf fences, a race can appear (if the card is slow
> and the rendering hasn't finished before the server card reads the buffer),
> and then old content is displayed. If a user hits this, he should probably
> revert to the DRI2 solution (LIBGL_DRI3_DISABLE). Users with cards fast
> enough seem to not hit this in practice (I have an Amd hd 7730m, and I
> don't hit this, except if I force a low dpm mode)
> . for non-fullscreen apps, the DRI2 GPU offloading solution requires
> compositing. This DRI3 solution doesn't have this requirement. Rendering
> to a pixmap also works.
> . There is no need to have a DDX loaded for the secondary card.

If X doesn't know anything about the secondary card, the secondary card
must use the server side GLX information from the driver of the primary
card, right? That seems rather hackish to me, and like it can only work
as long as the cards / drivers are 'similar enough'...


Patches 1, 2 and 10 look good to me though FWIW. The radeonsi piglit
multisampling regressions with DRI3 compared to DRI2 can be addressed
later as far as I'm concerned.


-- 
Earthling Michel Dänzer|  http://www.amd.com
Libre software enthusiast  |Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 08/11] GLX/DRI3: Add GPU offloading support.

2014-06-19 Thread Axel Davy

I've just noted
I forgot to update the blitImage flags on this patch,

when I use 1 as flush_flag argument it should be replaced by
__BLIT_FLAG_FLUSH.

Axel Davy

On 18/06/2014 23:27, Axel Davy wrote :

The differences with DRI2 GPU offloading are:
. There's no logic for GPU offloading needed in the Xserver
. for DRI2, the card would render to a back buffer, and
the content would be copied to the front buffer (the same buffers
everytime). Here we can potentially use several back buffers and copy
to buffers with no tiling to share with X. We send them with the
Present extension.
That means than the DRI2 solution is forced to have tearings with GPU
offloading. In the ideal scenario, this DRI3 solution doesn't have this
problem.
However without dma-buf fences, a race can appear (if the card is slow
and the rendering hasn't finished before the server card reads the buffer),
and then old content is displayed. If a user hits this, he should probably
revert to the DRI2 solution (LIBGL_DRI3_DISABLE). Users with cards fast
enough seem to not hit this in practice (I have an Amd hd 7730m, and I
don't hit this, except if I force a low dpm mode)
. for non-fullscreen apps, the DRI2 GPU offloading solution requires
compositing. This DRI3 solution doesn't have this requirement. Rendering
to a pixmap also works.
. There is no need to have a DDX loaded for the secondary card.

V4: Fixes some piglit tests

Signed-off-by: Axel Davy 
---
  src/glx/dri3_glx.c  | 236 +++-
  src/glx/dri3_priv.h |   2 +
  2 files changed, 198 insertions(+), 40 deletions(-)

diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index b309cd4..f147112 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -596,22 +596,44 @@ dri3_copy_sub_buffer(__GLXDRIdrawable *pdraw, int x, int 
y,
  {
 struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
 struct dri3_screen *psc = (struct dri3_screen *) pdraw->psc;
+   struct dri3_context *pcp = (struct dri3_context *) __glXGetCurrentContext();
 xcb_connection_t *c = XGetXCBConnection(priv->base.psc->dpy);
-   struct dri3_buffer *back = dri3_back_buffer(priv);
+   struct dri3_buffer *back;
  
-   unsigned flags;

+   unsigned flags = __DRI2_FLUSH_DRAWABLE;
  
 /* Check we have the right attachments */

 if (!priv->have_back || priv->is_pixmap)
return;
  
-   flags = __DRI2_FLUSH_DRAWABLE;

 if (flush)
flags |= __DRI2_FLUSH_CONTEXT;
 dri3_flush(psc, priv, flags, __DRI2_THROTTLE_SWAPBUFFER);
  
+   back = dri3_back_buffer(priv);

 y = priv->height - y - height;
  
+   if (psc->is_different_gpu && (&pcp->base != &dummyContext) && pcp->base.psc == &psc->base) {

+  /* Update the linear buffer part of the back buffer
+   * for the dri3_copy_area operation
+   */
+  psc->image->blitImage(pcp->driContext,
+back->linear_buffer,
+back->image,
+0, 0, back->width,
+back->height,
+0, 0, back->width,
+back->height, 1);
+  /* We use blitImage to update our fake front,
+   */
+  if (priv->have_fake_front)
+ psc->image->blitImage(pcp->driContext,
+   dri3_fake_front_buffer(priv)->image,
+   back->image,
+   x, y, width, height,
+   x, y, width, height, 1);
+   }
+
 dri3_fence_reset(c, back);
 dri3_copy_area(c,
dri3_back_buffer(priv)->pixmap,
@@ -622,7 +644,7 @@ dri3_copy_sub_buffer(__GLXDRIdrawable *pdraw, int x, int y,
 /* Refresh the fake front (if present) after we just damaged the real
  * front.
  */
-   if (priv->have_fake_front) {
+   if (priv->have_fake_front && !psc->is_different_gpu) {
dri3_fence_reset(c, dri3_fake_front_buffer(priv));
dri3_copy_area(c,
   dri3_back_buffer(priv)->pixmap,
@@ -655,25 +677,62 @@ dri3_copy_drawable(struct dri3_drawable *priv, Drawable 
dest, Drawable src)
  static void
  dri3_wait_x(struct glx_context *gc)
  {
+   struct dri3_context *pcp = (struct dri3_context *) gc;
 struct dri3_drawable *priv = (struct dri3_drawable *)
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
+   struct dri3_screen *psc;
+   struct dri3_buffer *front;
  
 if (priv == NULL || !priv->have_fake_front)

return;
  
-   dri3_copy_drawable(priv, dri3_fake_front_buffer(priv)->pixmap, priv->base.xDrawable);

+   psc = (struct dri3_screen *) priv->base.psc;
+   front = dri3_fake_front_buffer(priv);
+
+   dri3_copy_drawable(priv, front->pixmap, priv->base.xDrawable);
+
+   /* In the psc->is_different_gpu case, the linear buffer has been updated,
+* but not yet the tiled buffer.
+* Copy back to the tiled buffer we use for rendering.
+* Note that we don't need flushing.
+*/
+   if (p

[Mesa-dev] [PATCH 08/11] GLX/DRI3: Add GPU offloading support.

2014-06-18 Thread Axel Davy
The differences with DRI2 GPU offloading are:
. There's no logic for GPU offloading needed in the Xserver
. for DRI2, the card would render to a back buffer, and
the content would be copied to the front buffer (the same buffers
everytime). Here we can potentially use several back buffers and copy
to buffers with no tiling to share with X. We send them with the
Present extension.
That means than the DRI2 solution is forced to have tearings with GPU
offloading. In the ideal scenario, this DRI3 solution doesn't have this
problem.
However without dma-buf fences, a race can appear (if the card is slow
and the rendering hasn't finished before the server card reads the buffer),
and then old content is displayed. If a user hits this, he should probably
revert to the DRI2 solution (LIBGL_DRI3_DISABLE). Users with cards fast
enough seem to not hit this in practice (I have an Amd hd 7730m, and I
don't hit this, except if I force a low dpm mode)
. for non-fullscreen apps, the DRI2 GPU offloading solution requires
compositing. This DRI3 solution doesn't have this requirement. Rendering
to a pixmap also works.
. There is no need to have a DDX loaded for the secondary card.

V4: Fixes some piglit tests

Signed-off-by: Axel Davy 
---
 src/glx/dri3_glx.c  | 236 +++-
 src/glx/dri3_priv.h |   2 +
 2 files changed, 198 insertions(+), 40 deletions(-)

diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index b309cd4..f147112 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -596,22 +596,44 @@ dri3_copy_sub_buffer(__GLXDRIdrawable *pdraw, int x, int 
y,
 {
struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
struct dri3_screen *psc = (struct dri3_screen *) pdraw->psc;
+   struct dri3_context *pcp = (struct dri3_context *) __glXGetCurrentContext();
xcb_connection_t *c = XGetXCBConnection(priv->base.psc->dpy);
-   struct dri3_buffer *back = dri3_back_buffer(priv);
+   struct dri3_buffer *back;
 
-   unsigned flags;
+   unsigned flags = __DRI2_FLUSH_DRAWABLE;
 
/* Check we have the right attachments */
if (!priv->have_back || priv->is_pixmap)
   return;
 
-   flags = __DRI2_FLUSH_DRAWABLE;
if (flush)
   flags |= __DRI2_FLUSH_CONTEXT;
dri3_flush(psc, priv, flags, __DRI2_THROTTLE_SWAPBUFFER);
 
+   back = dri3_back_buffer(priv);
y = priv->height - y - height;
 
+   if (psc->is_different_gpu && (&pcp->base != &dummyContext) && pcp->base.psc 
== &psc->base) {
+  /* Update the linear buffer part of the back buffer
+   * for the dri3_copy_area operation
+   */
+  psc->image->blitImage(pcp->driContext,
+back->linear_buffer,
+back->image,
+0, 0, back->width,
+back->height,
+0, 0, back->width,
+back->height, 1);
+  /* We use blitImage to update our fake front,
+   */
+  if (priv->have_fake_front)
+ psc->image->blitImage(pcp->driContext,
+   dri3_fake_front_buffer(priv)->image,
+   back->image,
+   x, y, width, height,
+   x, y, width, height, 1);
+   }
+
dri3_fence_reset(c, back);
dri3_copy_area(c,
   dri3_back_buffer(priv)->pixmap,
@@ -622,7 +644,7 @@ dri3_copy_sub_buffer(__GLXDRIdrawable *pdraw, int x, int y,
/* Refresh the fake front (if present) after we just damaged the real
 * front.
 */
-   if (priv->have_fake_front) {
+   if (priv->have_fake_front && !psc->is_different_gpu) {
   dri3_fence_reset(c, dri3_fake_front_buffer(priv));
   dri3_copy_area(c,
  dri3_back_buffer(priv)->pixmap,
@@ -655,25 +677,62 @@ dri3_copy_drawable(struct dri3_drawable *priv, Drawable 
dest, Drawable src)
 static void
 dri3_wait_x(struct glx_context *gc)
 {
+   struct dri3_context *pcp = (struct dri3_context *) gc;
struct dri3_drawable *priv = (struct dri3_drawable *)
   GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
+   struct dri3_screen *psc;
+   struct dri3_buffer *front;
 
if (priv == NULL || !priv->have_fake_front)
   return;
 
-   dri3_copy_drawable(priv, dri3_fake_front_buffer(priv)->pixmap, 
priv->base.xDrawable);
+   psc = (struct dri3_screen *) priv->base.psc;
+   front = dri3_fake_front_buffer(priv);
+
+   dri3_copy_drawable(priv, front->pixmap, priv->base.xDrawable);
+
+   /* In the psc->is_different_gpu case, the linear buffer has been updated,
+* but not yet the tiled buffer.
+* Copy back to the tiled buffer we use for rendering.
+* Note that we don't need flushing.
+*/
+   if (psc->is_different_gpu && (&pcp->base != &dummyContext) && pcp->base.psc 
== &psc->base)
+  psc->image->blitImage(pcp->driContext,
+front->image,
+front->linear_buffer,
+