Re: [Mesa-dev] [PATCH v2 2/2] st/mesa: EGLImageTarget* error handling

2017-03-29 Thread Nicolai Hähnle

On 29.03.2017 14:28, Philipp Zabel wrote:

On Wed, 2017-03-29 at 13:01 +0200, Nicolai Hähnle wrote:

On 29.03.2017 09:44, Philipp Zabel wrote:

Stop trying to specify texture or renderbuffer objects for unsupported
EGL images. Generate the error codes specified in the OES_EGL_image
extension.

EGLImageTargetTexture2D and EGLImageTargetRenderbuffer would call
the pipe driver's create_surface callback without ever checking that
the given EGL image is actually compatible with the chosen target
texture or renderbuffer. This patch adds a call to the pipe driver's
is_format_supported callback and generates an INVALID_OPERATION error
for unsupported EGL images. If the EGL image handle does not describe
a valid EGL image, an INVALID_VALUE error is generated.

Signed-off-by: Philipp Zabel 
Reviewed-by: Nicolai Hähnle 
---
v2: fixed get_surface to actually use the usage and error parameters


The v2 usually goes above :)


Ok, I'll remember that next time.


Do you need someone to commit this for you?


Yes, please.


Done.



regards
Philipp




--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 2/2] st/mesa: EGLImageTarget* error handling

2017-03-29 Thread Philipp Zabel
On Wed, 2017-03-29 at 13:01 +0200, Nicolai Hähnle wrote:
> On 29.03.2017 09:44, Philipp Zabel wrote:
> > Stop trying to specify texture or renderbuffer objects for unsupported
> > EGL images. Generate the error codes specified in the OES_EGL_image
> > extension.
> >
> > EGLImageTargetTexture2D and EGLImageTargetRenderbuffer would call
> > the pipe driver's create_surface callback without ever checking that
> > the given EGL image is actually compatible with the chosen target
> > texture or renderbuffer. This patch adds a call to the pipe driver's
> > is_format_supported callback and generates an INVALID_OPERATION error
> > for unsupported EGL images. If the EGL image handle does not describe
> > a valid EGL image, an INVALID_VALUE error is generated.
> >
> > Signed-off-by: Philipp Zabel 
> > Reviewed-by: Nicolai Hähnle 
> > ---
> > v2: fixed get_surface to actually use the usage and error parameters
> 
> The v2 usually goes above :)

Ok, I'll remember that next time.

> Do you need someone to commit this for you?

Yes, please.

regards
Philipp

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 2/2] st/mesa: EGLImageTarget* error handling

2017-03-29 Thread Nicolai Hähnle

On 29.03.2017 09:44, Philipp Zabel wrote:

Stop trying to specify texture or renderbuffer objects for unsupported
EGL images. Generate the error codes specified in the OES_EGL_image
extension.

EGLImageTargetTexture2D and EGLImageTargetRenderbuffer would call
the pipe driver's create_surface callback without ever checking that
the given EGL image is actually compatible with the chosen target
texture or renderbuffer. This patch adds a call to the pipe driver's
is_format_supported callback and generates an INVALID_OPERATION error
for unsupported EGL images. If the EGL image handle does not describe
a valid EGL image, an INVALID_VALUE error is generated.

Signed-off-by: Philipp Zabel 
Reviewed-by: Nicolai Hähnle 
---
v2: fixed get_surface to actually use the usage and error parameters


The v2 usually goes above :)

Do you need someone to commit this for you?


---
 src/mesa/state_tracker/st_cb_eglimage.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_eglimage.c 
b/src/mesa/state_tracker/st_cb_eglimage.c
index e1fc9bff75..158a824e59 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -25,6 +25,7 @@
  *Chia-I Wu 
  */

+#include "main/errors.h"
 #include "main/texobj.h"
 #include "main/teximage.h"
 #include "util/u_inlines.h"
@@ -44,9 +45,11 @@
  * FIXME: I think this should operate on resources, not surfaces
  */
 static struct pipe_surface *
-st_egl_image_get_surface(struct gl_context *ctx, GLeglImageOES image_handle)
+st_egl_image_get_surface(struct gl_context *ctx, GLeglImageOES image_handle,
+ unsigned usage, const char *error)
 {
struct st_context *st = st_context(ctx);
+   struct pipe_screen *screen = st->pipe->screen;
struct st_manager *smapi =
   (struct st_manager *) st->iface.st_context_private;
struct st_egl_image stimg;
@@ -56,8 +59,18 @@ st_egl_image_get_surface(struct gl_context *ctx, 
GLeglImageOES image_handle)
   return NULL;

memset(, 0, sizeof(stimg));
-   if (!smapi->get_egl_image(smapi, (void *) image_handle, ))
+   if (!smapi->get_egl_image(smapi, (void *) image_handle, )) {
+  /* image_handle does not refer to a valid EGL image object */
+  _mesa_error(ctx, GL_INVALID_VALUE, error);
   return NULL;
+   }
+
+   if (!screen->is_format_supported(screen, stimg.format, PIPE_TEXTURE_2D,
+stimg.texture->nr_samples, usage)) {
+  /* unable to specify a texture object using the specified EGL image */
+  _mesa_error(ctx, GL_INVALID_OPERATION, error);
+  return NULL;
+   }

u_surface_default_template(_tmpl, stimg.texture);
surf_tmpl.format = stimg.format;
@@ -108,7 +121,8 @@ st_egl_image_target_renderbuffer_storage(struct gl_context 
*ctx,
struct st_renderbuffer *strb = st_renderbuffer(rb);
struct pipe_surface *ps;

-   ps = st_egl_image_get_surface(ctx, image_handle);
+   ps = st_egl_image_get_surface(ctx, image_handle, PIPE_BIND_RENDER_TARGET,
+"glEGLImageTargetRenderbufferStorage");
if (ps) {
   strb->Base.Width = ps->width;
   strb->Base.Height = ps->height;
@@ -192,7 +206,8 @@ st_egl_image_target_texture_2d(struct gl_context *ctx, 
GLenum target,
 {
struct pipe_surface *ps;

-   ps = st_egl_image_get_surface(ctx, image_handle);
+   ps = st_egl_image_get_surface(ctx, image_handle, PIPE_BIND_SAMPLER_VIEW,
+"glEGLImageTargetTexture2D");
if (ps) {
   st_bind_surface(ctx, target, texObj, texImage, ps);
   pipe_surface_reference(, NULL);




--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 2/2] st/mesa: EGLImageTarget* error handling

2017-03-29 Thread Philipp Zabel
Stop trying to specify texture or renderbuffer objects for unsupported
EGL images. Generate the error codes specified in the OES_EGL_image
extension.

EGLImageTargetTexture2D and EGLImageTargetRenderbuffer would call
the pipe driver's create_surface callback without ever checking that
the given EGL image is actually compatible with the chosen target
texture or renderbuffer. This patch adds a call to the pipe driver's
is_format_supported callback and generates an INVALID_OPERATION error
for unsupported EGL images. If the EGL image handle does not describe
a valid EGL image, an INVALID_VALUE error is generated.

Signed-off-by: Philipp Zabel 
Reviewed-by: Nicolai Hähnle 
---
v2: fixed get_surface to actually use the usage and error parameters
---
 src/mesa/state_tracker/st_cb_eglimage.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_eglimage.c 
b/src/mesa/state_tracker/st_cb_eglimage.c
index e1fc9bff75..158a824e59 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -25,6 +25,7 @@
  *Chia-I Wu 
  */
 
+#include "main/errors.h"
 #include "main/texobj.h"
 #include "main/teximage.h"
 #include "util/u_inlines.h"
@@ -44,9 +45,11 @@
  * FIXME: I think this should operate on resources, not surfaces
  */
 static struct pipe_surface *
-st_egl_image_get_surface(struct gl_context *ctx, GLeglImageOES image_handle)
+st_egl_image_get_surface(struct gl_context *ctx, GLeglImageOES image_handle,
+ unsigned usage, const char *error)
 {
struct st_context *st = st_context(ctx);
+   struct pipe_screen *screen = st->pipe->screen;
struct st_manager *smapi =
   (struct st_manager *) st->iface.st_context_private;
struct st_egl_image stimg;
@@ -56,8 +59,18 @@ st_egl_image_get_surface(struct gl_context *ctx, 
GLeglImageOES image_handle)
   return NULL;
 
memset(, 0, sizeof(stimg));
-   if (!smapi->get_egl_image(smapi, (void *) image_handle, ))
+   if (!smapi->get_egl_image(smapi, (void *) image_handle, )) {
+  /* image_handle does not refer to a valid EGL image object */
+  _mesa_error(ctx, GL_INVALID_VALUE, error);
   return NULL;
+   }
+
+   if (!screen->is_format_supported(screen, stimg.format, PIPE_TEXTURE_2D,
+stimg.texture->nr_samples, usage)) {
+  /* unable to specify a texture object using the specified EGL image */
+  _mesa_error(ctx, GL_INVALID_OPERATION, error);
+  return NULL;
+   }
 
u_surface_default_template(_tmpl, stimg.texture);
surf_tmpl.format = stimg.format;
@@ -108,7 +121,8 @@ st_egl_image_target_renderbuffer_storage(struct gl_context 
*ctx,
struct st_renderbuffer *strb = st_renderbuffer(rb);
struct pipe_surface *ps;
 
-   ps = st_egl_image_get_surface(ctx, image_handle);
+   ps = st_egl_image_get_surface(ctx, image_handle, PIPE_BIND_RENDER_TARGET,
+"glEGLImageTargetRenderbufferStorage");
if (ps) {
   strb->Base.Width = ps->width;
   strb->Base.Height = ps->height;
@@ -192,7 +206,8 @@ st_egl_image_target_texture_2d(struct gl_context *ctx, 
GLenum target,
 {
struct pipe_surface *ps;
 
-   ps = st_egl_image_get_surface(ctx, image_handle);
+   ps = st_egl_image_get_surface(ctx, image_handle, PIPE_BIND_SAMPLER_VIEW,
+"glEGLImageTargetTexture2D");
if (ps) {
   st_bind_surface(ctx, target, texObj, texImage, ps);
   pipe_surface_reference(, NULL);
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev