Commit Graph

1104 Commits

Author SHA1 Message Date
Erich Gubler
08c9d8c397 chore: bump WGPU workspace crates to 23 2024-10-30 07:14:10 -07:00
Xiaopeng Li
8b99c3c4f5
Vulkan: create texture from d3d11 shared handle (#6161) 2024-10-30 03:48:06 +00:00
teoxoy
9c781d64d6 [metal] use restrict bounds check policy by default 2024-10-23 16:51:44 +02:00
teoxoy
207747cab5 [hlsl-out] add support for restricting indexing to avoid OOB accesses 2024-10-23 16:51:44 +02:00
teoxoy
daaf7da09a print source in log 2024-10-23 16:51:44 +02:00
Nathan Adams
759c3262ad
Optimise GL fence checking by querying less (#6427) 2024-10-20 20:02:10 -04:00
Erich Gubler
fe7fbd4a4a refactor(dx12): merge PipelineLayoutShared::special_constants_{root_index,cmd_signatures} into new struct 2024-10-14 15:22:18 +02:00
teoxoy
bbee35b145 [d3d12] get num_workgroups builtin working for indirect dispatches 2024-10-14 15:22:18 +02:00
Erich Gubler
d22aa2eb55 chore: format TOML files with taplo 0.9.3 2024-10-11 14:40:01 -04:00
Imbris
c5a4b4ecc3
Fix unaligned slice::from_raw_parts in gles push contant handling. (#6341) 2024-10-03 20:40:43 +00:00
Erich Gubler
6e528aaf24 style: split (most) string literals over 100-column line width limit 2024-10-03 10:57:28 -04:00
Dzmitry Malyshau
7074380945
metal: fix query set result copies (#6322)
The NSRange expects length, not end element. See 9bbe74b1d3/src/lib.rs (L51)
2024-09-25 09:22:38 +02: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
Teodor Tanasoaia
ff52b86331
[d3d12] handle absence of Windows SDK (#6262) 2024-09-13 15:56:26 +02:00
Daniel McNab
c2e0ad293f
Vulkan: Avoid undefined behaviour with adversarial debug label (#6257) 2024-09-12 15:03:04 +02:00
Teodor Tanasoaia
055372902d
[d3d12] handle known error variants returned by D3D12CreateDevice (#6241) 2024-09-09 09:01:24 -04: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
Brad Werth
9b36a3e129
Make bind group an Option for set_bind_group calls. (#6216)
This is just an API change for all the "set_bind_group" calls. Calls
that pass a Some() argument should have unchanged behavior. The None
cases are left as TODOs.
2024-09-06 14:29:09 -07: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
e6a2a86f2c
Fix a regression from #6223 (#6227)
buffer and texture got swapped in one of theses few places where the type system couldn't catch my mistake.
2024-09-06 09:39:09 +00: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
Marijn Suijten
960555a426
[wgpu-hal] Allow importing external WGL contexts as with EGL (#6152) 2024-09-04 15:11:47 +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
595ae7cb47 [wgpu-hal] add null terminations to symbols to avoid reallocation 2024-09-03 17:15:19 +02:00
teoxoy
9d24888848 [d3d12] use windows-rs's bindings for DXC instead of hassle-rs 2024-09-03 17:15:19 +02:00
teoxoy
912bdcd336 [d3d12] simplify enumerate_adapters() fn
Also fixes an issue where only high performance adapters would be enumerated if DXGI 1.6 is available.
2024-09-03 17:15:19 +02:00
teoxoy
6c2f23c6a2 [d3d12] simplify create_factory() fn 2024-09-03 17:15:19 +02: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
teoxoy
e25051ec8f [d3d12] treat failure to populate references to resources as DeviceError::Unexpected
These are guaranteed to be populated if the creation methods didn't error. If they are not, the driver/runtime is at fault.
2024-09-03 17:15:19 +02:00
teoxoy
43f6279605 [d3d12] refactor buffer/texture creation functions to return resources instead of using out params 2024-09-03 17:15:19 +02:00
Erich Gubler
85346dfd20 chore: use std::mem::size_of{,_val} s'more
As before, this is to minimize diffs. with Rust 1.80.
2024-09-03 10:18:25 -04:00
Erich Gubler
e1c0aed520 chore(dx12): satisfy clippy::manual_bits 2024-09-03 10:18:25 -04:00
Erich Gubler
e323817425 chore: satisfy unused_qualifications _again_ 😩 2024-09-03 10:18:25 -04:00
Marijn Suijten
4454cbfaab
[wgpu-hal] #5956 windows-rs migration followups and cleanups (#6173)
PR #5956 wasn't fully complete and still had some outstanding minor
issues and cleanups to be done, as well as hidden semantic changes.
This addresses a bunch of them:

- Remove unnecessary `Error` mapping to `String` as `windows-rs`'s
  `Error` has a more complete `Display` representation by itself.
- Remove `into_result()` as every call could have formatted the
  `windows-rs` `Error` in a log call directly.
- Pass `None` instead of a pointer to an empty slice wherever possible
  (waiting for https://github.com/microsoft/win32metadata/pull/1971 to
  trickle down into `windows-rs`).
- Remove `.clone()` on COM objects (temporarily increasing the refcount)
  when it can be avoided by inverting the order of operations on `raw`
  variables.
2024-08-30 11:02:38 +02:00
Marijn Suijten
71b41c6638 [wgpu-hal] Make raw-gles runnable on X11 and Wayland platforms again
PR #6150 suffered a much larger rebase "hell" than I anticipated.  On
my Linux box I made this change, but lost it while force-pushing from
Windows (and created some other compiler errors while at it...).

By disabling all features on `glutin`/`glutin-winit` (the latter only
uses `x11`, and only forwards `wayland` to `glutin`) we may have dropped
a lot of "unused" dependencies for other GL backends, but also made the
crate unable to import X11 (Xlib/Xcb) and Wayland handles into EGL.

Also import the missing `glutin::context::Version` struct again which
was added last-minute to #6150 (to make sure my Intel card on Windows
creates a GLES 3.0+ instead of GLES 2.0 context) while the import was
accidentally squashed into #6152 (not merged yet).
2024-08-28 09:55:07 +02:00
Jan Procházka
5deaef3b67
Add VideoFrame to ExternalImageSource enum (#6170) 2024-08-27 18:05:45 +00: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
Imbris
fccd2981d0
Ensure glow::Context is current when dropped (#6114)
Cleanup code in glow needs the context to be current (mainly for debug
message callbacks).

See https://docs.rs/glow/0.14.0/glow/trait.HasContext.html#safety
2024-08-27 12:15:41 -04:00
Daniel McNab
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
Valaphee The Meerkat
b4db97f97b
Add HTMLImageElement/ImageData as external source for copying images (#5668)
* Add `HTMLImageElement` as external source for copying images

* Typo
2024-08-20 12:54:24 -04:00
Marijn Suijten
a157c3cf4b
[wgpu-hal] Migrate d3d12 backend over to windows-rs (#5956)
* windows-rs 0.58

* Clean up suspicious committed allocation workaround

* dx12: Flatten suballocation module
2024-08-20 11:48:37 -04:00
Kornel
222f1ea733 Reduce code size of error handling 2024-08-19 14:38:20 +01:00
Erich Gubler
abc56417bb
refactor(web): satisfy unused_qualifications (#6121) 2024-08-15 16:56:12 +00:00