Commit Graph
227 Commits
Author SHA1 Message Date
teoxoy d489e4c2e8 remove hal::Device::exit, add Drop implementations to Device and Queue instead 2024-11-14 06:27:37 -08:00
Jerzy Wilczek 4e47ba4ac0 [wgpu-hal] Change the DropCallback API to use FnOnce instead of FnMut (#6482) 2024-10-31 11:28:41 -04:00
Nicolas Silva 81963e24ca Fix the internal buffer and texture count (#6223)
Currently, we only increment the internal buffer/texture counters when creating them in the regular way (not when creating them from externally built hal objects (create_texture_from_hal/create_buffer_from_hal). However we decrement the counter in all cases, which makes the counters incorrect when these externally created resources are involved.

This commit fixes it by adding hooks (add_raw_buffer and add_raw_texture) in the hal device abstractions to inform when buffer or textures are created externally.
2024-09-05 18:53:01 +00:00
Jim Blandy 9ff161d5e0 [hal] Document some CommandEncoder trait methods.
Add documentation for the following `CommandEncoder` trait methods:
- `set_bind_group`
- `begin_render_pass`
- `begin_compute_pass`
- `end_render_pass`
- `end_compute_pass`
2024-09-04 16:31:33 -07:00
Jim Blandy ee35b0e586 [core, hal, types] Clarify wgpu_hal's bounds check promises.
In `wgpu_hal`:

- Document that `wgpu_hal` guarantees that shaders will not access buffer
  contents beyond the bindgroups' bound regions, rounded up to some
  adapter-specific alignment. Introduce the term "accessible region" for
  the portion of the buffer that shaders can actually get at.

- Document that all bets are off if you disable bounds checks with
  `ShaderModuleDescriptor::runtime_checks`.

- Provide this alignment in `wgpu_hal::Alignments`. Update all backends
  appropriately.

- In the Vulkan backend, use Naga to inject bounds checks on buffer accesses
  unless `robustBufferAccess2` is available; `robustBufferAccess` is not
  sufficient. Retrieve `VK_EXT_robustness2`'s properties, as needed to discover
  the alignment above.

In `wgpu_core`:

- Use buffer bindings' accessible regions to determine which parts of the buffer
  need to be initialized.

In `wgpu_types`:

- Document some of the possible effects of using
  `ShaderBoundsChecks::unchecked`.

Fixes #1813.
2024-09-03 12:33:02 -04:00
teoxoy dd01b6d209 [d3d12] make DxgiLib and D3D12Lib methods consistent 2024-09-03 17:15:19 +02:00
teoxoy 29e288f81c move hal_usage_error from the vk backend to lib.rs 2024-09-03 17:15:19 +02:00
Erich Gubler e323817425 chore: satisfy unused_qualifications _again_ 😩 2024-09-03 10:18:25 -04:00
Jerzy Wilczek a9047c2af5 Change the DropGuard public API to a callback-based one. (#6164)
This patch also unifies the behavior of the the `DropGuard`-ish
constructs in the Vulkan-based implementation.
2024-08-27 16:44:34 +00:00
teoxoy 2c31414517 add an Unexpected variant to DeviceError 2024-08-15 13:56:05 +01:00
Fionn Langhans 273c2c4b1a Fixed spelling mistake in URL of d3d12 2024-08-14 23:16:58 +02:00
Andreas Reich 5b9198fd43 introduce DynInstance 2024-08-14 17:34:11 +02:00
Andreas Reich 6f01cbff06 introduce DynAdapter 2024-08-14 17:34:11 +02:00
Andreas Reich 99ffc129eb remove unnecessary debug constraints from Api (handled by Dyn traits) 2024-08-14 17:34:11 +02:00
Andreas Reich 9e1f1487b4 DynDevice acceleration structure handling 2024-08-14 17:34:11 +02:00
Andreas Reich 3932f8b854 DynDevice create/destroy compute/render pipeline 2024-08-14 17:34:11 +02:00
Andreas Reich 276753f963 DynDevice create/destroy bind group
bindgroup fixup
2024-08-14 17:34:11 +02:00
Andreas Reich 33f57e2305 DynDevice create/destroy pipeline layout 2024-08-14 17:34:11 +02:00
Andreas Reich 1da319f804 DynDevice create/destroy bind group layout 2024-08-14 17:34:11 +02:00
Andreas Reich 05a09338cd DynDevice create/destroy command encoder 2024-08-14 17:34:11 +02:00
Andreas Reich ea0df25d5e DynDevice create/destroy for texture/textureview/sampler 2024-08-14 17:34:11 +02:00
Andreas Reich 72f30a34f5 introduce DynQueue 2024-08-14 17:34:11 +02:00
Andreas Reich 4e5721350f introduce DynSurface 2024-08-14 17:34:11 +02:00
Andreas Reich 70f7641193 impl DynSurfaceTexture for all surface textures 2024-08-14 17:34:11 +02:00
Andreas Reich 1d19a205a5 impl DynFence for all fences 2024-08-14 17:34:11 +02:00
Andreas Reich 3faed2bf52 Device now has to implement DynResource 2024-08-14 17:34:11 +02:00
Andreas Reich df5cc12935 impl DynCommandBuffer 2024-08-14 17:34:11 +02:00
Andreas Reich a9cb7fc855 impl DynShaderModule for all backends 2024-08-14 17:34:11 +02:00
Andreas Reich b4c6741970 add most remaining dyn type traits 2024-08-14 17:34:11 +02:00
Andreas Reich add54f19d8 Introduce DynDevice 2024-08-14 17:34:11 +02:00
Andreas Reich b7e11c76df texture & buffer transitioning always uses DynCommandEncoder now
collateral: ComputePass uses DynCommandEncoder during recording
2024-08-14 17:34:11 +02:00
Andreas Reich 39b408218f implement transition_textures for DynCommandEncoder 2024-08-14 17:34:11 +02:00
Andreas Reich a47a0cb3d9 render/compute pass descriptors work now with dyn types 2024-08-14 17:34:11 +02:00
Andreas Reich bdf6710d58 introduce DynTexture & DynTextureView 2024-08-14 17:34:11 +02:00
Andreas Reich bea9a10f90 fold ComputePassTimestampWrites & RenderPassTimestampWrites and make PassTimestampWrites usable with DynQuerySet 2024-08-14 17:34:11 +02:00
Andreas Reich fc764b4b17 Introduce DynComputePipeline & DynRenderPipeline 2024-08-14 17:34:11 +02:00
Andreas Reich 50a1811229 Introduce DynPipelineLayout & DynBindGroup 2024-08-14 17:34:11 +02:00
Andreas Reich f8871e6ed1 introduce DynQuerySet, associated DynCommandEncoder methods 2024-08-14 17:34:11 +02:00
Andreas Reich 256ec6e447 Introduce DynCommandEncoder, implement index & vertex buffer ops on it 2024-08-14 17:34:11 +02:00
Andreas Reich a4d9d38d03 BufferBarrier no longer depend on hal api struct, but directly on buffer type 2024-08-14 17:34:11 +02:00
Andreas Reich cda9d9af65 Buffer bindings no longer depend on hal api struct, but directly on buffer type 2024-08-14 17:34:11 +02:00
Andreas Reich d2508d9ad6 introduce DynResource & DynBuffer as first user 2024-08-14 17:34:11 +02:00
Teodor Tanasoaia 94f54b3dc8 Add a separate pipeline constants error (#6094) 2024-08-12 09:20:36 +02:00
teoxoy 1cb7ebab99 [wgpu-hal] replace Instance.destroy_surface() with Drop impls on Surfaces
Only the metal and vulkan backends require
destruction code and it can go in a `Drop` impl since
the `Instance` is unused in those implementations.
2024-07-29 17:31:24 +02:00
Erich Gubler 723995d9a9 refactor: warn on and satisfy clippy::{ptr_as_ptr,ref_as_ptr} in wgpu-{core,hal,types}
…using `cargo +1.79.0 clippy --workspace --all-features --all-targets
--fix`, plus some manual changes to (1) catch some missed cases (not run
on all platforms?) and (2) `--fix` doesn't make things compile again. 😀
2024-07-24 12:09:15 -04:00
Bruce Mitchener 06649a39f3 Fix a clippy::doc_lazy_continuation lint (#6036) 2024-07-24 18:08:21 +02:00
Bruce Mitchener 4f02057359 Convert some module doc comments
Some module doc comments were using `/*! ... */` syntax and had
leading ` *` prefixes on each line. This interferes with the
tracking of `clippy::doc_lazy_continuation`, so switch those over
to `//!` style comment blocks.

This leaves `/*! ... */` blocks alone which didn't prefix each
line.
2024-07-24 11:17:00 -04:00
Bruce Mitchener cf5798291f Remove allow(unknown_lints) and clippy::if_then_panic (#6000) 2024-07-20 03:35:19 +00:00
Brad Werth 6cd387412f Remove vertex_pulling_transfrom from PipelineCompilationOptions.
This option was only evaluated for Metal backends, and now it's required
there so the option is going away. It is still configurable for tests
via the PipelineOptions struct, deserialized from .ron files.

This also fixes some type problems with the unpack functions in
writer.rs. Metal << operator extends operand to int-sized, which then
has to be cast back down to the real size before as_type bit conversion.
The math for the snorm values is corrected, in some cases using the
metal unpack_snorm2x16_to_float function because we can't directly
cast a bit-shifted ushort value to half.
2024-07-19 17:13:45 +02:00
Nicolas Silva bc7622f641 Expose GPU allocation reports in wgpu, wgpu-core and wgpu-hal 2024-07-19 10:16:29 +02:00