Commit Graph

1987 Commits

Author SHA1 Message Date
teoxoy
278620be26 destroy subsequent command buffers if we encountered an error at submission
This gets the `wgpu_test::ray_tracing::as_build::out_of_order_as_build` test to pass.

This seems to be an issue even on trunk, looking at the nr of calls to `create_command_encoder` & `destroy_command_encoder` in hal, they are not equal. So, I'm not sure why the validation layers don't raise the `VUID-vkDestroyDevice-device-05137`.

There is still an issue with previous command buffers being leaked but I will fix this in a follow-up.
2024-11-14 06:27:37 -08:00
teoxoy
5a3de2d3a8 add a retry mechanism for waiting on the last submission in Queue::drop 2024-11-14 06:27:37 -08:00
teoxoy
d489e4c2e8 remove hal::Device::exit, add Drop implementations to Device and Queue instead 2024-11-14 06:27:37 -08:00
teoxoy
394bf37f98 expect to timeout when targeting WebGL 2024-11-14 06:27:37 -08:00
teoxoy
ddf0e67da7 wait for the last successful submission to complete before dropping the Queue 2024-11-14 06:27:37 -08:00
teoxoy
9e17e32686 extract Queue.maintain 2024-11-14 06:27:37 -08:00
teoxoy
5061ae3e5e map buffers immediately in map_async if the Queue has been dropped 2024-11-14 06:27:37 -08:00
teoxoy
6cc53421bf move LifetimeTracker into the Queue
The `Device` should not contain any `Arc`s to resources as that creates cycles (since all resources hold strong references to the `Device`).
Note that `LifetimeTracker` internally has `Arc`s to resources.
2024-11-14 06:27:37 -08:00
teoxoy
e934595bb2 move device_lost_closure from Device::life_tracker to Device 2024-11-14 06:27:37 -08:00
teoxoy
61c84f956e Remove outdated locking comments
We should rely on the ranks in `wgpu-core\src\lock\rank.rs`.
2024-11-14 06:27:37 -08:00
teoxoy
6c7dbba399 move PendingWrites into the Queue
The `Device` should not contain any `Arc`s to resources as that creates cycles (since all resources hold strong references to the `Device`).
Note that `PendingWrites` internally has `Arc`s to resources.

I think this change also makes more sense conceptually since most operations that use `PendingWrites` are on the `Queue`.
2024-11-14 06:27:37 -08:00
teoxoy
97acfd26ce rely on our ownership model to keep the device alive while there are still active submissions
`Global::device_drop` was wrongly assuming `device_poll` with `Maintain::Wait` was called but this is not a documented invariant and only `wgpu` was upholding this.
2024-11-14 06:27:37 -08:00
Jamie Nicol
4fb32170bf
[wgpu-core] Replace usage of PreHashedMap with FastHashMap (#6541)
PreHashedMap was introduced as a performance optimization. It is,
however, potentially unsound as it cannot distinguish between keys
that are not equal yet have the same hash. This patch replaces its
usage with a simple FastHashMap, which should be good enough. If this
is found to cause real life performance issues down the line then we
can figure out a better solution.
2024-11-14 13:09:51 +00:00
Erich Gubler
d0fd6a231c chore: satisfy unused_qualifications (again) 2024-11-14 07:56:22 -05:00
Erich Gubler
3767a62339 chore: qualify std::mem::size_of with use (again) 2024-11-14 07:56:22 -05:00
Erich Gubler
a2044aefe7
fix: allow non-filterable float on derived BGLs for texture binding usage w/ no sampler (#6531) 2024-11-13 12:20:02 +00:00
Erich Gubler
b5986a9df1 diag: re-word CreateBindGroupError::InvalidTextureSampleType 2024-11-13 07:02:53 -05:00
Erich Gubler
5fb5719cdc diag: add CreateBindGroupError::InvalidTextureSampleType::view_sample_type 2024-11-13 07:02:53 -05:00
Andreas Reich
ae6c6fbea4
Fix Vulkan surface capabilities being advertised when its query failed. (#6510)
* distinguish `GetSurfaceSupportError` between backend unsupported and failing to get surface caps

* Fix vulkan backend returning invalid surface configuration

* changelog entry
2024-11-12 23:51:07 +01:00
Vecvec
79a6f2cd31
Ray Queries (#6291)
* fix more compile errors

* fix err

* fix all compile errors

* fix clippy errors

* fix issues in ray-traced-triangle example

* fix clippy warnings

* fix wasm not compiling

* fix test

* fix clippy (again)

* fix some rustfmt issues

* fix more rustfmt issues

* fix even more rustfmt issues

* fix yet more rustfmt issues

* add #[allow(dead_code)] to some structs to fix clippy on web assembly

* more format fixes

* even more format fixes

* close to final format fixes

* final format fixes (hopefully)

* actual final format fixes (hopefully)

* move ray_cube_cube example and fix bugs

* move other examples

* fix crash when dropping

* fix test

* apply clippy and rustfmt changes

* fix some memory leaks

* fix incompatibility with new wgpu trunk changes

* fix clippy & fmt

* fix clippy errors on github

* update to trunk

* remove a line that printed log "Created blas ..." in device create tlas

* fix merge issues

* fix merge

* fix fmt

* restored example ray scene functionality

* WIP fix rebase

* Fix compile issues

* More fixes

* Fix rebase

* Add wgls backend write_value_type AccelerationStructure

* Add back xtask Cargo.lock

* Revert serde path

* Doc typos

* Add -diff

* Revert more serde

* Revert serde again?

* Fix doc typo

* add test

* clippy & fmt

* fix error "blas does not exist"

* fix various things

* fix unused acceleration structures causing invalid SPIR-V

* fix merge

* fix use after free in a different way (now moved tlas instances to wgpu_core)

* refactor & fmt

* remove accidentally created file

* remove accidentally created file (actually)

* merge & fix

* Fix problems

* fix validation error

* fix validation

* fix merge

* fmt

* fix merge

* use staging buffer trackers in creating the ray-tracing staging buffers (not the tlas_s)

* change one missed staging buffer's tracker

* wip: example

* finished shadow!

* fix merge

* clippy

* remove some uses of blas ids

* fmt

* fix merge

* deduplicate code shared between command_encoder_build_acceleration_structures and command_encoder_build_acceleration_structures_unsafe_tlas

* clippy

* fix merge

* fix warnings

* clippy & fmt

* re-add matching to get_raw_tlas_instance_size and tlas_instance_into_bytes

* fmt

* fix command

* wip: fix merge

* fix merge

* fmt & docs

* fix wasm clippy

* fix issues with tests

* fix issues with tests

* fmt & clippy (wasm)

* wip ray-traced-triangle (non hal)

* unify camera location in ray_shadows

* fix tests

* add readme to ray_traced_triangle

* note that vertex format must be f32x3 (not yet validated)

* changelog

* require VertexFormat::Float32x3

* fix compile error

* when creating and building acceleration structures require Features::RAY_TRACING_ACCELERATION_STRUCTURE is enabled

* remove duplicate workaround

* fix most feedback

* remove all changes from .gitattributes

* fix compile error in test

* more changes along same lines

* format

* apply feedback to more places

* fix `cargo clippy` not just `cargo clippy --all-features`

* cache max instances from tlas creation

* fix clippy

* fix examples

* fix tests

* remove now useless docs

* add more docs

* yet more docs

* still more docs

* Documentation.

* Running out of unique commit messages to say writing docs.

* Add more references to docs.

* Get BindGroup in scope

* Remove unintentional changes

* Remove #[allow(dead_code)]

* Remove old comments

* Add device.poll

* make ray_scene start right way up

* fmt

* move scratch buffer to its own module

* actually remove intentional changes (turns out wgt is inconsistent)

* use better names in ray_scene/shader.wgsl

* fmt

* remove more unintentional changes.

* work on ray_tracing use after free

* spelling

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* grammar

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* move things into struct (should be all vectors with 3 item types or more)

* remove long-standing locks.

* fmt

* move not using index buffer to test

* impl index & index mut for tlas package

* impl index & index mut for tlas package

* fix errors

* fix test errors

* move everything out of ray_tracing.rs

* more index_mut

* fmt

* fix docs links

* move to separate impl block

* fix older request review

* fmt

* remove missed deref

* fix wasm clippy

* change to suggestions

* fmt

* add a note as to why `command_encoder_build_acceleration_structures_unsafe_tlas` and `command_encoder_build_acceleration_structures` are currently separate

* add a todo to reconsider soon `command_encoder_build_acceleration_structures_unsafe_tlas`

* switch to mat4 in ray-tracing examples

* Combine RT Tests Under Single Submodule

* Add More Raytracing Tests and Re-Organize

* Documentation and Formatting Fixes

* Remove Forced Alignment in wgpu-hal

* work on out_of_order_as_build and add out_of_order_as_build_use

* fmt

* update test label naming

* fix one validation error

* fix clippy & fmt

* add acceleration structure creation tests

* make mis-matched index test use the correct function

* move validation into validate_command_buffer

* fix tests

* add blas and tlas to pending writes to remove (now unneeded) `device.poll()`s

* remove commented out code from examples and properly use the constants in ray_shadow

* add examples to examples\README.md

* rename ray tracing to ray queries in readme

* remove unneeded usage from scratch buffer creation

* use snatchables for raw acceleration structures

* format

* add EXPERIMENTAL_ to features

* fix missed comment

---------

Co-authored-by: Daniel Keitel <daniel.mg.keitel@fau.de>
Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
Co-authored-by: atlas dostal <rodol@rivalrebels.com>
Co-authored-by: vero <email@atlasdostal.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-11-09 17:59:48 +00:00
Erich Gubler
01973a98dc
fix(core): handle HAL errors from query set creation (#6505)
* fix(core): handle HAL errors from query set creation

* Update CHANGELOG.md

Co-authored-by: Andreas Reich <r_andreas2@web.de>

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-11-09 12:21:58 +00:00
Erich Gubler
5936fe58f4 fix: check for device mismatch in create_{render,compute}_pass 2024-11-06 01:33:32 -05:00
Erich Gubler
2e46a6c9c9 fix: req. TIMESTAMP_QUERY feat. for <pass desc.>::timestamp_writes 2024-11-06 01:33:32 -05:00
Elie Michel
6a75a73300
[wgpu-core] Return submission index for map_async and on_submitted_work_done to track down completion of async callbacks (#6360) 2024-11-04 14:21:09 +00:00
Erich Gubler
08c9d8c397 chore: bump WGPU workspace crates to 23 2024-10-30 07:14:10 -07:00
teoxoy
f669024eeb [WeakVec] scan all weak references only before a reallocation would happen 2024-10-18 17:24:52 +02:00
teoxoy
8ba5c82831 minimize moves by introducing WeakVec 2024-10-18 17:24:52 +02:00
cybersoulK
a8214b67f6
Fix missing binding in wgpu-core/src/instance.rs when profiling has a backend enabled (#6422) 2024-10-18 00:15:25 +00:00
teoxoy
94e040bc8a avoid creating the bind group for indirect validation if buffer size is 0 2024-10-17 18:41:24 +02:00
teoxoy
bbee35b145 [d3d12] get num_workgroups builtin working for indirect dispatches 2024-10-14 15:22:18 +02:00
Teodor Tanasoaia
7f708edd1f
Ensure safety of indirect dispatch (#5714)
by injecting a compute shader that validates the content of the indirect buffer
2024-10-14 15:02:01 +02:00
teoxoy
c0e39721a2 remove Hub.clear() 2024-10-14 13:24:44 +02:00
teoxoy
3eb9c781cf impl Drop for Surface 2024-10-14 13:24:44 +02:00
teoxoy
b7d465a2b4 move surface methods on the Surface 2024-10-14 13:24:44 +02:00
teoxoy
26624c04e0 add SurfaceError::TextureDestroyed 2024-10-14 13:24:44 +02:00
teoxoy
39629d0de0 Improve the ownership story of textures returned by get_current_texture
`present` and `discard` will no longer automatically remove the texture from the registry.
2024-10-14 13:24:44 +02:00
teoxoy
e86330977b remove parent_id field of TextureInner::Surface
The `parent_id` will always match `surface_id` because we got the texture from the `acquired_texture` field.
2024-10-14 13:24:44 +02:00
teoxoy
c38ed8d9fa move surface creation methods on the Instance 2024-10-14 13:24:44 +02:00
teoxoy
de97e5449c move enumerate_adapters on the Instance 2024-10-14 13:24:44 +02:00
teoxoy
952ba3e12c move queue methods on the Queue type 2024-10-14 13:24:44 +02:00
teoxoy
c65c4626f1 make Fallible<T> public 2024-10-14 13:24:44 +02:00
teoxoy
4d55c6917e make remaining Adapter methods public 2024-10-14 13:24:44 +02:00
teoxoy
d1c95d2bfd add adapter getters 2024-10-14 13:24:44 +02:00
teoxoy
321bd64ba2 add Adapter::backend() 2024-10-14 13:24:44 +02:00
teoxoy
5627a0b6d9 move request_adapter on the Instance 2024-10-14 13:24:44 +02:00
teoxoy
40206ce4d7 add new Instance::as_hal fn 2024-10-14 13:24:44 +02:00
Erich Gubler
91447aefc9 refactor: s/once_cell::sync::OnceCell/std::sync::OnceLock
Weaken our dependence on the `once_cell` crate by using functionality
from `std` instead that was upstreamed from `once_cell`.

It's not yet possible to eliminate this dependency entirely, but do what
we can for now.
2024-10-11 15:52:21 -07:00
teoxoy
71b4f361e2 chore(core): more detail on TODO for push constants 2024-10-02 04:41:34 -04:00
teoxoy
38a13b94f0 refactor: make Snatchable::snatch take _guard by &mut _ 2024-10-02 04:41:34 -04:00
teoxoy
7ac533a312 add missing indirect buffer offset validation 2024-10-02 04:41:34 -04:00