Commit Graph

1467 Commits

Author SHA1 Message Date
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
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
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
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
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
Jim Blandy
8af6975d5e
Prefer Arc::into_inner over Arc::try_unwrap. (#5018) 2024-01-08 19:24:33 -05:00
Jim Blandy
a24bdbaa25
[wgpu-core] Minor doc fixes for initialization tracking. (#5017) 2024-01-08 16:46:57 -05:00
Nicolas Silva
c6eea50b04
Track the actual size of the buffer for memory init (#5014) 2024-01-08 17:24:09 +01:00
Nicolas Silva
8358868526
Propagate errors when openning/closing a command encoder (#4999) 2024-01-06 10:14:38 +01:00
Nicolas Silva
4b82121501 Snatch the raw texture when destroying it 2024-01-05 11:42:28 +01:00
Nicolas Silva
95c451a3b8 Check thata bindgroup's textures are not destroyed before using it 2024-01-05 11:42:28 +01:00
Nicolas Silva
defd43dff2 Rename Texture::as_raw into Texture::raw
For consistency with Buffer::raw.
2024-01-05 11:27:17 +01:00
Nicolas Silva
bfe235a295 Put raw texture access behind snatch guards 2024-01-05 11:27:17 +01: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
Connor Fitzgerald
d96d953025
Shorten Lock Lifetimes (#4976) 2024-01-04 09:24:54 +01:00
Connor Fitzgerald
b989e56874
Use Custom Mesa for Building (#4977) 2024-01-03 22:49:40 -05:00
Connor Fitzgerald
fd37dbfae9
Fix hang in multithreaded test (#4975) 2024-01-03 23:05:35 +01: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
Connor Fitzgerald
e26a853654
BGL Weak Pointer Deduplication Pool (#4927)
* Ho boy

* BGL pool finished

* Remove id32 feature

* Add BGL Test

* Iteration

* Working Dedupe

* Tests

* Iteration

* Re-iteration

* Hash Cleanup

* Add large slew of tests

* Whoops
2024-01-02 09:27:22 -05:00
Erich Gubler
e1baa5a56e docs: inline document-features usage, remove dep.
Re-implements https://github.com/gfx-rs/wgpu/pull/4886 (CC @Wumpf)
without the `document-features` crate, which has issues integrating into
Firefox builds after being `cargo vendor`ed into its repository. This
issue is being tracked against
https://github.com/slint-ui/document-features/issues/20. Once resolved,
I expect that we will want to revert this PR in its entirety, since
`document-features` is still a good addition to `wgpu`'s documentation
story.

Internally, consensus has already been achieved for this change.
Firefox's ability to build unfortunately take priority over this
particular convenience. Hopefully, we won't have to compromise shortly!

I tested this by ensuring that the HTML output of our existing
`document_features::document_features!(…)` usage was exactly the same.
There should be exactly zero regressions in the current state of
documentation for users. For maintainers, I have added a disclaimer that
one needs to keep changes in sync. with the relevant `Cargo.toml`
manifests.
2023-12-22 14:31:12 -05:00
Andrew Farkas
2993650ede
Fix typo "layout pipeline layout" -> "pipeline layout" (#4921) 2023-12-22 01:02:41 +00:00
Connor Fitzgerald
87ecc089dd Remove id32 feature 2023-12-20 21:39:24 -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
Nicolas Silva
85b91c0408
Buffer snatching (#4896)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-12-20 16:42:42 -05:00
Nicolas Silva
164e478fcb
Simplify some code around buffer unmapping (#4892) 2023-12-20 15:21:32 -05:00
Nicolas Silva
0524c88c03
Check that raw buffers and raw bind groups are valid (#4895) 2023-12-20 15:13:20 -05:00
sotaroikeda
1d6c7a0263
Support Device fence sharing with dx12 on Windows (#4900)
Co-authored-by: Sotaro Ikeda <you@example.com>
2023-12-20 13:33:47 -05: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
Nicolas Silva
aade481bdf
Remove some locks in BindGroup (#4894)
* Remove some locks in BindGroup

These are only written to clear the vectors when triaging bindgroups for destruction, which is not necessary. We can let the reference counts drop when the bind group is dropped.

* Make the mem_leak test pass again
2023-12-19 10:29:32 +01:00
Nicolas Silva
a1b183f736
Avoid allocating memory every time we might log a label (#4893)
We allocate a String every time we want to get a label for logging. The string is also allocated when logging is disabled. Either way, the allocation is unnecessary. This commit replaces the String with a dyn Debug reference which does not need any allocation.
2023-12-18 13:08:18 +01:00
Nicolas Silva
192a2fe16c
Simplify ResourceMaps (#4880)
* Remove the abstractions in resource maps

ResourceMaps had a rather convoluted system for erasing types that isn't needed anywhere except in one place in the triage_resource function. Everywhere else we are always dealing with specific types so using a member of the resource maps is simpler than going through an abstraction. More importantly there was a constraint that all contents of the resource maps implement the Resource trait which got in the way of some of the ongoing buffer snatching changes.

This commit simplifies this by removing the abstraction. Each resource type has its hash map directly in ResourceMaps and it is easier to have different requirements and behaviors depending on the type of the each resource.
2023-12-18 08:27:58 +00:00
Mikko Lehtonen
159ac9e373
validation: More detailed on incompatible BGL (#4826) 2023-12-17 18:22:39 -05:00
Andreas Reich
ba56dd2901
Document wgpu & wgpu-core features (#4886) 2023-12-17 22:10:38 +00:00
Nicolas Silva
10dd5844ac
Allow clippy::pattern_type_mismatch (#4887) 2023-12-17 15:00:02 -05: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
Nicolas Silva
855b06977f
Refactor create_buffer so that we can snatch the raw buffer in the error path. (#4878)
The general idea is to register postpone reigistering the buffer until towards the end of the function so that our unique reference to it lets us easily snatch the raw buffer if an error happens.
2023-12-15 10:08:03 +01:00
Nicolas Silva
c5e6122b65
Reintroduce buffer snatching Part 1 (#4867)
Introduce snatch guards
2023-12-14 13:14:49 +01:00
Teodor Tanasoaia
0cbabcf229
Update multi-planar texture API (#4837) 2023-12-07 14:06:56 -05:00
Connor Fitzgerald
dc842ae289
Some minor cleanups (#4843) 2023-12-07 08:55:02 +01:00
Daniel Keitel
0f4df52b5a
[wgpu-hal] Inline RayQuery Support (#3507)
Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
Co-authored-by: Ashley Ruglys <ashley.ruglys@gmail.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-12-06 21:12:41 +00:00
daxpedda
3e0fb2c14e
Expose shader validation (#4811)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-12-06 21:06:04 +00:00
Valaphee The Meerkat
a1fafe394f
Remove DX11 backend (#4828) 2023-12-06 15:12:46 -05:00
Nicolas Silva
537f656626
Use Display instead of Debug to log errors. (#4830) 2023-12-04 18:49:33 -05:00
Almar Klein
32c5a22293
Add feature float32-filterable (#4759) 2023-12-04 14:23:13 +01:00
teoxoy
acdc9fcced move alignments & downlevel .clone()s inside function 2023-11-29 19:55:18 +01:00
teoxoy
da73522720 rename DeviceDescriptor.limits to DeviceDescriptor.required_limits 2023-11-29 19:55:18 +01:00
teoxoy
9be6c8890f rename DeviceDescriptor.features to DeviceDescriptor.required_features 2023-11-29 19:55:18 +01:00
Andreas Reich
8da4925948
Remove surface extent validation (and thus fix the annoying Requested size ... is outside of the supported range warning) (#4796)
* Remove surface extent validation

* silence pnext vulkan validation warning which can happen on surface resize

* remove old VUID-VkSwapchainCreateInfoKHR-imageExtent-01689 validation warning ignore

* Validate surface against max texture size
2023-11-29 18:21:26 +01:00
Jim Blandy
276c978b70 [naga] Introduce ScalarKind::AbstractInt and AbstractFloat.
Introduce new variants of `naga::ScalarKind`, `AbstractInt` and
`AbstractFloat`, for representing WGSL abstract types.
2023-11-29 08:58:47 +01:00
Xiaopeng Li
a6503e59c9
Support nv12 texture format (#4573)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-11-28 16:11:26 +00:00
Mauro Gentile
238c3732a4
Don't keep a strong ref in storage for destroyed resources (#4786) 2023-11-27 13:37:09 +01:00
Mauro Gentile
2c67f79970
Remove resources ONLY when needed inside wgpu and not in user land (#4782) 2023-11-27 13:09:50 +01:00
Mauro Gentile
281a7aecd5
remove_abandoned fix (#4781)
* remove_abandoned fix

* Updated doc
2023-11-26 14:58:00 +00:00
Nicolas Silva
ebcfd25b58
Downgrade resource lifetime management log level to trace. (#4772)
* Downgrade resource lifetime management log level to trace.

Allow promoting it back to info via an feature flag.

* Don't filter out info and warning log in the examples.

* Changelog entry.
2023-11-25 17:33:02 +01:00
Nicolas Silva
ca4e1313f7
Downgrade some of wgpu_core's logging level from info to trace and debug (#4771)
* Downgrade storage log level from info to trace

* Downgrade tracking log level from info to trace

* Demote present log from info to debug

* Downgrade device/life.rs log from info to debug and trace

* Downgrade more log from info to trace
2023-11-24 20:09:36 +01:00
Nicolas Silva
350c9633fe
Conditionally lift API logging from trace to info level (#4769)
* Conditionally lift API logging from trace to info level

Most of this logging used to be info level until I demoted it to trace. Unfortunately this gets in my way because:
 - Most of the logging I currently need is these API entry points, there is is a fair amount of more verbose logging in wgpu at higher levels than trace
 - Firefox disable all trace and debug logging for optimized builds, which means I miss the this API logging where I need most.

This patch lifts the api logging back to info level.

* Move the api logging behind the api_log macro
2023-11-24 19:14:38 +01:00
Nicolas Silva
039660ec85
Logging cleanups in device/global.rs (#4752)
* Clean up the trace-level logging for devices

* Log the descriptors for create_buffer and create_texture.

* Make logged ids more concise

Logged ids go from 'Id { index: 204, epoch: 1, backend: Vulkan }' to 'Id(204,1,vk)'.

* Log errors in more places.
2023-11-22 19:28:55 +00:00
Nicolas Silva
7dad106039
Make the command_encoder_clear_buffer's size an Option<BufferAddress> (#4737)
* Make the size parameter of command_encoder_clear_buffer an Option<BufferAddress>

* Add a changelog entry
2023-11-22 11:42:34 +01:00
Brad Werth
877dd5b26c
Ensure DeviceLostClosureC callbacks have null-terminated message strings. (#4744) 2023-11-22 09:00:28 +01:00
Connor Fitzgerald
1df98d9888
Test And Normalize Vertex Behavior on All Backends (#4723)
Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>
2023-11-21 22:11:24 +00:00
Jim Blandy
72462267e8 [naga]: Let TypeInner::Matrix hold a Scalar, not just a width.
Let `naga::TypeInner::Matrix` hold a full `Scalar`, with a kind and
byte width, not merely a byte width, to make it possible to represent
matrices of AbstractFloats for WGSL.
2023-11-21 12:02:50 +01:00
Nicolas Silva
6786548d1e
Fix max_vertex_buffers validation (#4708) 2023-11-20 10:17:19 +01:00
Mauro Gentile
6e21f7a929
Arcanization of wgpu core resources (#3626)
Arcanization of wgpu_core resources

---------

Co-authored-by: Elabajaba <Elabajaba@users.noreply.github.com>
Co-authored-by: Niklas Korz <niklas@niklaskorz.de>
Co-authored-by: grovesNL <josh@joshgroves.com>
Co-authored-by: Jim Blandy <jimb@red-bean.com>
Co-authored-by: Mauro Gentile <Mauro.Gentile@ubisoft.com>
Co-authored-by: Sludge <96552222+SludgePhD@users.noreply.github.com>
2023-11-20 08:41:52 +01:00
Nicolas Silva
1d7c7c8a3c Prevent panic when submitting a destroyed buffer 2023-11-16 14:16:53 +01:00
Nicolas Silva
b47fe3b413 Prevent panic in buffer mapping logic if the buffer is already destroyed. 2023-11-15 13:58:16 +01:00
Nicolas Silva
f5665f73bd Prevent panic in untrack if a resource is already destroyed 2023-11-15 12:15:16 +01:00
Nicolas Silva
a697e4352c
Keep the value in its storage after destroy (#4678)
* Keep the value in its storage after destroy

in #4657 the destroy implementation was made to remove the value from the storage and leave an error variant in its place.
Unfortunately this causes some issues with the tracking code which expects the ID to be unregistered after the value has been fully destroyed, even if the latter is not in storage anymore.
To work around that, this commit adds a `Destroyed` variant in storage which keeps the value so that the tracking behavior is preserved while
still making sure that most accesses to the destroyed resource lead to validation errors.

... Except for submitted command buffers that need to be consumed right away. These are replaced with `Element::Error` like before this commit.

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2023-11-14 14:23:23 +00:00
Jim Blandy
9f91c95c24 [naga] Introduce Scalar type to IR.
Introduce a new struct type, `Scalar`, combining a `ScalarKind` and a
`Bytes` width, and use this whenever such pairs of values are passed
around.

In particular, use `Scalar` in `TypeInner` variants `Scalar`, `Vector`,
`Atomic`, and `ValuePointer`.

Introduce associated `Scalar` constants `I32`, `U32`, `F32`, `BOOL`
and `F64`, for common cases.

Introduce a helper function `Scalar::float` for constructing `Float`
scalars of a given width, for dealing with `TypeInner::Matrix`, which
only supplies the scalar width of its elements, not a kind.

Introduce helper functions on `Literal` and `TypeInner`, to produce
the `Scalar` describing elements' values.

Use `Scalar` in `wgpu_core::validation::NumericType` as well.
2023-11-14 14:21:27 +01:00