Commit Graph

255 Commits

Author SHA1 Message Date
teoxoy
aa280ecd44 [wgpu-core] change return type of device creation methods to be more rusty
This is fine from the WebGPU spec's perspective as device creation returns a promise that can reject.
2024-09-10 11:58:54 +02:00
teoxoy
98426329a4 [wgpu-core] introduce Registry .strict_get() & .strict_unregister() and use them for adapters
This works because we never assign errors to adapters (they are never invalid).
2024-09-10 11:58:54 +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
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
Andreas Reich
0287eaf022 Remove gfx_select. 2024-08-14 17:34:11 +02:00
Andreas Reich
24498f04d4 The second unraveling: hub and all types on it are generic free!
gfx_select macros are empty husks now that are waiting to be removed
2024-08-14 17:34:11 +02:00
teoxoy
8c7c5c4974 decouple device and queue IDs
Devices and queues can have different lifetimes, we shouldn't assume that their IDs match.
2024-08-05 15:46:12 +02:00
teoxoy
650054bbcd [player] simplify sync buffer writing 2024-07-29 17:31:24 +02:00
teoxoy
2ea081fabf remove waiting functionality from Global.{buffer,texture,texture_view}_drop()
Those resources won't be destroyed if used by a submission anyway.
2024-07-29 17:31:24 +02:00
teoxoy
d1da4456a6 remove Global.clear_backend()
The method was only used by the player's tests which
was refactored to create a new `Global` instead.

Removing it cleans up the internals of `Hub.clear()`,
we should avoid having test only items.
2024-07-29 17:31:24 +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
teoxoy
91924fb603 [wgpu-core] make implicit_pipeline_ids arg optional for users that don't provide IDs 2024-07-17 16:57:01 +02:00
teoxoy
140495006e remove device_maintain_ids 2024-07-09 10:48:52 +02:00
teoxoy
5266bd1f08 change prepare_staging_buffer to return a non null u8 pointer 2024-07-09 10:48:52 +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
Andreas Reich
b4c7987aa7
Separate renderpass arc resolve & renderpass consume on end (#5794) 2024-06-25 09:37:29 +02:00
Brad Werth
9b7a965667 Add an experimental vertex pulling flag to Metal pipelines.
This proves a flag in msl::PipelineOptions that attempts to write all
Metal vertex entry points to use a vertex pulling technique. It does
this by:

1) Forcing the _buffer_sizes structure to be generated for all vertex
entry points. The structure has additional buffer_size members that
contain the byte sizes of the vertex buffers.
2) Adding new args to vertex entry points for the vertex id and/or
the instance id and for the bound buffers. If there is an existing
@builtin(vertex_index) or @builtin(instance_index) param, then no
duplicate arg is created.
3) Adding code at the beginning of the function for vertex entry points
to compare the vertex id or instance id against the lengths of all the
bound buffers, and force an early-exit if the bounds are violated.
4) Extracting the raw bytes from the vertex buffer(s) and unpacking
those bytes into the bound attributes with the expected types.
5) Replacing the varyings input and instead using the unpacked
attributes to fill any structs-as-args that are rebuilt in the entry
point.

A new naga test is added which exercises this flag and demonstrates the
effect of the transform. The msl generated by this test passes
validation.

Eventually this transformation will be the default, always-on behavior
for Metal pipelines, though the flag may remain so that naga
translation tests can be run with and without the tranformation.
2024-05-30 13:08:59 +02:00
Andreas Reich
2fd09945cd
Make compute pass end consume the pass (#5575)
* rename `command_encoder_run_*_pass` to `*_pass_end` and make it a method of compute/render pass instead of encoder

* executing a compute pass consumes it now such that it can't be executed again

* use handle_error instead of handle_error_nolabel for wgpu compute pass

* use handle_error instead of handle_error_nolabel for render_pass_end

* changelog addition

* feat: `compute_pass_set_push_constant`: move panics to error variants

Co-Authored-By: Erich Gubler <erichdongubler@gmail.com>

---------

Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-05-25 18:54:48 +02:00
Daniel McNab
4902e470ce
Pipeline cache API and implementation for Vulkan (#5319)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-05-16 13:52:56 +00:00
Andreas Reich
edf1a86148
Separate out ComputeCommand id->arc resolve (a step towards no lifetimes on wgpu::ComputePass) (#5432)
* move out compute command to separate module

* introduce ArcComputeCommand

* stateless tracker now returns reference to arc upon insertion

* add insert_merge_single to buffer tracker

* compute pass execution now works internally with an ArcComputeCommand

* compute pass execution now translates Command to ArcCommand ahead of time

* don't clone commands in compute pass execution

* remove doc hiding

* use option insert

* clippy fix

* fix private doc issue

* remove unnecessary copied over doc hide
2024-04-23 07:01:29 +00:00
Daniel McNab
965b00c06b
Allow configuring whether workgroup memory is zero initialised (#5508) 2024-04-17 15:50:31 -04:00
Jim Blandy
03db77cb8c
[core] Replace id transmute method with explicit functions. (#5509)
Replace the `wgpu_core:🆔:Id::transmute` method, the `transmute`
private module, and the `Transmute` sealed trait with some associated
functions with obvious names.
2024-04-08 21:51:30 -04:00
teoxoy
3bda381812 add pipeline constants plumbing 2024-04-05 18:07:41 +02:00
Erich Gubler
d365927903 test(player): don't specify shader entry points
This is done to exercise the prior change.
2024-02-27 13:57:17 -05:00
Erich Gubler
023b0e063f feat!: make ProgrammableStage::entry_point optional in wgpu-core 2024-02-27 13:57:17 -05:00
andristarr
3028972817
buffer_map_async should use offset + size (#5185) 2024-02-09 09:48:00 +01:00
John-John Tedro
950d765a4d
Remove G parameter in Global<G> and generic IdentityHandlerFactory (#5159) 2024-01-29 15:37:57 +01:00
John-John Tedro
dec6ea5ea4
Improve the consistency of identifiers (#5108) 2024-01-29 10:56:04 +01:00
Bude
4face1c2ba
Feature/serde feature (#5149)
* Add serde, serialize, deserialize features to wgpu and wgpu-core
Remove trace, replay features from wgpu-types

* Do not use trace, replay in wgpu-types anymore

* Make use of deserialize, serialize features in wgpu-core

* Make use of serialize, deserialize features in wgpu

* Run cargo fmt

* Use serde(default) for deserialize only

* Fix serial-pass feature

* Add a comment for new features

* Add CHANGELOG entry

* Run cargo fmt

* serial-pass also needs serde features for Id<T>

* Add feature documentation to lib.rs docs

* wgpu-types implicit serde feature

* wgpu-core explicit serde feature

* wgpu explicit serde feature

* Update CHANGELOG.md

* Fix compilation with default features

* Address review comments
2024-01-28 20:13:04 +00:00
vero
0003db18c4
Refactor tests to be feature flag bit-width agnostic (#5155) 2024-01-28 01:42:02 +00:00
Connor Fitzgerald
ad625f433f
Convert Tests to Use Async Poll (#5053)
* Convert Tests to Use Async Poll

* Update examples/src/repeated_compute/mod.rs

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

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-01-13 17:34:51 +00:00
Andreas Reich
4fd4a7142e
Unify surface creation by introducing new SurfaceTarget enum (#4984) 2024-01-11 22:24:01 -05:00
Valaphee The Meerkat
a1fafe394f
Remove DX11 backend (#4828) 2023-12-06 15:12:46 -05:00
Leon
1823f8bbdf
Fixes and changes to the documentation for increasing clarity (#4806)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-12-01 14:02:00 -05: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
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
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
daxpedda
37fe6a5424
Mark some methods unsafe (#4596) 2023-10-29 23:59:48 -04:00
TornaxO7
4c5a817071
Bump raw window handle to 0.6.0 (#4202)
Co-authored-by: junglie85 <junglie85@gmail.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-10-27 05:24:46 +00:00
Teodor Tanasoaia
858d7d590e
Fix features of player tests (#4232) 2023-10-11 17:11:47 -04:00
Nicolas Silva
f95d1c55e3
Expose Instance flags (#4230)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-10-11 17:39:04 +00:00
Leo Kettmeir
d0a7f46e3a
update deno and spec (#4143)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-10-04 04:25:56 +00:00
Teodor Tanasoaia
fd02a12726
Make GLES optional on Windows & macOS (#4185) 2023-10-03 16:16:24 -04:00
Nicolas Silva
90b022d437
Print errors in a more readable format in the player. (#4137)
Co-authored-by: Nicolas Silva <nical@fastnmail.com>
2023-09-14 18:12:35 +02: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
Christopher Fleetwood
3305e88d63
feature: Timestamp queries (#3636)
Co-authored-by: Andreas Reich <r_andreas2@web.de>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: Connor Fitzgerald <connor@modyfi.io>
2023-08-02 18:04:24 -04:00
Valaphee The Meerkat
494ae1a815
Add support for occlusion queries (#3402)
Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-08-02 19:05:59 +00:00