diff --git a/.pick_status.json b/.pick_status.json
index 33d35f94261..a8f82c8fa82 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -6224,7 +6224,7 @@
"description": "rusticl/gl: flush and wait on gl objects inside clEnqueueAcquireGLObjects",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null
diff --git a/src/gallium/frontends/rusticl/api/memory.rs b/src/gallium/frontends/rusticl/api/memory.rs
index 33de229d6f6..7dec8612dae 100644
--- a/src/gallium/frontends/rusticl/api/memory.rs
+++ b/src/gallium/frontends/rusticl/api/memory.rs
@@ -3185,13 +3185,27 @@ fn enqueue_acquire_gl_objects(
return Err(CL_INVALID_GL_OBJECT);
}
+ // We need to flush on the applications thread:
+ //
+ // If an OpenGL context is bound to the current thread, then any OpenGL commands which
+ // 1. affect or access the contents of a memory object listed in the mem_objects list, and
+ // 2. were issued on that OpenGL context prior to the call to clEnqueueAcquireGLObjects
+ // will complete before execution of any OpenCL commands following the clEnqueueAcquireGLObjects
+ // which affect or access any of those memory objects. If a non-NULL event object is returned,
+ // it will report completion only after completion of such OpenGL commands.
+ let fence_fd = q.context.flush_gl_mem_objects(&objs)?;
create_and_queue(
q,
CL_COMMAND_ACQUIRE_GL_OBJECTS,
evs,
event,
false,
- Box::new(move |_, ctx| copy_cube_to_slice(ctx, &objs)),
+ Box::new(move |_, ctx| {
+ if let Some(fence_fd) = fence_fd {
+ ctx.import_fence(&fence_fd).gpu_wait(ctx);
+ }
+ copy_cube_to_slice(ctx, &objs)
+ }),
)
}
diff --git a/src/gallium/frontends/rusticl/core/context.rs b/src/gallium/frontends/rusticl/core/context.rs
index 7f58298fc45..5614f1faacd 100644
--- a/src/gallium/frontends/rusticl/core/context.rs
+++ b/src/gallium/frontends/rusticl/core/context.rs
@@ -10,6 +10,7 @@ use crate::core::util::*;
use crate::impl_cl_type_trait;
use mesa_rust::pipe::context::RWFlags;
+use mesa_rust::pipe::fence::FenceFd;
use mesa_rust::pipe::resource::*;
use mesa_rust::pipe::screen::ResourceType;
use mesa_rust_gen::*;
@@ -654,6 +655,11 @@ impl Context {
Ok(res)
}
+
+ pub fn flush_gl_mem_objects(&self, mem_objects: &[Mem]) -> CLResult