Commit Graph
256 Commits
Author SHA1 Message Date
Teodor Tanasoaia 7e112ca4c0 [wgpu-core] fix length of copy in queue_write_texture (#5973)
The size of the given `data` might be less than the size of the staging buffer.
This issue became apparent with the refactor in 6f16ea460a (https://github.com/gfx-rs/wgpu/pull/5946) since there is now an assert in `StagingBuffer.write()`.

Ruffle ran into this in https://github.com/gfx-rs/wgpu/issues/3193#issuecomment-2231209711.
2024-07-17 10:33:48 -04:00
teoxoy 6f16ea460a make the StagingBuffer implementation more robust 2024-07-12 16:33:57 +02:00
teoxoy 347d902bcb introduce FlushedStagingBuffer 2024-07-12 16:33:57 +02:00
teoxoy 2f282cdd06 remove instance_flags arg from StagingBuffer::new 2024-07-12 16:33:57 +02:00
teoxoy 26f65ddffd [wgpu-hal] remove return type from Device.unmap_buffer()
It's already documented that to unmap a buffer it has to have been mapped.
Vulkan was the only backend that was returning an OOM on missing `Buffer.block` but `Buffer.map_buffer` already returns an error in this case.
2024-07-12 16:33:57 +02:00
teoxoy 5e2df1406d use StagingBuffer.flush() in Buffer.unmap_inner()
We should have always unmapped the staging buffer as we are using it on the GPU after this point.
2024-07-12 16:33:57 +02:00
teoxoy 9a7f44bf09 make StagingBuffer creation a method 2024-07-12 16:33:57 +02:00
teoxoy a8b0f2f6a6 remove device arg from StagingBuffer.flush() 2024-07-12 16:33:57 +02:00
teoxoy 4d285d8b61 remove the Mutex around StagingBuffer's internal buffer 2024-07-12 16:33:57 +02:00
teoxoy a0c185a28c [wgpu-core] fix trying to create 0 sized staging buffers when creating mapped_at_creation buffers
This issue was introduced by fabbca294a.
2024-07-11 14:10:22 +02:00
teoxoy 425526828f introduce DeviceTextureTracker which holds weak references to textures 2024-07-09 10:48:52 +02:00
teoxoy 0e1c1f7c07 replace the tracker in Device with a new DeviceTracker 2024-07-09 10:48:52 +02:00
teoxoy 3cc6c2743a remove LifetimeTracker.future_suspected_{buffers,textures} 2024-07-09 10:48:52 +02:00
teoxoy 61739d9583 remove PendingWrites.executing_command_buffers
The Vec only ever contained 0 or 1 command buffers.
We now acquire an encoder on every submit for pending writes but that's not a problem since those are coming from a pool anyway.
2024-07-09 10:48:52 +02:00
teoxoy 439e28bfc1 move trackers into EncoderInFlight on submit 2024-07-09 10:48:52 +02:00
teoxoy c6761bdd7a add ActiveSubmission.temp_resources that contains all temporary resources.
It's worth noting that `suspected_resources` never contained those resources.
2024-07-09 10:48:52 +02:00
teoxoy 7223bfa88d remove Arcs around TempResource variants 2024-07-09 10:48:52 +02:00
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