308 Commits

Author SHA1 Message Date
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
Connor Fitzgerald
79e5169255 Add BGL Deduplication Index Test (#4914) 2023-12-21 12:16:20 -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
Teodor Tanasoaia
0cbabcf229 Update multi-planar texture API (#4837) 2023-12-07 14:06:56 -05:00
Valaphee The Meerkat
a1fafe394f Remove DX11 backend (#4828) 2023-12-06 15:12:46 -05:00
Almar Klein
32c5a22293 Add feature float32-filterable (#4759) 2023-12-04 14:23:13 +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
Xiaopeng Li
a6503e59c9 Support nv12 texture format (#4573)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-11-28 16:11:26 +00:00
Jacob Hughes
f9711831d2 Rename gpu.rs to root.rs 2023-11-28 10:46:28 -05:00
Jacob Hughes
00a8a9f89f Delete root.rs so git recognizes rename in following commit 2023-11-28 10:46:28 -05: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
Connor Fitzgerald
4f24c31765 Fixes for Skybox and All Examples (#4780) 2023-11-27 11:40:37 +01:00
Connor Fitzgerald
7a37229630 Revamp Examples to Match Website (#4765)
* Revamp examples to match website

* Small fixes

* Fix stencil_triangles on resize

* Fix

* Fix everything
2023-11-25 17:20:11 -05:00
Connor Fitzgerald
06e9876adf Move to A Single Example Executable (#4756)
* Move to combined examples

* Fix paths

* Curtail some tests

* Format

* Clippy

* Fix wasm

* Refactor main for wasm

* Style sheet

* Readme

* Lock
2023-11-23 05:26:42 -05:00
Connor Fitzgerald
3c261f3652 Allow Tests to Expect Certain Panic or Validation Messages (#4748) 2023-11-23 03:49:01 -05: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
Connor Fitzgerald
30d67a329a Skip Flaky Test (#4746) 2023-11-21 23:26:37 -05: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
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
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
049cb75976 [wgpu-test] Fix typo in error message. 2023-11-13 14:23:32 -08:00
Andreas Reich
f7420511d0 rename/deprecate block_size -> block_copy_size, improve docs (#4647)
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2023-11-13 19:04:35 +00:00
Nicolas Silva
1dc5347b14 Better handle destroying textures and buffers (#4657)
* Better handle destroying textures and buffers

Before this commit, explicitly destroying a texture or a buffer (without dropping it)
schedules the asynchronous destruction of its raw resources but does not actually mark
it as destroyed. This can cause some incorrect behavior, for example mapping a buffer
after destroying it does not cause a validation error (and later panics due to the
map callback being dropped without being called).

This Commit adds `Storage::take_and_mark_destroyed` for use in `destroy` methods.
Since it puts the resource in the error state, other methods properly catch that
the resource is no longer usable when attempting to access it and raise validation
errors.

There are other resource types that require similar treatment and will be addressed
in followup work.

* Add a changelog entry
2023-11-09 15:48:06 +01:00
Brad Werth
4e65eca1e8 More complete implementation of "lose the device". (#4645)
* More complete implementation of "lose the device".

This provides a way for wgpu-core to specify a callback on "lose the
device". It ensures this callback is called at the appropriate times:
either after device.destroy has empty queues, or on demand from
device.lose.

A test has been added to device.rs.

* Updated CHANGELOG.md.

* Fix conversion to *const c_char.

* Use an allow lint to permit trivial_casts.

* rustfmt changes.
2023-11-08 22:22:18 +01:00
Connor Fitzgerald
7f72c9fc3b Fix GL Push Constant Layout (#4607)
* It verks!

* More tests

* Fixes

* Working multi-stage push constants

* Comments

* Add push constant partial update teste

* Docs

* Update Cargo.toml

* Comments
2023-11-06 07:58:26 -05:00
Connor Fitzgerald
2aa7c29068 Extra Profiling Scopes (#4610) 2023-10-30 03:58:32 +00:00
Connor Fitzgerald
2a9fdf9aa1 Misc Repo Cleanup Tasks (#4579)
* Misc Repo Cleanup Tasks

* Dependency Trimming

* Dep cleanup

* Restrict libfuzzer

* Flip cfg

* mod fuzz
2023-10-27 00:15:51 -04:00
Connor Fitzgerald
ca7ac86ccd DXC on DX12 in CI (#4571) 2023-10-26 04:01:38 -04:00
Connor Fitzgerald
04ac5f2851 Update WARP and Install Mesa on Windows CI (#4270) 2023-10-22 00:34:00 -04:00
Connor Fitzgerald
543f921639 GPU Test Framework (#3873) 2023-10-19 12:06:42 -04:00
Zoxc
2b985e2fad Add WGL context creation and OpenGL support (#4248)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-10-18 18:40:33 +00:00
Nicolas Silva
ff306d20e0 Add support for bgra8unorm-storage (#4228)
* Add `BGRA8UNORM_STORAGE` extension

* Leave a comment in the backends that don't support bgra8unorm-storage

* Pass the appropriate storage format to naga

* Check for bgra8unorm storage support in the vulkan backend

* Add a test

Co-authored-by: Jinlei Li <jinleili0@outlook.com>
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2023-10-13 10:07:11 +00:00
Nicolas Silva
f95d1c55e3 Expose Instance flags (#4230)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-10-11 17:39:04 +00:00
Brad Werth
e6097ce3d4 Make buffer_map and buffer_unmap check for device validity, add tests. (#4212)
* Make buffer_unmap check for device validity, add tests.

This patch makes buffer_unmap check for a valid device, and corrects
buffer_map to return the appropriate error for an invalid device.
Tests are added for both operations.

It also adds device validity checks to device_maintain_ids and to the
functions that get and set buffer sub data.

* Update changelog and test comment.

* Run rustfmt.

* Update test device_lose_then_more to specify more buffer usages to keep Vulkan happy.
2023-10-07 16:28:07 +02:00
Nicolas Silva
198e1dfadc Validate that resources belong to the right device. (#4207) 2023-10-04 14:39:03 -04:00
Teodor Tanasoaia
422c636877 Add Rgb10a2Uint format (#4199) 2023-10-03 14:56:21 +02:00
Brad Werth
57f8757fad Add device destroy method (#4163)
Plus tests that ensure that an invalid device behaves correctly.
Mostly a stub implementation otherwise.
2023-09-27 14:34:23 +02:00
Jim Blandy
3666f1aef8 Add test case for #4167, marked as an expected failure. (#4168) 2023-09-25 19:55:55 -04:00
Andreas Reich
507101987b Make StoreOp an enum instead of a bool (#4147)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-09-18 14:58:41 -04:00
Jim Blandy
f2bd557186 Tests for wgpu#4139. (#4148) 2023-09-17 14:08:42 -04:00
Kevin Reid
7c575a0b40 Add details to RequestDeviceError. (#4145) 2023-09-16 00:16:49 -04:00
Connor Fitzgerald
b488e03d9f Workaround NV bug (#4132) 2023-09-14 16:38:21 -04:00
Jim Blandy
54a7f0eac9 Skip test_multithreaded_compute on MoltenVK. (#4096)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-09-04 03:54:39 +00:00
Kevin Reid
332cd0325d Add details to InstanceError and CreateSurfaceError. (#4066)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-09-01 01:48:31 -04:00
Brad Werth
5c2c840159 Prevent Metal from crashing when a still-open encoder is deallocated, resolve issue #2077. (#4023) 2023-08-28 18:23:35 -07:00
Nicolas Silva
399637e2b8 Bind group layout dedup (#3925)
* Remove generic parameter in compat::Manager.

The code is specific to bind group layout ids and the generic parameter gets in the way.

* Add a test.

The test actually covers wgpu's configuration where deduplication does not require the indirection rather than the new code. I used it to debug the new code with the configuration hard-coded. It's tedious to add a test to cover dedpuplication of bind group layouts for users of wgpu_core to provide their IDs, we can rely on the CTS which has test for that.

* Implement bind group layout deduplication for all configurations

Currently wgpu-core implement bind group layout deduplication only when it creates its own resource IDs. In other words it works for wgpu but not in Firefox.
This PR bridges the gap by allowing an optional indirection in bind group layouts: each BGL may store an ID referring to its "deduplicated" BGL.
When referring to a BGL the rest of the code must make sure to follow the indirection. The exception is command buffer processing which is considered hot code and where we first validate against the provided BGL ID and only follow the indirection if the initial check failed.

The main pain point with this approach is the various places where wgpu-core manually updates reference counts: we have to be careful about following the indirection to track the right BGL.

* Avoid making decisions based on the size of some generic type.
2023-08-25 21:48:22 +02:00
Pieter-Jan Briers
e973a06268 Allow specifying minor GLES3 version (#3998) 2023-08-16 11:51:56 -04:00
Connor Fitzgerald
f825ce4ac2 Fix Callback Ordering (#4036)
* Fix Callback Ordering

* Format & Changelog
2023-08-14 08:33:50 -04:00