Commit Graph

9013 Commits

Author SHA1 Message Date
Patrick LaFontaine
190bd37e22 [rs] spelling error in skybox 2021-02-24 17:29:13 -05:00
Jökull Máni Reynisson
ce4668a7ac const in ShaderStage that represents vertex and fragment access (#1229)
* const in ShaderStage that represents vertex and fragment access

We can store `ShaderStage`s as const values or members of const structs in all individual cases, but for example `ShaderStage::VERTEX | ShaderStage::FRAGMENT` cannot be stored in a const. This is not very elegant, but would be convenient.

* Correct VERTEX_FRAGMENT definition

VERTEX_FRAGMENT definition now follows directly from the bit representation of `ShaderStage::VERTEX` and `Shaderstage::FRAGMENT` such that it does not need to be independently maintained.
2021-02-24 16:37:05 -05:00
Anthony Cowley
822be23f35 Validate signed integer array size constants (#517)
Until we have some amount of type inference, an integer literal used as a constant array size must have a `u` suffix. This is inconsistent with the surface syntax presented in the spec, and is a minor inconvenience.

For now, allow a signed integer array size to pass validation so that user code need not change when type inference deduces values of the correct type.
2021-02-24 12:47:02 -05:00
Pelle Johnsen
51cbd4c112 [glsl-in] Add initial support for glslpp-rs (#513)
* [glsl-in] Add initial support for glslpp-rs

* [glsl-in] Add remaining Punct mappings

Fix some tests.

* [glsl-in] Add basic error handling for glslpp-rs

* [glsl-in] Fix clippy issues

* [glsl.in] Add pp-rs floats

* [glsl-in] Remove old lex and preprocessor

* [glsl-in] Improve lexer token code

* [glsl-in] Rename lex_pp > lex

Also LexerPP > Lexer

* [glsl-in] glslpp-rs review feedback

* [glsl-in] Use rev for pp-rs dep

* [glsl-in] Parse on lexer err
2021-02-24 12:07:09 -05:00
Dzmitry Malyshau
df14c4b7ca [spv-in] fix OpString and OpLine parsing 2021-02-24 09:10:26 -05:00
Joshua Groves
9c47a5fe17 [wgsl] Track token span for unexpected errors 2021-02-23 21:08:46 -05:00
bors[bot]
f430adb828 Merge #1231
1231: Added TextureFormatFeatures::filterable which may overwrite TextureSampleType::Float.filterable r=kvark a=Wumpf

**Description**
The expectation is that with `wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES` enabled, any texture format which is sampled as float may be (linearly) filtered if so supported by the adapter, not only those that the webgpu specification denotes as filterable.

This arguably causes a bit of a mess in the way we distinguish `sample_type` and `(guaranteed_)format_features`: The float sample type (via spec) essentially integrates a feature, namely if it is filterable or not. Unlike the actual format _type_ which is just a property of the format, this property may or may not be available depending on the device.
So the type of `sample_type` stays statically defined whereas the Float.filterable property suddenly becomes overwritten by a format_feature which may or may not be present. Couldn't come up with a cleaner solution so far.

**Testing**
Tested in project (blub) depending on R32F filtering - passing now what was previously causing
```
wgpu error: Validation Error

Caused by:
    In Device::create_bind_group
      note: label = `BindGroup: Narrow Range filter 1`
    texture binding 1 expects sample type = Float { filterable: true }, but given a view with format = R32Float
```
(Blub still can't run on latest wgpu because of other reported issues)

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2021-02-24 01:20:12 +00:00
Andreas Reich
dfe686bbc6 Added TextureFormatFeatures::filterable
Can overwrite TextureSampleType::Float.filterable
2021-02-23 23:59:17 +01:00
Dzmitry Malyshau
0cefc1c46c Remove mutation from the Call expression 2021-02-22 23:37:26 -05:00
Dzmitry Malyshau
d3062a2f3b Statement validation 2021-02-22 15:36:25 -05:00
Ashley
0476822863 [rs] Fix create_texture_with_data for 3d textures (#771)
* Fix create_texture_with_data for 3d textures

* Remove depth_per_iteration variable
2021-02-22 12:19:57 -05:00
Dzmitry Malyshau
c0d5a6bde4 Rewrite the type validation 2021-02-22 10:12:09 -05:00
Dzmitry Malyshau
694a00afcb [spv-out] optimize if/else branching 2021-02-22 10:11:36 -05:00
Joshua Groves
ce84b1d1c0 [wgsl] Add parser error snapshot 2021-02-22 01:17:15 -05:00
bors[bot]
e5f1f6a5c0 Merge #1227
1227: Derive more things for primitive and multisampling states r=kvark a=kvark

**Connections**
Related to https://github.com/gfx-rs/wgpu-rs/issues/769

**Description**
Adding a few derives and fixing a doc comment.

**Testing**
CI gets it

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-22 06:12:14 +00:00
Dzmitry Malyshau
c506c76e45 Derive more things for primitive and multisampling states 2021-02-22 01:10:26 -05:00
bors[bot]
e913cefcc6 [rs] Merge #768
768: Update naga to gfx-12 r=kvark a=kvark

See https://github.com/gfx-rs/wgpu/pull/1226

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-21 17:07:53 +00:00
Dzmitry Malyshau
cb58bc214d [rs] Update naga to gfx-12 2021-02-21 12:07:26 -05:00
bors[bot]
2d0142a2e7 Merge #1226
1226: Update gfx and naga to gfx-12 r=kvark a=kvark

**Connections**
Picks up https://github.com/gfx-rs/gfx/pull/3650
Fixes #1225

**Description**
Also fixes our playtests, interestingly. One of the changes here was that now `Analysis` is needed for everything, including the SPV-out backend of Naga. And we can only get it via validating the `naga::Module`.

What we used to was: if validation isn't enabled, we'd carry the module around, and then still try to produce a SPIR-V from it, if there is no original SPIR-V. This precise thing was happening in the tests. However, we had `dummy` backend depending on the `wgpu-core/cross` feature, which means the playtests were actually built and run with spirv-cross enabled!
Another factor here is the introduction of `ShaderModule::flags` instead of a single boolean, which was done in #1093. The problem here was that the playtest RON files weren't updated accordingly, they still had `experimental_translation: true` in them, which got ignored now.
So with this combination of events, the playtests ended up generating SPIR-V from Naga modules, without validation(!), and passing the SPIR-V to gfx-rs and SPIRV-Cross... Which still worked, as we'd expect, but definitely not want here.

So this PR fixes everything. It makes it required to have the validation for a module, and we force-validate if there is no SPV source to fall back on. And it disables "cross" feature implicitly enabled in testing.

**Testing**
Tested on wgpu-rs examples.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-21 16:36:54 +00:00
Dzmitry Malyshau
91f5329b33 Update gfx and naga to gfx-12 2021-02-21 11:25:45 -05:00
Matúš Talčík
fa7d4d8b51 spv-in: fix if condition when merge node == false node
format
2021-02-20 10:41:54 -05:00
Dzmitry Malyshau
2a5c478b21 Fix type resolves of matrix by vectors 2021-02-20 00:02:28 -05:00
Dzmitry Malyshau
f03a99d6a3 Implement Debug for arena and handle 2021-02-19 23:20:11 -05:00
Dzmitry Malyshau
26e6c2bdac Use source attribute of errors 2021-02-19 22:10:25 -05:00
Dzmitry Malyshau
99c1add358 [msl] fake bindings 2021-02-19 19:20:21 -05:00
Dzmitry Malyshau
0e3f745fb2 [msl] derive thiserror 2021-02-19 16:56:45 -05:00
Dzmitry Malyshau
db0a8875d9 TypifyError with the expression handle 2021-02-19 16:56:45 -05:00
bors[bot]
c0b217a273 [rs] Merge #766
766: Blend state API update r=kvark a=kvark

Based on https://github.com/gfx-rs/wgpu/pull/1224

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-19 21:16:58 +00:00
Dzmitry Malyshau
5c680a1629 [rs] Blend state API update 2021-02-19 16:16:19 -05:00
bors[bot]
53bab9d68f Merge #1224
1224: Update the blend API to upstream r=kvark a=kvark

**Connections**
Matches https://github.com/gpuweb/gpuweb/pull/1134

**Description**
Makes blending state ON/OFF explicit.

**Testing**
Simple enough!

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-19 17:38:16 +00:00
Dzmitry Malyshau
ff31911760 Update the blend API to upstream 2021-02-19 12:07:47 -05:00
bors[bot]
b75f6118bb [rs] Merge #765
765: Update naga to gfx-11 r=cwfitzgerald a=kvark

Gets us https://github.com/gfx-rs/wgpu/pull/1220

Note that "cross" feature is not optional here. We could lift it up and add to `default = []` but that would make the Web backend to always unconditionally depend on `wgpu-core` (since enabling a feature on it automatically enables it). So we ideally need a way for Cargo to allow platform-specific default features...

About the shadow example - the experimental translation works on the main pipeline, but fails on the baking pipeline because of https://github.com/gfx-rs/naga/issues/483. Fortunately, it falls back to SPIRV-Cross gracefully here.

The new validation detected a flaw in our shader (comparison sampler mismatch), yay!

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-19 05:03:27 +00:00
João Capucho
19e7f456c4 Remove the call graph processor
Uses the GlobalUse in glsl-out to check for function availability
2021-02-18 11:43:18 -05:00
Systemcluster
9f113bdd95 [wgsl] limit allowed for statement initializer statements 2021-02-18 10:55:16 -05:00
Systemcluster
e49910bb0a [wgsl] allow empty for statement headers 2021-02-18 10:55:16 -05:00
Dzmitry Malyshau
5f21cf360f Refactor snapshot testing to include some IR 2021-02-18 10:19:25 -05:00
Dzmitry Malyshau
4c5a1ba054 Global usage tests in the analyzer 2021-02-17 16:22:19 -05:00
Dzmitry Malyshau
8a0382a89d Move global use flags into FunctionInfo 2021-02-17 15:37:37 -05:00
Pelle Johnsen
9f0cdfe9e5 [glsl-in] Multi entry, don't use find on hashmap 2021-02-17 10:05:40 -05:00
Pelle Johnsen
408002815f [glsl-in] Multi entry points - address comments 2021-02-17 10:05:40 -05:00
Pelle Johnsen
1861fca4ba [glsl-in] Support multiple entrypoints 2021-02-17 10:05:40 -05:00
Systemcluster
dea3e0e1e1 Add MIT license 2021-02-17 09:34:17 -05:00
Systemcluster
59479f137d [wgsl] support nested type parameters 2021-02-16 16:57:34 -05:00
Dzmitry Malyshau
06b04a49e9 [rs] Update naga to gfx-11 2021-02-16 10:55:29 -05:00
Systemcluster
321420c019 Set default SPIR-V version in convert example 2021-02-16 10:25:02 -05:00
bors[bot]
5afe832c3c Merge #1220
1220: Update naga to gfx-11, make spirv-cross optional r=kvark a=kvark

**Connections**
https://github.com/gfx-rs/gfx/pull/3642
https://github.com/gfx-rs/gfx/pull/3641

**Description**
Gets us the latest Naga updates, plus the ability to make spirv-cross optional (on Linux and Windows only for now).

**Testing**
Will be tested on wgpu-rs

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-16 15:24:03 +00:00
Dzmitry Malyshau
fdd50e10fd Update naga to gfx-11 2021-02-16 09:46:22 -05:00
Dzmitry Malyshau
847d127ec8 Optimize Interface with a bitmask to avoid re-visiting expressions 2021-02-16 09:08:05 -05:00
Dzmitry Malyshau
e37268e60c [msl] fix support for private globals 2021-02-16 09:08:05 -05:00
Dzmitry Malyshau
35ba4dac66 Fix the ClipDistance validation - expect an array 2021-02-16 09:08:05 -05:00