Skip to content

mesa/st, dri2, wgl, d3d12: GL/CL interop interface

Jesse Natalie requested to merge jenatali/mesa:cl-gl-interop into main

This passes the CL/GL interop tests in the CL CTS for me.

There were already interop interfaces that were mostly what I'd want, with some things that needed to be changed:

  • They weren't implemented on Windows, only in the dri2 path. I moved the core impl to mesa/st and plumbed it into wgl and egl.
  • A path for implementing clEnqueueAcquireGLObjects was needed, which needs to explicitly resolve (flush_resource) the already-exported resources on the GL side. I added a new interop method for that. It returns a GLsync which can be used to implement the cl_event return from clEnqueueAcquireGLObjects instead of just doing an implicit glFinish in the call.
  • There was space in the resource export structs for driver private data, but it wasn't hooked up for gallium... so I added a pipe method to fill it out. For d3d12 specifically, I want to use that to export the raw ID3D12Resource COM object, because WDDM requires shareable resources to be declared as such upfront, and there's a cost to that so I don't want all GL resources to be shareable.
    • This also requires CL to share the GL screen's device, so I added a driver-private field to the device query to return the device (and queue, because why not).

I think this should be sufficient for anybody to implement CL/GL interop on a Mesa GL driver, including rusticl and CLOn12 (with copies of the Mesa/driver interop headers).

Edited by Jesse Natalie

Merge request reports

Loading