Re: [Mesa-dev] [PATCH] mesa/st: fix yuv EGLImage's
On Wed, May 17, 2017 at 6:30 AM, Philipp Zabelwrote: > On Tue, 2017-05-16 at 10:33 -0400, Rob Clark wrote: >> Don't reject YUV formats that the driver doesn't handle natively, since >> mesa/st already knows how to lower this in shader. >> >> Fixes: 83e9de2 ("st/mesa: EGLImageTarget* error handling") >> Cc: 17.1 > Signed-off-by: Rob Clark >> --- >> src/mesa/state_tracker/st_cb_eglimage.c | 32 >> ++-- >> 1 file changed, 30 insertions(+), 2 deletions(-) >> >> diff --git a/src/mesa/state_tracker/st_cb_eglimage.c >> b/src/mesa/state_tracker/st_cb_eglimage.c >> index 3a62ef7..a104b64 100644 >> --- a/src/mesa/state_tracker/st_cb_eglimage.c >> +++ b/src/mesa/state_tracker/st_cb_eglimage.c >> @@ -39,6 +39,35 @@ >> #include "st_sampler_view.h" >> #include "util/u_surface.h" >> >> +static bool >> +is_format_supported(struct pipe_screen *screen, enum pipe_format format, >> +unsigned nr_samples, unsigned usage) >> +{ >> + bool supported = screen->is_format_supported(screen, format, >> PIPE_TEXTURE_2D, >> +nr_samples, usage); >> + >> + /* for sampling, some formats can be emulated.. it doesn't matter that >> +* the surface will have a format that the driver can't cope with because >> +* we'll give it sampler view formats that it can deal with and generate >> +* a shader variant that converts. >> +*/ >> + if ((usage == PIPE_BIND_SAMPLER_VIEW) && !supported) { >> + if (format == PIPE_FORMAT_IYUV) { >> + supported = screen->is_format_supported(screen, >> PIPE_FORMAT_R8_UNORM, >> + PIPE_TEXTURE_2D, >> nr_samples, >> + usage); >> + } else if (format == PIPE_FORMAT_NV12) { >> + supported = screen->is_format_supported(screen, >> PIPE_FORMAT_R8_UNORM, >> + PIPE_TEXTURE_2D, >> nr_samples, >> + usage) && >> + screen->is_format_supported(screen, >> PIPE_FORMAT_R8G8_UNORM, >> + PIPE_TEXTURE_2D, >> nr_samples, >> + usage); >> + } >> + } >> + >> + return supported; >> +} > > But this only works for target == GL_TEXTURE_EXTERNAL_OES, right? > If so, I think we would have to pass the target enum through > st_egl_image_get_surface to is_format_supported and make a decision > based on that. possibly, this doesn't seem to be enforced elsewhere.. but I've already pushed this patch BR, -R ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mesa/st: fix yuv EGLImage's
On Tue, 2017-05-16 at 10:33 -0400, Rob Clark wrote: > Don't reject YUV formats that the driver doesn't handle natively, since > mesa/st already knows how to lower this in shader. > > Fixes: 83e9de2 ("st/mesa: EGLImageTarget* error handling") > Cc: 17.1Signed-off-by: Rob Clark > --- > src/mesa/state_tracker/st_cb_eglimage.c | 32 ++-- > 1 file changed, 30 insertions(+), 2 deletions(-) > > diff --git a/src/mesa/state_tracker/st_cb_eglimage.c > b/src/mesa/state_tracker/st_cb_eglimage.c > index 3a62ef7..a104b64 100644 > --- a/src/mesa/state_tracker/st_cb_eglimage.c > +++ b/src/mesa/state_tracker/st_cb_eglimage.c > @@ -39,6 +39,35 @@ > #include "st_sampler_view.h" > #include "util/u_surface.h" > > +static bool > +is_format_supported(struct pipe_screen *screen, enum pipe_format format, > +unsigned nr_samples, unsigned usage) > +{ > + bool supported = screen->is_format_supported(screen, format, > PIPE_TEXTURE_2D, > +nr_samples, usage); > + > + /* for sampling, some formats can be emulated.. it doesn't matter that > +* the surface will have a format that the driver can't cope with because > +* we'll give it sampler view formats that it can deal with and generate > +* a shader variant that converts. > +*/ > + if ((usage == PIPE_BIND_SAMPLER_VIEW) && !supported) { > + if (format == PIPE_FORMAT_IYUV) { > + supported = screen->is_format_supported(screen, > PIPE_FORMAT_R8_UNORM, > + PIPE_TEXTURE_2D, nr_samples, > + usage); > + } else if (format == PIPE_FORMAT_NV12) { > + supported = screen->is_format_supported(screen, > PIPE_FORMAT_R8_UNORM, > + PIPE_TEXTURE_2D, nr_samples, > + usage) && > + screen->is_format_supported(screen, > PIPE_FORMAT_R8G8_UNORM, > + PIPE_TEXTURE_2D, nr_samples, > + usage); > + } > + } > + > + return supported; > +} But this only works for target == GL_TEXTURE_EXTERNAL_OES, right? If so, I think we would have to pass the target enum through st_egl_image_get_surface to is_format_supported and make a decision based on that. regards Philipp ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mesa/st: fix yuv EGLImage's
On 16.05.2017 16:33, Rob Clark wrote: Don't reject YUV formats that the driver doesn't handle natively, since mesa/st already knows how to lower this in shader. Fixes: 83e9de2 ("st/mesa: EGLImageTarget* error handling") Cc: 17.1Seems reasonable. Reviewed-by: Nicolai Hähnle --- src/mesa/state_tracker/st_cb_eglimage.c | 32 ++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index 3a62ef7..a104b64 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -39,6 +39,35 @@ #include "st_sampler_view.h" #include "util/u_surface.h" +static bool +is_format_supported(struct pipe_screen *screen, enum pipe_format format, +unsigned nr_samples, unsigned usage) +{ + bool supported = screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, +nr_samples, usage); + + /* for sampling, some formats can be emulated.. it doesn't matter that +* the surface will have a format that the driver can't cope with because +* we'll give it sampler view formats that it can deal with and generate +* a shader variant that converts. +*/ + if ((usage == PIPE_BIND_SAMPLER_VIEW) && !supported) { + if (format == PIPE_FORMAT_IYUV) { + supported = screen->is_format_supported(screen, PIPE_FORMAT_R8_UNORM, + PIPE_TEXTURE_2D, nr_samples, + usage); + } else if (format == PIPE_FORMAT_NV12) { + supported = screen->is_format_supported(screen, PIPE_FORMAT_R8_UNORM, + PIPE_TEXTURE_2D, nr_samples, + usage) && + screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM, + PIPE_TEXTURE_2D, nr_samples, + usage); + } + } + + return supported; +} /** * Return the surface of an EGLImage. @@ -65,8 +94,7 @@ st_egl_image_get_surface(struct gl_context *ctx, GLeglImageOES image_handle, return NULL; } - if (!screen->is_format_supported(screen, stimg.format, PIPE_TEXTURE_2D, -stimg.texture->nr_samples, usage)) { + if (!is_format_supported(screen, stimg.format, stimg.texture->nr_samples, usage)) { /* unable to specify a texture object using the specified EGL image */ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(format not supported)", error); return 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
Re: [Mesa-dev] [PATCH] mesa/st: fix yuv EGLImage's
On Tue, May 16, 2017 at 10:33 AM, Rob Clarkwrote: > Don't reject YUV formats that the driver doesn't handle natively, since > mesa/st already knows how to lower this in shader. I probably should have mentioned that 'kmscube -M nv12-1img' is a good way to test this BR, -R > Fixes: 83e9de2 ("st/mesa: EGLImageTarget* error handling") > Cc: 17.1 Signed-off-by: Rob Clark > --- > src/mesa/state_tracker/st_cb_eglimage.c | 32 ++-- > 1 file changed, 30 insertions(+), 2 deletions(-) > > diff --git a/src/mesa/state_tracker/st_cb_eglimage.c > b/src/mesa/state_tracker/st_cb_eglimage.c > index 3a62ef7..a104b64 100644 > --- a/src/mesa/state_tracker/st_cb_eglimage.c > +++ b/src/mesa/state_tracker/st_cb_eglimage.c > @@ -39,6 +39,35 @@ > #include "st_sampler_view.h" > #include "util/u_surface.h" > > +static bool > +is_format_supported(struct pipe_screen *screen, enum pipe_format format, > +unsigned nr_samples, unsigned usage) > +{ > + bool supported = screen->is_format_supported(screen, format, > PIPE_TEXTURE_2D, > +nr_samples, usage); > + > + /* for sampling, some formats can be emulated.. it doesn't matter that > +* the surface will have a format that the driver can't cope with because > +* we'll give it sampler view formats that it can deal with and generate > +* a shader variant that converts. > +*/ > + if ((usage == PIPE_BIND_SAMPLER_VIEW) && !supported) { > + if (format == PIPE_FORMAT_IYUV) { > + supported = screen->is_format_supported(screen, > PIPE_FORMAT_R8_UNORM, > + PIPE_TEXTURE_2D, nr_samples, > + usage); > + } else if (format == PIPE_FORMAT_NV12) { > + supported = screen->is_format_supported(screen, > PIPE_FORMAT_R8_UNORM, > + PIPE_TEXTURE_2D, nr_samples, > + usage) && > + screen->is_format_supported(screen, > PIPE_FORMAT_R8G8_UNORM, > + PIPE_TEXTURE_2D, nr_samples, > + usage); > + } > + } > + > + return supported; > +} > > /** > * Return the surface of an EGLImage. > @@ -65,8 +94,7 @@ st_egl_image_get_surface(struct gl_context *ctx, > GLeglImageOES image_handle, >return NULL; > } > > - if (!screen->is_format_supported(screen, stimg.format, PIPE_TEXTURE_2D, > -stimg.texture->nr_samples, usage)) { > + if (!is_format_supported(screen, stimg.format, stimg.texture->nr_samples, > usage)) { >/* unable to specify a texture object using the specified EGL image */ >_mesa_error(ctx, GL_INVALID_OPERATION, "%s(format not supported)", > error); >return NULL; > -- > 2.9.3 > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev