Commit Graph

633 Commits

Author SHA1 Message Date
Ben Reeves
2fac5e983e
Properly handle the case where Navigator.gpu is undefined and WebGPU is the only compiled backend (#6197)
* Properly handle the case where `Navigator.gpu` is undefined and WebGPU is the only compiled backend.

Previously, `Instance::request_adapter` would invoke a wasm binding with an undefined arg0,
thus crashing the program. Now it will cleanly return `None` instead.

Fixes #6196.

* Fix typo in `Instance::new` doc comment.
* Add note to CHANGELOG.md
* Introduce `DefinedNonNullJsValue` type.
* Assert definedness of self.gpu in surface_get_capabilities.
* Use DefinedNonNullJsValue in signature of get_browser_gpu_property().
* Clarify meaning of gpu field with a comment.
2024-09-15 08:07:40 +00:00
Johann Muszynski
d79ebc4db3
Update some docs containing OpenGL or GLSL references (#6271) 2024-09-15 07:07:39 +00: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
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
Valaphee The Meerkat
07684d3623
Rename Rg11b10UFloat to Rg11b10Ufloat (#6226) 2024-09-06 11:46:49 +02: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
Erich Gubler
04618b36a8
feat(wgsl): add first and either sampling for @interpolate(flat, …) (#6181) 2024-08-30 15:08:00 +00: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
Erich Gubler
7164f3eb4e fix(wgsl): narrow accepted args. of cross to vec3<$float> 2024-08-28 13:26:54 -04: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
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
Teodor Tanasoaia
338678ad5f
Remove IDs from wgpu traits (#6134)
Remove `wgpu`'s `.global_id()` getters.

Implement `PartialEq`, `Eq`, `Hash`, `PartialOrd` and `Ord` for wgpu resources.
2024-08-27 10:00:19 +00: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
vero
3178ffb0d7
Fix hlsl image type conversion (#6123) 2024-08-19 10:24:40 +02:00
Andreas Reich
92ecafebac changelog entry 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
James Pruitt
594476c991
Check Opengl version is 3.3+ before creating a GL context over a GL ES context (#5996)
* Retry with GLES if creating a GL context fails

* Cleaner GL context creation retry
2024-08-06 08:19:23 +00:00
Nicolas Silva
9c6ae1beae
Log spring cleaning (#6065)
Remove unused logs in wgpu-core and wgpu-hal
2024-07-31 16:24:23 +00:00
Matthew Wong
339ecf37da
Fix error message in create_render_pass (#6041) 2024-07-26 16:59:41 +00:00
Andreas Reich
d3c38a4fd0
Fix AnyDevice drop implementation dropping the wrong thing (#6052) 2024-07-26 10:31:36 +02:00
teoxoy
03f6d24ea6 deduplicate derived BGLs 2024-07-25 18:15:29 +02:00
Marijn Suijten
2611d18b15 gles/wgl: Migrate from ancient/unmaintained winapi to windows-rs 2024-07-25 11:15:26 +02:00
Samson
2897fb58db
Error instead of panic in check bind (#6012)
Removed zipping of binding entries introduced in 4a19ac279c (to make sure binding numbers actually match) and add unknown error for fallback.
2024-07-24 17:50:18 +02:00
Erich Gubler
fa93676991 docs(CHANGELOG): add entry for const. eval of first{Leading,Trailing}Bit 2024-07-24 09:12:23 -04:00
Imbris
6d7975eb3b [naga hlsl-out glsl-out] Work around backend loop/switch bugs.
Introduce a new module, `naga:🔙:continue_forward`, containing
shared code for rendering Naga `Continue` statements as backend
`break` statements and assignments to introduced `bool` locals.
See the module's documentation for details.

- [hlsl-out] Transform degenerate single body switches into `do-while`
  loops. Properly render `Continue` statements enclosed by
  `Switch` statements enclosed by `Loop` statements.

- [glsl-out] Transform degenerate single body switches into `do-while`
  loops.

Improve `naga xtask validate spv` error message.

Fixes #4485.
Fixes #4514.
2024-07-23 18:12:19 -07:00
Vladas Zakrevskis
5a0e2187f0
Print requested and supported usages on UnsupportedUsage error (#6007)
* Print requested and supported usages on UnsupportedUsage error

* fmt

* changelog
2024-07-21 21:12:28 -04:00
Andreas Reich
c0e7c1ef94 Bump core MSRV to 1.76 2024-07-20 15:55:28 -04:00
Kevin Reid
b5934e89f7 Disable wgpu-core documentation as a workaround for #4905.
This enables `cargo doc` to succeed in a reasonable amount of time,
as long as the reader isn't looking for documentation for `wgpu-core`
itself.
2024-07-19 11:37:00 -04:00
Bruce Mitchener
20973d1cdc
Fix profiling with tracy. (#5988)
The profiling APIs require a `&str`, but since the label here
is now an `Option<String>`, we must get a `&str` from it.
2024-07-19 00:56:16 -04:00
Erich Gubler
e883fa7b8b docs(CHANGELOG): add Unreleased section 2024-07-18 11:55:08 -04:00
Erich Gubler
6a1432c132 chore: release 22.0.0 2024-07-18 11:54:46 -04:00
teoxoy
911d28fd1a add a few missing changelog entries 2024-07-18 14:25:12 +02:00
Teodor Tanasoaia
69a1134e02
[wgpu] remove trace feature temporarily (#5975) 2024-07-17 18:10:49 +00:00
Erich Gubler
32acb207fa
docs(CHANGELOG): backport 0.19.5 entries (#5966) 2024-07-16 15:11:43 +00:00
Dzmitry Malyshau
1b4e8ada63 spv-out: fix acceleration structure in a function argument 2024-07-15 10:05:51 +02:00
Andreas Reich
d3edbc57a9
Compute pass benchmark (#5767)
Adds a benchmark for compute pass recording, very similar to what we have for render passes.
2024-07-14 22:13:50 +02:00
Andreas Reich
9796766e8e
Changelog cleanup round (#5936)
* Add missing changelog entry for `msl-out-if-target-apple`/`hlsl-out-if-target-windows` feature addition

* minor changelog reorganisation

* fix missing author attribution & pr link in changelog

* import patch release changelogs and remove redundant items

* move pipeline overridable constants from bugfixes to features
2024-07-11 09:27:47 +02:00
Nicolas Silva
4c6318c0d2
Expose gpu allocation configuration options (#5875)
* Expose gpu allocation configuration options

This commit adds hints to control memory allocations strategies to the configuration options. These hints allow for automatic profiles such as optimizing for performance (the default, makes sense for a game), optimizing for memory usage (typically more useful for a web browser or UI library) and specifying settings manually.

The details of gpu allocation are still in flux. The goal is to switch vulkan and metal to gpu_allocator which is currently used with d3d12. gpu_allocator will also likely receive more configuration options, in particular the ability to start with smaller memory block sizes and progressively grow the block size. So the manual settings already provision for this upcoming option. Another approach could be to wait and add the manual option after the dust settles.

The reason for providing presets and defining values in the backends is that I am convinced that optimal fonigurations should take hardware capabilities into consideration. It's a deep rabbithole, though, so that will be an exercise for later.

* changelog

* Update CHANGELOG.md

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

* Add a comment about not entirely knowing what we are doing

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-07-08 14:49:44 +02:00
teoxoy
9f34acd567 [wgpu-hal] return None in Adapter.surface_capabilities() if the Surface and the Adapter don't share the same WebGL2 context 2024-07-04 10:17:07 +02:00
teoxoy
7910fd8059 [wgpu-hal] require a Surface to be passed to Instance.enumerate_adapters() on WebGL2
Also makes wgpu's `enumerate_adapters()` native only.
2024-07-04 10:17:07 +02:00
Imbris
3a6814770a
Allow unconsumed inputs in fragment shaders (#5531)
* Allow unconsumed inputs in fragment shaders by removing them from vertex
outputs when generating HLSL.

Fixes https://github.com/gfx-rs/wgpu/issues/3748

* Add naga:🔙:hlsl::FragmentEntryPoint for providing information
  about the fragment entry point when generating vertex entry points via
  naga:🔙:hlsl::Writer::write. Vertex outputs not consumed by the
  fragment entry point are omitted in the final output struct.
* Add naga snapshot test for this new feature,
* Remove Features::SHADER_UNUSED_VERTEX_OUTPUT,
  StageError::InputNotConsumed, and associated validation logic.
* Make wgpu dx12 backend pass fragment shader info when generating
  vertex HLSL.
* Add wgpu regression test for allowing unconsumed inputs.

* Address review

* Add note that nesting structs for the inter-stage interface can't
  happen.
* Remove new TODO notes (some addressed and some transferred to an issue
  https://github.com/gfx-rs/wgpu/issues/5577)
* Changed issue that regression test refers to 3748 -> 5553
* Add debug_assert that binding.is_some() in hlsl writer
* Fix typos caught in CI

Also, fix compiling snapshot test when hlsl-out feature is not enabled.
2024-07-04 09:08:46 +02:00
Andreas Reich
0a76c0fa84
Renderpass take resource ownership (#5884)
* share timestamp write struct

* Make name of set_push_constants methods consistently plural

* remove lifetime bounds of resources passed into render pass

* first render pass resource ownership test

* introduce dynrenderpass & immediately create ArcCommands and take ownership of resources passed on pass creation

* Use of dynrenderpass in deno

* Separate active occlusion & pipeline statitics query

* resolve render/compute command is now behind `replay` feature

* add vertex & index buffer to ownership test

* test for pipeline statistics query

* add occlusion query set to pass resource test

* add tests for resource ownership of render pass query timestamps

* RenderPass can now be made 'static just like ComputePass. Add respective test

* Extend encoder_operations_fail_while_pass_alive test to also check encoder locking errors with render passes

* improve changelog entry on lifetime bounds
2024-07-01 18:36:24 +02:00
9SMTM6
a7d4d2c79f
Allow using include_wgsl! in const contexts (#5872)
* include_wgsl! Switch from into() call to construction

This allows usage in const contexts.

* Describe constification of include_wgsl! in changelog
2024-06-24 17:46:30 +00:00
Nicolas Silva
ddff69ba21
Avoid leaking submitted command encoders (#5141)
* Avoid leaking submitted command encoders

* changelog
2024-06-24 12:16:55 +00:00