Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interop with underlying graphics API #965

Closed
dylanede opened this issue Oct 7, 2020 · 8 comments
Closed

Interop with underlying graphics API #965

dylanede opened this issue Oct 7, 2020 · 8 comments
Labels
area: api Issues related to API surface type: question Further information is requested

Comments

@dylanede
Copy link

dylanede commented Oct 7, 2020

Is there a user-facing mechanism for accessing the native API handles underlying given wgpu objects so that interop can be performed? If not, are there any plans for such an escape hatch? Specifically I'm interested in using external memory objects from Vulkan.

@kvark kvark added area: api Issues related to API surface type: question Further information is requested labels Oct 7, 2020
@kvark
Copy link
Member

kvark commented Oct 7, 2020

There isn't currently any mechanism to do so. I assume that you are talking about native-only support, outside of WebGPU proper. In this case, first step would be implementing the "external memory objects" in gfx-hal. Then we'd be able to hook it up here.

@AdrianEddy
Copy link
Contributor

Is there any progress on this issue?

My use case is the following: I want to do video processing on the GPU, I have the textures from OpenGL, Metal, DirectX and Vulkan and I would like to pass them to wgpu, process the pixels and draw it back, all without going through CPU memory.

I use Qt and it supports different graphic APIs via the QRhi, so it'd be nice to be able to support the same graphic APIs to do the processing directly, and for that I need to be able to feed the wgpu shader with an external texture and render target from the underlying graphic api.

@kvark
Copy link
Member

kvark commented Dec 17, 2021

There is quite a bit of progress overall, although more may be needed.
First, we have our own wgpu-hal now, not using gfx-hal any more. So doing any plumbing work becomes much easier - everything is in this repo.
Second, we have create_texture_from_hal - #1609

@coderedart
Copy link
Contributor

coderedart commented Apr 19, 2022

I have a use case where i would like to export a wgpu texture, so that i can use it in opengl.
I need window level transparency and wgpu does not support it at the moment. #687
even if it exposes the composite modes, nvidia drivers (vulkan) only export opaque mode, but don't care about it.instead they just allow transparency. since its a very niche issue, i'm afraid driver devs won't take it seriously and prioritize it or any bugs that follow after exposing composite modes.

meanwhile, opengl works great already for transparency.
the second use case is using older apps like mpv. mpv can use opengl context to render its video directly into my app. there is no mature video player using vk/wgpu afaik like mpv, so using opengl is helpful.

but ofcourse, all the unsafe and thread-safety of openGL :( is horrible to deal with in rust.

my plan is to

  1. create an opengl window
  2. create wgpu (vk ) texture.
  3. import that texture into opengl.
  4. render all my stuff in wgpu using its safe and rusty api into the exported texture.
  5. put it on to gl framebuffer. use mpv to render video if needed. swapBuffers in opengl after synchronization.
  6. repeat 4 and 5.

I can then release the above opengl-wgpu hybrid version, and a normal full wgpu version. those who have issues with vk drivers can use hybrid version.

this way, i can stay with wgpu 90% of the time and only use opengl in specific / backwards compatible places, waiting to deprecate it as issues are fixed or wgpu getting GL backend.

@cwfitzgerald
Copy link
Member

Note that wgpu does have an OpenGL backend, so you shouldn't need to share between native apis at all, you can just run us from that same context

@coderedart
Copy link
Contributor

coderedart commented Apr 19, 2022

that's nice. but i need vulkan backend.

  1. angle is only Best Effort Support according to README :(
  2. rend3 only lists vulkan / dx / metal as its supported platforms( with vulkan for gpu-driven profile). :(
  3. I also need some features like multi draw indirect count or non-uniform indexing which are only available on vulkan :(

@coderedart
Copy link
Contributor

#1460 might be a duplicate of this

@cwfitzgerald
Copy link
Member

Closing in favor of #4067 which is a concrete plan

@cwfitzgerald cwfitzgerald closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface type: question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants