mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 09:30:13 +01:00
mesa: simplify st_egl_image binding process for texture storage
The dmabuf imported edge case is now properly handled. Signed-off-by: Simon Zeni <simon@bl4ckb0ne.ca> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18673>
This commit is contained in:
parent
25f569f58a
commit
6a3f5c6512
3 changed files with 35 additions and 52 deletions
|
|
@ -3543,13 +3543,32 @@ egl_image_target_texture(struct gl_context *ctx,
|
|||
|
||||
texObj->External = GL_TRUE;
|
||||
|
||||
struct st_egl_image stimg;
|
||||
bool native_supported;
|
||||
if (!st_get_egl_image(ctx, image, PIPE_BIND_SAMPLER_VIEW, caller,
|
||||
&stimg, &native_supported))
|
||||
return;
|
||||
|
||||
if (tex_storage) {
|
||||
st_egl_image_target_tex_storage(ctx, target, texObj, texImage,
|
||||
image);
|
||||
} else {
|
||||
st_egl_image_target_texture_2d(ctx, target, texObj, texImage,
|
||||
image);
|
||||
/* EXT_EGL_image_storage
|
||||
* If the EGL image was created using EGL_EXT_image_dma_buf_import,
|
||||
* then the following applies:
|
||||
* - <target> must be GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES.
|
||||
* Otherwise, the error INVALID_OPERATION is generated.
|
||||
*/
|
||||
if (stimg.imported_dmabuf &&
|
||||
(target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES)) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"%s(texture is imported from dmabuf)", caller);
|
||||
return;
|
||||
}
|
||||
st_bind_egl_image(ctx, texObj, texImage, &stimg, true, native_supported);
|
||||
} else {
|
||||
st_bind_egl_image(ctx, texObj, texImage, &stimg,
|
||||
target != GL_TEXTURE_EXTERNAL_OES, native_supported);
|
||||
}
|
||||
|
||||
pipe_resource_reference(&stimg.texture, NULL);
|
||||
|
||||
_mesa_dirty_texobj(ctx, texObj);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ is_nv12_as_r8_g8b8_supported(struct pipe_screen *screen, struct st_egl_image *ou
|
|||
/**
|
||||
* Return the gallium texture of an EGLImage.
|
||||
*/
|
||||
static bool
|
||||
bool
|
||||
st_get_egl_image(struct gl_context *ctx, GLeglImageOES image_handle,
|
||||
unsigned usage, const char *error, struct st_egl_image *out,
|
||||
bool *native_supported)
|
||||
|
|
@ -260,7 +260,7 @@ st_egl_image_target_renderbuffer_storage(struct gl_context *ctx,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
st_bind_egl_image(struct gl_context *ctx,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage,
|
||||
|
|
@ -410,44 +410,6 @@ st_bind_egl_image(struct gl_context *ctx,
|
|||
_mesa_dirty_texobj(ctx, texObj);
|
||||
}
|
||||
|
||||
void
|
||||
st_egl_image_target_texture_2d(struct gl_context *ctx, GLenum target,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage,
|
||||
GLeglImageOES image_handle)
|
||||
{
|
||||
struct st_egl_image stimg;
|
||||
bool native_supported;
|
||||
|
||||
if (!st_get_egl_image(ctx, image_handle, PIPE_BIND_SAMPLER_VIEW,
|
||||
"glEGLImageTargetTexture2D", &stimg,
|
||||
&native_supported))
|
||||
return;
|
||||
|
||||
st_bind_egl_image(ctx, texObj, texImage, &stimg,
|
||||
target != GL_TEXTURE_EXTERNAL_OES,
|
||||
native_supported);
|
||||
pipe_resource_reference(&stimg.texture, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
st_egl_image_target_tex_storage(struct gl_context *ctx, GLenum target,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage,
|
||||
GLeglImageOES image_handle)
|
||||
{
|
||||
struct st_egl_image stimg;
|
||||
bool native_supported;
|
||||
|
||||
if (!st_get_egl_image(ctx, image_handle, PIPE_BIND_SAMPLER_VIEW,
|
||||
"glEGLImageTargetTexture2D", &stimg,
|
||||
&native_supported))
|
||||
return;
|
||||
|
||||
st_bind_egl_image(ctx, texObj, texImage, &stimg, true, native_supported);
|
||||
pipe_resource_reference(&stimg.texture, NULL);
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
st_validate_egl_image(struct gl_context *ctx, GLeglImageOES image_handle)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,14 +35,16 @@ extern void
|
|||
st_init_eglimage_functions(struct dd_function_table *functions,
|
||||
bool has_egl_image_validate);
|
||||
|
||||
void st_egl_image_target_texture_2d(struct gl_context *ctx, GLenum target,
|
||||
bool st_get_egl_image(struct gl_context *ctx, GLeglImageOES image_handle,
|
||||
unsigned usage, const char *error,
|
||||
struct st_egl_image *out, bool *native_supported);
|
||||
void st_bind_egl_image(struct gl_context *ctx,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage,
|
||||
GLeglImageOES image_handle);
|
||||
void st_egl_image_target_tex_storage(struct gl_context *ctx, GLenum target,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage,
|
||||
GLeglImageOES image_handle);
|
||||
struct st_egl_image *stimg,
|
||||
bool tex_storage,
|
||||
bool native_supported);
|
||||
|
||||
void st_egl_image_target_renderbuffer_storage(struct gl_context *ctx,
|
||||
struct gl_renderbuffer *rb,
|
||||
GLeglImageOES image_handle);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue