Giter Site home page Giter Site logo

WGPU backend support about smithay HOT 3 OPEN

nohenry avatar nohenry commented on June 20, 2024
WGPU backend support

from smithay.

Comments (3)

heavyrain266 avatar heavyrain266 commented on June 20, 2024 1

Additionally, there is only one real learning resource for wgpu and it's pretty low quality. Another problem is that WebGPU standard is not stable and WGSL requires custom pre-processor to implement fake import directives and many other features present in GLSL and HLSL.

There is already discussion about wgpu, see discussions section.

from smithay.

i509VCB avatar i509VCB commented on June 20, 2024

Hi everyone! What are your thoughts on implementing a WGPU graphics backend? This seems related to #129 and #134. I'm wondering if there would be any benefit to using WGPU over gfx-hal as WGPU has a (mostly) safe api.

wgpu is indeed a safer API and hides a lot of nasty things like memory barriers. That is a plus over gfx-hal.

However there are some parts of a Wayland compositor that wgpu arguably does not go low enough level to let us access.

Here are some things wgpu does not address for a Wayland compositor (this list is not exhaustive):

  • Lacks the APIs for colorspace management, ala color representation protocol proposal (https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/183).
  • Cannot support YUV buffers (actually this might change, but it will only work for importing YUV formatted images gfx-rs/wgpu#3145)
  • wgpu does not natively support many features with the high level API (you'll need to manually do many of these things via the wgpu-hal API) including but not limited to:
    • Importing an texture from a dmabuf.
    • wgpu cannot allocate it's own buffers. This means the Offscreen trait is off limits.
    • wgpu does not allocate it's fences or whatever sync is internally to be exported as a sync fd (this is planned for the existing renderers)
    • Vulkan requires the extensions that are needed to be declared when creating an Instance and Device. This means you need to use wgpu-hal to initialize Vulkan.

Essentially wgpu lacks what is needed to be a first class renderer that I'd consider suitable for inclusion into Smithay.

However this does not mean wgpu is unusable.

It should be entirely possible to use wgpu as a guest renderer ontop of the gles2 (you'll need to ensure gles 3.0 is available because wgpu requires gles 3.0) or the future vulkan renderer. This would involve using the wgpu-hal APIs to create an Instance and Device while telling wgpu to not take ownership of the instance and device (which smithay would own).

I've been experimenting on my own with WGPU and DRM and have gotten EGL rendering but I still have yet to implement Vulkan.

I do have some pointers on that. In fact I have made a (hacky, it works on amdgpu with a 6700xt but stuff is hardcoded so it may just spit out errors on your system) example of how you'd render to a buffer wgpu imports via it's vulkan hal types and then scan it out: https://gist.github.com/i509VCB/649d3b62f23a458ef18d3f2f4731eca7

I do have a plan to adjust the VulkanAllocator to allow importing dmabufs so that if you truly wanted to do that you'd have smithay deal with all the mess of importing the dmabuf and give you a VkImage.

This does require using wgpu-hal, but it is a use case I do want to support. I am also on the smithay and wgpu matrix if you have questions about that (see the badges in the README).

from smithay.

Drakulix avatar Drakulix commented on June 20, 2024

Previous discussions on that subject for reference:

from smithay.

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.