Commit Graph
9013 Commits
Author SHA1 Message Date
Xiaopeng Li 39f3f08b55 Add Device::as_hal and always assume texture from hal is initialized (#2180)
* Add Device::as_hal, create_texture_from_hal_initialized

* Add Safety doc

* Always assume that the texture from hal is initialized
2021-11-18 17:34:01 -05:00
Layl Bongers 29571cc4cf Add multiview wgsl builtin 2021-11-18 09:57:37 -05:00
Jim Blandy 6a5b33fa24 Move BoundsCheckPolicy/Policies into proc, from back. (#1537) 2021-11-17 19:15:59 -08:00
bjorn3 38366e382f Switch to rustc-hash
See gfx-rs/rspirv#221 for the rationale behind this change
2021-11-16 23:51:19 -05:00
Igor Shaposhnik 30a0a37af0 Update dependencies 2021-11-16 23:46:54 -05:00
Jim Blandy ce18eba695 Check that stores are permitted by the pointer's storage access.
Fixes #1533.
2021-11-16 23:40:56 -05:00
Boris-Chengbiao Zhou 47fd77619f Don't use duplicate function name in boids shader (#2183)
From the spec: "A declaration must not introduce a name when that
identifier is already in scope with the same end scope as another
instance of that name."

naga doesn't yet check this (gfx-rs/naga#1480) but Chrome/Tint rightly
complains with: error: redefinition of 'main'
2021-11-16 23:25:33 -05:00
Boris-Chengbiao Zhou 3545a4fdd5 Introduce SamplerBindingType enum and fix bug in validation (#2181)
* Introduce SamplerBindingType enum and fix bug in validation

This matches the WebGPU spec more closely and also lets us implement the
validation as it's written in the spec[1]. This fixes a bug which
previously prevented the "shadow" example from running in Firefox.

Previously the validation would check whether the filtering was
appropiate even if it was a comparison sampler. This didn't matter when
running the shadow example natively since the example was setting
`filtering: true` in addition to `comparison: true`. But this failed
when running through a browser since there the used WebIDL has the
proper enum representation and eventually resulted in `filtering: false`
being passed to wgpu-core which would then fail validation.[2]

[1]: https://gpuweb.github.io/gpuweb/#bind-group-creation
[2]: https://github.com/mozilla/gecko-dev/blob/674b6582bafedc11fba6dc537769c88e9ed921d3/dom/webgpu/ipc/WebGPUChild.cpp#L502-L513

* Fix remaining examples

* Fix deno_webgpu
2021-11-16 23:08:03 -05:00
Jim Blandy 3d6cbcf8a6 Remove IndexableLength::Specializable variant.
Specializable constants are no longer permitted as array lengths, so this case
should not arise in valid code.
2021-11-16 09:12:42 -05:00
Jim Blandy 90daa9edfe Forbid specializable constants as array lengths.
Only the SPIR-V front end can produce such array types, and it seems that our
back ends don't support this case well.
2021-11-16 09:12:42 -05:00
Dzmitry Malyshau 1ff70329f1 Refactor texture view non-referenced resources (#2184) 2021-11-15 15:58:47 -05:00
Jerónimo Sánchez 052cb3da39 Renaming CommandEncoder::clearBuffer to CommandEncoder::fillBuffer (#2174)
* Renamed clear_buffer to fill_buffer (keeping up with spec)
* fill_buffer does not require CLEAR_BUFFER feature

* Changed ClearBuffer to FillBuffer for `trace` feature

* Renamed clearBuffer for web backend
2021-11-14 19:16:10 -05:00
Boris-Chengbiao Zhou 1dcde48d09 [valid] Check that switches have a default case (#1529)
From the WGSL spec: "Each switch statement must have exactly one default clause."
2021-11-15 00:07:55 +00:00
Jay Oster 66c3499df8 [spv-out] Fix scalar-times-matrix operations (#1524) 2021-11-14 19:07:38 -05:00
Boris-Chengbiao Zhou 08b9c46ec4 Validate strip_index_format (#2177)
The spec mandates that stripIndexFormat is set even when drawIndexed is
not used. (https://www.w3.org/TR/webgpu/#primitive-state)
There is some recent discussion about this though:
https://github.com/gpuweb/gpuweb/issues/2199
2021-11-14 19:03:33 -05:00
Jim Blandy e69a70bfb7 [spv-in] Permit pointers to runtime arrays only in StorageBuffer. (#1522)
* [spv-in] Change shadow.spv test input to use StorageBuffer.

The ecosystem around Naga will generally not be able to use Vulkan adapters that
don't support the SPV_KHR_storage_buffer_storage_class (which was incorporated
into SPIR-V 1.3), so we can assume it is present.

Changing the test not to use runtime-sized arrays in the Uniform storage class
will allow Naga to tighten up some validation checks.

* [spv-in] Permit pointers to runtime arrays only in StorageBuffer.

Fixes #1519.
2021-11-10 16:58:57 -05:00
Dzmitry Malyshau f25a45f4e2 Evolve depth clamping into clip control (#2171) 2021-11-10 16:55:27 -05:00
Dzmitry Malyshau 27aae2a2a2 Update naga to eda078d (#2172) 2021-11-10 16:06:32 -05:00
João Capucho eda078d736 [glsl-in] Allow more operations as access bases (#1521) 2021-11-10 12:16:19 -05:00
João Capucho d168f15d81 [glsl-in] Allow constructors from non-scalar to scalar (#1520) 2021-11-10 12:15:43 -05:00
Mariusz Kryński cf2fb0b665 do not query work group params on gles < 3.1 (#2166)
* do not query work group params on gles < 3.1

* address reviewer comment
2021-11-10 08:21:27 -05:00
João Capucho c3c4ab7548 [glsl-in] Add test for matrix from matrix constructor 2021-11-09 15:15:11 +00:00
João Capucho 7234d19d00 [glsl-in] Implement matrix to matrix constructor 2021-11-09 15:15:11 +00:00
João Capucho e26bff1b8d [glsl-in] Split constructor calls into two functions
Improves code readability and removes nesting
2021-11-09 15:15:11 +00:00
Markus Siglreithmaier 6fc0587b2d hal/vk: add physical device features for extensions (#2167) 2021-11-09 09:59:41 -05:00
João Capucho 8a1dbcb050 [spv-in] Always use get_expr_handle for expressions in image expressions (#1516)
* [spv-in] Use `get_expr_handle` in `parse_image_write`

* [spv-in] Use BlockContext directly instead of its fields

* [spv-in] Use `get_expr_handle` for depth ref
2021-11-09 09:52:29 -05:00
João Capucho 8e2c4fbef5 [glsl-in] Don't panic on UB integer operations (#1518) 2021-11-09 09:35:59 -05:00
Mariusz Kryński 9a5dec2cf0 gles backend: unbind PIXEL_UNPACK_BUFFER (#2162) 2021-11-09 09:32:40 -05:00
Dzmitry Malyshau 8bc3aa824b Refactor namer scheme, fix trailing digits (#1510) 2021-11-09 09:24:41 -05:00
Jonathan Behrens 098e4af52f [spv-out] Fix word order for constants 2021-11-07 14:51:40 +00:00
Mariusz Kryński 746c938d19 fix run-wasm-example.sh 2021-11-07 10:20:02 -03:30
Dzmitry Malyshau 7e00abf651 Manually implement Error for ShaderError (#2160) 2021-11-06 17:17:08 -04:00
Dzmitry Malyshau 693bc58bdd Validate device descriptor before opening (#2159) 2021-11-06 17:09:52 -04:00
Dzmitry Malyshau 2755cd08eb Add clippy non_send_fields_in_send_ty (#2156) 2021-11-05 08:57:09 -04:00
Timo Kösters dbf65234a3 fix typo (#2153) 2021-11-05 02:47:16 +00:00
Alphyr 99830957e8 Update ron (#2154) 2021-11-04 22:41:21 -04:00
Mike Welsh 7b3caad779 web: Implement Device::on_uncaptured_error 2021-11-04 22:05:48 -02:30
Dzmitry Malyshau 28c45321e5 hlsl: respect array stride in storage buffers (#1507) 2021-11-03 22:44:46 -04:00
Shohei Jinno d9b166816b [glsl-in] Add helper to reduce repetition. (#1505)
```
Ok(self.constants.fetch_or_append(
    Constant {
        name: None,
        specialization: None,
        inner,
    },
    span,
))
```

was called repetitively, so I added
`ConstantSolver::register_constant(&mut self, ConstantInner, Span)`
that returns Handle<Constant>.
2021-11-02 18:05:59 -07:00
Jerónimo Sánchez c824c8fa53 Added shader workgroup size validation (#2142) 2021-11-02 17:19:15 -04:00
Dzmitry Malyshau ca7ca749cd Update naga to 323999f, report pretty errors in shader validation (#2141) 2021-11-01 16:57:33 -04:00
Jim Blandy c1b378842e Make tests properly exercise Some("") global names. (#1503)
The GLSL empty-global-name.frag test doesn't suffice because the GLSL front end
doesn't produce the same IR as the SPIR-V included in the bug report. As far as
I know, only a genuine SPIR-V input test can produce a global whose name is
`Some("")`.

Include the SPIR-V assembly source.
2021-11-01 14:07:11 -04:00
Jasper St. Pierre 8a76920349 queue: Another attempt at cube map rendering (#2143)
The last one was wrong, because I misread
a confusing line in the GL ES spec.
2021-11-01 14:06:10 -04:00
Dzmitry Malyshau 323999fcb9 Fix span includes into function validation (#1500) 2021-10-31 23:58:58 -04:00
Dzmitry Malyshau 07b02e694d Update naga to 9d2b357 (#2140) 2021-10-31 23:29:49 -04:00
Jasper St. Pierre 191a8efae6 gles: Fix rendering to cubemap faces (#2139) 2021-11-01 03:00:01 +00:00
939d54f88d Compute max workgroup size limits (#2133)
* Creation of max compute workgroup size limits
* Implemented for Vulkan and Dx12

* Follow up of gfx-rs/wgpu#1808

* Check if current dispatch operation is under the limit

* Typos and some forgotten fixes

* Port to GLES

* Port to Metal with default limits

* Change Vulkan max_workroup_size_per_dims to pick the min of the reported dimensions

Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-10-31 22:32:10 -04:00
Connor Fitzgerald d2d8affb79 Merge pull request #2137 from kvark/copy-dst
Don't require COPY_DST on surface textures
2021-10-31 00:44:21 -04:00
Dzmitry Malyshau 1b33d996a0 Don't require COPY_DST on surface textures 2021-10-31 00:37:14 -04:00
Connor Fitzgerald 8e5b1f281e Merge pull request #2136 from dlunch/master 2021-10-30 21:12:14 -04:00