Re: [Mesa-dev] [PATCH 2/2] loader/dri3: Invalidate the drawable after copySubBuffer

2017-09-05 Thread Thomas Hellstrom

On 09/05/2017 08:50 AM, Thomas Hellstrom wrote:

Hi, Michel,



[...]

I guess what could perhaps be done is to process any received events 
in dri3_fence_await, and invalidate only if we see a drawable change 
to try to mimic dri2 behaviour..


Actually this seems like a better and more general approach. I'll send 
out a new patch in a moment.


/Thomas




/Thomas






___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] loader/dri3: Invalidate the drawable after copySubBuffer

2017-09-05 Thread Thomas Hellstrom

Hi, Michel,

On 09/05/2017 06:02 AM, Michel Dänzer wrote:

On 04/09/17 09:27 PM, Thomas Hellstrom wrote:

Anyone using copySubBuffer as a replacement for swapBuffers would probably
want window resizing to update the viewport.

Signed-off-by: Thomas Hellstrom 
---
  src/loader/loader_dri3_helper.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index c0a6e0d..9549b18 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -664,6 +664,8 @@ loader_dri3_copy_sub_buffer(struct loader_dri3_drawable 
*draw,
dri3_fence_trigger(draw->conn, dri3_fake_front_buffer(draw));
dri3_fence_await(draw->conn, dri3_fake_front_buffer(draw));
 }
+
+   draw->ext->flush->invalidate(draw->dri_drawable);
 dri3_fence_await(draw->conn, back);
  }

Your rationale makes some sense to me, but I notice that
dri2CopySubBuffer doesn't seem to do this. Do you have a test case where
this makes a difference?


If you hack glxgears to use copySubBuffer as done in the attached diff, 
you'll see the problem. With dri3 without this patch the window stops 
updating if you resize it.


The bahavior with dri2 is different. If the server doesn't send 
invalidate events (old dri2 server side drivers), then the behavior is, 
as expected, similar to dri3 except rendering continues with an 
incorrect viewport. dri2 with server side events works.


Now dri3 also get server side events on resizing, but the difference 
compared to dri2 is that the dri2 events are processed in _Xreply, so 
they'd automatically get processed when we wait for the server's 
copy_sub_buffer reply, and if there is an invalidate event, we 
invalidate. With dri3 currently we need to explicitly post an 
invalidation to have the code even check for events.


I guess what could perhaps be done is to process any received events in 
dri3_fence_await, and invalidate only if we see a drawable change to try 
to mimic dri2 behaviour..


/Thomas




diff --git a/src/xdemos/glxgears.c b/src/xdemos/glxgears.c
index 54fbf97..e0e823d 100644
--- a/src/xdemos/glxgears.c
+++ b/src/xdemos/glxgears.c
@@ -107,7 +107,8 @@ static GLboolean animate = GL_TRUE;	/* Animation */
 static GLfloat eyesep = 5.0;		/* Eye separation. */
 static GLfloat fix_point = 40.0;	/* Fixation point distance.  */
 static GLfloat left, right, asp;	/* Stereo frustum params.  */
-
+static int savedWidth, savedHeight;
+static PFNGLXCOPYSUBBUFFERMESAPROC pglXCopySubBufferMESA;
 
 /*
  *
@@ -339,7 +340,11 @@ draw_frame(Display *dpy, Window win)
}
 
draw_gears();
-   glXSwapBuffers(dpy, win);
+   if (pglXCopySubBufferMESA) {
+  (*pglXCopySubBufferMESA)(dpy, win, 0, 0, savedWidth, savedHeight);
+   } else {
+  glXSwapBuffers(dpy, win);
+   }
 
frames++;

@@ -361,6 +366,9 @@ draw_frame(Display *dpy, Window win)
 static void
 reshape(int width, int height)
 {
+   savedWidth = width;
+   savedHeight = height;
+
glViewport(0, 0, (GLint) width, (GLint) height);
 
if (stereo) {
@@ -632,6 +640,14 @@ query_vsync(Display *dpy, GLXDrawable drawable)
 interval);
   }
}
+
+   if (is_glx_extension_supported(dpy, "GLX_MESA_copy_sub_buffer")) {
+  pglXCopySubBufferMESA =
+	 (PFNGLXCOPYSUBBUFFERMESAPROC)
+	 glXGetProcAddressARB((const GLubyte *) "glXCopySubBufferMESA");
+  if (pglXCopySubBufferMESA)
+	 printf("Using glXCopySubBuffer.\n");
+   }
 }
 
 /**
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] loader/dri3: Invalidate the drawable after copySubBuffer

2017-09-04 Thread Michel Dänzer
On 04/09/17 09:27 PM, Thomas Hellstrom wrote:
> Anyone using copySubBuffer as a replacement for swapBuffers would probably
> want window resizing to update the viewport.
> 
> Signed-off-by: Thomas Hellstrom 
> ---
>  src/loader/loader_dri3_helper.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
> index c0a6e0d..9549b18 100644
> --- a/src/loader/loader_dri3_helper.c
> +++ b/src/loader/loader_dri3_helper.c
> @@ -664,6 +664,8 @@ loader_dri3_copy_sub_buffer(struct loader_dri3_drawable 
> *draw,
>dri3_fence_trigger(draw->conn, dri3_fake_front_buffer(draw));
>dri3_fence_await(draw->conn, dri3_fake_front_buffer(draw));
> }
> +
> +   draw->ext->flush->invalidate(draw->dri_drawable);
> dri3_fence_await(draw->conn, back);
>  }

Your rationale makes some sense to me, but I notice that
dri2CopySubBuffer doesn't seem to do this. Do you have a test case where
this makes a difference?


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


[Mesa-dev] [PATCH 2/2] loader/dri3: Invalidate the drawable after copySubBuffer

2017-09-04 Thread Thomas Hellstrom
Anyone using copySubBuffer as a replacement for swapBuffers would probably
want window resizing to update the viewport.

Signed-off-by: Thomas Hellstrom 
---
 src/loader/loader_dri3_helper.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index c0a6e0d..9549b18 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -664,6 +664,8 @@ loader_dri3_copy_sub_buffer(struct loader_dri3_drawable 
*draw,
   dri3_fence_trigger(draw->conn, dri3_fake_front_buffer(draw));
   dri3_fence_await(draw->conn, dri3_fake_front_buffer(draw));
}
+
+   draw->ext->flush->invalidate(draw->dri_drawable);
dri3_fence_await(draw->conn, back);
 }
 
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev