[Mesa-dev] [PATCH 1/6] st/dri: allow to create image for formats that only support SV or RT binding
Eric Anholt
eric at anholt.net
Fri Apr 19 18:16:26 UTC 2019
Michel Dänzer <michel at daenzer.net> writes:
> On 2019-04-12 7:33 p.m., Lucas Stach wrote:
>> Unconditionally requesting both bindings can lead to premature
>> failure to create a valid image.
>>
>> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
>> ---
>> src/gallium/state_trackers/dri/dri2.c | 13 +++++++++++--
>> 1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
>> index efb43c0d7973..510b7f8d04a7 100644
>> --- a/src/gallium/state_trackers/dri/dri2.c
>> +++ b/src/gallium/state_trackers/dri/dri2.c
>> @@ -987,14 +987,23 @@ dri2_create_image_common(__DRIscreen *_screen,
>> {
>> const struct dri2_format_mapping *map = dri2_get_mapping_by_format(format);
>> struct dri_screen *screen = dri_screen(_screen);
>> + struct pipe_screen *pscreen = screen->base.screen;
>> __DRIimage *img;
>> struct pipe_resource templ;
>> - unsigned tex_usage;
>> + unsigned tex_usage = 0;
>>
>> if (!map)
>> return NULL;
>>
>> - tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
>> + if (pscreen->is_format_supported(pscreen, map->pipe_format, screen->target,
>> + 0, 0, PIPE_BIND_RENDER_TARGET))
>> + tex_usage |= PIPE_BIND_RENDER_TARGET;
>> + if (pscreen->is_format_supported(pscreen, map->pipe_format, screen->target,
>> + 0, 0, PIPE_BIND_SAMPLER_VIEW))
>> + tex_usage |= PIPE_BIND_SAMPLER_VIEW;
>> +
>> + if (!tex_usage)
>> + return NULL;
>>
>> if (use & __DRI_IMAGE_USE_SCANOUT)
>> tex_usage |= PIPE_BIND_SCANOUT;
>>
>
> Since there are no __DRI_IMAGE_USE_* flags for rendering & sampling, the
> expectation does seem to be that both are supported. What happens if an
> image is created for a format which only supports sampling, then the
> caller attempts rendering to it?
From OES_EGL_image.txt:
If the GL is unable to specify a texture object using the supplied
eglImageOES <image> (if, for example, <image> refers to a multisampled
eglImageOES), the error INVALID_OPERATION is generated.
...
If the GL is unable to create a renderbuffer using the specified
eglImageOES, the error INVALID_OPERATION is generated. If <image>
does not refer to a valid eglImageOES object, the error
INVALID_VALUE is generated.
and st_cb_eglimage.c is checking the screen for sampler / rendertarget
support for the images that it looks up.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190419/eec89e49/attachment.sig>
More information about the mesa-dev
mailing list