cuda-python icon indicating copy to clipboard operation
cuda-python copied to clipboard

Sharing buffers with display renderers (like OpenGL, Vulkan, etc.)

Open jakirkham opened this issue 1 year ago • 4 comments

A common use case is to do some computation on the GPU and then render the result in a display ( https://github.com/cupy/cupy/issues/5711 ) ( https://github.com/vispy/vispy/issues/1985 ) ( https://github.com/vispy/vispy/issues/1986 ) ( https://github.com/napari/napari/issues/2243 ). This could be an image that is shown or a plot or something else. Given the registration/unregistration and mapping/unmappaing of memory, this can generate quite a bit of boilerplate in Python ( https://github.com/vispy/vispy/pull/2391 ), which in turn hinders adoption. Ideally some standard objections/functions could be supplied (ideally in CUDA Python) that users could leverage to prep data for rendering. Preferably they could use one function call to covert any __cuda_array_interface__, __dlpack__, etc. supporting object into one that can be used for rendering (and hang onto the lifetimes of any supporting buffers via RAII-style semantics)

jakirkham avatar Nov 13 '24 22:11 jakirkham

Adding @rparolin to evaluate how the APIs would look like to make comptue-graphics interop easy and performant

leofang avatar Sep 10 '25 23:09 leofang

@leofang : Is there a use case that we are looking to enable that can help focus the conversation? Is there a graphics API that the majority of the community is using? For example, pygame? opengl?

rparolin avatar Sep 16 '25 00:09 rparolin

I think OpenGL should be the primary target. John has linked to various discussions and works in the issue description that some of us contributed to in the past few years, which should be good starting points especially those involving CuPy <-> vispy inter-op.

leofang avatar Sep 18 '25 01:09 leofang

My understanding is users would like an object that represents a GL buffer (analogous to StridedMemoryView) and has RAII style behavior so cleanup happens during Python GC

Having a function to facilitate that conversion (StridedMemoryView to GLStridedMemoryView?) would also help

This comment captures this: https://github.com/vispy/vispy/issues/1986#issuecomment-1307609294

jakirkham avatar Jan 10 '26 03:01 jakirkham