Giter Site home page Giter Site logo

Comments (4)

AdrianEddy avatar AdrianEddy commented on September 10, 2024 1

First of all, you mentioned that it is possible to interoperate outside of wgpu, how is this possible? Currently, there doesn't seem to be any method or implementation for the Texture type that returns the internal raw texture.

There are texture_from_raw , create_texture_from_hal, as_hal and raw_device methods already in wgpu which allow all the access to raw resources and importing/exporting them to/from external code. Check out the code I linked, it uses all these methods and it works fine

from wgpu.

AdrianEddy avatar AdrianEddy commented on September 10, 2024

there's #6161 but in general there's no universal interface to interop with all possible APIs.
I also wish there were, but for now I have a few interops implemented in Gyroflow in wgpu_interop*.rs ( gyroflow/gyroflow#565 )

btw, as far as I can tell, all the interops are possible to implement outside of wgpu, so wgpu itself doesn't need to change any APIs. It would be really nice to have it directly there though. If not, I was thinking about implementing it in a separate crate (and name it like wgpu-interop)

That might be a good question to the maintainers: Do you prefer more PRs like #6161 or a separate crate for these zero-copy texture/buffer interops?

from wgpu.

mycrl avatar mycrl commented on September 10, 2024

@AdrianEddy Thank you for answering my questions!

First of all, you mentioned that it is possible to interoperate outside of wgpu, how is this possible? Currently, there doesn't seem to be any method or implementation for the Texture type that returns the internal raw texture.

My understanding is that wgpu's Texture is just a wrapper around the backend texture, and if I'm wrong then there really isn't a good way to implement the as_raw and from_raw I mentioned above.

At the moment I don't need to interoperate between different backends, I think #6161 is for interoperating between different backends, from D3D to Vulkan.

Maybe I'm not describing it very well, what I might need is that if the backend wgpu is currently using is D3D, then Texture::from_raw_texture can only use D3D resources, and the same goes for other backends.

What I mean is, when wgpu and other external implementations are using the same backend, how can we easily use the external resources with zero overhead instead of sharing the resources between different implementations.

Because in reality, other implementations or modules (not even Rust at all) often use the same GPU devices and graphics APIs as the wgpu, in which case the resources of the other implementation or module can actually be used directly by the wgpu at zero or low cost.

Finally, to answer your last question, if the wgpu is using the same set of graphics APIs as the external implementation and needs to interoperate at this point, then I'd be inclined to have the wgpu itself support this behavior, but if it's across different graphics APIs/backends then I think it's best to let the external crate do the work and the wgpu doesn't have much need to bother with it.

Of course, this is just my personal opinion, so please forgive me and bring it up if you find it problematic.

from wgpu.

mycrl avatar mycrl commented on September 10, 2024

Sorry, I saw the method from_hal before but didn't understand how to use it, it feels like the example you gave here(https://github.com/gyroflow/gyroflow/blob/master/src/core/gpu/wgpu_interop_directx.rs#L186)
Sorry for taking up your time and thanks again.

from wgpu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.