gfx-rs / wgpu-rs

Rust bindings to wgpu native library
https://wgpu.rs
Mozilla Public License 2.0
1.69k stars 186 forks source link

WGSL textureStore function not recognized. #820

Closed 5nefarious closed 3 years ago

5nefarious commented 3 years ago

I'm trying to render to a storage texture inside a compute shader using the textureStore function, documented here. Compilation throws the following error:

ERROR wgpu_core::device: Failed to parse WGSL code: error while parsing WGSL in scopes [FunctionDecl, Block, Statement] at line 10 pos 16: unknown identifier: `textureStore`
wgpu error: Validation Error

Has this function been implemented as of v0.7? If not, then does anyone have any recommendations for what I should do instead?

kvark commented 3 years ago

It was implemented in https://github.com/gfx-rs/naga/pull/465, which landed before Naga-0.3.0 was published. I highly recommend using master branch if you can. Alternatively, you'd have to resort to SPIR-V as a workaround. You can even keep the shader in WGSL, but add a build step using the latest Naga from master that would translate it to SPIR-V that you feed into wgpu-0.7. Would any of this work for you?

5nefarious commented 3 years ago

I would like to update wgpu-rs to master, but I think I'm stuck with v0.7.

error: failed to select a version for `web-sys`.
    ... required by package `wasm-bindgen-futures v0.4.23`
    ... which is depended on by `wgpu v0.7.0 (https://github.com/gfx-rs/wgpu-rs.git#841a610a)`
    ... which is depended on by `render-test v0.1.0 (/Users/REDACTED/Code/bevy/render-test)`
versions that meet the requirements `=0.3.46` are: 0.3.46

all possible versions conflict with previously selected packages.

  previously selected package `web-sys v0.3.50`
    ... which is depended on by `wgpu v0.7.0 (https://github.com/gfx-rs/wgpu-rs.git#841a610a)`
    ... which is depended on by `render-test v0.1.0 (/Users/REDACTED/Code/bevy/render-test)`

failed to select a version for `web-sys` which could resolve this conflict

How would I add the Naga build step?

kvark commented 3 years ago

Your error message looks suspicious. wgpu from master has to build by itself, we check it on CI. If there is nothing in your code that depends on web-sys, then there should be no conflicts either. cc @grovesNL

How would I add the Naga build step?

[build-dependencies.naga]
git = "https://github.com/gfx-rs/naga"
rev = "xxx"
features = ["wgsl-in", "spv-out"]

Then follow the path of https://github.com/gfx-rs/naga/blob/057fa336a8ae3e2006717460307fd6f8a7026bcb/bin/convert.rs#L209 from WGSL to SPV

5nefarious commented 3 years ago

@kvark, thanks for the help. As it turns out, I can update wgpu-rs to master by disabling most of the features in Bevy and building it without its own rendering infrastructure. This seemed to eliminate the dependency conflicts.

kvark commented 3 years ago

Ok, good. Let's close this issue then. textureStore was not included in the release, and it's not a bug to fix.