Commit Graph

1550 Commits

Author SHA1 Message Date
Jim Blandy
b9781ee6e2 [core] Move CommandAllocator into its own module.
No intended change in behavior.
2024-04-15 16:37:08 -04:00
Jim Blandy
c9212c6d46 [core] Document command encoding and command buffers.
Flesh out the documentation for `wgpu_core`'s `CommandBuffer`,
`CommandEncoder`, and associated types.

Allow doc links to private items. `wgpu-core` isn't entirely
user-facing, so it's useful to document internal items.
2024-04-14 20:53:15 -07:00
dependabot[bot]
6756601089
build(deps): bump crate-ci/typos from 1.19.0 to 1.20.4 (#5506)
* build(deps): bump crate-ci/typos from 1.19.0 to 1.20.4

Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.19.0 to 1.20.4.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.19.0...v1.20.4)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* update to typoes 1.20.8 since it has a few important fixes

* typo fixes & exceptions

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-04-14 09:28:36 +00:00
Jim Blandy
0b7f91c4a9
[core] Make wgpu_core::command::BakedCommands pub(crate), not pub. (#5526) 2024-04-14 09:40:50 +02:00
Jim Blandy
b7519bb73b
[core] Make Hub members and related types pub(crate), not pub. (#5502) 2024-04-10 19:52:16 -04:00
Jim Blandy
8289711b65
[core] Provide an explicit type for some CommandBuffer pointers. (#5512) 2024-04-10 19:51:56 -04:00
Jim Blandy
f8deb0317f
[core] Use expect instead of "if let else panic". (#5513)
Use `Option::expect` to check the result from `Arc::into_inner`,
rather than `if let Some ... else panic!`.
2024-04-10 03:53:10 -04:00
Andreas Reich
82dead09e4
Bump wgpu-core/hal/types & naga versions to match latest released patch versions (#5404) 2024-04-09 00:33:43 -04:00
Jim Blandy
03db77cb8c
[core] Replace id transmute method with explicit functions. (#5509)
Replace the `wgpu_core:🆔:Id::transmute` method, the `transmute`
private module, and the `Transmute` sealed trait with some associated
functions with obvious names.
2024-04-08 21:51:30 -04:00
lylythechosenone
d814851350
[wgpu-core] pass resources as Arcs when adding them to the registry (#5499)
* [wgpu-core] pass resources as Arcs when adding them to the registry (fix gfx-rs#5493)

* [wgpu-core] also add `Arc::new` to `#[cfg(dx12)]` blocks

* [wgpu-core] allow `clippy::arc_with_non_send_sync`
2024-04-06 09:10:24 +02:00
teoxoy
7ce422c57a remove naga's clone feature 2024-04-05 18:07:41 +02:00
teoxoy
3bda381812 add pipeline constants plumbing 2024-04-05 18:07:41 +02:00
Erich Gubler
fb305b85f6 docs: add warning about stack size for WGSL compilation 2024-04-03 15:54:43 -04:00
Chase MacDonnell
3db0e46f7d
Implement Unorm10_10_10_2 VertexFormat (#5477) 2024-04-03 19:43:54 +00:00
JMS55
ed843f8029
Add more hal methods (#5452)
* Add return value to Texture::as_hal()

* Add TextureView::as_hal()

* Add CommandEncoder::as_hal_mut()

* Add changelog

* Add TextureView::raw_handle()

* Add CommandEncoder::raw_handle()

* Add additional docs for command_encoder_as_hal_mut
2024-04-03 00:37:18 +02:00
Erich Gubler
0c5bebca51 fix: unlock guard for release_gpu_resources call in Device::maintain 2024-04-02 16:12:28 -04:00
Andreas Reich
ed7d9de439
Fix indexed drawing with RenderBundle (#5441)
* enhance vertex_indices test to also run with render bundles

* fix render bundle index limit check

* changelog entry
2024-03-30 10:19:17 +01:00
Sludge
6b996dd9c7
Avoid recursive snatch lock acquisitions (#5426)
* Avoid recursive snatch lock acquisitions

* Always acquire the snatch lock before the fence lock

* Address review comments

* Add changelog entry
2024-03-23 21:29:00 +01:00
robtfm
ed95dfe9b4
Pool tracker vecs (#5414)
* pool tracker vecs

* pool

* ci

* move pool to device

* use pool ref, cleanup and comment

* suspect all the future suspects (#5413)

* suspect all the future suspects

* changelog

* changelog

* review feedback

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-03-23 11:42:08 +00:00
Brad Werth
00e0e72596
Invoke a DeviceLostClosure immediately if set on an invalid device. (#5358)
Invoke a DeviceLostClosure immediately if set on an invalid device.

To make the device invalid, this defines an explicit, test-only method
make_invalid. It also modifies calls that expect to always retrieve a
valid device.

Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-03-21 13:33:25 -04:00
robtfm
152a94bc6c
suspect all the future suspects (#5413)
* suspect all the future suspects

* changelog
2024-03-18 10:53:41 -04:00
dependabot[bot]
e04a9f4c6f
build(deps): bump the patch-updates group with 29 updates (#5376)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-14 13:00:43 -04:00
Erich Gubler
6040820099 refactor: extract Global::poll_single_device helper 2024-03-12 10:49:44 -04:00
Erich Gubler
9499e8c9df refactor: rename Global::poll_device to poll_all_devices_of_api 2024-03-12 10:49:44 -04:00
Erich Gubler
c5ee3b6880 refactor: Global::device_poll: hoist submission_index extr. 2024-03-12 10:49:44 -04:00
Erich Gubler
fe28eda3e0 refactor: Global::poll_device: use &= for all_queue_empty 2024-03-12 10:49:44 -04:00
Erich Gubler
e3b23a6c62 fix: add missing deferred resource dtor. in Global::poll_all_devices 2024-03-12 10:49:44 -04:00
vero
4e6f873da5
Add shader I64 and U64 support (#5154)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-03-12 12:34:06 +01:00
Lucas Kent
cf4f8bc3a3
Minor rewording of ConfigureSurfaceError::TooLarge (#5371) 2024-03-10 20:48:30 +01:00
Erich Gubler
8f1981d5b1
fix: emit valid. err. on dev. mismatch in queue_write_buffer (#5359) 2024-03-07 11:20:42 +01:00
Connor Fitzgerald
330a8608e3
Fix Presentation (#5312) 2024-02-27 20:36:20 -05:00
dependabot[bot]
744454b9e2
Bump Many Dependencies and MSRV (#5241)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-27 14:43:05 -05:00
Erich Gubler
023b0e063f feat!: make ProgrammableStage::entry_point optional in wgpu-core 2024-02-27 13:57:17 -05:00
Erich Gubler
2c66504a59 refactor(valid): factor out shader_stage_from_stage_bit helper 2024-02-27 13:57:17 -05:00
Erich Gubler
be384fc001 refactor: factor out stage_err helper in pipeline creation 2024-02-27 13:57:17 -05:00
Nicolas Silva
6f68d3dffa Correctly set the tacker sizes before executing render bundles 2024-02-27 10:05:09 -05:00
Nicolas Silva
ed852c4774 Don't put the mapped-at-creation staging buffer in the registry 2024-02-27 10:05:09 -05:00
Nicolas Silva
c77b4d3f56
Use a unique tracker index per resource instead of the ID in trackers (#5244)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-26 20:25:12 +00:00
Erich Gubler
d6465702b6 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-26 09:32:26 -05:00
Erich Gubler
9747a0ed23 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>
2024-02-26 09:32:26 -05:00
Erich Gubler
751cddc510 refactor: command_encoder_clear_buffer: s/end/end_offset 2024-02-26 09:32:26 -05:00
Erich Gubler
7300b9f037 style: fix fmt. of assert!(…) in clear_texture_via_buffer_copies 2024-02-26 09:32:26 -05:00
Augusto Hack
a315925882
wgpu-core: Inform user about possible fix (#5298) 2024-02-25 14:30:55 -05:00
Nicolas Silva
75a98f2712
Validate that the view dimension of a multisampled texture binding is 2d (#5274)
* Validate that the view dimension of a multisampled texture binding is 2d

* typo
2024-02-21 08:56:28 +01:00
Nicolas Silva
004e3efe84
Simplify the ID allocation in IdentityValues (#5229)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-15 20:55:55 +00:00
Nicolas Silva
66ba64b721
Store Arcs instead of IDs in render bundles (#5242) 2024-02-15 15:54:11 -05:00
Nicolas Silva
286306d7e8
Store the device's queue via a weak ref instead of an ID (#5230) 2024-02-15 15:42:28 -05:00
Erich Gubler
18b7904b8e fix: discard cmd. enc. buf. on wgpu_core::Global::command_encoder_drop 2024-02-15 10:45:32 -05:00
andristarr
a7d76743a8
MissingBufferUsageError now has an id prop (#5203) 2024-02-14 13:27:58 +01:00
Andreas Reich
f350f28c35
Separate native-only feature for wgpu::CommandEncoder::write_timestamp (#5188)
* split out TIMESTAMP_QUERY_INSIDE_ENCODERS from TIMESTAMP_QUERY

* changelog entry

* update changelog change number

* fix web warnings

* single line changelog

* note on followup issue
2024-02-13 16:03:33 +00:00
Jim Blandy
59e79c0664 [wgpu-core] Document and improve naming in PendingWrites. 2024-02-09 11:33:52 -08:00
Bruce Mitchener
665c075fa0
Remove TextureInner::Surface::has_work. (#5200)
When no work is submitted for a frame, presenting the surface results
in a timeout due to no work having been submitted.

Fixes #3189.

This flag was added in #1892 with a note that it was going to be
temporary until #1688 landed.
2024-02-09 11:36:24 +00:00
Erich Gubler
f21087ddaf
Revert "docs: inline document-features usage, remove dep." (#5169)
* docs: sync. `wgpu/Cargo.toml` feature comments with `lib.rs`

* Revert "docs: inline `document-features` usage, remove dep."

This reverts commit 3d5bec659b9cf19f1c64274de0d11808d771cc66, with an
update to `document-features`, and preferring to keep new `feature`
content. To be clear, the only difference I have observed is the
addition of the `serde` feature.

In case it shortens anyone's search, the specific issue resolved is
[`slint-ui/document-features`#20](https://github.com/slint-ui/document-features/issues/20).
2024-02-09 11:44:29 +01:00
andristarr
3028972817
buffer_map_async should use offset + size (#5185) 2024-02-09 09:48:00 +01:00
Nicolas Silva
990324fc33
Add max_color_attachments and max_color_attachment_bytes_per_sample (#5218) 2024-02-09 09:39:29 +01:00
Jim Blandy
4af531cf69
[wgpu-core] Compute minimum binding size correctly for arrays. (#5222)
* [wgpu-core] Add tests for minimum binding size validation.

* [wgpu-core] Compute minimum binding size correctly for arrays.

In early versions of WGSL, `storage` or `uniform` global variables had
to be either structs or runtime-sized arrays. This rule was relaxed,
and now globals can have any type; Naga automatically wraps such
variables in structs when required by the backend shading language.

Under the old rules, whenever wgpu-core saw a `storage` or `uniform`
global variable with an array type, it could assume it was a
runtime-sized array, and take the stride as the minimum binding size.
Under the new rules, wgpu-core must consider fixed-sized and
runtime-sized arrays separately.
2024-02-09 03:08:01 +00:00
Nicolas Silva
499bd64c29
Prevent a deadlock when destroying resources (#5216)
It's risky to get write access through the snatchlock from a drop implementation since the snatch lock is typically held for large scopes. This commit makes it so we deffer snatching some resources to when the device is polled and we know the snatch lock is not held.

Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-02-07 16:17:04 +00:00
Nicolas Silva
20fda69834 Fix the validation of max_bindings_per_bind_group 2024-02-06 15:03:19 +01:00
Connor Fitzgerald
faed98b45c
Add typos to Repository CI (#5191)
Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-02-05 12:30:29 -05:00
Nicolas Silva
32e70bc163
Prevent another deadlock. (#5201) 2024-02-05 17:52:04 +01:00
Nicolas Silva
4da46f35ef
Avoid a deadlock in Device::lose (#5197) 2024-02-05 10:01:05 -05:00
John-John Tedro
c038b5c433 Consistent debug formatting 2024-02-02 14:31:28 -05:00
John-John Tedro
f45d500c1c Remove HalSurface and fix layout assumptions in AnySurface and AnyDerive 2024-02-02 14:31:28 -05:00
John-John Tedro
84ba4e5461
Remove another unused A: HalApi parameter (#5181) 2024-02-01 14:03:46 +01:00
Nicolas Silva
617050ec16
Always serialize and deserialize ids the same way (#5182) 2024-02-01 13:29:50 +01:00
Nicolas Silva
d7bbababa7
Add information to some of the api logging (#5174) 2024-01-31 09:55:46 -05:00
Andreas Reich
45957088ad
Fix panic when creating a surface while no backend is available (#5166)
* Fix panic when creating a surface while no backend is available

* changelog entry
2024-01-31 08:48:33 +00:00
Brad Werth
0888a630a0
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-01-31 08:15:45 +01:00
John-John Tedro
950d765a4d
Remove G parameter in Global<G> and generic IdentityHandlerFactory (#5159) 2024-01-29 15:37:57 +01:00
Nicolas Silva
6e020a079e
Fix the validation for vertex limits for regular render passes (#5156) 2024-01-29 14:01:03 +01:00
John-John Tedro
dec6ea5ea4
Improve the consistency of identifiers (#5108) 2024-01-29 10:56:04 +01:00
Bude
4face1c2ba
Feature/serde feature (#5149)
* Add serde, serialize, deserialize features to wgpu and wgpu-core
Remove trace, replay features from wgpu-types

* Do not use trace, replay in wgpu-types anymore

* Make use of deserialize, serialize features in wgpu-core

* Make use of serialize, deserialize features in wgpu

* Run cargo fmt

* Use serde(default) for deserialize only

* Fix serial-pass feature

* Add a comment for new features

* Add CHANGELOG entry

* Run cargo fmt

* serial-pass also needs serde features for Id<T>

* Add feature documentation to lib.rs docs

* wgpu-types implicit serde feature

* wgpu-core explicit serde feature

* wgpu explicit serde feature

* Update CHANGELOG.md

* Fix compilation with default features

* Address review comments
2024-01-28 20:13:04 +00:00
Nicolas Silva
e2e9ef5547 Fix the validation of vertex/index/instance ranges in render bundles 2024-01-26 17:26:44 +01:00
Nicolas Silva
d47534ed9a
Discard draws when the instance/vertex/index count is zero (#5137) 2024-01-25 09:06:29 +01:00
Nicolas Silva
efb35d4fa1
Snatch bind groups associated with destroyed textures and buffers (#5136)
* Make bind groups snatchable

* Snatch bindgroups when destroying associated textures and buffers.
2024-01-25 05:11:43 +00:00
Nicolas Silva
7d0f656dd9
Snatch texture views of destroyed textures (#5131) 2024-01-24 20:55:20 +01:00
Nicolas Silva
b0e4734a7e Differentiate between device loss caused by an error and caused by dropping the device 2024-01-24 13:41:23 +01:00
Nicolas Silva
8d64915b3c
Remove the lock around TextureView::parent (#5126) 2024-01-23 10:31:13 -05:00
wayne
c4b5cc94ad
don't panic if naga parsing of shader source fails (#5034)
* naga: glsl parser should return singular ParseError similar to wgsl

* wgpu: treat glsl the same as wgsl when creating ShaderModule

* naga: update glsl parser tests to use new ParseError type

* naga: glsl ParseError errors field should be public

* wgpu-core: add 'glsl' feature

* fix some minor bugs in glsl parse error refactor

* naga/wgpu/wgpu-core: improve spirv parse error handling

* wgpu-core: feature gate use of glsl and spv naga modules

* wgpu: enable wgpu-core glsl and spirv features when appropriate

* obey clippy

* naga: derive Clone in Type

* naga: don't feature gate Clone derivation for Type

* obey cargo fmt

* wgpu-core: use bytemuck instead of zerocopy

* wgpu-core: apply suggested edit

* wgpu-core: no need to borrow spirv code

* Update wgpu/src/backend/wgpu_core.rs

Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>

---------

Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
2024-01-23 10:25:25 -05:00
Nicolas Silva
60a5739df2
d3d12: Propagate errors when closing command lists (#5125)
Before this commit, command lists that we failed to close were used anyway during submit, causing device loss.
2024-01-23 14:30:08 +01:00
Brad Werth
ac8756c2d3
Release GPU resources from device.trackers, not from lifetime_tracker. (#5075) 2024-01-22 17:55:42 +01:00
John-John Tedro
e5c62fb5bd
vulkan: Replace fence with semaphore when acquiring surfaces (#4967) 2024-01-21 18:14:17 -05:00
Connor Fitzgerald
8b2098bd4e
Release 0.19 (#5082) 2024-01-17 14:42:11 -05: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
John-John Tedro
90b078f037
Improve ergonomics of gfx_select! (#5069) 2024-01-16 11:15:56 +01:00
dependabot[bot]
c5a0b0b7b4
Bump the patch-updates group with 12 updates (#5061)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-14 23:48:30 -05: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
daxpedda
580340f2d3
Add cfg_aliases to wgpu-core and wgpu-hal (#5055) 2024-01-14 00:59:59 -05:00
Nicolas Silva
376d901d1e
Triage suspected resources after triaging submissions (#5050) 2024-01-12 13:19:19 -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
Nicolas Silva
bc65d84cdb
Remove the Destroyed state from Storage (#4970)
* Remove the Destroyed state from Storage

It used to be how we handled destroying buffers and textures but we moved to different approach.

* Explicit check for destroyed textures/buffers in a few entry points

This used to be checked automatically when getting the resource from the registry, but has to be done manually now that we track we track the destroyed state in the resources.
2024-01-11 10:45:12 +00:00
Nicolas Silva
b30c0c2e00
Remove the free_resources tracker (#5037) 2024-01-11 09:41:09 +00:00
Nicolas Silva
c90f43bc2a
Move the trace recording of destroy events out of triage_resources (#5036) 2024-01-11 00:48:25 -05:00
Nicolas Silva
f27bb443c1
Don't crash if a texture is destroyed before queue submission (#5028) 2024-01-10 14:36:02 +01:00
Nicolas Silva
4400a58470
Fix a bounds check in remove_abandoned (#5024) 2024-01-09 11:24:18 -05:00
Nicolas Silva
37755b6985 Validate that a binding offset fits in the buffer 2024-01-09 16:07:47 +01:00
Nicolas Silva
58fe7eac48
Don't case the dynamic offsets count to u8 (#5026) 2024-01-09 15:41:39 +01:00
Nicolas Silva
1bc71eb8b2
Validate max_vertex_buffers in render bundles. (#5025) 2024-01-09 15:41:24 +01:00