Native WebGPU implementation based on gfx-hal

Overview

This is an active GitHub mirror of the WebGPU implementation in Rust, which now lives in "gfx/wgpu" of Mozilla-central. Issues and pull requests are accepted, but some bidirectional synchronization may be involved.

WebGPU

Matrix Matrix Build Status

This is the core logic of an experimental WebGPU implementation. It's written in Rust and is based on gfx-hal with help of gpu-alloc and gpu-descriptor. See the upstream WebGPU specification (work in progress).

The implementation consists of the following parts:

  • Crates.io docs.rs - internal Rust API for WebGPU implementations to use
  • Crates.io docs.rs - Rust types shared between wgpu-core and wgpu-rs
  • player - standalone application for replaying the API traces, uses winit

This repository contains the core of wgpu, and is not usable directly by applications. If you are looking for the user-facing Rust API, you need wgpu-rs. If you are looking for the native implementation or bindings to the API in other languages, you need wgpu-native.

Supported Platforms

API Windows 7/10 Linux & Android macOS & iOS
DX11 🆗
DX12
Vulkan
Metal
GL ES3 🚧

= Primary support — 🆗 = Secondary support — 🚧 = Unsupported, but support in progress

Comments
  • Relicense under dual MIT/Apache-2.0

    Relicense under dual MIT/Apache-2.0

    TL;DR the Rust ecosystem is largely Apache-2.0. Being available under that license is good for interoperation. The MIT license as an add-on can be nice for GPLv2 projects to use your code.

    Why?

    The MIT license requires reproducing countless copies of the same copyright header with different names in the copyright field, for every MIT library in use. The Apache license does not have this drawback. However, this is not the primary motivation for me creating these issues. The Apache license also has protections from patent trolls and an explicit contribution licensing clause. However, the Apache license is incompatible with GPLv2. This is why Rust is dual-licensed as MIT/Apache (the "primary" license being Apache, MIT only for GPLv2 compat), and doing so would be wise for this project. This also makes this crate suitable for inclusion and unrestricted sharing in the Rust standard distribution and other projects using dual MIT/Apache, such as my personal ulterior motive, the Robigalia project.

    Some ask, "Does this really apply to binary redistributions? Does MIT really require reproducing the whole thing?" I'm not a lawyer, and I can't give legal advice, but some Google Android apps include open source attributions using this interpretation. Others also agree with it. But, again, the copyright notice redistribution is not the primary motivation for the dual-licensing. It's stronger protections to licensees and better interoperation with the wider Rust ecosystem.

    How?

    To do this, get explicit approval from each contributor of copyrightable work (as not all contributions qualify for copyright, due to not being a "creative work", e.g. a typo fix) and then add the following to your README:

    ## License
    
    Licensed under either of
    
     * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
     * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
    
    at your option.
    
    ### Contribution
    
    Unless you explicitly state otherwise, any contribution intentionally submitted
    for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
    additional terms or conditions.
    

    and in your license headers, if you have them, use the following boilerplate (based on that used in Rust):

    // Copyright 2021 wgpu Developers
    //
    // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
    // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
    // http://opensource.org/licenses/MIT>, at your option. This file may not be
    // copied, modified, or distributed except according to those terms.
    

    It's commonly asked whether license headers are required. I'm not comfortable making an official recommendation either way, but the Apache license recommends it in their appendix on how to use the license.

    Be sure to add the relevant LICENSE-{MIT,APACHE} files. You can copy these from the Rust repo for a plain-text version.

    And don't forget to update the license metadata in your Cargo.toml to:

    license = "MIT OR Apache-2.0"
    

    I'll be going through projects which agree to be relicensed and have approval by the necessary contributors and doing this changes, so feel free to leave the heavy lifting to me!

    Contributor checkoff

    To agree to relicensing, comment with :

    I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to choose either at their option.
    

    Or, if you're a contributor, you can check the box in this repo next to your name. My scripts will pick this exact phrase up and check your checkbox, but I'll come through and manually review this issue later as well.

    • [x] @0x182d4454fb211940
    • [x] @98devin
    • [x] @Aaron1011
    • [x] @AlphaModder
    • [x] @Andful
    • [x] @AndrewGaspar
    • [x] @Atul9
    • [x] @Coder-256
    • [x] @DasEtwas
    • [x] @DavidPeicho
    • [x] @DevOrc
    • [x] @Diggsey
    • [x] @Dinnerbone
    • [x] @Dispersia
    • [x] @Dy11on
    • [x] @ElArtista
    • [x] @Frizi
    • [x] @Fruup
    • [x] @FuriouZz
    • [x] @GabrielMajeri
    • [x] @Gordon-F
    • [x] @HalfVoxel
    • [x] @HanKruiger
    • [x] @Healthire
    • [x] @HeroesGrave
    • [x] @Imberflur
    • [x] @JCapucho
    • [x] @JMS55
    • [ ] @Kimundi
    • [x] @Korijn
    • [x] @LPGhatguy
    • [x] @LU15W1R7H
    • [x] @LaylConway
    • [x] @MarkSwanson
    • [x] @Michael-Lfx
    • [x] @Napokue
    • [x] @Nehliin
    • [x] @OlegOAndreev
    • [x] @OptimisticPeach
    • [x] @PENGUINLIONG
    • [x] @Pat-Lafon
    • [x] @RichoDemus
    • [x] @ShalokShalom
    • [x] @StarArawn
    • [x] @StygianLightning
    • [x] @Systemcluster
    • [x] @Tnze
    • [x] @Uriopass
    • [x] @Vengarioth
    • [x] @Veykril
    • [x] @VincentJousse
    • [x] @WindowsVista42
    • [x] @Wumpf
    • [x] @Yatekii
    • [x] @acowley
    • [x] @adamnemecek
    • [x] @alankemp
    • [x] @almarklein
    • [x] @aloucks
    • [ ] @andykilroy
    • [x] @antonok-edm
    • [x] @arashikou
    • [x] @ashpil
    • [x] @benfrankel
    • [x] @bfrazho
    • [x] @bors[bot]
    • [x] @cab
    • [x] @cart
    • [x] @chinedufn
    • [x] @cloudhead
    • [x] @cormac-obrien
    • [x] @crispweed
    • [x] @csnewman
    • [x] @cwfitzgerald
    • [x] @danaugrs
    • [x] @danwilhelm
    • [x] @daveshah1
    • [x] @daxpedda
    • [x] @de-vri-es
    • [x] @dhardy
    • [x] @dragly
    • [x] @dzil123
    • [x] @expenses
    • [x] @fintelia
    • [x] @francesco-cattoglio
    • [x] @frbimo
    • [x] @glandium
    • [x] @grovesNL
    • [x] @hasenbanck
    • [x] @hecrj
    • [x] @igowen
    • [x] @im-0
    • [x] @infinitesnow
    • [x] @jakobhellermann
    • [x] @jazzay
    • [x] @jinleili
    • [x] @jshrake
    • [x] @kazimuth
    • [x] @kejor
    • [x] @khoek
    • [x] @kocsis1david
    • [x] @krupitskas
    • [x] @kunalmohan
    • [x] @kvark
    • [x] @kyren
    • [x] @lachlansneff
    • [x] @lain-dono
    • [x] @lberrymage
    • [x] @lordnoriyuki
    • [x] @lucacasonato
    • [x] @maghoff
    • [x] @malu
    • [x] @manuel-woelker
    • [x] @manugildev
    • [x] @maroider
    • [x] @memoryruins
    • [x] @mitchmindtree
    • [x] @mkeeter
    • [x] @msiglreith
    • [x] @nathany
    • [x] @neachdainn
    • [x] @niklaskorz
    • [x] @parasyte
    • [x] @paulkernfeld
    • [ ] @porky11
    • [x] @psincf
    • [x] @qthree
    • [x] @quadrupleslap
    • [x] @rukai
    • [x] @runemopar
    • [x] @rybertm
    • [x] @scoopr
    • [x] @segfault87
    • [x] @seivan
    • [x] @silphendio
    • [x] @snuk182
    • [x] @staktrace
    • [x] @swiftcoder
    • [x] @terrence2
    • [x] @unconed
    • [x] @unrelentingtech
    • [x] @waywardmonkeys
    • [x] @yanchith
    • [x] @yutannihilation
    • [x] @yzsolt
    • [ ] @zakorgy
    • [x] @zicklag
    • [ ] @masonblier
    area: infrastructure 
    opened by kvark 172
  • Implement WebGL2 Backend

    Implement WebGL2 Backend

    Connections Works towards #1617 .

    Closes #1740.

    Description Migrates the WebGL2 backend from gfx-hal-backend to wgpu-hal.

    Testing Tested WebGL ( Brave Browser ( Chrome fork ), and Firefox ) and GL backends on Ubuntu 20.04 in.


    Currently only the cube, triangle, and msaa-line examples work. This is still work-in-progress, with some things still to be done, but I wanted to get the code up here, and there isn't a lot that I think will changing drastically.

    image

    Remaining Work

    • [x] A little script for building and serving the examples for web
    • [x] Fix fastclear bug workaround
    • [x] Update shadows example to not use SSBOs on WebGL
    • [x] Fix lack of sRGB conversion
    • [x] Properly determining the web hardware limit values ( see adapter.rs:183 )
    • [ ] Fix webgl-lint errors
    • [ ] Fix issue with water rendering on water shader
    opened by zicklag 42
  • DeviceLost with D3D12 on Intel HD 4000

    DeviceLost with D3D12 on Intel HD 4000

    I was trying this tutorial on my laptop but it does not run. The message is:

    called Result::unwrap() on an Err value: DeviceLost

    at ...\wgpu-core-0.5.6\src\device\life.rs:263.

    My laptop is running Intel HD Graphics 4000, but it runs fine on my desktop with a GTX 1080. The issue still persists with examples from this repo.

    type: bug 
    opened by MarekLg 40
  • Executable cross-compiled from Linux to Windows will not run on Wine

    Executable cross-compiled from Linux to Windows will not run on Wine

    Description Executable cross-compiled from Linux to Windows will not run on Wine. Memory types offered by Wine are not compatible with what WGPU wants.

    fixme:vkd3d_allocate_device_memory: Failed to find suitable memory type (allowed types 0x82).

    Here's the Vulkan spec for those bits.

    I realize this is likely to result in finger-pointing between the WGPU side ("Wine doesn't support the memory type we want") and the Wine side ("WGPU should be more flexible in the types of memory it accepts.") The NVidia position is stated here: Discussion by NVidia: "A memory allocator that follows the rules and guidance of the Vulkan specification should be able to handle all these memory types gracefully by properly interpreting the VkMemoryRequirements::memoryTypeBits member when selecting an allocation for a specific resource."

    Repro steps

    1. Install current Rust on Ubuntu Linux (20.04 LTS used).
    2. Install current Wine (6.0.1) or use Wine 5 that ships with 20.04 LTS.
    3. Install Rust target for x86_64-pc-windows-gnu
    4. Build WGPU examples for that target, debug mode.
    5. wine cube.exe

    Expected vs observed behavior Expected cube to appear in a window. Got errors. See attachment.

    Extra materials Screenshots to help explain your problem. Validation logs can be attached in case there are warnings and errors. Zip-compressed API traces and GPU captures can also land here.

    Platform Information about your OS, version of wgpu, your tech stack, etc. Ubuntu 20.04 LTS. Tried two different machines, one with Wine 6.0.1 (current stable) and one with the Wine 5 that ships with Ubuntu.

    wgpubug01.txt

    type: enhancement help wanted external: driver-bug 
    opened by John-Nagle 32
  • Every 676 frames, Queue::write_buffer takes ~25ms

    Every 676 frames, Queue::write_buffer takes ~25ms

    Description Every 676 frames (varies by vsync / workload, but is exact within one set of settings), one Queue::write_buffer or Device::create_buffer call takes ~25ms. The submit call on the next frame also takes longer than usual, generally about 16ms.

    See also: https://github.com/gfx-rs/wgpu-rs/issues/363, since it appears to be a similar issue with a previous allocator.

    Repro steps I don't have a minimal example and the code that I am experiencing this in is not public, but here's the general overview for reproduction.

    My application allocates most memory at the start, and only rarely creates new buffers. There are about 10 write_buffer calls per frame, with reasonably small buffers for each. A random one of these calls takes 25ms on the spike frame. My application allocates a large amount of memory, which could be causing this. It allocates 1 or 2 128MiB vertex buffers, and sub allocates within those buffers to reduce vertex buffer swapping. There are not many individual buffers, so that shouldn't be the cause of the issue.

    To find the spikes, I have been using tracing and tracing-tracy; this integrates with wgpu's tracing setup, so it can show some more detail.

    Expected vs observed behavior I would expect the frame time to be consistent, with no random or regular spikes. Instead, once every n frames, a single Queue::write_buffer call takes 25ms, and submitting the next frame after that frame (not the submit after the write, the second submit after the write...) takes ~10ms.

    The n here varies based on whether vsync is enabled or the general frame time, but is very consistent. The number of frames between all frame spikes are the exact same, while the time may vary. Running a more minimal render and increasing the framerate as much as possible makes this more visible.

    Extra materials These images use the Tracy profiler, watching tracing's output at the trace level for all crates. I added a patch to gpu-alloc to add more tracing information - most of the time is spent in the backend allocate memory function, which I believe is provided in gfx-hal in this case.

    Tracy inspection of a two frame spike: Tracy view of the frame spike Comparison to nearby normal frames: Tracy view of the frame spike with nearby frames shown for comparison

    Platform GPU: GTX 970 OS: Manjaro Linux Backend used: Vulkan wgpu version: 0.7.0

    type: bug help wanted area: performance 
    opened by Aeledfyr 28
  • Relicense Examples to More Permissive License

    Relicense Examples to More Permissive License

    Because the examples are MPL, they carry with them a requirement that any copies of them also be MPL. This is obviously not desired as we want the examples to be copyable.

    Steps to accomplish this:

    • [x] Determine license (MIT/Apache)
    • [x] Enumerate all contributors with code in examples using git blame
    • [x] Ask for permission from them.
    • [ ] Relicense
    type: enhancement area: ecosystem 
    opened by cwfitzgerald 27
  • Add buffer debug labels

    Add buffer debug labels

    Related #404

    @kvark Is this what you had in mind? The webgpu headers have labels on all the descriptor structs and I didn't see any specific functions for altering/adding labels after creation. I'll add the rest if this looks good to you.

    I also went looking for command buffer marker support in gfx-hal so that I could add group labels and markers. Is this functionality absent in hal or did I miss it?

    opened by aloucks 27
  • Use EGL surfaceless platform when windowing system is not found

    Use EGL surfaceless platform when windowing system is not found

    Connections Addresses #1551

    Description Falling back to egl::DEFAULT_DISPLAY usually results in X11 EGL platform being picked and then rejected because of unavailability on a head/GPU-less system. EGL_PLATFORM_SURFACELESS_MESA works with both radeonsi and llvmpipe/swrast when Xorg/Wayland sockets are being hidden from application. Needs to be tested in a truly GPU-less environment such as CI it is required to run in.

    Testing MESA_LOADER_DRIVER_OVERRIDE=llvmpipe RUST_BACKTRACE=1 RUST_LOG=info WAYLAND_DISPLAY= DISPLAY= WGPU_BACKEND=gl cargo run --example capture MESA_LOADER_DRIVER_OVERRIDE=llvmpipe RUST_BACKTRACE=1 RUST_LOG=info WAYLAND_DISPLAY= DISPLAY= WGPU_BACKEND=vulkan cargo run --example capture

    Tested on a desktop, but without X/Wayland accessible for test program (same conditions led to eglInitialize error). red.png is being created and has proper content.

    @ maintainers please test in CI

    opened by sh7dm 25
  • OffscreenCanvas Support for WebGL Backend

    OffscreenCanvas Support for WebGL Backend

    Connections Ideas discussed in #1686, Thanks @zicklag for helping me to get started 🙏

    Description The goal is to expose create_surface_from_canvas() and create_surface_from_offscreen_canvas() also for the WebGL Backend.

    Testing Will be tested in Firefox and Chrome on Windows 10. The skybox_offscreen example can be used for testing.

    opened by haraldreingruber-dedalus 24
  • wgpu may lock up in ioctl on Linux/Vulkan/Intel

    wgpu may lock up in ioctl on Linux/Vulkan/Intel

    Description Under certain scenarios, we may see a hang in ioctl.

    Repro steps Unknown.

    Expected vs observed behavior No hangs.

    Extra materials Looks like this is described in https://www.reddit.com/r/vulkan/comments/b37762/command_queue_grows_indefinitely_on_intel_gpus/ Edit: actually, no, we aren't expecting vkAcquireNextImageKHR to block. We are explicitly blocking on the fence, which was passed to it, instead.

    Platform wgpu master

    type: bug help wanted external: driver-bug 
    opened by kvark 24
  • Fastclear Bug With Intel Mesa Adapters on the GL Backend

    Fastclear Bug With Intel Mesa Adapters on the GL Backend

    Description When using the OpenGL backend on Linux the clear color seems to behaving strangely. For one, the color itself is lighter than it should be. For two, the borders around any objects drawn on top of the clear color have an even lighter, pixelated version of the clear color.

    I'm currently troubleshooting but I opened the issue to start the discussion. With my experimentation so far it seems completely related to the act of clearing the draw framebuffer. All other rendering and examples seem to work fine, and if you have an example where you can't see the clear color, such as the skybox example, everything looks great.

    Also I've noticed some weird related behavior in my Renderdoc captures:

    When I launch the example with Renderdoc it has the same problem as running it without Renderdoc ( which makes sense ):

    image

    And when I view the renderbuffer contents after the initial clear in renderdoc, it shows the clear color like it shows in the render, lighter than it should be:

    image

    The clear color shows the same in the draw step, all the way until the final framebuffer blit, where it is dark enough ( but still with pixelated edges ):

    image

    Yet, when I hover over the pixels in the image, the little thumbnail at the bottom shows the wrong ligher color:

    image

    Very strange.

    I found that I could get rid of the pixelated edges by forcing the renderbuffer pixel format to be RGBA8, but the color was still off. I think thats the closest lead I have and I'm going to look into how different pixel formats efffect it, and maybe try binding the framebuffer storage to a texture instead of a renderbuffer and see if that makes any difference.


    PS: Very excited that the new GL backend on wgpu-hal is working for all the examples! This is the first time I've tried it that the shadow, boids, and skybox examples have worked. I might try to tackle #1617, but I figured I'd try to get this one out of the way first. :)

    Repro steps Run the cube or shadow example with the OpenGL backend.

    Expected vs observed behavior There should be no pixelated edges around objects and the clear color should be darker.

    Expected: image

    Actual ( I think it's fine if the lines for the trangles aren't there, the issue is the background color ) : image

    Extra materials

    Shadow example: image

    Platform Running WGPU cube or shadow examples on Linux Pop!_OS ( Ubuntu ) 20.04. Adapter info:

    [2021-07-10T16:54:11Z INFO  wgpu_hal::gles::adapter] Vendor: Intel
    [2021-07-10T16:54:11Z INFO  wgpu_hal::gles::adapter] Renderer: Mesa Intel(R) UHD Graphics (CML GT2)
    [2021-07-10T16:54:11Z INFO  wgpu_hal::gles::adapter] Version: OpenGL ES 3.2 Mesa 20.0.8
    [2021-07-10T16:54:11Z INFO  wgpu_hal::gles::adapter] SL version: OpenGL ES GLSL ES 3.20
    
    type: bug external: driver-bug 
    opened by zicklag 24
  • Implement TextureFormat::Stencil8 + add stencil example

    Implement TextureFormat::Stencil8 + add stencil example

    Checklist

    • [X] Run cargo clippy.
    • [ ] Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
    • [x] Add change to CHANGELOG.md. See simple instructions inside file.

    Connections Fixes https://github.com/gfx-rs/wgpu/issues/3196

    Description It's common for 2d applications to use the stencil buffer without depth buffers, but wgpu so far required you to allocate (at minimum) a Depth24PlusStencil8, which can be wasteful. Stencil8 will, on supported platforms, only contain the stencil buffer and nothing else.

    It currently maps to:

    | Backend | Texture Type | Notes | |---------|---------------------------------------------------------------|:------------------------------------------------------------------------------------| | Vulkan | Either S8_UINT, D24_UNORM_S8_UINT or D32_SFLOAT_S8_UINT | Left to right, first one supported | | GLES | GL_STENCIL_INDEX8 | It's a required format in ES3 | | Metal | MTLPixelFormat.stencil8 | It appears to be required in Metal, there's no mention to it being feature gated. | | DX12 | DXGI_FORMAT_D24_UNORM_S8_UINT | Effectively same as Depth24PlusStencil8 | | DX11 | DXGI_FORMAT_D24_UNORM_S8_UINT | Effectively same as Depth24PlusStencil8 |

    Testing In addition to adding the new format to the existing clear_texture_tests, I've added an example called stencil-triangles which shows how to use stencil testing in wgpu.

    All tests* pass for me on Windows and Mac. *except for shadow on Mac, and water on Windows. Those seem to be known bugs and unrelated to my code though.

    I've also confirmed that a large project I contribute to, Ruffle, runs and passes all its visual tests using Stencil8 on DX12, Vulkan, and GLES. I'm not able to run it on Metal currently.

    opened by Dinnerbone 1
  • Incorrect link in documentation for wgpu::VertexBufferLayout

    Incorrect link in documentation for wgpu::VertexBufferLayout

    This links to the render pass descriptor instead of #dictdef-gpuvertexbufferlayout. https://github.com/gfx-rs/wgpu/blob/6f4ec4fbab2e6209e59e563402db5f11e0b2a16e/wgpu/src/lib.rs#L1065-L1072

    opened by ScanMountGoat 0
  • [Metal] Add a way to create a device and queue from raw resources in wgpu-hal

    [Metal] Add a way to create a device and queue from raw resources in wgpu-hal

    Checklist

    • [x] Run cargo clippy.
    • [ ] Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
    • [x] Add change to CHANGELOG.md. See simple instructions inside file.

    Connections Related to #3145 and #2320

    Description This PR adds device_from_raw and queue_from_raw in addition to the existing texture_from_raw. This allows to get the MTLDevice and/or MTLCommandQueue from external application, and use them to process external memory/texture in wgpu. My use case involves OpenFX plugin for DaVinci Resolve video editor, and Resolve provides MTLTexture and MTLCommandQueue pointers, which I then use in a plugin written in Rust and wgpu.

    With these 2 new functions, one can create wgpu::Device and wgpu::Queue from a raw pointer to MTLCommandQueue the following way:

    use foreign_types::ForeignType;
    use wgpu_hal::api::Metal;
    
    let mtl_command_queue: *mut metal::MTLCommandQueue = ...;
    
    let (device, queue) = unsafe {
        let mtl_queue = metal::CommandQueue::from_ptr(mtl_command_queue);
        let mtl_device = mtl_queue.device();
    
        adapter.create_device_from_hal(wgpu_hal::OpenDevice::<Metal> {
            device: <Metal as wgpu_hal::Api>::Device::device_from_raw(mtl_device.to_owned(), wgpu::Features::empty()),
            queue: <Metal as wgpu_hal::Api>::Queue::queue_from_raw(mtl_queue)
        }, &wgpu::DeviceDescriptor {
            label: None,
            features: wgpu::Features::empty(),
            limits: wgpu::Limits::default()
        }, None).unwrap()
    };
    

    Testing I tested these changes with pointers provided by the DaVinci Resolve, and also with pointers provided from Qt and QML renderer, both cases work as intended.

    opened by AdrianEddy 0
  • `textureStore` causes a panic on GL backend with compute shaders.

    `textureStore` causes a panic on GL backend with compute shaders.

    Description When using the textureStore function in a compute shader, naga validates the shader but the gles hal layer panics with "Unsupported uniform type!". I get no errors when using the Vulkan backend, and the program works as expected. As far as I can tell from other references online (such as this post), this operation should be supported. However, I have very little experience with wgpu and compute shaders, so please correct me if I am wrong.

    Repro steps Create a compute pipeline with any shader that uses the textureStore function with the gles backend. For example:

    // texture
    @group(0) @binding(0) var my_tex: texture_storage_2d<rgba8unorm, write>;
    
    @compute @workgroup_size(16, 16, 1)
    fn main_color(@builtin(global_invocation_id) global_id: vec3<u32>) {
        textureStore(my_tex, vec2<i32>(i32(global_id.x), i32(global_id.y)), vec4<f32>(0.5));
    }
    

    Expected vs observed behavior I expect this to fill the entire texture with a half-transparent gray. However, it panics when creating the compute pipeline.

    Extra materials

    Error log:
    Adapter info: AdapterInfo { name: "Mesa Intel(R) UHD Graphics 620 (KBL GT2)", vendor: 32902, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }
    thread 'main' panicked at 'Unsupported uniform datatype!', /home/kiran/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-hal-0.14.1/src/gles/conv.rs:447:14
    stack backtrace:
       0: rust_begin_unwind
                 at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
       1: core::panicking::panic_fmt
                 at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
       2: wgpu_hal::gles::conv::uniform_byte_size
                 at /home/kiran/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-hal-0.14.1/src/gles/conv.rs:447:14
       3: wgpu_hal::gles::device::<impl wgpu_hal::gles::Device>::create_pipeline
                 at /home/kiran/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-hal-0.14.1/src/gles/device.rs:316:36
       4: wgpu_hal::gles::device::<impl wgpu_hal::Device<wgpu_hal::gles::Api> for wgpu_hal::gles::Device>::create_compute_pipeline
                 at /home/kiran/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-hal-0.14.1/src/gles/device.rs:1049:21
       5: wgpu_core::device::Device<A>::create_compute_pipeline
                 at /home/kiran/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-core-0.14.2/src/device/mod.rs:2427:22
       6: wgpu_core::device::<impl wgpu_core::hub::Global<G>>::device_create_compute_pipeline
                 at /home/kiran/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-core-0.14.2/src/device/mod.rs:4943:34
       7: <wgpu::backend::direct::Context as wgpu::Context>::device_create_compute_pipeline
                 at /home/kiran/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.14.2/src/backend/direct.rs:1447:27
       8: wgpu::Device::create_compute_pipeline
                 at /home/kiran/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.14.2/src/lib.rs:2202:17
       9: accelerated_mandel::test
                 at ./src/main.rs:69:27
      10: accelerated_mandel::main
                 at ./src/main.rs:118:5
      11: core::ops::function::FnOnce::call_once
                 at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:248:5
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
    

    Platform Information about your OS, version of wgpu, your tech stack, etc. OS: Arch Linux (rolling) wgpu version: 0.14.2 (also having the same issue on the latest git version) Adapter info: AdapterInfo { name: "Mesa Intel(R) UHD Graphics 620 (KBL GT2)", vendor: 32902, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }

    opened by KiranWells 0
  • Updated the API for `QueueWriteBufferView` and `BufferViewMut`

    Updated the API for `QueueWriteBufferView` and `BufferViewMut`

    Checklist

    • [X] Run cargo clippy.
    • [X] Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
    • [X] Add change to CHANGELOG.md. See simple instructions inside file.

    Connections #3134

    Description

    According to the documentation for Queue::write_buffer_with:

    The returned value can be dereferenced to a &mut [u8]; dereferencing it to a &[u8] panics!

    According to the documentation for Deref:

    this trait should never fail. Failure during dereferencing can be extremely confusing when Deref is invoked implicitly.

    A similar problem appears in BufferViewMut.

    The way I solved this problem was to get rid of the implementations of Deref and DerefMut for each, implement AsMut for QueueWriteBufferView, and add the read method to BufferViewMut

    Testing I ran cargo nextest run.

    opened by botahamec 0
  • Vulkan UPDATE_AFTER_BIND usage Unsound

    Vulkan UPDATE_AFTER_BIND usage Unsound

    Description

    Currently we use UPDATE_AFTER_BIND to allow us to raise the limits on vk/intel/windows of images and buffers to reasonable levels (1600 -> 1,000,000).

    This is unfortunately unsound as if a descriptor set has any dynamic offsets in it, it cannot be labeled as update after bind.

    We have two options:

    • Explicitly add UPDATE_AFTER_BIND-ness to the api (under a different name)
    • Disable the UPDATE_AFTER_BIND workaround entirely.

    Because we are going to be switching to DX12 soon, and this only affects windows/intel drivers not linux/intel, we should just scrap the workaround.

    type: bug area: correctness api: vulkan 
    opened by cwfitzgerald 0
Releases(v0.14.2)
  • v0.14.2(Nov 30, 2022)

    This release includes wgpu, and wgpu-core. The crates wgpu-hal and wgpu-types are still at 0.14.1.

    Bug Fixes

    • Fix incorrect offset in get_mapped_range by @nical in #3233
    Source code(tar.gz)
    Source code(zip)
  • v0.14.1(Nov 2, 2022)

    This release includes wgpu-hal, and wgpu-types. The crates wgpu and wgpu-core are still at 0.14.0.

    Bug Fixes

    • Make wgpu::TextureFormat::Depth24PlusStencil8 available on all backends by making the feature unconditionally available and the feature unneeded to use the format. By @Healthire and @cwfitzgerald in #3165
    Source code(tar.gz)
    Source code(zip)
  • v0.14.0(Oct 5, 2022)

    Major Changes

    @invariant Warning

    When using CompareFunction::Equal or CompareFunction::NotEqual on a pipeline, there is now a warning logged if the vertex shader does not have a @invariant tag on it. On some machines, rendering the same triangles multiple times without an @invariant tag will result in slightly different depths for every pixel. Because the *Equal functions rely on depth being the same every time it is rendered, we now warn if it is missing.

    -@vertex
    -fn vert_main(v_in: VertexInput) -> @builtin(position) vec4<f32> {...}
    +@vertex
    +fn vert_main(v_in: VertexInput) -> @builtin(position) @invariant vec4<f32> {...}
    

    Surface Alpha and PresentModes

    Surface supports alpha_mode now. When alpha_mode is equal to PreMultiplied or PostMultiplied, the alpha channel of framebuffer is respected in the compositing process, but which mode is available depends on the different API and Device. If don't care about alpha_mode, you can set it to Auto.

    SurfaceConfiguration {
    // ...
    + alpha_mode: surface.get_supported_alpha_modes(&adapter)[0],
    }
    

    The function to enumerate supported presentation modes changed:

    - pub fn wgpu::Surface::get_supported_modes(&self, adapter: &wgpu::Adapter) -> Vec<PresentMode>
    + pub fn wgpu::Surface::get_supported_present_modes(&self, adapter: &wgpu::Adapter) -> Vec<PresentMode>
    

    Updated raw-window-handle to 0.5

    This will allow use of the latest version of winit. As such the bound on create_surface is now RWH 0.5 and requires both raw_window_handle::HasRawWindowHandle and raw_window_handle::HasRawDisplayHandle.

    Added/New Features

    • Add Buffer::size() and Buffer::usage(); by @kpreid in #2923
    • Split Blendability and Filterability into Two Different TextureFormatFeatureFlags; by @stakka in #3012
    • Expose alpha_mode on SurfaceConfiguration, by @jinleili in #2836
    • Introduce fields for driver name and info in AdapterInfo, by @i509VCB in #3037
    • Implemented copy_external_image_to_texture on WebGPU, by @ybiletskyi in #2781

    Bug Fixes

    General

    • Free StagingBuffers even when an error occurs in the operation that consumes them. By @jimblandy in #2961
    • Avoid overflow when checking that texture copies fall within bounds. By @jimblandy in #2963
    • Improve the validation and error reporting of buffer mappings by @nical in #2848
    • Fix compilation errors when using wgpu-core in isolation while targetting wasm32-unknown-unknown by @Seamooo in #2922
    • Fixed opening of RenderDoc library by @abuffseagull in #2930
    • Added missing validation for BufferUsages mismatches when Features::MAPPABLE_PRIMARY_BUFFERS is not enabled. By @imberflur in #3023
    • Fixed CommandEncoder not being Send and Sync on web by @i509VCB in #3025
    • Document meaning of vendor in AdapterInfo if the vendor has no PCI id.
    • Fix missing resource labels from some Errors by @scoopr in #3066

    Metal

    • Add the missing msg_send![view, retain] call within from_view by @jinleili in #2976
    • Fix max_buffer max_texture and max_vertex_buffers limits by @jinleili in #2978
    • Remove PrivateCapabilities's format_rgb10a2_unorm_surface field by @jinleili in #2981
    • Fix validation error when copying into a subset of a single-layer texture by @nical in #3063
    • Fix _buffer_sizes encoding by @dtiselice in #3047

    Vulkan

    • Fix astc_hdr formats support by @jinleili in [#2971]](https://github.com/gfx-rs/wgpu/pull/2971)
    • Update to Naga b209d911 (2022-9-1) to avoid generating SPIR-V that violates Vulkan valid usage rules VUID-StandaloneSpirv-Flat-06202 and VUID-StandaloneSpirv-Flat-04744. By @jimblandy in #3008
    • Fix bug where the Vulkan backend would panic when using a supported window and display handle but the dependent extensions are not available by @i509VCB in #3054.

    GLES

    • Report vendor id for Mesa and Apple GPUs. By @i509VCB #3036
    • Report Apple M2 gpu as integrated. By @i509VCB #3036

    Changes

    General

    • Changed wgpu-hal and wgpu-core implementation to pass RawDisplayHandle and RawWindowHandle as separate parameters instead of passing an impl trait over both HasRawDisplayHandle and HasRawWindowHandle. By @i509VCB in #3022
    • Changed Instance::as_hal<A> to just return an Option<&A::Instance> rather than taking a callback. By @jimb in #2991
    • Added downlevel restriction error message for InvalidFormatUsages error by @Seamooo in #2886
    • Add warning when using CompareFunction::*Equal with vertex shader that is missing @invariant tag by @cwfitzgerald in #2887
    • Update Winit to version 0.27 and raw-window-handle to 0.5 by @wyatt-herkamp in #2918
    • Address Clippy 0.1.63 complaints. By @jimblandy in #2977
    • Don't use PhantomData for IdentityManager's Input type. By @jimblandy in #2972
    • Changed Naga variant in ShaderSource to Cow<'static, Module>, to allow loading global variables by @daxpedda in #2903

    Metal

    • Extract the generic code into get_metal_layer by @jinleili in #2826

    Vulkan

    • Remove use of Vulkan12Features/Properties types. By @i509VCB in #2936
    • Provide a means for wgpu users to access vk::Queue and the queue index. By @anlumo in #2950
    • Use the use effective api version for determining device features instead of wrongly assuming VkPhysicalDeviceProperties.apiVersion is the actual version of the device. By @i509VCB in #3011

    GLES

    • Add Rgba16Float format support for color attachments. By @jinleili in #3045
    • TEXTURE_COMPRESSION_ASTC_HDR feature detection by @jinleili in #3042

    Performance

    • Made StagingBelt::write_buffer() check more thoroughly for reusable memory; by @kpreid in #2906

    Documentation

    • Add WGSL examples to complement existing examples written in GLSL by @norepimorphism in #2888
    • Document wgpu_core resource allocation. @jimblandy in #2973
    • Expanded StagingBelt documentation by @kpreid in #2905
    • Fixed documentation for Instance::create_surface_from_canvas and Instance::create_surface_from_offscreen_canvas regarding their safety contract. These functions are not unsafe. By @jimblandy #2990
    • Document that write_buffer_with() is sound but unwise to read from by @kpreid in #3006
    • Explain why Adapter::as_hal and Device::as_hal have to take callback functions. By @jimblandy in #2992

    Dependency Updates

    WebGPU

    • Update wasm32 dependencies, set alpha_mode on web target by @jinleili in #3040

    Build Configuration

    • Add the "strict_asserts" feature, to enable additional internal run-time validation in wgpu-core. By @jimblandy in #2872.

    Full API Diff

    Manual concatination of cargo public-api --diff-git-checkouts v0.13.2 v0.14.0 -p wgpu and cargo public-api --diff-git-checkouts v0.13.2 v0.14.0 -p wgpu-types

    Removed items from the public API
    =================================
    -pub fn wgpu::Surface::get_supported_modes(&self, adapter: &wgpu::Adapter) -> Vec<PresentMode>
    -pub const wgpu::Features::DEPTH24UNORM_STENCIL8: Self
    -pub enum variant wgpu::TextureFormat::Depth24UnormStencil8
    
    Changed items in the public API
    ===============================
    -pub unsafe fn wgpu::Instance::as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&<A as >::Instance>) -> R, R>(&self, hal_instance_callback: F) -> R
    +pub unsafe fn wgpu::Instance::as_hal<A: wgc::hub::HalApi>(&self) -> Option<&<A as >::Instance>
    -pub unsafe fn wgpu::Instance::create_surface<W: raw_window_handle::HasRawWindowHandle>(&self, window: &W) -> wgpu::Surface
    +pub unsafe fn wgpu::Instance::create_surface<W: raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle>(&self, window: &W) -> wgpu::Surface
    
    Added items to the public API
    =============================
    +pub fn wgpu::Buffer::size(&self) -> wgt::BufferAddress
    +pub fn wgpu::Buffer::usage(&self) -> BufferUsages
    +pub fn wgpu::Surface::get_supported_alpha_modes(&self, adapter: &wgpu::Adapter) -> Vec<CompositeAlphaMode>
    +pub fn wgpu::Surface::get_supported_present_modes(&self, adapter: &wgpu::Adapter) -> Vec<PresentMode>
    +#[repr(C)] pub enum wgpu::CompositeAlphaMode
    +impl RefUnwindSafe for wgpu::CompositeAlphaMode
    +impl Send for wgpu::CompositeAlphaMode
    +impl Sync for wgpu::CompositeAlphaMode
    +impl Unpin for wgpu::CompositeAlphaMode
    +impl UnwindSafe for wgpu::CompositeAlphaMode
    +pub const wgpu::Features::DEPTH24PLUS_STENCIL8: Self
    +pub const wgpu::TextureFormatFeatureFlags::BLENDABLE: Self
    +pub enum variant wgpu::CompositeAlphaMode::Auto = 0
    +pub enum variant wgpu::CompositeAlphaMode::Inherit = 4
    +pub enum variant wgpu::CompositeAlphaMode::Opaque = 1
    +pub enum variant wgpu::CompositeAlphaMode::PostMultiplied = 3
    +pub enum variant wgpu::CompositeAlphaMode::PreMultiplied = 2
    +pub enum variant wgpu::TextureFormat::Depth16Unorm
    +pub fn wgpu::CompositeAlphaMode::clone(&self) -> wgpu::CompositeAlphaMode
    +pub fn wgpu::CompositeAlphaMode::eq(&self, other: &wgpu::CompositeAlphaMode) -> bool
    +pub fn wgpu::CompositeAlphaMode::fmt(&self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
    +pub fn wgpu::CompositeAlphaMode::hash<__H: $crate::hash::Hasher>(&self, state: &mut __H) -> ()
    +pub struct field wgpu::AdapterInfo::driver: String
    +pub struct field wgpu::AdapterInfo::driver_info: String
    +pub struct field wgpu::SurfaceConfiguration::alpha_mode: wgpu_types::CompositeAlphaMode
    
    Source code(tar.gz)
    Source code(zip)
  • v0.13.2(Jul 14, 2022)

    This release includes wgpu-core, wgpu-hal, and wgpu-types. The crate wgpu is still at 0.13.1.

    Bug Fixes

    General

    • Prefer DeviceType::DiscreteGpu over DeviceType::Other for PowerPreference::LowPower so Vulkan is preferred over OpenGL again by @Craig-Macomber in #2853
    • Allow running get_texture_format_features on unsupported texture formats (returning no flags) by @cwfitzgerald in #2856
    • Allow multi-sampled textures that are supported by the device but not WebGPU if TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES is enabled by @cwfitzgerald in #2856
    • get_texture_format_features only lists the COPY_* usages if the adapter actually supports that usage by @cwfitzgerald in #2856
    • Fix bind group / pipeline deduplication not taking into account RenderBundle execution resetting these values by @shoebe #2867
    • Fix panics that occur when using as_hal functions when the hal generic type does not match the hub being looked up in by @i509VCB #2871
    • Add some validation in map_async by @nical in #2876
    • Fix bugs when mapping/unmapping zero-sized buffers and ranges by @nical in #2877

    DX12

    • DownlevelCapabilities::default() now returns the ANISOTROPIC_FILTERING flag set to true so DX12 lists ANISOTROPIC_FILTERING as true again by @cwfitzgerald in #2851
    • Properly query format features for UAV/SRV usages of depth formats by @cwfitzgerald in #2856

    GLES

    • Fix depth stencil texture format capability by @jinleili in #2854
    • get_texture_format_features now only returns usages for formats it actually supports by @cwfitzgerald in #2856

    Hal

    • Allow access to queue family index in Vulkan hal by @i509VCB in #2859
    • Allow access to the EGLDisplay and EGLContext pointer in Gles hal Adapter and Device by @i509VCB in #2860

    Documentation

    • Update present_mode docs as most of them don't automatically fall back to Fifo anymore. by @Elabajaba in #2855

    Hal

    • Document safety requirements for Adapter::from_external in gles hal by @i509VCB in #2863
    Source code(tar.gz)
    Source code(zip)
  • v0.13.1(Jul 3, 2022)

    This release includes wgpu, wgpu-core, and wgpu-hal. The crate wgpu-types is still at 0.13.0.

    General

    • Fix out of bounds access when surface texture is written to by multiple command buffers by @cwfitzgerald in #2843

    GLES

    • AutoNoVSync now correctly falls back to Fifo by @simbleau in #2842
    • Fix GL_EXT_color_buffer_float detection on native by @cwfitzgerald in #2843
    Source code(tar.gz)
    Source code(zip)
  • v0.13.0(Jul 1, 2022)

    This release includes wgpu, wgpu-core, wgpu-hal, and wgpu-types.

    Major Changes

    WGSL Syntax

    WGSL syntax has changed in a couple ways. The new syntax is easier to read and work with.

    Attribute declarations are written differently:

    - [[group(1), binding(0)]]
    + @group(1) @binding(0)
    

    Stage declarations are now separate attributes rather than part of the stage attribute:

    - [[stage(vertex)]]
    + @vertex
    

    Structs now use , as field separator and no longer need semicolons after the declaration:

    - struct MyStruct {
    -     my_member: u32;
    - };
    + struct MyStruct {
    +     my_member: u32,
    + }
    

    Surface API

    The method of getting the preferred swapchain format has changed to allow viewing all formats supported by the surface.

    - let format = surface.get_preferred_format(&adapter).unwrap();
    + let format = surface.get_supported_formats(&adapter)[0];
    

    Presentation modes now need to match exactly what the surface supports. FIFO is always supported, but all other modes vary from API to API and Device to Device. To get a list of all supported modes, call the following. The order does not indicate preference.

    let modes = surface.get_supported_present_modes(&adapter);
    

    Timestamp Queries

    Timestamp queries are now restricted behind multiple features to allow implementation on TBDR (Tile-Based Deferred Rendering) based GPUs, such as mobile devices and Apple's M chips.

    Features::TIMESTAMP_QUERIES now allows for calling write_timestamp only on CommandEncoders.

    Features::WRITE_TIMESTAMP_INSIDE_PASSES is needed to call write_timestamp on RenderPassEncoders or ComputePassEncoders.

    map_async

    The function for mapping buffers no longer returns a future, and instead calls a callback when the buffer is mapped.

    This aligns with the use of the API more clearly - you aren't supposed to block and wait on the future to resolve, you are supposed to keep rendering and wait until the buffer maps on its own. Mapping and the flow of mapping is an under-documented area that we hope to improve in the future.

    - let future = buffer.slice(..).map_async(MapMode::Read);
    + buffer.slice(..).map_async(MapMode::Read, || {
    +     // Called when buffer is mapped.  
    + })
    

    Submission Indexes

    Calling queue.submit now returns an opaque submission index that can be used as an argument to device.poll to say which submission to wait to complete.

    Other Breaking Changes

    Device::create_shader_module now takes the shader descriptor by value:

    - device.create_shader_module(&shader_module_descriptor)
    + device.create_shader_module(shader_module_descriptor)
    

    Color attachments can be sparse, so they are now optional:

    FragmentState {
    -  targets: &[color_target_state]
    +  targets: &[Some(color_target_state)]
      // ..
    }
    
    RenderPassDescriptor {
    -  color_attachments: &[render_pass_color_attachment]
    +  color_attachments: &[Some(render_pass_color_attachment)]
      // ..
    }
    
    RenderBundleEncoderDescriptor {
    -  color_formats: &[texture_format]
    +  color_formats: &[Some(texture_format)]
      // ..
    }
    

    Extent3d::max_mips now requires you to pass a TextureDimension to specify whether or not depth_or_array_layers should be ignored:

    Extent3d {
      width: 1920,
      height: 1080,
      depth_or_array_layers: 6,
    - }.max_mips()
    + }.max_mips(wgpu::TextureDimension::D3)
    

    Limits has a new field, max_buffer_size (not an issue if you don't define limits manually):

    Limits {
      // ...
    + max_buffer_size: 256 * 1024 * 1024, // adjust as you see fit
    }
    

    ComputePass::dispatch has been renamed to ComputePass::dispatch_workgroups

    - cpass.dispatch(self.work_group_count, 1, 1)
    + cpass.dispatch_workgroups(self.work_group_count, 1, 1)
    

    Added/New Features

    General

    • Add util::indirect::* helper structs by @IcanDivideBy0 in #2365
    • Add AddressMode::ClampToZero by @laptou in #2364
    • Add MULTISAMPLED_SHADING downlevel flag by @jinleili in #2425
    • Allow non struct buffers in wgsl by @IcanDivideBy0 in #2451
    • Prefix every wgpu-generated label with (wgpu). by @kpreid in #2590
    • Permit non-struct, non-array types as buffers. by @jimblandy in #2584
    • Return queue_empty for Device::poll by @xiaopengli89 in #2643
    • Add SHADER_FLOAT16 feature by @jinleili in #2646
    • Add DEPTH32FLOAT_STENCIL8 featue by @jinleili in #2664
    • Add DEPTH24UNORM_STENCIL8 feature by @jinleili in #2689
    • Implement submission indexes by @cwfitzgerald in #2700
    • [WebGL] Add a downlevel capability for rendering to floating point textures by @expenses in #2729
    • allow creating wgpu::Instance from wgpu_core::Instance by @i509VCB in #2763
    • Force binding sizes to be multiples of 16 on webgl by @cwfitzgerald in #2808
    • Add Naga variant to ShaderSource by @rttad in #2801
    • Implement Queue::write_buffer_with by @teoxoy in #2777

    Vulkan

    • Re-allow vk backend on Apple platforms via vulkan-portability feature by @jinleili in #2488
    • vulkan: HDR ASTC formats support by @jinleili in #2496

    Metal

    • Implement push constants for metal backend by @TheOnlyMrCat in #2314
    • Metal backend ASTC HDR formats support by @jinleili in #2477
    • Add COPY_DST to Metal's surface usage bits by @vl4dimir in #2491
    • Add Features::MULTI_DRAW_INDIRECT to Metal by @expenses in #2737

    GLES

    • Support externally initialized contexts by @kvark in #2350
    • Angle support on macOS by @jinleili in #2461
    • Use EGL surfaceless platform when windowing system is not found by @sh7dm in #2339
    • Do a downlevel check for anisotrophy and enable it in the webgl backend by @expenses in #2616
    • OffscreenCanvas Support for WebGL Backend by @haraldreingruber-dedalus in #2603

    DX12

    • Support to create surface from visual on Windows by @xiaopengli89 in #2434
    • Add raw_queue for d3d12 device by @xiaopengli89 in #2600

    DX11

    • Dx11 Backend by @cwfitzgerald in #2443

    Hal

    • Adapter and Instance as_hal functions by @i509VCB in #2663
    • expose some underlying types in Vulkan hal by @i509VCB in #2667
    • Add raw_device method for dx12, vulkan hal by @xiaopengli89 in #2360
    • expose egl display in gles Instance hal by @i509VCB in #2670
    • Add raw_adapter method for dx12 hal adapter by @xiaopengli89 in #2714
    • Acquire texture: Option<std::time::Duration> timeouts by @rib in #2724
    • expose vulkan physical device capabilities, enabled device extensions by @i509VCB in #2688

    Emscripten

    • feature: emscripten by @caiiiycuk in #2422
    • feature = emscripten, compability fixes for wgpu-native by @caiiiycuk in #2450

    Changes

    General

    • Make ShaderSource #[non_exhaustive] by @fintelia in #2312
    • Make execute_bundles() receive IntoIterator by @maku693 in #2410
    • Raise wgpu_hal::MAX_COLOR_TARGETS to 8. by @jimblandy in #2640
    • Rename dispatch -> dispatch_workgroups by @jinleili in #2619
    • Update texture_create_view logic to match spec by @jinleili in #2621
    • Move TEXTURE_COMPRESSION_ETC2 | ASTC_LDR to web section to match spec by @jinleili in #2671
    • Check that all vertex outputs are consumed by the fragment shader by @cwfitzgerald in #2704
    • Convert map_async from being async to being callback based by @cwfitzgerald in #2698
    • Align the validation of Device::create_texture with the WebGPU spec by @nical in #2759
    • Add InvalidGroupIndex validation at create_shader_module by @jinleili in #2775
    • Rename MAX_COLOR_TARGETS to MAX_COLOR_ATTACHMENTS to match spec by @jinleili in #2780
    • Change get_preferred_format to get_supported_formats by @stevenhuyn in #2783
    • Restrict WriteTimestamp Inside Passes by @cwfitzgerald in #2802
    • Flip span labels to work better with tools by @cwfitzgerald in #2820

    Gles

    • Make GLES DeviceType unknown by default by @PolyMeilex in #2647

    Metal

    • metal: check if in the main thread when calling create_surface by @jinleili in #2736

    Hal

    • limit binding sizes to i32 by @kvark in #2363

    Bug Fixes

    General

    • Fix trac(y/ing) compile issue by @cwfitzgerald in #2333
    • Improve detection and validation of cubemap views by @kvark in #2331
    • Don't create array layer trackers for 3D textures. by @ElectronicRU in #2348
    • Limit 1D texture mips to 1 by @kvark in #2374
    • Texture format MSAA capabilities by @kvark in #2377
    • Fix write_buffer to surface texture @kvark in #2385
    • Improve some error messages by @cwfitzgerald in #2446
    • Don't recycle indices that reach EOL by @kvark in #2462
    • Validated render usages for 3D textures by @kvark in #2482
    • Wrap all validation logs with catch_unwinds by @cwfitzgerald in #2511
    • Fix clippy lints by @a1phyr in #2560
    • Free the raw device when wgpu::Device is dropped. by @jimblandy in #2567
    • wgpu-core: Register new pipelines with device's tracker. by @jimblandy in #2565
    • impl Debug for StagingBelt by @kpreid in #2572
    • Use fully qualified syntax for some calls. by @jimblandy in #2655
    • fix: panic in Storage::get by @SparkyPotato in #2657
    • Report invalid pipelines in render bundles as errors, not panics. by @jimblandy in #2666
    • Perform "valid to use with" checks when recording render bundles. by @jimblandy in #2690
    • Stop using storage usage for sampling by @cwfitzgerald in #2703
    • Track depth and stencil writability separately. by @jimblandy in #2693
    • Improve InvalidScissorRect error message by @jinleili in #2713
    • Improve InvalidViewport error message by @jinleili in #2723
    • Don't dirty the vertex buffer for stride/rate changes on bundles. by @jimblandy in #2744
    • Clean up render bundle index buffer tracking. by @jimblandy in #2743
    • Improve read-write and read-only texture storage error message by @jinleili in #2745
    • Change WEBGPU_TEXTURE_FORMAT_SUPPORT to 1 << 14 instead of 1 << 15 by @expenses in #2772
    • fix BufferMapCallbackC & SubmittedWorkDoneClosureC by @rajveermalviya in #2787
    • Fix formatting of TextureDimensionError::LimitExceeded. by @kpreid in #2799
    • Remove redundant #[cfg] conditions from backend/direct.rs. by @jimblandy in #2811
    • Replace android-properties with android_system_properties. by @nical in #2815
    • Relax render pass color_attachments validation by @jinleili in #2778
    • Properly Barrier Compute Indirect Buffers by @cwfitzgerald in #2810
    • Use numeric constants to define wgpu_types::Features values. by @jimblandy in #2817

    Metal

    • Fix surface texture clear view by @kvark in #2341
    • Set preserveInvariance for shader options by @scoopr in #2372
    • Properly set msl version to 2.3 if supported by @cwfitzgerald in #2418
    • Identify Apple M1 GPU as integrated by @superdump in #2429
    • Fix M1 in macOS incorrectly reports supported compressed texture formats by @superdump in #2453
    • Msl: support unsized array not in structures by @kvark in #2459
    • Fix Surface::from_uiview can not guarantee set correct contentScaleFactor by @jinleili in #2470
    • Set max_buffer_size by the correct physical device restriction by @jinleili in #2502
    • Refactor PrivateCapabilities creation by @jinleili in #2509
    • Refactor texture_format_capabilities function by @jinleili in #2522
    • Improve push | pop_debug_marker by @jinleili in #2537
    • Fix some supported limits by @jinleili in #2608
    • Don't skip incomplete binding resources. by @dragostis in #2622
    • Fix Rgb9e5Ufloat capabilities and sampler_lod_average support by @jinleili in #2656
    • Fix Depth24Plus | Depth24PlusStencil8 capabilities by @jinleili in #2686
    • Get_supported_formats: sort like the old get_preferred_format and simplify return type by @victorvde in #2786
    • Restrict hal::TextureUses::COLOR_TARGET condition within create_texture by @jinleili in #2818

    DX12

    • Fix UMA check by @kvark in #2305
    • Fix partial texture barrier not affecting stencil aspect by @Wumpf in #2308
    • Improve RowPitch computation by @kvark in #2409

    Vulkan

    • Explicitly set Vulkan debug message types instead of !empty() by @victorvde in #2321
    • Use stencil read/write masks by @kvark in #2382
    • Vulkan: correctly set INDEPENDENT_BLEND,make runable on Android 8.x by @jinleili in #2498
    • Fix ASTC format mapping by @kvark in #2476
    • Support flipped Y on VK 1.1 devices by @cwfitzgerald in #2512
    • Fixed builtin(primitive_index) for vulkan backend by @kwillemsen in #2716
    • Fix PIPELINE_STATISTICS_QUERY feature support by @jinleili in #2750
    • Add a vulkan workaround for large buffers. by @nical in #2796

    GLES

    • Fix index buffer state not being reset in reset_state by @rparrett in #2391
    • Allow push constants trough emulation by @JCapucho in #2400
    • Hal/gles: fix dirty vertex buffers that are unused by @kvark in #2427
    • Fix texture description for bgra formats by @JCapucho in #2520
    • Remove a log::error! debugging statement from the gles queue by @expenses in #2630
    • Fix clearing depth and stencil at the same time by @expenses in #2675
    • Handle cubemap copies by @expenses in #2725
    • Allow clearing index buffers by @grovesNL in #2740
    • Fix buffer-texture copy for 2d arrays by @tuchs in #2809

    Wayland

    • Search for different versions of libwayland by @sh7dm in #2336

    WebGPU

    • Fix compilation on wasm32-unknown-unknown without webgl feature by @jakobhellermann in #2355
    • Solve crash on WebGPU by @cwfitzgerald in #2807

    Emscripten

    • Fix emscripten by @cwfitzgerald in #2494

    Performance

    • Do texture init via clear passes when possible by @Wumpf in #2307
    • Bind group deduplication by @cwfitzgerald in #2623
    • Tracking Optimization and Rewrite by @cwfitzgerald in #2662

    Documentation

    • Add defaults to new limits and correct older ones by @MultisampledNight in #/2303
    • Improve shader source documentation by @grovesNL in #2315
    • Fix typo by @rustui in #2393
    • Add a :star: to the feature matrix of examples README by @yutannihilation in #2457
    • Fix get_timestamp_period type in docs by @superdump in #2478
    • Fix mistake in Access doc comment by @nical in #2479
    • Improve shader support documentation by @cwfitzgerald in #2501
    • Document the gfx_select! macro. by @jimblandy in #2555
    • Add Windows 11 to section about DX12 by @HeavyRain266 in #2552
    • Document some aspects of resource tracking. by @jimblandy in #2558
    • Documentation for various things. by @jimblandy in #2566
    • Fix doc links. by @jimblandy in #2579
    • Fixed misspelling in documentation by @zenitopires in #2634
    • Update push constant docs to reflect the API by @Noxime in #2637
    • Exclude dependencies from documentation by @yutannihilation in #2642
    • Document GpuFuture. by @jimblandy in #2644
    • Document random bits and pieces. by @jimblandy in #2651
    • Add cross-references to each wgpu type's documentation. by @kpreid in #2653
    • RenderPassDescriptor: make label lifetime match doc, and make names descriptive. by @kpreid in #2654
    • Document VertexStepMode. by @jimblandy in #2685
    • Add links for SpirV documents. by @huandzh in #2697
    • Add symlink LICENSE files into crates. by @dskkato in #2604
    • Fix documentation links. by @jimblandy in #2756
    • Improve push constant documentation, including internal docs. by @jimblandy in #2764
    • Clarify docs for wgpu_core's Id and gfx_select!. by @jimblandy in #2766
    • Update the Supported Platforms table in README by @jinleili in #2770
    • Remove depth image from readme - we don't dictate direction of depth by @cwfitzgerald in #2812

    Dependency Updates

    • Update ash to 0.37 by @a1phyr in #2557
    • Update parking_lot to 0.12. by @emilio in #2639
    • Accept both parking-lot 0.11 and 0.12, to avoid windows-rs. by @jimblandy in #2660
    • Update web-sys to 0.3.58, sparse attachments support by @jinleili in #2813

    deno-webgpu

    • Clean up features in deno by @crowlKats in #2445
    • Dont panic when submitting same commandbuffer multiple times by @crowlKats in #2449
    • Handle error sources to display full errors by @crowlKats in #2454
    • Pull changes from deno repo by @crowlKats in #2455
    • Fix cts_runner by @crowlKats in #2456
    • Update deno_webgpu by @crowlKats in #2539
    • Custom op arity by @crowlKats in #2542

    Examples

    • Fix conserative-raster low res target getting zero sized on resize by @Wumpf in #2318
    • Replace run-wasm-example.sh with aliased rust crate (xtask) by @rukai in #2346
    • Get cargo-run-wasm from crates.io by @rukai in #2415
    • Fix msaa-line example's unnecessary MSAA data store by @jinleili in #2421
    • Make shadow example runnable on iOS Android devices by @jinleili in #2433
    • Blit should only draw one triangle by @CurryPseudo in #2474
    • Fix wasm examples failing to compile by @Liamolucko in #2524
    • Fix incorrect filtering used in mipmap generation by @LaylBongers in #2525
    • Correct program output ("Steps", not "Times") by @skierpage in #2535
    • Fix resizing behaviour of hello-triangle example by @FrankenApps in #2543
    • Switch from cgmath to glam in examples by @a1phyr in #2544
    • Generate 1x1 mip level by @davidar in #2551
    • Wgpu/examples/shadow: Don't run on llvmpipe. by @jimblandy in #2595
    • Avoid new WGSL reserved words in wgpu examples. by @jimblandy in #2606
    • Move texture-array example over to wgsl by @cwfitzgerald in #2618
    • Remove the default features from wgpu-info by @jinleili in #2753
    • Fix bunnymark test screenshot and replace rand with nanorand by @stevenhuyn in #2746
    • Use FIFO swapchain in examples by @cwfitzgerald in #2790

    Testing/Internal

    • Test WebGPU backend with extra features by @kvark in #2362
    • Lint deno_webgpu & wgpu-core by @AaronO in #2403
    • IdentityManager: from_index method is unneeded. by @jimblandy in #2424
    • Added id32 feature by @caiiiycuk in #2464
    • Update dev deps by @rukai in #2493
    • Use cargo nextest for running our tests by @cwfitzgerald in #2495
    • Many Steps Towards GL Testing Working by @cwfitzgerald in #2504
    • Rename ci.txt to ci.yml by @simon446 in #2510
    • Re-enable GL testing in CI by @cwfitzgerald in #2508
    • Expect shadow example to pass on GL by @kvark in #2541
    • Simplify implementation of RefCount and MultiRefCount. by @jimblandy in #2548
    • Provide a proper new method for RefCount. by @jimblandy in #2570
    • Add logging to LifetimeTracker::triage_suspected. by @jimblandy in #2569
    • wgpu-hal: Work around cbindgen bug: ignore gles::egl module. by @jimblandy in #2576
    • Specify an exact wasm-bindgen-cli version in publish.yml. by @jimblandy in #2624
    • Rename timeout_us to timeout_ns, to match actual units. by @jimblandy in #2645
    • Move set_index_buffer FFI functions back into wgpu. by @jimblandy in #2661
    • New function: Global::create_buffer_error. by @jimblandy in #2673
    • Actually use RenderBundleEncoder::set_bind_group in tests. by @jimblandy in #2678
    • Eliminate wgpu_core::commands::bundle::State::raw_dynamic_offsets. by @jimblandy in #2684
    • Move RenderBundleEncoder::finish's pipeline layout id into the state. by @jimblandy in #2755
    • Expect shader_primitive_index tests to fail on AMD RADV POLARIS12. by @jimblandy in #2754
    • Introduce VertexStep: a stride and a step mode. by @jimblandy in #2768
    • Increase max_outliers on wgpu water example reftest. by @jimblandy in #2767
    • wgpu_core::command::bundle: Consolidate pipeline and vertex state. by @jimblandy in #2769
    • Add type annotation to render pass code, for rust-analyzer. by @jimblandy in #2773
    • Expose naga span location helpers by @nical in #2752
    • Add create_texture_error by @nical in #2800
    Source code(tar.gz)
    Source code(zip)
Owner
Rust Graphics Mages
Portable Graphics and Compute in Rust
Rust Graphics Mages
visualizations/charts for media collections, based on mediainfo

Media Collection Viewer Early WIP! Demo is live Description Upload a mediainfo.json

Ashley 14 Sep 14, 2022
A high-performance SVG renderer, powered by Rust based resvg and napi-rs.

resvg-js resvg-js is a high-performance SVG renderer, powered by Rust based resvg and napi-rs. Fast, safe and zero dependencies! No need for node-gyp

一丝 744 Jan 7, 2023
Generic framebuffer implementation in Rust for use with embedded-graphics library

Fraramebuffer implementation for Rust's Embedded-graphics Framebuffer approach helps to deal with display flickering when you update multiple parts of

Bernard Kobos 9 Nov 29, 2022
State of the art "build your own engine" kit powered by gfx-hal

A rendering engine based on gfx-hal, which mimics the Vulkan API. Building This library requires standard build tools for the target platforms, except

Amethyst Foundation 801 Dec 28, 2022
Freebsd-embedded-hal - Like linux-embedded-hal but FreeBSD

freebsd-embedded-hal Implementation of embedded-hal traits for FreeBSD devices: gpio: using libgpio, with stateful and toggleable support, with suppor

null 2 Oct 1, 2022
A WebGPU implementation based on the excellent wgpu crate.

A WebGPU implementation based on the excellent wgpu crate.

Ben Noordhuis 3 Jul 30, 2022
Proof-of-concept of getting OpenXR rendering support for Bevy game engine using gfx-rs abstractions

Introduction Proof-of-concept of getting OpenXR rendering support for Bevy game engine using gfx-rs abstractions. (hand interaction with boxes missing

Mika 52 Nov 14, 2022
Guide for using gfx-rs's wgpu library.

Introduction What is wgpu? Wgpu is a Rust implementation of the WebGPU API spec. WebGPU is a specification published by the GPU for the Web Community

sotrh 1k Dec 29, 2022
Implementation of the RWKV language model in pure WebGPU/Rust.

Web-RWKV This is an implementation of the language model of RWKV in pure WebGPU. Compile and Run Install Rust. Run cargo run --release --example gen t

研究社交 22 Jul 12, 2023
esp-serial-dbg - debugging of esp-hal based applications via serial

esp-serial-dbg - debugging of esp-hal based applications via serial About This is still work in progress! At least the contained examples should work

Björn Quentin 3 Aug 23, 2022
RTS game/engine in Rust and WebGPU

What is this? A real time strategy game/engine written with Rust and WebGPU. Eventually it will be able to run in a web browser thanks to WebGPU. This

Thomas SIMON 258 Dec 25, 2022
Windowing support for Deno WebGPU.

deno_desktop Windowing support for Deno WebGPU. In very early stages at the moment. Usage const win = Deno.createWindow({ title: "Deno Desktop", w

DjDeveloper 56 Oct 26, 2022
wgpugd: A WebGPU Graphics Device for R

wgpugd: A WebGPU Graphics Device for R Overview What is WebGPU? WebGPU is an API that exposes the capabilities of GPU hardware. What is wgpu? As the n

Hiroaki Yutani 42 Dec 11, 2022
A hardware-accelerated GPU terminal emulator powered by WebGPU, focusing to run in desktops, browsers, tvs and everywhere.

Rio term tl;dr: Rio is a terminal built to run everywhere, as a native desktop applications by Rust/WebGPU or even in the browser powered by WebAssemb

Raphael Amorim 208 Apr 24, 2023
Game Of Life using webgpu, written in Rust

Game of Life using webgpu ✨ Description This is the implementation of the tutorial Your first WebGPU app in Rust where we're using webgpu to implement

BADR 4 Aug 17, 2023
🪄 Shader art using webgpu

✨ Shader art using webgpu ✨ This is the implementation of An introduction to Shader Art Coding in Rust using webgpu. ?? Setup You need: Rust compiler

BADR 7 Aug 29, 2023
rust-native-tls — Bindings for native TLS libraries

rust-native-tls Documentation An abstraction over platform-specific TLS implementations. Specifically, this crate uses SChannel on Windows (via the sc

Steven Fackler 371 Jan 8, 2023
weggli-native a "native" C API for Google's weggli

weggli-native a "native" C API for Google's weggli

Trail of Bits 3 Jul 13, 2022
TMM is a Linux native game modding tool. it allows to install and depoly mods for Linux native and wine games.

Tux Mod Manager TMM is a Linux native mod manager made with the Tauri toolkit. It can install, load, remove and deploy mods for both Linux native and

Mathiew May 119 Dec 27, 2022
A Rust Embedded-HAL for the rp series microcontrollers

rp-hal A Rust HAL impl for the RP family of microcontrollers from the Raspberry Pi Foundation Explore the docs » View Demo · Report Bug · Request Feat

rp-rs 706 Jan 7, 2023