On Sun, Jul 18, 2010 at 9:04 PM, Thinker K.F. Li <thin...@branda.to> wrote:
> I had found that the state tracker of EGL does not implement
> eglCreatePbufferFromClientBuffer().  Without this function, user
> should copy pixels between pbuffers with a temporary buffer allocated
> by the application.  Are there any plan to implement it?
Does the attached patch work for you?  I've had it for a while, but did not
commit it due to the lack of a demo to verify.

-- 
o...@lunarg.com
From 0f5fbcfaff37fc846d2b4867cfd438c9e11ceb34 Mon Sep 17 00:00:00 2001
From: Chia-I Wu <o...@lunarg.com>
Date: Fri, 12 Mar 2010 09:54:12 +0800
Subject: [PATCH 1/2] st/vega: Implement get_resource_for_egl_image hook.

---
 src/gallium/state_trackers/vega/vg_manager.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c
index c2aa98b..f10ee80 100644
--- a/src/gallium/state_trackers/vega/vg_manager.c
+++ b/src/gallium/state_trackers/vega/vg_manager.c
@@ -332,6 +332,27 @@ vg_context_flush(struct st_context_iface *stctxi, unsigned flags,
       vg_manager_flush_frontbuffer(ctx);
 }
 
+static boolean
+vg_context_get_resource_for_egl_image(struct st_context_iface *stctxi,
+                                      struct st_context_resource *res)
+{
+   struct vg_image *img;
+
+   if (res->type != ST_CONTEXT_RESOURCE_OPENVG_PARENT_IMAGE ||
+       (VGImage) res->resource == VG_INVALID_HANDLE)
+      return FALSE;
+
+   img = (struct vg_image *) res->resource;
+   /* must be a parent image */
+   if (img->parent)
+      return FALSE;
+
+   res->texture = NULL;
+   pipe_resource_reference(&res->texture, img->sampler_view->texture);
+
+   return TRUE;
+}
+
 static void
 vg_context_destroy(struct st_context_iface *stctxi)
 {
@@ -365,6 +386,8 @@ vg_api_create_context(struct st_api *stapi, struct st_manager *smapi,
 
    ctx->iface.teximage = NULL;
    ctx->iface.copy = NULL;
+   ctx->iface.get_resource_for_egl_image =
+      vg_context_get_resource_for_egl_image;
 
    ctx->iface.st_context_private = (void *) smapi;
 
-- 
1.7.1

From 0afb39d7ca1d78646625b44c6da4fb60bd1ad979 Mon Sep 17 00:00:00 2001
From: Chia-I Wu <o...@lunarg.com>
Date: Mon, 19 Jul 2010 02:58:37 +0800
Subject: [PATCH 2/2] st/egl: Add support for pbuffer from EGL_OPENVG_IMAGE.

get_resource_for_egl_image is used to get the pipe_resource of an
VGImage.  It is not perfect.  The callback intentionally rejects child
images, while eglCreatePbufferFromClientBuffer allows it.  There is also
no access control.
---
 src/gallium/state_trackers/egl/common/egl_g3d_st.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
index 05cdb0d..9c1a7b3 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
@@ -34,6 +34,7 @@
 #include "egldriver.h"
 #include "eglimage.h"
 #include "eglmutex.h"
+#include "eglcurrent.h"
 
 #include "egl_g3d.h"
 #include "egl_g3d_st.h"
@@ -124,7 +125,21 @@ egl_g3d_st_framebuffer_flush_front_pbuffer(struct st_framebuffer_iface *stfbi,
 static void
 pbuffer_reference_openvg_image(struct egl_g3d_surface *gsurf)
 {
-   /* TODO */
+   _EGLContext *ctx = _eglGetAPIContext(EGL_OPENVG_API);
+   struct egl_g3d_context *gctx = egl_g3d_context(ctx);
+   struct st_context_resource stres;
+
+   memset(&stres, 0, sizeof(stres));
+   stres.type = ST_CONTEXT_RESOURCE_OPENVG_PARENT_IMAGE;
+   stres.resource = (void *) gsurf->client_buffer;
+
+   if (!gctx ||
+       !gctx->stctxi->get_resource_for_egl_image(gctx->stctxi, &stres)) {
+      _eglError(EGL_BAD_PARAMETER, "eglCreatePbufferFromClientBuffer");
+      return;
+   }
+
+   gsurf->render_texture = stres.texture;
 }
 
 static void
-- 
1.7.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to