Commit Graph

453 Commits

Author SHA1 Message Date
Eshed Schacham
75fd68939c
wgpu-hal: add ndk-sys dependency to fix linking error. (#5326) 2024-03-01 17:00:26 -05:00
Connor Fitzgerald
bb09828a9e
Vendor WebGPU Bindings from web_sys (#5325) 2024-03-01 17:00:26 -05:00
Erich Gubler
d189cf27e8
fix: discard cmd. enc. buf. on wgpu_core::Global::command_encoder_drop 2024-03-01 16:48:28 -05:00
Bartłomiej Maryńczak
f8355a8114
[wgpu-hal.gles] Error log for failed GLES heuristics (#5266)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-29 17:00:09 -05:00
Erich Gubler
7214da6820
Fix missing validation for Device::clear_buffer where offset + size > buffer.size was not checked when size was omitted. (#5282)
style: fix fmt. of `assert!(…)` in `clear_texture_via_buffer_copies`

refactor: `command_encoder_clear_buffer`: s/end/end_offset

fix: always check buffer clear `offset` for OOB

Fuzz testing in Firefox encountered crashes for calls of
`Global::command_encoder_clear_buffer` where:

* `offset` is greater than `buffer.size`, but…
* `size` is `None`.

Oops! We should _always_ check this (i.e., even when `size` is `None`),
because we have no guarantee that `offset` and the fallback value of
`size` is in bounds. 😅 So, we change validation here to unconditionally
compute `size` and run checks we previously gated behind `if let
Some(size) = size { … }`.

For convenience, the spec. link for this method:
<https://gpuweb.github.io/gpuweb/#dom-gpucommandencoder-clearbuffer>

fix: `command_encoder_clear_buffer`: err. on `offset + size > u64::MAX`

Rust would have made this operation either an overflow in release mode,
or a panic in debug mode. Neither seem appropriate for this context,
where I suspect an error should be returned instead. Web browsers, for
instance, shouldn't crash simply because of an issue of this nature.
Users may, quite reasonably, have bad arguments to this in early stages
of development!
2024-02-29 17:00:09 -05:00
Alphyr
c27f743558
Avoid a clone when creating a Glsl shader (#5118) 2024-02-29 16:50:26 -05:00
Christian Schwarz
7bc7220170
Fix glsl backend errors regarding samplerCubeArrayShadow (#5171)
* add GL_EXT_texture_shadow_lod feature detection

* allow more cases of cube depth texture sampling in glsl

* add test for sampling a cubemap array depth texture with lod

* add test for chosing GL_EXT_texture_shadow_lod over the grad workaround if instructed

* add changelog entry for GL_EXT_texture_shadow_lod

* fix criteria for requiring and using TEXTURE_SHADOW_LOD

* require gles 320 for textureSampling over cubeArrayShadow

* prevent false positives in TEXTURE_SHADOW_LOD in checks

* make workaround_lod_with_grad usecase selection less context dependant

* move 3d array texture error into the validator

* correct ImageSample logic errors
2024-02-29 16:49:01 -05:00
Augusto Hack
091d7869cf
Docs surface creation no longer unsafe (#5265)
* doc: as of #4597 surface creation is no longer unsafe

* doc: extend documentation of the include_wgsl macro
2024-02-29 16:48:14 -05:00
Peter Whidden
502b140bde
fix typo in docstring (#5281) 2024-02-29 16:46:51 -05:00
HexoKnight
753c502548
fix doc link (#5280) 2024-02-29 16:40:07 -05:00
David Stern
40ebec1dfd
Try to load libX11.so.6 in addition to libX11.so. (#5307) 2024-02-29 16:32:32 -05:00
ark
565f6990c2
using non alpha channeled texture 2024-02-29 16:30:54 -05:00
Connor Fitzgerald
c9a3c1a692
Add AccelerationStructure to WGSL write_value_type (#5261)
Co-Authored-By: JMS55 <47158642+JMS55@users.noreply.github.com>
2024-02-29 16:29:00 -05:00
Augusto Hack
a9a4187643
wgpu-core: Inform user about possible fix (#5298) 2024-02-29 16:26:51 -05:00
Connor Fitzgerald
e9720bfb7a
Fix docs.rs Builds (#5310) 2024-02-29 16:24:22 -05:00
Nicolas Silva
08f235c126
Simplify the ID allocation in IdentityValues (#5229)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-29 16:22:47 -05:00
Connor Fitzgerald
8bda25cb0a
Nested loop test 2024-02-29 16:06:07 -05:00
Connor Fitzgerald
9ca3e936db
Ord for Id (#5176) 2024-02-29 16:02:45 -05:00
Brad Werth
e029858a18
Call device lost callback when it is replaced, or when the global is dropped. (#5168)
This fixes two cases where a DeviceLostClosureC might not be consumed
before it is dropped, which is a requirement:

1) When the closure is replaced, this ensures the to-be-dropped closure
is invoked.
2)  When the global is dropped, this ensures that the closure is invoked
before it is dropped.

The first of these two cases is tested in a new test,
DEVICE_LOST_REPLACED_CALLBACK. The second case has a stub,
always-skipped test, DROPPED_GLOBAL_THEN_DEVICE_LOST. The test is
always-skipped because there does not appear to be a way to drop the
global from within a test. Nor is there any other way to reach
Device.prepare_to_die without having first dropping the device.
2024-02-29 15:56:37 -05:00
Okko Hakola
446a3dcdbf
[d3d12] Avoid panic on instance drop (#5134) 2024-02-29 15:53:31 -05:00
Connor Fitzgerald
6e95491c9d
Update changelog 2024-01-21 18:35:17 -05:00
i509VCB
ec48ee3ba6
Document Wayland specifics related to SurfaceTexture::present (#5093)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-01-21 18:20:39 -05:00
Imbris
e1481b656a
Make sure to unset current context in wgl Surface::configure/present (#5087) 2024-01-21 18:20:16 -05:00
Connor Fitzgerald
8b2098bd4e
Release 0.19 (#5082) 2024-01-17 14:42:11 -05:00
Andreas Reich
4c18e283d1
polish changelog for upcoming release (#5078)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-01-17 18:24:43 +00:00
Andreas Reich
b8f27c7284
Expose maximum_frame_latency (#4899)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-01-17 12:46:34 -05:00
Connor Fitzgerald
2e38187954
Re-export public dependencies (#5063) 2024-01-16 19:21:51 +00:00
Andreas Reich
7774f31021
Allow WebGPU & WebGL in same wasm and detect WebGPU availability (#5044)
* Rename backends: web -> webgpu, direct -> wgpu_core

* rename context objects for web & core

* allow webgpu & webgl features side-by-side

* make sure webgl ci doesn't use webgpu

* update any_backend_feature_enabled

* add panicing generate_report method for compatibility

* RequestDeviceErrorKind::Web rename, fixup various cfg attributes

* automatic webgpu support detection

* changelog entry

* fix emscripten

* fix weird cfg, fix comment typo

* remove try_generate_report again

* Make get_mapped_range_as_array_buffer WebGPU only again
2024-01-14 09:45:52 +00:00
Brad Werth
f89bd3b978
Make DeviceLostClosure.from_c consume the closure before dropping it. (#5032)
This clarifies that the Rust and C-style callbacks/closures need to be
consumed (not called) before they are dropped. It also makes the from_c
function consume the param closure so that it can be dropped without
panicking.

It also relaxes the restriction that the callback/closure can only be
called once.
2024-01-14 02:53:40 -05:00
Nicolas Silva
11c29c825f
Prevent a few integer overflows (#5042)
* Prevent a few integer overflows

* Add a changelog entry

* use u64
2024-01-12 16:23:23 +01:00
Andreas Reich
4fd4a7142e
Unify surface creation by introducing new SurfaceTarget enum (#4984) 2024-01-11 22:24:01 -05:00
Nick
00cf05c1d0
Fix Queue::write_texture, Fix DX12 write_texture_subset_2d and re-enable the test. (#4990) 2024-01-04 19:50:41 -05:00
Martin Vilcans
8e0b715954
hello_compute: check for missing command-line args (#4939)
* hello_compute: check for missing command-line args

Fixes off-by-one error when checking for missing arguments.
Before this, running the example gave this scary looking error message:

```
$ cargo run --bin wgpu-examples hello_compute
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/wgpu-examples hello_compute`
[2023-12-27T22:14:26Z ERROR wgpu::backend::direct] Handling wgpu errors as fatal by default
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_bind_group
    Buffer binding size 0 is less than minimum 4
      note: buffer = `Storage Buffer`

', wgpu/src/backend/direct.rs:3139:5
```

As this was the first example I tried to run, it almost scared me
away, thinking it was a driver issue.

Instead, without arguments the example should use defaults.

* Add PR #4939 to changelog as instructed
2024-01-02 21:08:41 +00:00
Nathan Adams
ec920e85d1
Fix incorrect ConfigureSurfaceError::TooLarge message (#4960)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-01-02 15:32:51 -05:00
Nathan Adams
aa48558e3f
Change examples page menu on smaller screens (#4958) 2024-01-02 13:27:39 -05:00
Divy Srivastava
92d494e4b1
Align wgpu_types::CompositeAlphaMode serde serializations to spec (#4940)
* Align wgpu_types::CompositeAlphaMode serde serializations to spec

* add changelog
2023-12-28 05:10:16 -05:00
Jim Blandy
de3df51807 [naga xtask] Add validate all subcommand. 2023-12-27 13:07:09 -08:00
Jim Blandy
9afd54ea24 [naga xtask] Use naga-cli's --bulk-validate option.
Use `naga --bulk-validate` for `cargo xtask validate wgsl`, reducing
runtime from 12s to 0.8s.
2023-12-24 12:03:28 -08:00
Brad Werth
9eea31a4ae
Eagerly release GPU resources when we lose the device. (#4851)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-12-20 22:43:43 +00:00
Brad Werth
56d9d32a07
[wgpu-core] Ensure that DeviceLostCallback is always called exactly once
* Ensure device lost closure is called exactly once before being dropped.

This requires a change to the Rust callback signature, which is now Fn
instead of FnOnce. When the Rust callback or the C closure are dropped,
they will panic if they haven't been called. `device_drop` is changed
to call the closure with a message of "Device dropped." A test is added.
2023-12-19 23:16:10 +00:00
Andreas Reich
ba56dd2901
Document wgpu & wgpu-core features (#4886) 2023-12-17 22:10:38 +00:00
daxpedda
2053358d89
Add wgpu crate features for backends (#4815)
* Introduce `dx12` and `metal` crate features to `wgpu`

* Implement dummy `Context` to allow compilation with `--no-default-features`

* Address review

* Remove `dummy::Context` in favor of `hal::api::Empty`

* Add changelog entry

* Panic early in `Instance::new()` if no backend is enabled

Co-Authored-By: Andreas Reich <1220815+Wumpf@users.noreply.github.com>

---------

Co-authored-by: Andreas Reich <1220815+Wumpf@users.noreply.github.com>
2023-12-16 10:39:53 +01:00
Jim Blandy
d9d051b7a5 [naga wgsl] Let unary operators accept and produce abstract types.
Fixes #4445.
Fixes #4492.
Fixes #4435.
2023-12-14 10:54:46 +01:00
Jim Blandy
c4b43875e5 [naga wgsl-in] Support abstract operands to binary operators. 2023-12-13 08:42:26 -08:00
Jim Blandy
3ffd5a1e56 [naga wgsl-out] Include the f suffix on f32 literals.
Without the suffix, `Expression::Literal(Literal::F32)` expressions
get written without any suffix on the number, meaning that they get
re-parsed as `AbstractFloat` values. In theory, this should always be
fine, but since we don't actually support abstract types yet in all
the places we should, having them appear in the output causes
validation problems.

See also: #4863, which did the same for `i32` literals.
2023-12-13 13:42:05 +01:00
Jim Blandy
6dc9ccab85
[naga wgsl-out] Include the i suffix on i32 literals. (#4863)
Without the suffix, `Expression::Literal(Literal::I32)` expressions
get written without any suffix on the decimal number, meaning that
they get re-parsed as AbstractInt values. In theory, this should
always be fine, but since we don't actually support abstract types yet
in all the places we should, having them appear in the output causes
validation problems.
2023-12-12 12:07:10 +00:00
Jim Blandy
4b6a2d1dfa [naga] Teach the constant evaluator vector/vector operators.
Allow constant evaluation of binary operators whose left and right
operands are both vectors.
2023-12-12 12:48:10 +01:00
Michael Palmos
eff9a362be
Add COPY_SRC to Metal's surface usage bits. (#4852) 2023-12-10 08:32:36 +00:00
Andreas Reich
d801c6111d
Fix BufferMapRange not being Send/Sync (on native) (#4818)
* Make `BufferMappedRange` trait WasmNotSendSync

* make QueueWriteBuffer trait Debug

* add changelog

* fix pr numbers in changelog

* missing send/sync on web.rs on BufferMappedRange for fragile-send-sync-non-atomic-wasm + !atomics
2023-12-09 11:25:27 +00:00
Theo Dulka
cf8e11efc3
Use VK_EXT_robustness2 only when not using an outdated intel iGPU driver (#4602) 2023-12-07 14:08:21 -05:00