[Mesa-dev] [PATCH] st/dri: fix OpenGL-OpenCL interop for GL_TEXTURE_BUFFER
Alex Deucher
alexdeucher at gmail.com
Thu Mar 8 19:13:43 UTC 2018
On Wed, Mar 7, 2018 at 3:35 PM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> Tested by our OpenCL team.
>
> Fixes: 9c499e6759b26c5e "st/mesa: don't invoke st_finalize_texture & st_convert_sampler for TBOs"
Acked-by: Alex Deucher <alexander.deucher at amd.com>
> ---
> src/gallium/state_trackers/dri/dri2.c | 58 ++++++++++++++++++++---------------
> 1 file changed, 34 insertions(+), 24 deletions(-)
>
> diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
> index 2a3a2a8..31d17d4 100644
> --- a/src/gallium/state_trackers/dri/dri2.c
> +++ b/src/gallium/state_trackers/dri/dri2.c
> @@ -1870,53 +1870,63 @@ dri2_interop_export_object(__DRIcontext *_ctx,
> * miplevel is zero or if the GL texture object is incomplete."
> */
> if (!obj ||
> obj->Target != target ||
> !obj->_BaseComplete ||
> (in->miplevel > 0 && !obj->_MipmapComplete)) {
> simple_mtx_unlock(&ctx->Shared->Mutex);
> return MESA_GLINTEROP_INVALID_OBJECT;
> }
>
> - /* From OpenCL 2.0 SDK, clCreateFromGLTexture:
> - * "CL_INVALID_MIP_LEVEL if miplevel is less than the value of
> - * levelbase (for OpenGL implementations) or zero (for OpenGL ES
> - * implementations); or greater than the value of q (for both OpenGL
> - * and OpenGL ES). levelbase and q are defined for the texture in
> - * section 3.8.10 (Texture Completeness) of the OpenGL 2.1
> - * specification and section 3.7.10 of the OpenGL ES 2.0."
> - */
> - if (in->miplevel < obj->BaseLevel || in->miplevel > obj->_MaxLevel) {
> - simple_mtx_unlock(&ctx->Shared->Mutex);
> - return MESA_GLINTEROP_INVALID_MIP_LEVEL;
> - }
> -
> - if (!st_finalize_texture(ctx, st->pipe, obj, 0)) {
> - simple_mtx_unlock(&ctx->Shared->Mutex);
> - return MESA_GLINTEROP_OUT_OF_RESOURCES;
> - }
> + if (target == GL_TEXTURE_BUFFER) {
> + struct st_buffer_object *stBuf =
> + st_buffer_object(obj->BufferObject);
>
> - res = st_get_texobj_resource(obj);
> - if (!res) {
> - /* Incomplete texture buffer object? This shouldn't really occur. */
> - simple_mtx_unlock(&ctx->Shared->Mutex);
> - return MESA_GLINTEROP_INVALID_OBJECT;
> - }
> + if (!stBuf || !stBuf->buffer) {
> + /* this shouldn't happen */
> + simple_mtx_unlock(&ctx->Shared->Mutex);
> + return MESA_GLINTEROP_INVALID_OBJECT;
> + }
> + res = stBuf->buffer;
>
> - if (target == GL_TEXTURE_BUFFER) {
> out->internal_format = obj->BufferObjectFormat;
> out->buf_offset = obj->BufferOffset;
> out->buf_size = obj->BufferSize == -1 ? obj->BufferObject->Size :
> obj->BufferSize;
>
> obj->BufferObject->UsageHistory |= USAGE_DISABLE_MINMAX_CACHE;
> } else {
> + /* From OpenCL 2.0 SDK, clCreateFromGLTexture:
> + * "CL_INVALID_MIP_LEVEL if miplevel is less than the value of
> + * levelbase (for OpenGL implementations) or zero (for OpenGL ES
> + * implementations); or greater than the value of q (for both OpenGL
> + * and OpenGL ES). levelbase and q are defined for the texture in
> + * section 3.8.10 (Texture Completeness) of the OpenGL 2.1
> + * specification and section 3.7.10 of the OpenGL ES 2.0."
> + */
> + if (in->miplevel < obj->BaseLevel || in->miplevel > obj->_MaxLevel) {
> + simple_mtx_unlock(&ctx->Shared->Mutex);
> + return MESA_GLINTEROP_INVALID_MIP_LEVEL;
> + }
> +
> + if (!st_finalize_texture(ctx, st->pipe, obj, 0)) {
> + simple_mtx_unlock(&ctx->Shared->Mutex);
> + return MESA_GLINTEROP_OUT_OF_RESOURCES;
> + }
> +
> + res = st_get_texobj_resource(obj);
> + if (!res) {
> + /* Incomplete texture buffer object? This shouldn't really occur. */
> + simple_mtx_unlock(&ctx->Shared->Mutex);
> + return MESA_GLINTEROP_INVALID_OBJECT;
> + }
> +
> out->internal_format = obj->Image[0][0]->InternalFormat;
> out->view_minlevel = obj->MinLevel;
> out->view_numlevels = obj->NumLevels;
> out->view_minlayer = obj->MinLayer;
> out->view_numlayers = obj->NumLayers;
> }
> }
>
> /* Get the handle. */
> switch (in->access) {
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list