Commit Graph
8897 Commits
Author SHA1 Message Date
Max Ammann abc4e1572a Explicitely enable std, and don't rely on environment (#2062) 2022-09-17 12:39:34 -07:00
Jim Blandy 7e3750a7f2 [wgsl] Fix line endings on wgsl reserved words list. (#2059) 2022-09-17 00:52:00 +00:00
i509VCB b752c7d248 statically assert public wgpu types appropriately implement Send and Sync (#3025) 2022-09-16 12:36:23 -04:00
i509VCB 9e3efd7019 pass around RawDisplayHandle and RawWindowHandle in implementation (#3022)
This change is to help with an attempt to allow the Context type in wgpu to be swappable at runtime. In order to do that, the functions provided by Context and it's associated types need to be object safe. Instead of passing a impl trait that combines both HasRawWindowHandle and HasRawDisplayHandle, we seperate the types into their RawDisplayHandle and RawWindowHandle parts internally to reduce some of the hal implementation code mess.
2022-09-15 16:29:20 -07:00
Jim Blandy 33392382ee [wgsl-in] Break up long string, reformat rest of file. (#2057)
Whitespace and formatting changes only.

It turns out that if `cargo fmt` comes across a single line it can't
make fit within the margins, then it sort of gives up on the
surrounding construct. So breaking up the error message for
`Error::UnknownScalarType` in `Error::as_parse_error` and then
re-running `cargo fmt` cleans up lots of other stuff in the file.

cargo fmt issue:
https://github.com/rust-lang/rustfmt/issues/3863
2022-09-15 19:06:11 +00:00
Shaye Garg 5166c2a1d8 wgsl-in: Improve assignment diagnostics (#2056)
Fixes #2052.

* improved assignment statement errors

* hint immutable binding

* fix clippy

* add diagnostic tests

* cleanup formatting
2022-09-15 09:17:00 -07:00
SparkyPotato 4f8db997b0 remove trailing trivia 2022-09-14 23:16:24 -07:00
SparkyPotato 5d9cdd361f fix inclusion of trivia in spans 2022-09-14 23:16:24 -07:00
João Capucho 1a99c1cf06 wgsl-in: Fix bad span in assignment lhs error
The wgsl frontend was emiting errors for lhs expressions on assignments
that weren't references using a span that didn't skip blankspaces
causing the span to look weird (like starting at the end of the previous
line)

This is fixed by consuming the blankspace before constructing the span
2022-09-12 13:02:36 -07:00
João Capucho ff69053bf2 valid: Check regular functions don't have bindings
Checks that all arguments and return types have no bindings in regular functions.
2022-09-10 10:31:11 -07:00
João Capucho db1321cfb6 wgsl-in: Splat on compound assignments
Compound assignments on wgsl follow the same semantics as their
underlying operation, this includes the splatting behavior when mixing
scalar and vector operands, which was done for binary operations but not
for compound assignments.
2022-09-10 10:17:20 -07:00
Jim Blandy eb6124ec94 Document arithmetic binary operation type rules. 2022-09-10 17:12:35 +01:00
João Capucho 7d0e9847b0 Remove the glsl-validate feature
When it was introduced it was supposed to allow for fast compiles by
skipping glsl specific validation, but as it turns the subset of glsl that's
compilable code is already pretty close to the subset of valid glsl code.

So the current code gated behind glsl-validate amounts to a single branch that
isn't even performance sensitive, and most of the validation is not specific to
glsl and is made by naga's validator which can be turned off, so the original
goal of fast compile times by disabling validation can still be accomplished.
2022-09-05 19:37:39 -07:00
João Capucho d9c9fe6218 glsl-in: Migrate to SymbolTable 2022-09-05 13:30:55 +01:00
João Capucho 544f14ad2f Add some methods to SymbolTable and implement Debug 2022-09-05 13:30:55 +01:00
Jim Blandy 94ce76391b Fix link in README.md. 2022-09-04 09:22:25 -07:00
Jim Blandy 13a0d28ddc wgsl-in: Rename Scope to Rule, since we now have lexical scope.
Rename related functions and variables appropriately.

Also, make `Rule` private to the WGSL front end, and remove the unused
`ImportDecl` variant.
2022-09-03 08:56:52 -07:00
Jim Blandy 7505187476 [spv-out] Don't emit no-op OpBitCast instructions.
As reported in #2015, some drivers trip over these.
2022-09-03 16:39:07 +01:00
Jim Blandy 90eb399d43 Fill in Adapter::as_hal and Device::as_hal documentation. (#2992)
In particular, explain why a callback is needed, rather than just
having these functions return an `Option<&A::Mumble>`.
2022-09-02 20:56:27 -07:00
Jinlei Li e350f50b2f metal: remove PrivateCapabilities's format_rgb10a2_unorm_surface field (#2981)
* metal: remove PrivateCapabilities's format_rgb10a2_unorm_surface field

* Update CHANGELOG
2022-09-02 20:28:26 -07:00
Jim Blandy 254937c1b5 Explain which WGSL version wgpu supports in various configs. (#3009) 2022-09-02 20:26:46 -07:00
Jim Blandy bec26b79ec Don't use a callback to return backend instance handles. (#2991)
Change `Instance::as_hal<A>` to simply return an
`Option<&A::Instance>`, rather than passing it to a callback. We're
just borrowing a reference to some `wgpu_hal::Api::Instance` owned by
the `wgpu_core::instance::Instance`, so there's no special scoping or
locking magic required here.
2022-09-02 17:32:58 -07:00
Kevin Reid 4a7fc68df0 Document that write_buffer_with is sound to read from. (#3006)
* Document that `write_buffer_with` is sound to read from.

To a reader informed about Rust's memory model, the existing claim that

> dereferencing it to a `&[u8]` panics

without further context sounds awfully like someone thinks they've
invented a write-only reference, and that the API might actually be
exposing undefined behavior via an uninitialized `&mut [u8]`. Therefore,
let's specify what happens if you *do* read through the mutable
reference.  The text added in this commit is based on what was said in
the review when `write_buffer_with` was added:
https://github.com/gfx-rs/wgpu/pull/2777/files#r901392551

This is also relevant information to someone considering using
`write_buffer_with()` for performance gains: for example, it suggests
that it might be a bad idea to write data into the view and then sort
it in-place. (Or is that not a bad idea? Is it not slow if the CPU
already wrote over all the memory contiguously? I don't know.)

* Changelog addition (+ fixing duplicate documentation section)
2022-09-02 23:50:15 +00:00
Jim Blandy 7e84bb2eae Correct create_surface_from_(offscreen)_canvas docs. (#2990)
The function's does not depend on the `canvas` argument meeting the
given requirements to avoid undefined behavior, so it should just be a
normal contract, not a safety contract.
2022-09-02 16:29:06 -07:00
Andreas Monitzer 6348a07d28 Expose the vk::Queue and the queue index in the Vulkan hal. (#2950) 2022-09-02 22:58:01 +00:00
Jim Blandy 701564da8c Use () instead of PhantomData as IdentityManager's Input type. (#2972)
* Use () instead of PhantomData as IdentityManager's Input type.

PhantomData suggests that there's some sort of persuasion required
for lifetime variance inference or other sorts of arcana, but it
doesn't seem to be necessary at all. `()` works just fine.
2022-09-02 15:37:21 -07:00
Jinlei Li ee7fd47ecb metal: fix max_storage_xx max_texture max_sampler and max_vertex_xx limits (#2978) 2022-09-02 15:36:07 -07:00
Mauro GentileandMauro Gentile 35deadc108 Depth clear value for web target (#2984)
* Fix depth clear value on web

* Defaulting to 0.

* Added also stencil clear

Co-authored-by: Mauro Gentile <Mauro.Gentile@ubisoft.com>
2022-09-02 15:35:42 -07:00
i509VCB c519901d57 vulkan: remove use of Vulkan12Features/Properties types (#2936)
Vulkan prohibits including `VkPhysicalDeviceVulkan12Features` structures in the chain passed to `VkCreateDevice` along with other more specific features structs. Similiar restrictions apply to the `...Properties` structures.

Fixes #2925.
2022-09-02 21:05:13 +00:00
François 27f6302d5b changelog 2022-09-02 11:41:20 -07:00
François b9564dbe74 enable union feature of smallvec 2022-09-02 11:41:20 -07:00
François a50335f0f8 use smallvec instead of onplace_it with fixed size 2022-09-02 11:41:20 -07:00
Jim Blandy 58bc205f2a Update to Naga b209d911 (2022-9-1).
This removes an expected failure on AMD RADV. I guess #2751 was our
bug all along.
2022-09-02 11:33:55 -07:00
João Capucho d64d78ff0b wgsl-in: Implement lexical scopes
Previously the wgsl frontend wasn't aware of lexical scopes causing all
variables and named expressions to share a single function scope, this
meant that if a variable was defined in a block with the same name as a
variable in the function body, the variable in the function body would
be lost and exiting the block all references to the variable in the
function body would be replaced with the variable of the block.

This commit fixes that by using the previously introduced `SymbolTable`
to track the lexical and perform the variable lookups, scopes are pushed
and popped as defined in the wgsl specification.
2022-09-01 17:31:50 -07:00
João Capucho 66f5506e10 Add a frontend agnostic symbol table
Adds a new type `SymbolTable` to allow sharing code between the
frontends related to variable name lookup and lexical scope management,
this way improvements in variable lookup can be shared among all
frontends.
2022-09-01 17:31:50 -07:00
Jim Blandy b209d91168 [spv-out] Properly combine the fixes for #2035 and #2038.
The Vulkan decoration rules require us to distinguish vertex shader
inputs, fragment shader inputs, and everything else, so just pass the
stage to `Writer::write_varying`. Together with the SPIRV storage
class, this is sufficient to distinguish all the cases in a way that
closely follows the spec language.
2022-09-01 15:55:42 -07:00
Jim Blandy 5be898e7e7 Use Option::as_deref as appropriate. 2022-09-01 10:46:28 -07:00
Nicolas Silva b63436af36 Decorate most builtins as Flat in the spirv writer.
Fixes #2032
2022-09-01 10:27:19 -07:00
Nicolas Silva 6b3c111f3f Don't decorate varyings with interpolation modes at the beginning and end of the pipeline.
Fixes #2036.
2022-09-01 10:17:55 -07:00
João Capucho 9df243c42c hlsl-out: Add support for push constants (#2005)
Push constants need to be configured by the consumer which must pass the
bind target of the constant buffer used for the push constants.
2022-08-29 11:58:02 +01:00
Jim Blandy 7d138e2e76 Avoid overflow in check texture copy bounds. (#2963) 2022-08-28 20:07:04 -04:00
Jim Blandy a0dfb28b8d Document wgpu_core id handling, factories, etc. (#2973) 2022-08-28 19:49:09 -04:00
i509VCB f5fa92aa79 note PresentMode::Mailbox support for Wayland (#2937) 2022-08-28 19:48:22 -04:00
Jim Blandy 2cd08a1c9c Placate Clippy 0.1.63. (#2977) 2022-08-24 17:25:59 -04:00
Adeline e7ddd3564c glsl-in: Fix missing stores for local declarations (#2029)
Previously, if a local variable was declared with a constant value, we
would elide the store and instead give the variable an initial value (as
if it was a global variable). This caused variables to not be
re-initialized each time through a loop.
2022-08-24 22:05:11 +01:00
Jinlei Li f918ac1ed1 vk: fix astc_hdr formats support (#2971)
* vk: fix `astc_hdr` formats support

* Update CHANGELOG
2022-08-20 19:18:39 +00:00
Jinlei Li a08ea2a255 metal: add the missing msg_send![view, retain] call within from_view (#2976)
* metal: add the missing `msg_send![view, retain]` call within `from_view`

* Update CHANGELOG
2022-08-20 07:14:57 -07:00
daxpedda 48e79388b5 Implement Clone for Module (#2013)
This is hidden behind the `clone` feature flag
2022-08-16 11:45:19 +01:00
Evan Mark Hopkins a80967f860 Add support for the saturate function (#2025)
uses clamp in place of saturate in spv and glsl
2022-08-16 10:43:41 +00:00
João Capucho 6f4003ca9b Fix clippy lints for 1.63 (#2026) 2022-08-15 21:53:14 -04:00