diff options
Diffstat (limited to '0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch')
-rw-r--r-- | 0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch | 290 |
1 files changed, 146 insertions, 144 deletions
diff --git a/0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch b/0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch index 516af4bc3312..1ab6d5cf0900 100644 --- a/0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch +++ b/0002-gl-renderer-Add-support-for-EGLDevice-composited-fra.patch @@ -1,9 +1,8 @@ -From 75abc9e631667949c2ab8cf46882206d4ed71d0e Mon Sep 17 00:00:00 2001 +From e3914a22b9dfb64705b2bcc8d497ebb464fa2fc7 Mon Sep 17 00:00:00 2001 From: "Miguel A. Vico" <mvicomoya@nvidia.com> Date: Mon, 2 May 2016 16:34:01 +0200 Subject: [PATCH 2/6] gl-renderer: Add support for EGLDevice composited frame presentation -X-NVConfidentiality: public EGLDevice provides means to enumerate native devices, and then create an EGL display connection from them. @@ -42,54 +41,129 @@ Reviewed-by: Andy Ritger <aritger@nvidia.com> Reviewed-by: Adam Cheney <acheney@nvidia.com> Reviewed-by: James Jones <jajones@nvidia.com> --- - libweston/gl-renderer.c | 262 +++++++++++++++++++++++++++++++++++++++- - libweston/gl-renderer.h | 16 +++ - shared/weston-egl-ext.h | 40 ++++++ - 3 files changed, 315 insertions(+), 3 deletions(-) + libweston/renderer-gl/egl-glue.c | 45 +++++ + libweston/renderer-gl/gl-renderer-internal.h | 22 +++ + libweston/renderer-gl/gl-renderer.c | 197 ++++++++++++++++++- + libweston/renderer-gl/gl-renderer.h | 15 ++ + shared/weston-egl-ext.h | 40 ++++ + 5 files changed, 314 insertions(+), 5 deletions(-) -diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c -index 74315347..f3fb2c65 100644 ---- a/libweston/gl-renderer.c -+++ b/libweston/gl-renderer.c -@@ -101,6 +101,8 @@ struct gl_output_state { - struct gl_border_image borders[4]; - enum gl_border_status border_status; - -+ EGLStreamKHR egl_stream; -+ - struct weston_matrix output_matrix; +diff --git a/libweston/renderer-gl/egl-glue.c b/libweston/renderer-gl/egl-glue.c +index 28be4ffe..60cebd8f 100644 +--- a/libweston/renderer-gl/egl-glue.c ++++ b/libweston/renderer-gl/egl-glue.c +@@ -503,6 +503,8 @@ platform_to_extension(EGLenum platform) + return "x11"; + case EGL_PLATFORM_SURFACELESS_MESA: + return "surfaceless"; ++ case EGL_PLATFORM_DEVICE_EXT: ++ return "device"; + default: + assert(0 && "bad EGL platform enum"); + } +@@ -600,6 +602,19 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec) + (void *) eglGetProcAddress("eglQueryWaylandBufferWL"); + gr->set_damage_region = + (void *) eglGetProcAddress("eglSetDamageRegionKHR"); ++ gr->get_output_layers = (void *) eglGetProcAddress("eglGetOutputLayersEXT"); ++ gr->query_output_layer_attrib = ++ (void *) eglGetProcAddress("eglQueryOutputLayerAttribEXT"); ++ gr->create_stream = (void *) eglGetProcAddress("eglCreateStreamKHR"); ++ gr->destroy_stream = (void *) eglGetProcAddress("eglDestroyStreamKHR"); ++ gr->create_stream_producer_surface = ++ (void *) eglGetProcAddress("eglCreateStreamProducerSurfaceKHR"); ++ gr->stream_consumer_output = ++ (void *) eglGetProcAddress("eglStreamConsumerOutputEXT"); ++#ifdef EGL_NV_stream_attrib ++ gr->stream_consumer_acquire_attrib = ++ (void *) eglGetProcAddress("eglStreamConsumerAcquireAttribNV"); ++#endif - EGLSyncKHR begin_render_sync, end_render_sync; -@@ -238,6 +240,28 @@ struct gl_renderer { + extensions = + (const char *) eglQueryString(gr->egl_display, EGL_EXTENSIONS); +@@ -689,5 +704,35 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec) + "to missing EGL_KHR_wait_sync extension\n"); + } - int has_surfaceless_context; ++ if (weston_check_egl_extension(extensions, "EGL_EXT_output_base")) ++ gr->has_egl_output_base = true; ++ ++ if (weston_check_egl_extension(extensions, "EGL_EXT_output_drm")) ++ gr->has_egl_output_drm = true; ++ ++ if (weston_check_egl_extension(extensions, "EGL_NV_output_drm_flip_event")) ++ gr->has_egl_output_drm_flip_event = true; ++ ++ if (weston_check_egl_extension(extensions, "EGL_KHR_stream")) ++ gr->has_egl_stream = true; ++ ++ if (weston_check_egl_extension(extensions, "EGL_KHR_stream_producer_eglsurface")) ++ gr->has_egl_stream_producer_eglsurface = true; ++ ++ if (weston_check_egl_extension(extensions, "EGL_EXT_stream_consumer_egloutput")) ++ gr->has_egl_stream_consumer_egloutput = true; ++ ++ if (weston_check_egl_extension(extensions, "EGL_NV_stream_attrib")) ++ gr->has_egl_stream_attrib = true; ++ ++ if (weston_check_egl_extension(extensions, "EGL_EXT_stream_acquire_mode")) ++ gr->has_egl_stream_acquire_mode = true; ++ ++ if (weston_check_egl_extension(extensions, "EGL_KHR_stream_consumer_gltexture")) ++ gr->has_egl_stream_consumer_gltexture = true; ++ ++ if (weston_check_egl_extension(extensions, "EGL_WL_wayland_eglstream")) ++ gr->has_egl_wayland_eglstream = true; ++ + return 0; + } +diff --git a/libweston/renderer-gl/gl-renderer-internal.h b/libweston/renderer-gl/gl-renderer-internal.h +index 529cb2f9..e122f64a 100644 +--- a/libweston/renderer-gl/gl-renderer-internal.h ++++ b/libweston/renderer-gl/gl-renderer-internal.h +@@ -91,6 +91,28 @@ struct gl_renderer { + struct wl_list dmabuf_images; + struct wl_list dmabuf_formats; + PFNEGLGETOUTPUTLAYERSEXTPROC get_output_layers; + PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC query_output_layer_attrib; -+ int has_egl_output_base; -+ int has_egl_output_drm; -+ int has_egl_output_drm_flip_event; ++ bool has_egl_output_base; ++ bool has_egl_output_drm; ++ bool has_egl_output_drm_flip_event; + + PFNEGLCREATESTREAMKHRPROC create_stream; + PFNEGLDESTROYSTREAMKHRPROC destroy_stream; -+ int has_egl_stream; ++ bool has_egl_stream; + + PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC create_stream_producer_surface; -+ int has_egl_stream_producer_eglsurface; ++ bool has_egl_stream_producer_eglsurface; + + PFNEGLSTREAMCONSUMEROUTPUTEXTPROC stream_consumer_output; -+ int has_egl_stream_consumer_egloutput; ++ bool has_egl_stream_consumer_egloutput; + +#ifdef EGL_NV_stream_attrib + PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC stream_consumer_acquire_attrib; +#endif -+ int has_egl_stream_attrib; -+ int has_egl_stream_acquire_mode; ++ bool has_egl_stream_attrib; ++ bool has_egl_stream_acquire_mode; + - int has_dmabuf_import; - struct wl_list dmabuf_images; + bool has_gl_texture_rg; + + struct gl_shader texture_shader_rgba; +diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c +index 0c9e197a..6fc469ba 100644 +--- a/libweston/renderer-gl/gl-renderer.c ++++ b/libweston/renderer-gl/gl-renderer.c +@@ -91,6 +91,8 @@ struct gl_output_state { + struct gl_border_image borders[4]; + enum gl_border_status border_status; + ++ EGLStreamKHR egl_stream; ++ + struct weston_matrix output_matrix; -@@ -1503,6 +1527,38 @@ gl_renderer_repaint_output(struct weston_output *output, + EGLSyncKHR begin_render_sync, end_render_sync; +@@ -1521,6 +1523,38 @@ gl_renderer_repaint_output(struct weston_output *output, update_buffer_release_fences(compositor, output); } @@ -128,7 +202,7 @@ index 74315347..f3fb2c65 100644 static int gl_renderer_read_pixels(struct weston_output *output, pixman_format_code_t format, void *pixels, -@@ -3195,9 +3251,93 @@ gl_renderer_create_window_surface(struct gl_renderer *gr, +@@ -3238,9 +3272,93 @@ gl_renderer_create_window_surface(struct gl_renderer *gr, return egl_surface; } @@ -223,7 +297,7 @@ index 74315347..f3fb2c65 100644 { struct gl_output_state *go; int i; -@@ -3207,6 +3347,7 @@ gl_renderer_output_create(struct weston_output *output, +@@ -3250,6 +3368,7 @@ gl_renderer_output_create(struct weston_output *output, return -1; go->egl_surface = surface; @@ -231,7 +305,7 @@ index 74315347..f3fb2c65 100644 for (i = 0; i < BUFFER_DAMAGE_COUNT; i++) pixman_region32_init(&go->buffer_damage[i]); -@@ -3244,13 +3385,41 @@ gl_renderer_output_window_create(struct weston_output *output, +@@ -3283,7 +3402,7 @@ gl_renderer_output_window_create(struct weston_output *output, return -1; } @@ -240,6 +314,15 @@ index 74315347..f3fb2c65 100644 if (ret < 0) weston_platform_destroy_egl_surface(gr->egl_display, egl_surface); +@@ -3322,13 +3441,41 @@ gl_renderer_output_pbuffer_create(struct weston_output *output, + return -1; + } + +- ret = gl_renderer_output_create(output, egl_surface); ++ ret = gl_renderer_output_create(output, egl_surface, EGL_NO_STREAM_KHR); + if (ret < 0) + eglDestroySurface(gr->egl_display, egl_surface); + return ret; } @@ -274,7 +357,7 @@ index 74315347..f3fb2c65 100644 static void gl_renderer_output_destroy(struct weston_output *output) { -@@ -3280,6 +3449,9 @@ gl_renderer_output_destroy(struct weston_output *output) +@@ -3358,6 +3505,9 @@ gl_renderer_output_destroy(struct weston_output *output) if (go->end_render_sync != EGL_NO_SYNC_KHR) gr->destroy_sync(gr->egl_display, go->end_render_sync); @@ -284,87 +367,21 @@ index 74315347..f3fb2c65 100644 free(go); } -@@ -3393,6 +3565,19 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec) - (void *) eglGetProcAddress("eglUnbindWaylandDisplayWL"); - gr->query_buffer = - (void *) eglGetProcAddress("eglQueryWaylandBufferWL"); -+ gr->get_output_layers = (void *) eglGetProcAddress("eglGetOutputLayersEXT"); -+ gr->query_output_layer_attrib = -+ (void *) eglGetProcAddress("eglQueryOutputLayerAttribEXT"); -+ gr->create_stream = (void *) eglGetProcAddress("eglCreateStreamKHR"); -+ gr->destroy_stream = (void *) eglGetProcAddress("eglDestroyStreamKHR"); -+ gr->create_stream_producer_surface = -+ (void *) eglGetProcAddress("eglCreateStreamProducerSurfaceKHR"); -+ gr->stream_consumer_output = -+ (void *) eglGetProcAddress("eglStreamConsumerOutputEXT"); -+#ifdef EGL_NV_stream_attrib -+ gr->stream_consumer_acquire_attrib = -+ (void *) eglGetProcAddress("eglStreamConsumerAcquireAttribNV"); -+#endif - - extensions = - (const char *) eglQueryString(gr->egl_display, EGL_EXTENSIONS); -@@ -3467,6 +3652,30 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec) - "to missing EGL_KHR_wait_sync extension\n"); - } - -+ if (weston_check_egl_extension(extensions, "EGL_EXT_output_base")) -+ gr->has_egl_output_base = 1; -+ -+ if (weston_check_egl_extension(extensions, "EGL_EXT_output_drm")) -+ gr->has_egl_output_drm = 1; -+ -+ if (weston_check_egl_extension(extensions, "EGL_NV_output_drm_flip_event")) -+ gr->has_egl_output_drm_flip_event = 1; -+ -+ if (weston_check_egl_extension(extensions, "EGL_KHR_stream")) -+ gr->has_egl_stream = 1; -+ -+ if (weston_check_egl_extension(extensions, "EGL_KHR_stream_producer_eglsurface")) -+ gr->has_egl_stream_producer_eglsurface = 1; -+ -+ if (weston_check_egl_extension(extensions, "EGL_EXT_stream_consumer_egloutput")) -+ gr->has_egl_stream_consumer_egloutput = 1; -+ -+ if (weston_check_egl_extension(extensions, "EGL_NV_stream_attrib")) -+ gr->has_egl_stream_attrib = 1; -+ -+ if (weston_check_egl_extension(extensions, "EGL_EXT_stream_acquire_mode")) -+ gr->has_egl_stream_acquire_mode = 1; -+ - renderer_setup_egl_client_extensions(gr); - - return 0; -@@ -3492,6 +3701,15 @@ static const EGLint gl_renderer_alpha_attribs[] = { - EGL_NONE - }; +@@ -3503,7 +3653,8 @@ gl_renderer_display_create(struct weston_compositor *ec, + if (gl_renderer_setup_egl_extensions(ec) < 0) + goto fail_with_error; -+static const EGLint gl_renderer_opaque_stream_attribs[] = { -+ EGL_SURFACE_TYPE, EGL_STREAM_BIT_KHR, -+ EGL_RED_SIZE, 1, -+ EGL_GREEN_SIZE, 1, -+ EGL_BLUE_SIZE, 1, -+ EGL_ALPHA_SIZE, 0, -+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, -+ EGL_NONE -+}; +- if (!gr->has_configless_context) { ++ if (!gr->has_configless_context || ++ options->egl_platform == EGL_PLATFORM_DEVICE_EXT) { + EGLint egl_surface_type = options->egl_surface_type; - /** Checks whether a platform EGL client extension is supported - * -@@ -3565,6 +3783,8 @@ platform_to_extension(EGLenum platform) - return "wayland"; - case EGL_PLATFORM_X11_KHR: - return "x11"; -+ case EGL_PLATFORM_DEVICE_EXT: -+ return "device"; - default: - assert(0 && "bad EGL platform enum"); - } -@@ -3706,6 +3926,38 @@ gl_renderer_display_create(struct weston_compositor *ec, EGLenum platform, + if (!gr->has_surfaceless_context) +@@ -3526,6 +3677,38 @@ gl_renderer_display_create(struct weston_compositor *ec, if (gr->has_native_fence_sync && gr->has_wait_sync) ec->capabilities |= WESTON_CAP_EXPLICIT_SYNC; -+ if (platform == EGL_PLATFORM_DEVICE_EXT) { ++ if (options->egl_platform == EGL_PLATFORM_DEVICE_EXT) { + if (!gr->has_egl_output_base || + !gr->has_egl_output_drm || + !gr->has_egl_stream || @@ -399,51 +416,36 @@ index 74315347..f3fb2c65 100644 wl_list_init(&gr->dmabuf_images); if (gr->has_dmabuf_import) { gr->base.import_dmabuf = gl_renderer_import_dmabuf; -@@ -4077,10 +4329,12 @@ gl_renderer_get_drm_device_file(EGLDeviceEXT device, - WL_EXPORT struct gl_renderer_interface gl_renderer_interface = { - .opaque_attribs = gl_renderer_opaque_attribs, - .alpha_attribs = gl_renderer_alpha_attribs, -+ .opaque_stream_attribs = gl_renderer_opaque_stream_attribs, - +@@ -3892,9 +4075,13 @@ WL_EXPORT struct gl_renderer_interface gl_renderer_interface = { .display_create = gl_renderer_display_create, - .display = gl_renderer_display, .output_window_create = gl_renderer_output_window_create, + .output_pbuffer_create = gl_renderer_output_pbuffer_create, + .output_stream_create = gl_renderer_output_stream_create, .output_destroy = gl_renderer_output_destroy, - .output_surface = gl_renderer_output_surface, .output_set_border = gl_renderer_output_set_border, -@@ -4088,5 +4342,7 @@ WL_EXPORT struct gl_renderer_interface gl_renderer_interface = { - .print_egl_error_state = gl_renderer_print_egl_error_state, - + .create_fence_fd = gl_renderer_create_fence_fd, ++ .get_devices = gl_renderer_get_devices, - .get_drm_device_file = gl_renderer_get_drm_device_file + .get_drm_device_file = gl_renderer_get_drm_device_file, + + .output_stream_flip = gl_renderer_output_stream_flip }; -diff --git a/libweston/gl-renderer.h b/libweston/gl-renderer.h -index 151879da..973097bf 100644 ---- a/libweston/gl-renderer.h -+++ b/libweston/gl-renderer.h -@@ -60,6 +60,7 @@ enum gl_renderer_border_side { - struct gl_renderer_interface { - const EGLint *opaque_attribs; - const EGLint *alpha_attribs; -+ const EGLint *opaque_stream_attribs; - - int (*display_create)(struct weston_compositor *ec, - EGLenum platform, -@@ -78,6 +79,9 @@ struct gl_renderer_interface { - const EGLint *visual_id, - const int n_ids); +diff --git a/libweston/renderer-gl/gl-renderer.h b/libweston/renderer-gl/gl-renderer.h +index 80c3379b..f46c21c6 100644 +--- a/libweston/renderer-gl/gl-renderer.h ++++ b/libweston/renderer-gl/gl-renderer.h +@@ -179,6 +179,9 @@ struct gl_renderer_interface { + int (*output_pbuffer_create)(struct weston_output *output, + const struct gl_renderer_pbuffer_options *options); + int (*output_stream_create)(struct weston_output *output, + uint32_t plane_id, uint32_t crtc_id); + void (*output_destroy)(struct weston_output *output); - EGLSurface (*output_surface)(struct weston_output *output); -@@ -129,5 +133,17 @@ struct gl_renderer_interface { + /* Sets the output border. +@@ -226,4 +229,16 @@ struct gl_renderer_interface { int (*get_drm_device_file)(EGLDeviceEXT device, const char **drm_device_file); @@ -460,12 +462,11 @@ index 151879da..973097bf 100644 + int (*output_stream_flip)(struct weston_output *output, + void *flip_data); }; - diff --git a/shared/weston-egl-ext.h b/shared/weston-egl-ext.h -index 0784ea2d..f39990ed 100644 +index 4a757c8b..dc07c04a 100644 --- a/shared/weston-egl-ext.h +++ b/shared/weston-egl-ext.h -@@ -204,12 +204,52 @@ typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, +@@ -208,6 +208,45 @@ typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, #define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 #endif @@ -511,13 +512,14 @@ index 0784ea2d..f39990ed 100644 #else /* ENABLE_EGL */ /* EGL platform definition are keept to allow compositor-xx.c to build */ - #define EGL_PLATFORM_GBM_KHR 0x31D7 +@@ -215,6 +254,7 @@ typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, #define EGL_PLATFORM_WAYLAND_KHR 0x31D8 #define EGL_PLATFORM_X11_KHR 0x31D5 + #define EGL_PLATFORM_SURFACELESS_MESA 0x31DD +#define EGL_PLATFORM_DEVICE_EXT 0x313F #endif /* ENABLE_EGL */ -- -2.21.0 +2.25.1 |