[call for testing v2] clients: add cliptest program
Cliptest is for controlled testing of the calculate_edges() function in compositor.c. The function is copied verbatim into cliptest.c. v2: - show vertex coordinates - rewrite intersection computing; improved precision - remove duplicate vertices - fix non-transformed adjacent but not overlapping cases v1: original call for testing Signed-off-by: Pekka Paalanen ppaala...@gmail.com --- Hi all, a new version for testing. This can also be found in the git branch http://cgit.collabora.com/git/user/pq/wayland-demos.git/log/?h=cliptest2 where you can easily see the changes to v1. Thanks, pq clients/Makefile.am |5 + clients/cliptest.c | 889 +++ 2 files changed, 894 insertions(+), 0 deletions(-) create mode 100644 clients/cliptest.c diff --git a/clients/Makefile.am b/clients/Makefile.am index 1b7fa10..a72 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -48,6 +48,7 @@ terminal = weston-terminal clients_programs = \ flower \ image \ + cliptest\ dnd \ smoke \ resizor \ @@ -88,6 +89,10 @@ weston_terminal_LDADD = $(toolkit_libs) -lutil image_SOURCES = image.c image_LDADD = $(toolkit_libs) +cliptest_SOURCES = cliptest.c +cliptest_CPPFLAGS = $(AM_CPPFLAGS) $(PIXMAN_CFLAGS) +cliptest_LDADD = $(toolkit_libs) $(PIXMAN_LIBS) + dnd_SOURCES = dnd.c dnd_LDADD = $(toolkit_libs) diff --git a/clients/cliptest.c b/clients/cliptest.c new file mode 100644 index 000..41cedae --- /dev/null +++ b/clients/cliptest.c @@ -0,0 +1,889 @@ +/* + * Copyright © 2012 Collabora, Ltd. + * Copyright © 2012 Rob Clark + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* cliptest: for debugging calculate_edges() function, which is copied + * from compositor.c. + * controls: + * clip box position: mouse left drag, keys: w a s d + * clip box size: mouse right drag, keys: i j k l + * surface orientation: mouse wheel, keys: n m + * surface transform disable key: r + */ + +#include stdint.h +#include stdio.h +#include stdlib.h +#include string.h +#include fcntl.h +#include libgen.h +#include unistd.h +#include math.h +#include time.h +#include pixman.h +#include cairo.h +#include float.h +#include assert.h + +#include linux/input.h +#include wayland-client.h + +#include window.h + +typedef float GLfloat; + +struct geometry { + pixman_box32_t clip; + + pixman_box32_t surf; + float s; /* sin phi */ + float c; /* cos phi */ + float phi; +}; + +struct weston_surface { + struct { + int enabled; + } transform; + + struct geometry *geometry; +}; + +static void +weston_surface_to_global_float(struct weston_surface *surface, + GLfloat sx, GLfloat sy, GLfloat *x, GLfloat *y) +{ + struct geometry *g = surface-geometry; + + /* pure rotation around origin by sine and cosine */ + *x = g-c * sx + g-s * sy; + *y = -g-s * sx + g-c * sy; +} + +/* -- copied begins ---*/ + +struct polygon8 { + GLfloat x[8]; + GLfloat y[8]; + int n; +}; + +struct clip_context { + struct { + GLfloat x; + GLfloat y; + } prev; + + struct { + GLfloat x1, y1; + GLfloat x2, y2; + } clip; + + struct { + GLfloat *x; + GLfloat *y; + } vertices; +}; + +static GLfloat +float_difference(GLfloat a, GLfloat b) +{ + /* http://www.altdevblogaday.com/2012/02/22/comparing-floating-point-numbers-2012-edition/ */ + static const
[PATCH 1/3] simple-egl: Set the opaque region if windowed and -o is passed
Since commit d523a87d2d8c0099d8ac323375b3d083aafccf9a [1], window.opaque would be 1 only in fullscreen mode, causing the opaque region to be set only when running in fullscreen mode. Having it set properly for the windowed case is helpful to test the overlay path in compositor-drm. This reverts that commit and makes window.opaque independent of the -f switch. Instead, we set the opaque region if the window is fullscreen or -o was passed and leave window.opaque alone in the case -f was passed. [1] commit d523a87d2d8c0099d8ac323375b3d083aafccf9a Author: Scott Moreau ore...@gmail.com Date: Thu Aug 30 14:44:16 2012 -0600 simple-egl: Only set alpha_size=0 when -o is passed. --- clients/simple-egl.c | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/clients/simple-egl.c b/clients/simple-egl.c index 808c2ee..a67ce2f 100644 --- a/clients/simple-egl.c +++ b/clients/simple-egl.c @@ -280,12 +280,10 @@ toggle_fullscreen(struct window *window, int fullscreen) window-configured = 0; if (fullscreen) { - window-opaque = 1; wl_shell_surface_set_fullscreen(window-shell_surface, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL); } else { - window-opaque = 0; wl_shell_surface_set_toplevel(window-shell_surface); handle_configure(window, window-shell_surface, 0, window-window_size.width, @@ -403,7 +401,7 @@ redraw(void *data, struct wl_callback *callback, uint32_t time) eglSwapBuffers(window-display-egl.dpy, window-egl_surface); - if (window-opaque) { + if (window-opaque || window-fullscreen) { region = wl_compositor_create_region(window-display-compositor); wl_region_add(region, 0, 0, window-window_size.width, @@ -594,7 +592,7 @@ main(int argc, char **argv) struct sigaction sigint; struct display display = { 0 }; struct window window = { 0 }; - int i, opaque = 0; + int i; window.display = display; display.window = window; @@ -605,7 +603,7 @@ main(int argc, char **argv) if (strcmp(-f, argv[i]) == 0) window.fullscreen = 1; else if (strcmp(-o, argv[i]) == 0) - opaque = 1; + window.opaque = 1; else if (strcmp(-h, argv[i]) == 0) usage(EXIT_SUCCESS); else @@ -621,10 +619,7 @@ main(int argc, char **argv) wl_display_get_fd(display.display, event_mask_update, display); wl_display_iterate(display.display, WL_DISPLAY_READABLE); - if (window.fullscreen) - window.opaque = 1; - - init_egl(display, opaque); + init_egl(display, window.opaque); create_surface(window); init_gl(window); -- 1.7.9.5 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 2/2] compositor: Added the ability to draw damage to a texture and in turn to the framebuffer. Also added a shader which inverts colors.
--- src/compositor.c | 165 +-- src/compositor.h | 8 +++ src/shell.c | 11 3 files changed, 167 insertions(+), 17 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 7013b4a..e625171 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -1256,23 +1256,12 @@ triangle_fan_debug(struct weston_surface *surface, int first, int count) } static void -repaint_region(struct weston_surface *es, pixman_region32_t *region, - pixman_region32_t *surf_region) +repaint_region(struct weston_compositor *ec, struct weston_surface *es, + int nfans) { - struct weston_compositor *ec = es-compositor; GLfloat *v; unsigned int *vtxcnt; - int i, first, nfans; - - /* The final region to be painted is the intersection of -* 'region' and 'surf_region'. However, 'region' is in the global -* coordinates, and 'surf_region' is in the surface-local -* coordinates. texture_region() will iterate over all pairs of -* rectangles from both regions, compute the intersection -* polygon for each pair, and store it as a triangle fan if -* it has a non-zero area (at least 3 vertices, actually). -*/ - nfans = texture_region(es, region, surf_region); + int i, first; v = ec-vertices.data; vtxcnt = ec-vtxcnt.data; @@ -1287,7 +1276,7 @@ repaint_region(struct weston_surface *es, pixman_region32_t *region, for (i = 0, first = 0; i nfans; i++) { glDrawArrays(GL_TRIANGLE_FAN, first, vtxcnt[i]); - if (ec-fan_debug) + if (es ec-fan_debug) triangle_fan_debug(es, first, vtxcnt[i]); first += vtxcnt[i]; } @@ -1300,6 +1289,73 @@ repaint_region(struct weston_surface *es, pixman_region32_t *region, } static void +repaint_surface(struct weston_surface *es, pixman_region32_t *region, + pixman_region32_t *surf_region) +{ + /* The final region to be painted is the intersection of +* 'region' and 'surf_region'. However, 'region' is in the global +* coordinates, and 'surf_region' is in the surface-local +* coordinates. texture_region() will iterate over all pairs of +* rectangles from both regions, compute the intersection +* polygon for each pair, and store it as a triangle fan if +* it has a non-zero area (at least 3 vertices, actually). +*/ + int nfans = texture_region(es, region, surf_region); + + repaint_region(es-compositor, es, nfans); +} + +static void +output_emit_vertex(struct weston_output *output, GLfloat **v, int32_t x, int32_t y) +{ + struct weston_vector vector; + + /* position: */ + *((*v)++) = x; + *((*v)++) = y; + + /* texcoord: */ + + vector.f[0] = x; + vector.f[1] = y; + vector.f[2] = 0.0f; + vector.f[3] = 1.0f; + + weston_matrix_transform(output-matrix, vector); + + *((*v)++) = (vector.f[0] + 1.0f) * 0.5f; + *((*v)++) = (vector.f[1] + 1.0f) * 0.5f; +} + +static void +repaint_output(struct weston_output *output, pixman_region32_t *region) +{ + struct weston_compositor *ec = output-compositor; + GLfloat *v; + unsigned int *vtxcnt, nvtx = 0; + pixman_box32_t *rects; + int i, nrects; + + rects = pixman_region32_rectangles(region, nrects); + + v = wl_array_add(ec-vertices, nrects * 4 * 4 * sizeof *v); + vtxcnt = wl_array_add(ec-vtxcnt, nrects * sizeof *vtxcnt); + + for (i = 0; i nrects; i++) { + pixman_box32_t *rect = rects[i]; + + output_emit_vertex(output, v, rect-x1, rect-y1); + output_emit_vertex(output, v, rect-x2, rect-y1); + output_emit_vertex(output, v, rect-x2, rect-y2); + output_emit_vertex(output, v, rect-x1, rect-y2); + + vtxcnt[nvtx++] = 4; + } + + repaint_region(ec, NULL, nvtx); +} + +static void weston_compositor_use_shader(struct weston_compositor *compositor, struct weston_shader *shader) { @@ -1329,11 +1385,64 @@ weston_shader_uniforms(struct weston_shader *shader, WL_EXPORT void weston_output_repaint_start(struct weston_output *output, pixman_region32_t *damage) { + output-indirect_drawing = output-compositor-invert_color !output-indirect_disable; + + if(output-indirect_drawing) { + if(!output-indirect_fbo) + glGenFramebuffers(1, output-indirect_fbo); + + glBindFramebuffer(GL_FRAMEBUFFER, output-indirect_fbo); + + if(!output-indirect_texture) { + glGenTextures(1, output-indirect_texture); + + glBindTexture(GL_TEXTURE_2D, output-indirect_texture); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
Re: Weston framerate (Re: bare bones opengl weston client sample)
Sorry for the delay, my mail tool didn't link up this thread fro me. I am running w/ DRM not X11; running weston in an X client was not adequate for my test app. I start by obtaining a virtual terminal ;init 3 ; then weston-launch This way I eliminate any X11 variables. You can see egl loading the dri driver when it starts up. If there is a better way please let me know. I run the the application with glut and weston using the same MESA stack that I compiled for weston. So, the only real difference is between glut/simple-egl and gnome(X11)/weston My CPU usage is: weston - ~20+ fps - 3% glut(X11) - 60 fps - 17% - (60 is a hard limit for glut) tells me there is more to be had. This application renders ~100 256x256 rgb textures on a moving map display. I don't understand the wayland frame listener callback and how the wl_iterate works to drive redraw in simple-egl. So, I am hoping I am just using it wrong. I was hoping to do something similar to glutPostRedisplay() in a mouse drag event. This way I can start panning my textured tiles for a good test. On Fri, Sep 7, 2012 at 2:16 AM, Pekka Paalanen ppaala...@gmail.com wrote: On Thu, 6 Sep 2012 11:25:20 -0400 jegde jedge bubba...@gmail.com wrote: Thank you so much, that did the trick! Next Question :) On the same code, on the same hardware... I am getting the glut 60 fps limit when running my app using the glut front end via gnome and X. I am getting ~24 fps using the simple-egl front end on top of wayland. I also noticed the display using wayland likes to hover around 20 fps. Is there some kind of throttle built into the frame rate for the redraw callback? Hi, could you remind us, are you running Weston with the X11 or DRM backend? If you use the X11 backend, sloppy framerates are expected. X has no method of telling the X application (weston) that the image it posted has now hit the screen. Therefore the X11 backend fakes it by using a timer to blindly to trigger this image hit the screen callback. Obviously that is very flakey and inaccurate, but cannot really do any better. However, if you are on DRM backend, it is worth investigating. Thanks, pq ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel