RE: [PATCH 3/3] rdp-backend.so: OpenGL hardware acceleration

2018-04-04 Thread Raimundo Sagarzazu
n_renderer_output_create(>base) < 0) {
+   pixman_image_unref(output->shadow_surface);
+   return -1;
+   }
+   } else if (rdp_output_init_egl(output, b) < 0) {
+   weston_log("Failed to init output gl state\n");
pixman_image_unref(output->shadow_surface);
return -1;
}
 
+   if (!b->use_pixman) {
+   if (rdp_get_image_size(output) < 0)  return -1;
+   }
+
loop = wl_display_get_event_loop(b->compositor->wl_display);
output->finish_frame_timer = wl_event_loop_add_timer(loop, 
finish_frame_handler, output);
 
@@ -557,7 +858,11 @@ rdp_output_disable(struct weston_output *base)
return 0;
 
pixman_image_unref(output->shadow_surface);
-   pixman_renderer_output_destroy(>base);
+
+   if (b->use_pixman)
+   pixman_renderer_output_destroy(>base);
+   else
+   rdp_output_fini_egl(output);
 
wl_event_source_remove(output->finish_frame_timer);
b->output = NULL;
@@ -603,6 +908,13 @@ rdp_destroy(struct weston_compositor *ec)
int i;
 
weston_compositor_shutdown(ec);
+
+   if (!b->use_pixman) {
+   gbm_device_destroy(b->gbm);
+   close(b->drm_fd);
+   udev_unref(b->udev);
+   }
+
for (i = 0; i < MAX_FREERDP_FDS; i++)
if (b->listener_events[i])
wl_event_source_remove(b->listener_events[i]);
@@ -1281,6 +1593,7 @@ rdp_incoming_peer(freerdp_listener *instance, 
freerdp_peer *client)
 
 static const struct weston_rdp_output_api api = {
rdp_output_set_size,
+   rdp_output_set_gbm_format
 };
 
 static struct rdp_backend *
@@ -1300,6 +1613,22 @@ rdp_backend_create(struct weston_compositor *compositor,
b->base.destroy = rdp_destroy;
b->rdp_key = config->rdp_key ? strdup(config->rdp_key) : NULL;
b->no_clients_resize = config->no_clients_resize;
+   b->use_pixman = config->use_pixman;
+
+   if (parse_gbm_format(config->gbm_format, GBM_FORMAT_XRGB, 
>gbm_format) < 0)
+   goto err_compositor;
+
+   b->udev = udev_new();
+   if (b->udev == NULL) {
+   weston_log("failed to initialize udev context\n");
+   goto err_compositor;
+   }
+
+   b->drm_fd = open_drm_device(b->udev);
+   if (b->drm_fd < 0) {
+   weston_log("failed to find a suitable drm render node\n");
+   goto err_udev;
+   }
 
compositor->backend = >base;
 
@@ -1314,13 +1643,22 @@ rdp_backend_create(struct weston_compositor *compositor,
}
 
if (weston_compositor_set_presentation_clock_software(compositor) < 0)
-   goto err_compositor;
+   goto err_udev;
 
-   if (pixman_renderer_init(compositor) < 0)
-   goto err_compositor;
+   if (b->use_pixman) {
+   if (init_pixman(b) < 0) {
+   weston_log("failed to initialize pixman renderer\n");
+   goto err_udev;
+   }
+   } else {
+   if (init_egl(b) < 0) {
+   weston_log("failed to initialize egl\n");
+   goto err_udev;
+   }
+   }
 
if (rdp_backend_create_output(compositor) < 0)
-   goto err_compositor;
+   goto err_udev;
 
compositor->capabilities |= WESTON_CAP_ARBITRARY_MODES;
 
@@ -1363,6 +1701,8 @@ err_listener:
freerdp_listener_free(b->listener);
 err_output:
weston_output_release(>output->base);
+err_udev:
+   udev_unref(b->udev);
 err_compositor:
weston_compositor_shutdown(compositor);
 err_free_strings:
@@ -1383,6 +1723,7 @@ config_init_to_defaults(struct weston_rdp_backend_config 
*config)
config->server_key = NULL;
config->env_socket = 0;
config->no_clients_resize = 0;
+   config->use_pixman = 0;
 }
 
 WL_EXPORT int
diff --git a/libweston/compositor-rdp.h b/libweston/compositor-rdp.h
index bd0a6a9..f3d77c8 100644
--- a/libweston/compositor-rdp.h
+++ b/libweston/compositor-rdp.h
@@ -42,6 +42,15 @@ struct weston_rdp_output_api {
 */
int (*output_set_size)(struct weston_output *output,
   int width, int height);
+
+   /** The pixel format to be used by the output. Valid values are:
+* - NULL - The format set at backend creation time will be used;
+* - "xrgb";
+* - "rgb565"
+* - "xrgb2101010"
+*/
+   void (*set_gbm_format)(struct weston_output *output,
+  const char *gbm_format);
 };
 
 static inlin

Re: [PATCH 3/3] rdp-backend.so: OpenGL hardware acceleration

2018-04-03 Thread Hardening
Le 06/07/2017 à 12:06, Olivier Blin a écrit :
> From: DRC 
> 
> ---
>  compositor/main.c  |  23 +++-
>  configure.ac   |   4 +-
>  libweston/compositor-rdp.c | 314 
> +++--
>  libweston/compositor-rdp.h |  24 
>  4 files changed, 352 insertions(+), 13 deletions(-)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index f8a60e97..125cc0f8 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c
> @@ -601,6 +601,7 @@ usage(int error_code)
>   "  --rdp4-key=FILE\tThe file containing the key for RDP4 
> encryption\n"
>   "  --rdp-tls-cert=FILE\tThe file containing the certificate for 
> TLS encryption\n"
>   "  --rdp-tls-key=FILE\tThe file containing the private key for 
> TLS encryption\n"
> + "  --use-pixman\t\tUse the pixman (CPU) renderer\n"
>   "\n");
>  #endif
>  
> @@ -1331,11 +1332,14 @@ static void
>  rdp_backend_output_configure(struct wl_listener *listener, void *data)
>  {
>   struct weston_output *output = data;
> + struct weston_config *wc = wet_get_config(output->compositor);
>   struct wet_compositor *compositor = 
> to_wet_compositor(output->compositor);
>   struct wet_output_config *parsed_options = compositor->parsed_options;
> + struct weston_config_section *section;
>   const struct weston_rdp_output_api *api = 
> weston_rdp_output_get_api(output->compositor);
>   int width = 640;
>   int height = 480;
> + char *gbm_format = NULL;
>  
>   assert(parsed_options);
>  
> @@ -1344,6 +1348,8 @@ rdp_backend_output_configure(struct wl_listener 
> *listener, void *data)
>   return;
>   }
>  
> + section = weston_config_get_section(wc, "output", "name", output->name);
> +
>   if (parsed_options->width)
>   width = parsed_options->width;
>  
> @@ -1353,6 +1359,12 @@ rdp_backend_output_configure(struct wl_listener 
> *listener, void *data)
>   weston_output_set_scale(output, 1);
>   weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
>  
> + weston_config_section_get_string(section,
> +  "gbm-format", _format, NULL);
> +
> + api->set_gbm_format(output, gbm_format);
> + free(gbm_format);
> +
>   if (api->output_set_size(output, width, height) < 0) {
>   weston_log("Cannot configure output \"%s\" using 
> weston_rdp_output_api.\n",
>  output->name);
> @@ -1375,6 +1387,7 @@ weston_rdp_backend_config_init(struct 
> weston_rdp_backend_config *config)
>   config->server_key = NULL;
>   config->env_socket = 0;
>   config->no_clients_resize = 0;
> + config->use_pixman = false;
>  }
>  
>  static int
> @@ -1382,6 +1395,7 @@ load_rdp_backend(struct weston_compositor *c,
>   int *argc, char *argv[], struct weston_config *wc)
>  {
>   struct weston_rdp_backend_config config  = {{ 0, }};
> + struct weston_config_section *section;
>   int ret = 0;
>  
>   struct wet_output_config *parsed_options = wet_init_parsed_options(c);
> @@ -1399,11 +1413,17 @@ load_rdp_backend(struct weston_compositor *c,
>   { WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, 
> _clients_resize },
>   { WESTON_OPTION_STRING,  "rdp4-key", 0, _key },
>   { WESTON_OPTION_STRING,  "rdp-tls-cert", 0, _cert 
> },
> - { WESTON_OPTION_STRING,  "rdp-tls-key", 0, _key }
> + { WESTON_OPTION_STRING,  "rdp-tls-key", 0, _key },
> + { WESTON_OPTION_BOOLEAN, "use-pixman", 0, _pixman }
>   };
>  
>   parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv);
>  
> + section = weston_config_get_section(wc, "core", NULL, NULL);
> + weston_config_section_get_string(section,
> +  "gbm-format", _format,
> +  NULL);
> +
>   ret = weston_compositor_load_backend(c, WESTON_BACKEND_RDP,
>);
>  
> @@ -1417,6 +1437,7 @@ out:
>   free(config.rdp_key);
>   free(config.server_cert);
>   free(config.server_key);
> + free(config.gbm_format);
>  
>   return ret;
>  }
> diff --git a/configure.ac b/configure.ac
> index 53faee34..a7b2d517 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -250,9 +250,9 @@ AM_CONDITIONAL([ENABLE_RDP_COMPOSITOR],
> [test x$enable_rdp_compositor = xyes])
>  if test x$enable_rdp_compositor = xyes; then
>AC_DEFINE([BUILD_RDP_COMPOSITOR], [1], [Build the RDP compositor])
> -  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp2 >= 2.0.0],
> +  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp2 >= 2.0.0 libudev >= 136 gbm],
>  [],
> -[PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0],[])]
> +[PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0 libudev >= 136 
> gbm],[])]
>)
>  
>SAVED_CPPFLAGS="$CPPFLAGS"
> 

Re: [PATCH 3/3] rdp-backend.so: OpenGL hardware acceleration

2018-04-03 Thread Pekka Paalanen
On Fri, 23 Feb 2018 16:08:00 +0100
Raimundo Sagarzazu  wrote:

> Hi,
>  
> Two patches that improve performance in my case. 
>  
> First, supporting ARGB gbm-format for the output allows a much better 
> performance of the intelReadPixels function of the i965 driver of Mesa, which 
> is my case:
>  
> diff -rup a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
> --- a/libweston/compositor-rdp.c   2018-02-22 11:35:14.0 +0100
> +++ b/libweston/compositor-rdp.c2018-02-22 11:37:20.312159332 +0100
> @@ -592,6 +592,8 @@ parse_gbm_format(const char *s, uint32_t
>   *gbm_format = default_value;
>else if (strcmp(s, "xrgb") == 0)
>   *gbm_format = GBM_FORMAT_XRGB;
> + else if (strcmp(s, "argb") == 0)
> + *gbm_format = GBM_FORMAT_ARGB;
>else if (strcmp(s, "rgb565") == 0)
>   *gbm_format = GBM_FORMAT_RGB565;
>else if (strcmp(s, "xrgb2101010") == 0)
>  
> Second, reading just the damaged pixels and y-flipping back the image:

Hi,

thanks for the patches, the ideas look good to me, but the patches
themselves are not formatted such that they could be applied. Please see
https://cgit.freedesktop.org/wayland/wayland/tree/doc/Contributing
for some guidance.

I would expect a re-send of these patches. The OpenGL support in
RDP-backend has not been merged yet, so it would be good to point to
the depended-on patches in your cover letter or even offer a branch
from which people could test.


Thanks,
pq


pgp8AFovf1Fgx.pgp
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH 3/3] rdp-backend.so: OpenGL hardware acceleration

2018-02-23 Thread Raimundo Sagarzazu
Hi,
 
Two patches that improve performance in my case. 
 
First, supporting ARGB gbm-format for the output allows a much better 
performance of the intelReadPixels function of the i965 driver of Mesa, which 
is my case:
 
diff -rup a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
--- a/libweston/compositor-rdp.c   2018-02-22 11:35:14.0 +0100
+++ b/libweston/compositor-rdp.c2018-02-22 11:37:20.312159332 +0100
@@ -592,6 +592,8 @@ parse_gbm_format(const char *s, uint32_t
  *gbm_format = default_value;
   else if (strcmp(s, "xrgb") == 0)
  *gbm_format = GBM_FORMAT_XRGB;
+ else if (strcmp(s, "argb") == 0)
+ *gbm_format = GBM_FORMAT_ARGB;
   else if (strcmp(s, "rgb565") == 0)
  *gbm_format = GBM_FORMAT_RGB565;
   else if (strcmp(s, "xrgb2101010") == 0)
 
Second, reading just the damaged pixels and y-flipping back the image:
 
diff -rup a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
--- a/libweston/compositor-rdp.c   2018-02-20 16:04:20.0 +0100
+++ b/libweston/compositor-rdp.c2018-02-20 16:10:37.575768246 +0100
@@ -146,6 +146,12 @@ struct rdp_output {
   struct gbm_surface *gbm_surface;
   pixman_image_t *shadow_surface;
+ int format;
+ int stride;
+ int height;
+ uint32_t *tmpdata, *image;
+ uint32_t tmpdata_size;
+
   struct wl_list peers;
};
@@ -391,12 +397,25 @@ rdp_output_repaint(struct weston_output
   if (pixman_region32_not_empty(damage)) {
  if (!b->use_pixman) {
  /* TODO: Performance: Only read 
pixels that was actually repained by renderer->repaint_output. */
- 
ec->renderer->read_pixels(output_base,
+/*
ec->renderer->read_pixels(output_base,
 
pixman_image_get_format(output->shadow_surface),
 
pixman_image_get_data(output->shadow_surface),
 0, 
0,
 
pixman_image_get_width(output->shadow_surface),
- 
pixman_image_get_height(output->shadow_surface));
+
pixman_image_get_height(output->shadow_surface));*/
+int
 i, nrects;
+int
 x, y, width, height;
+pixman_box32_t 
*rect=pixman_region32_rectangles(damage, );
+for (i=0; irenderer->read_pixels(output_base, output->format, output->tmpdata, x, 
output->height-rect[i].y2, width, height);
+
pixman_blt(output->tmpdata, output->image, -width, output->stride, 32, 32, 0, 
1-height, x, y, width, height);
+}
  }
   wl_list_for_each(outputPeer, >peers, 
link) {
@@ -650,6 +669,30 @@ rdp_output_fini_egl(struct rdp_output *o
}
 static int
+rdp_get_image_size(struct rdp_output *output)
+{
+ uint32_t  
image_size=pixman_image_get_width(output->shadow_surface)*pixman_image_get_height(output->shadow_surface)*sizeof(uint32_t);
+
+ if (output->tmpdata_size < image_size) {
+ free(output->tmpdata);
+ output->tmpdata = malloc(image_size);
+ if (output->tmpdata == NULL) {
+output->tmpdata_size = 0;
+errno = ENOMEM;
+return -1;
+ }
+ 
+ output->tmpdata_size =