summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2018-03-07 13:47:28 -0500
committerJuan A. Suarez Romero <jasuarez@igalia.com>2018-03-28 16:51:20 +0200
commitb2603cdd528cce1cd1e69c64e50db8c54cc8a855 (patch)
treed0816cd17f5900f62cdaa14fd780e1a2a6d3e3e0
parent9475e58334e3eb7c33f55f6a760d531f92f6bcb4 (diff)
st/dri: fix OpenGL-OpenCL interop for GL_TEXTURE_BUFFER
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@amd.com> (cherry picked from commit db495b8962909f74e90b9eb0463fb37f37ac5f62) [Juan A. Suarez: resolve trivial conflicts] Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com> Conflicts: src/gallium/state_trackers/dri/dri2.c
-rw-r--r--src/gallium/state_trackers/dri/dri2.c58
1 files changed, 34 insertions, 24 deletions
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index e0cd0e0bc7c..cc55b69931c 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1793,32 +1793,17 @@ dri2_interop_export_object(__DRIcontext *_ctx,
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) {
- mtx_unlock(&ctx->Shared->Mutex);
- return MESA_GLINTEROP_INVALID_MIP_LEVEL;
- }
-
- if (!st_finalize_texture(ctx, st->pipe, obj, 0)) {
- 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. */
- mtx_unlock(&ctx->Shared->Mutex);
- return MESA_GLINTEROP_INVALID_OBJECT;
- }
+ if (!stBuf || !stBuf->buffer) {
+ /* this shouldn't happen */
+ 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 :
@@ -1826,6 +1811,31 @@ dri2_interop_export_object(__DRIcontext *_ctx,
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) {
+ mtx_unlock(&ctx->Shared->Mutex);
+ return MESA_GLINTEROP_INVALID_MIP_LEVEL;
+ }
+
+ if (!st_finalize_texture(ctx, st->pipe, obj, 0)) {
+ 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. */
+ 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;