Commit Graph
239 Commits
Author SHA1 Message Date
teoxoy ab88dce759 remove unused TempResource::Buffer 2024-07-09 10:48:52 +02:00
teoxoy fabbca294a use StagingBuffer instead of Buffer for mapped_at_creation Buffers 2024-07-09 10:48:52 +02:00
teoxoy 5266bd1f08 change prepare_staging_buffer to return a non null u8 pointer 2024-07-09 10:48:52 +02:00
teoxoy bd2b284a26 remove unused TempResource::Texture 2024-07-09 10:48:52 +02:00
teoxoy 96255d484f change FutureId.assign to not return a clone of the resource passed to it 2024-07-03 15:01:41 +02:00
teoxoy ed1e8ecf4b remove label getters from Global
Also removes label from `Element::Error` and slightly refactors ContextError.
2024-07-02 18:06:19 +02:00
teoxoy 4df5474c9c remove MissingCopyDstUsageFlag error variants 2024-07-02 18:06:19 +02:00
teoxoy 6fe041d544 make Queue.device non-optional 2024-07-02 18:06:19 +02:00
teoxoy c3ebfde302 remove Resource trait 2024-07-02 18:06:19 +02:00
teoxoy c63f0a02f2 introduce Trackable trait 2024-07-02 18:06:19 +02:00
teoxoy ae7da8f669 introduce Labeled trait 2024-07-02 18:06:19 +02:00
teoxoy 727956fcde introduce StorageItem trait 2024-07-02 18:06:19 +02:00
teoxoy 90f7377cc9 introduce ResourceType trait 2024-07-02 18:06:19 +02:00
teoxoy a422d1cba2 remove ResourceInfo.id 2024-07-02 18:06:19 +02:00
Nicolas Silva f25e07b984 Fix soundness issue with Snatchable
The code was written with the incorrect assumption that if no lifetime is specified in a method definition, then all lifetimes are elided to the lifetime of self. In fact only lifetimes in the returned value are elided to the lifetime of self, and other parameters get their own lifetimes.

Kudos to @teoxoy for catching the issue!
2024-07-01 18:41:12 +02:00
teoxoy ad2d797f81 move InvalidQueueId error variant to top level error types 2024-06-25 11:14:41 +02:00
teoxoy c4e067b394 use .error_ident() for resource_log! in Drop impls 2024-06-25 11:14:41 +02:00
teoxoy 5f78485f30 pass Label to ResourceInfo::new 2024-06-25 11:14:41 +02:00
teoxoy 1a4f6aca6f trace as soon as possible 2024-06-25 11:14:41 +02:00
teoxoy 1e784c9c0a use TrackerIndex instead of IDs in PendingWrites's fields 2024-06-20 16:34:17 +02:00
teoxoy f5072261c7 remove ID from QueueSubmitError::BufferStillMapped 2024-06-20 16:34:17 +02:00
teoxoy a024afe182 consolidate destroyed texture/buffer errors and separate them from invalid ID errors 2024-06-20 16:34:17 +02:00
teoxoy 97a038a768 make return type of TextureTracker.set_single non-optional 2024-06-20 16:34:17 +02:00
teoxoy a979d2ed46 simplify BufferTracker.set_single's return type 2024-06-20 16:34:17 +02:00
teoxoy a21bbdccf0 remove usage of Buffer IDs in clear code 2024-06-20 16:34:17 +02:00
teoxoy 8465a64104 remove usage of Texture IDs in clear code 2024-06-20 16:34:17 +02:00
Jim Blandy 584f9e189c [core] Improve resource and api logging.
- Improve logging in `StatelessTracker::remove_abandoned` to show the
  outcome of the call.

- Add similar logging to `BufferTracker` and `TextureTracker`.

- Let `device_create_buffer`'s log only the new buffer's label, id,
  and whether it's mapped at creation. It used to show the whole
  descriptor, which is too much detail.

- Have `queue_submit` log the submission id, and have `device_poll`
  log what it was waiting for, and what actually got done.

- Have `Device::drop` log the destruction of the raw device when it
  actually happens, so it's properly ordered with respect to logging
  from other parts of the device, like `Device::command_allocator`.
2024-06-19 21:13:38 -07:00
teoxoy ce716adb5e improve device mismatch errors 2024-06-19 11:15:38 +02:00
teoxoy 53f8477b15 validate for same device via Arc::ptr_eq rather than IDs 2024-06-19 11:15:38 +02:00
Elabajaba 2eb872e6f7 Deduplicate submitted surfaces to avoid a vulkan deadlock/crash (#5799) 2024-06-12 14:39:26 -04:00
Connor FitzgeraldandJim Blandy c7458638d1 [hal/vk] Rework Submission and Surface Synchronization (#5681)
Fix two major synchronization issues in `wgpu_val::vulkan`:

- Properly order queue command buffer submissions. Due to Mesa bugs, two semaphores are required even though the Vulkan spec says that only one should be necessary.

- Properly manage surface texture acquisition and presentation:

    - Acquiring a surface texture can return while the presentation engine is still displaying the texture. Applications must wait for a semaphore to be signaled before using the acquired texture.

    - Presenting a surface texture requires a semaphore to ensure that drawing is complete before presentation occurs.

Co-authored-by: Jim Blandy <jimb@red-bean.com>
2024-05-30 13:53:34 -07:00
Connor Fitzgerald eeb1a9d7b7 Add Benchmarks (#5694) 2024-05-16 09:05:41 -04:00
Erich Gubler ca91744955 chore: apply unused_qualifications lint via cargo +1.78.0 fix && cargo fmt 2024-05-13 10:10:54 -04:00
Jim Blandy 5f464688e6 [core] Don't check for uniquely referenced resources at submission.
Remove unreachable code from `Global::queue_submit` that checks
whether the resources used by the command buffer have a reference
count of one, and adds them to `Device::temp_suspected` if so.

When `queue_submit` is called, all the `Arc`s processed by this code
have a reference count of at least three, even when the user has
dropped the resource:

- `Device::trackers` holds strong references to all the device's
  resources.

- `CommandBufferMutable::trackers` holds strong references to all
  resources used by the command buffer.

- The `used_resources` methods of the various members of
  `CommandBufferMutable::trackers` all return iterators of owned
  `Arc`s.

Fortunately, since the `Global::device_drop_foo` methods all add the
`foo` being dropped to `Device::suspected_resources`, and
`LifetimeTracker::triage_suspected` does an adequate job of accounting
for the uninteresting `Arc`s and leaves the resources there until
they're actually dead, things do get cleaned up without the checks in
`Global::queue_submit`.

This allows `Device::temp_suspected` to be private to
`device::resource`, with a sole remaining use in `Device::untrack`.

Fixes #5647.
2024-05-03 17:00:07 -04:00
Jim Blandy 4a07ab2b57 [core] Ensure all lock guards are properly nested.
The lock analyzers in the `wgpu_core::lock` module can be a bit
simpler if they can assume that locks are acquired and released in a
stack-like order: that a guard is only dropped when it is the most
recently acquired lock guard still held. So:

- Change `Device::maintain` to take a `RwLockReadGuard` for the device's
  hal fence, rather than just a reference to it.

- Adjust the order in which guards are dropped in `Device::maintain`
  and `Queue::submit`.

Fixes #5610.
2024-05-03 13:06:00 -04:00
Jim Blandy b3c5a6fb84 [core] Enforce a deadlock-free locking order for Mutexes.
If `debug_assertions` or the `"validate-locks"` feature are enabled,
change `wgpu-core` to use a wrapper around `parking_lot::Mutex` that
checks for potential deadlocks.

At the moment, `wgpu-core` does contain deadlocks, so the ranking in
the `lock::rank` module is incomplete, in the interests of keeping it
acyclic. #5572 tracks the work needed to complete the ranking.
2024-04-22 18:49:03 -07:00
Jim Blandy 54740d5982 [core] Make cargo doc --document-private-items work again.
Add a CI job to check it, for the future.
2024-04-18 18:36:47 -07:00
Jim Blandy bab6f53e86 [core] Use internal locking in CommandAllocator.
Move the `Mutex` in `Device::command_allocator` inside the
`CommandAllocator` type itself, allowing it to be passed by shared
reference instead of mutable reference.

Passing `CommandAllocator` to functions like
`PendingWrites::post_submit` by mutable reference requires the caller
to acquire and hold the mutex for the entire time the callee runs, but
`CommandAllocator` is just a recycling pool, with very simple
invariants; there's no reason to hold the lock for a long time.
2024-04-15 16:37:08 -04:00
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
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 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
Jim Blandy 03db77cb8c [core] Replace id transmute method with explicit functions. (#5509)
Replace the `wgpu_core::id::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
Erich Gubler 0c5bebca51 fix: unlock guard for release_gpu_resources call in Device::maintain 2024-04-02 16:12:28 -04: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
robtfmandAndreas Reich 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
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
Nicolas SilvaandConnor Fitzgerald 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