gallium: Flush GL API resources in eglCreateImage

Some drivers need to be able to remove compression from resources before
they are handed to consumers that wouldn't understand or expect it.

Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8663>
This commit is contained in:
Nanley Chery 2021-01-13 14:31:05 -08:00 committed by Marge Bot
parent 0a8cc88202
commit b26f510978
1 changed files with 20 additions and 2 deletions

View File

@ -258,7 +258,9 @@ dri2_create_image_from_renderbuffer2(__DRIcontext *context,
int renderbuffer, void *loaderPrivate,
unsigned *error)
{
struct gl_context *ctx = ((struct st_context *)dri_context(context)->st)->ctx;
struct st_context *st_ctx = (struct st_context *)dri_context(context)->st;
struct gl_context *ctx = st_ctx->ctx;
struct pipe_context *p_ctx = st_ctx->pipe;
struct gl_renderbuffer *rb;
struct pipe_resource *tex;
__DRIimage *img;
@ -300,6 +302,13 @@ dri2_create_image_from_renderbuffer2(__DRIcontext *context,
pipe_resource_reference(&img->texture, tex);
/* If the resource supports EGL_MESA_image_dma_buf_export, make sure that
* it's in a shareable state. Do this now while we still have the access to
* the context.
*/
if (dri2_get_mapping_by_format(img->dri_format))
p_ctx->flush_resource(p_ctx, tex);
*error = __DRI_IMAGE_ERROR_SUCCESS;
return img;
}
@ -338,7 +347,9 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture,
void *loaderPrivate)
{
__DRIimage *img;
struct gl_context *ctx = ((struct st_context *)dri_context(context)->st)->ctx;
struct st_context *st_ctx = (struct st_context *)dri_context(context)->st;
struct gl_context *ctx = st_ctx->ctx;
struct pipe_context *p_ctx = st_ctx->pipe;
struct gl_texture_object *obj;
struct pipe_resource *tex;
GLuint face = 0;
@ -389,6 +400,13 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture,
pipe_resource_reference(&img->texture, tex);
/* If the resource supports EGL_MESA_image_dma_buf_export, make sure that
* it's in a shareable state. Do this now while we still have the access to
* the context.
*/
if (dri2_get_mapping_by_format(img->dri_format))
p_ctx->flush_resource(p_ctx, tex);
*error = __DRI_IMAGE_ERROR_SUCCESS;
return img;
}