Module: Mesa
Branch: main
Commit: 52e663959edd6085adadd66931efc9f61ae56333
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=52e663959edd6085adadd66931efc9f61ae56333

Author: Jesse Natalie <[email protected]>
Date:   Tue Sep 21 09:21:42 2021 -0700

egl/wgl: Hook up image validate/get in smapi

Acked-by: Daniel Stone <[email protected]>
Acked-by: Mike Blumenkrantz <[email protected]>
Acked-by: Sidney Just <[email protected]>
Acked-by: Jason Ekstrand <[email protected]>
Tested-by: Yonggang Luo <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12964>

---

 src/egl/drivers/wgl/egl_wgl.c              | 29 +++++++++++++++++++++++++++++
 src/gallium/frontends/wgl/stw_image.c      |  8 ++++++++
 src/gallium/frontends/wgl/stw_image.h      |  5 +++++
 src/gallium/targets/wgl/gallium_wgl.def.in |  1 +
 4 files changed, 43 insertions(+)

diff --git a/src/egl/drivers/wgl/egl_wgl.c b/src/egl/drivers/wgl/egl_wgl.c
index e04b037bf84..b90611b39a0 100644
--- a/src/egl/drivers/wgl/egl_wgl.c
+++ b/src/egl/drivers/wgl/egl_wgl.c
@@ -211,6 +211,33 @@ wgl_egl_st_get_param(struct st_manager *smapi, enum 
st_manager_param param)
    return 0;
 }
 
+static bool
+wgl_get_egl_image(struct st_manager *smapi, void *image, struct st_egl_image 
*out)
+{
+   struct wgl_egl_image *wgl_img = (struct wgl_egl_image *)image;
+   stw_translate_image(wgl_img->img, out);
+   return true;
+}
+
+static bool
+wgl_validate_egl_image(struct st_manager *smapi, void *image)
+{
+   struct wgl_egl_display *wgl_dpy = (struct wgl_egl_display *)smapi;
+   _EGLDisplay *disp = wgl_dpy->parent;
+   _EGLImage *img;
+
+   mtx_lock(&disp->Mutex);
+   img = _eglLookupImage(image, disp);
+   mtx_unlock(&disp->Mutex);
+
+   if (img == NULL) {
+      _eglError(EGL_BAD_PARAMETER, "wgl_validate_egl_image");
+      return false;
+   }
+
+   return true;
+}
+
 static EGLBoolean
 wgl_initialize_impl(_EGLDisplay *disp, HDC hdc)
 {
@@ -234,6 +261,8 @@ wgl_initialize_impl(_EGLDisplay *disp, HDC hdc)
 
    wgl_dpy->base.screen = stw_dev->screen;
    wgl_dpy->base.get_param = wgl_egl_st_get_param;
+   wgl_dpy->base.get_egl_image = wgl_get_egl_image;
+   wgl_dpy->base.validate_egl_image = wgl_validate_egl_image;
 
    disp->ClientAPIs = 0;
    if (_eglIsApiValid(EGL_OPENGL_API))
diff --git a/src/gallium/frontends/wgl/stw_image.c 
b/src/gallium/frontends/wgl/stw_image.c
index cedd8d25c29..78b245242d7 100644
--- a/src/gallium/frontends/wgl/stw_image.c
+++ b/src/gallium/frontends/wgl/stw_image.c
@@ -133,3 +133,11 @@ stw_destroy_image(struct stw_image *img)
    free(img);
 }
 
+void
+stw_translate_image(struct stw_image *in, struct st_egl_image *out)
+{
+   pipe_resource_reference(&out->texture, in->pres);
+   out->format = in->format;
+   out->layer = in->layer;
+   out->level = in->level;
+}
diff --git a/src/gallium/frontends/wgl/stw_image.h 
b/src/gallium/frontends/wgl/stw_image.h
index 2a1e04bcd16..2c477a3d8b4 100644
--- a/src/gallium/frontends/wgl/stw_image.h
+++ b/src/gallium/frontends/wgl/stw_image.h
@@ -28,6 +28,8 @@
 
 #include <GL/gl.h>
 
+struct st_egl_image;
+
 enum stw_image_error
 {
    STW_IMAGE_ERROR_SUCCESS,
@@ -55,3 +57,6 @@ stw_create_image_from_renderbuffer(struct stw_context *ctx, 
GLuint renderbuffer,
 
 void
 stw_destroy_image(struct stw_image *img);
+
+void
+stw_translate_image(struct stw_image *in, struct st_egl_image *out);
diff --git a/src/gallium/targets/wgl/gallium_wgl.def.in 
b/src/gallium/targets/wgl/gallium_wgl.def.in
index 76b93264382..7b482218fa4 100644
--- a/src/gallium/targets/wgl/gallium_wgl.def.in
+++ b/src/gallium/targets/wgl/gallium_wgl.def.in
@@ -42,3 +42,4 @@ stw_pbuffer_create
 stw_create_image_from_texture
 stw_create_image_from_renderbuffer
 stw_destroy_image
+stw_translate_image

Reply via email to