Commit Graph
382 Commits
Author SHA1 Message Date
Erich Gubler 6e528aaf24 style: split (most) string literals over 100-column line width limit 2024-10-03 10:57:28 -04:00
Hamir Mahal 8e787eb70a style: simplify string formatting for readability (#6316) 2024-09-24 23:40:53 -04:00
Vecvec dfc384a7fd Stop Vulkan generating validation error in build acceleration structures (#6282) 2024-09-18 23:02:25 +02:00
Dzmitry Malyshau eb18854b46 spv-out: configure source language in debug info 2024-09-13 11:37:23 -07:00
Daniel McNab c2e0ad293f Vulkan: Avoid undefined behaviour with adversarial debug label (#6257) 2024-09-12 15:03:04 +02:00
Mads Marquart fb0cb1eb11 [metal] Improve layer initialization and resizing (#6107)
* [metal]: Create a new layer instead of overwriting the existing one

Overriding the `layer` on `NSView` makes the view "layer-hosting", see
[wantsLayer], which disables drawing functionality on the view like
`drawRect:`/`updateLayer`.

This prevents crates like Winit from providing a robust rendering
callback that integrates well with the rest of the system.

Instead, if the layer is not CAMetalLayer, we create a new sublayer, and
render to that instead.

[wantsLayer]: https://developer.apple.com/documentation/appkit/nsview/1483695-wantslayer?language=objc

* [metal]: Fix double-free when re-using layer

* doc: Document the behavior when mis-configuring width/height of Surface

* [metal]: Use kCAGravityResize for smoother resizing

* [metal] Do not keep the view around that the surface was created from

We do not need to use it, and the layer itself is already retained, so
it won't be de-allocated from under our feet.

* Always set delegate on layers created by Wgpu

* More docs on contentsGravity
2024-09-08 16:28:14 +02:00
Erich Gubler 0e352f5b34 Resolve lints for Rust 1.78-1.81 that can be preempted before upgrade (#6225)
* chore: remove `Context` methods detected as dead code

This is detected by `rustc` as of Rust 1.79.0.

* refactor: satisfy `clippy::manual_inspect`

Detected as of Rust 1.81.0.

* refactor: satisfy `clippy::needless_borrows_for_generic_args`

Detected as of Rust 1.81.0.

* refactor: suppress false-positive `dead_code` lint for `SubmissionIndex`

* chore: eliminate `dead_code` when `target_os = "emscripten"`
2024-09-06 11:55:22 +02:00
Valaphee The Meerkat 07684d3623 Rename Rg11b10UFloat to Rg11b10Ufloat (#6226) 2024-09-06 11:46:49 +02: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 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 29e288f81c move hal_usage_error from the vk backend to lib.rs 2024-09-03 17:15:19 +02:00
Marijn Suijten 690a3fb3fb [wgpu-hal] Upgrade glutin to 0.31 (#6150)
* [wgpu-hal] Upgrade `glutin` to `0.31`

`glutin 0.30` onwards completely refactored its internals to no longer
be reliant on `winit`, as they (by default) have no direct relation
except needing to perform _some_ operations (platform-specific) at
strategic times in window creation and event loop handling.  Most of
that is handled by a new `glutin-winit` introp crate, while the core
`glutin` crate now exclusively focuses on wrapping the various OpenGL
context APIs (CGL, EGL, WGL, ...).

This does result in a little more verbose handling to get the right
`GLDisplay`, `GLConfig`, `GLContext` and `GLSurface`, but gives much
more control and makes all intricacies more explicit.  Most of the
code was copied from `glutin 0.31`'s example crate, with the code for
transparency support removed.

Note that the example doesn't at all handle event loop events properly:
resizes and redraws are not listened to, and mobile-specific surface
events (`Resumed` and `Suspended`) are equally ignored.

* [wgpu-hal] Implement proper `Surface` availability semantics in `raw-gles` example
2024-08-27 13:05:47 -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
Daniel McNabandMarijn Suijten 685c2133f2 hal: cargo feature to allow using VK_GOOGLE_display_timing unsafely (#6149)
* Expose the raw swapchain from a vulkan `Surface`

* Allow setting the present timing information on hal Vulkan

* Fix clippy without the feature enabled

* CHANGELOG

* Revert inadvertently formatted Cargo.toml

* Move display timing to a feature

* Update the changelog

* Whitespace and doc wording tweaks

* Apply suggestions from code review

Co-authored-by: Marijn Suijten <marijns95@gmail.com>

* Revert inadvertent formatting changes again

* Remove unused qualification

Co-authored-by: Marijn Suijten <marijns95@gmail.com>

* Address review feedback

* Fix flow of sentence and follow intra-doc-link

* Add more docs to `set_next_present_time`, and rename

* Also rename `next_present_times`

* Apply suggestions from code review

Co-authored-by: Marijn Suijten <marijns95@gmail.com>

---------

Co-authored-by: Marijn Suijten <marijns95@gmail.com>
2024-08-27 11:25:04 -04:00
Erich Gubler fac49ee97c chore: work around unused_qualifications from new prelude items in Rust 1.80
`std::mem::{size,align}_of{,_val}` was added to `std::prelude` in Rust
1.80; see
[`rust`#123168](https://github.com/rust-lang/rust/pull/123168/).
However, we don't have an MSRV at 1.80 or higher yet. So, let's work
around it by importing these items fully. Since neither `clippy` nor
`rustc` lint against shadowed `prelude` items yet (see also a [proposed
`clippy` lint] for such), that lets us remove the explicit `std::mem::*`
imports later at our leisure.

[proposed `clippy` lint]: https://github.com/rust-lang/rust-clippy/issues/8439
2024-08-23 16:20:34 -04:00
Kornel 222f1ea733 Reduce code size of error handling 2024-08-19 14:38:20 +01:00
Erich Gubler 23e7846400 refactor(hal): satisfy trivial_casts 2024-08-15 14:14:13 +01:00
Erich Gubler 89a64e911d refactor(hal): remove unneeded trivial_casts suppr. 2024-08-15 14:14:13 +01:00
teoxoy 2c31414517 add an Unexpected variant to DeviceError 2024-08-15 13:56:05 +01:00
teoxoy 24134e049f handle all vulkan error variants for each function explicitly 2024-08-15 13:56:05 +01:00
teoxoy e4c5b4760b introduce a new function that handles unexpected vulkan errors that can't be mapped to DeviceError::Lost 2024-08-15 13:56:05 +01:00
teoxoy 8b6450a9ce handle all variants of gpu_descriptor::AllocationError explicitly 2024-08-15 13:56:05 +01:00
teoxoy 7103520bd3 introduce a new function for hal usage errors 2024-08-15 13:56:05 +01:00
teoxoy a0c107f7c8 remove handling of error that is not documented to be returned by vkAllocateMemory 2024-08-15 13:56:05 +01: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 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 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 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 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 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
Samson c6a3d92734 Rg11b10Float -> Rg11b10UFloat and deduplicate entries in TEXTURE_FORMAT_LIST (#6108)
* Resync `TEXTURE_FORMAT_LIST` to match `TextureFormat`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* `Rg11b10Float` -> `Rg11b10UFloat`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Add changelog entry

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2024-08-13 08:28:55 +00:00
Teodor Tanasoaia 94f54b3dc8 Add a separate pipeline constants error (#6094) 2024-08-12 09:20:36 +02:00