Commit Graph

135 Commits

Author SHA1 Message Date
Teodor Tanasoaia
c8beade187
remove backend from ID (#6263) 2024-09-13 17:30:38 +02:00
teoxoy
3437589107 [wgpu-core] use .strict_get() & .strict_unregister() for devices
This works because we never assign errors to devices (they are never invalid).
2024-09-10 11:58:54 +02:00
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
Kornel
a87c8d77ba chore: #[must_use] annotations on getters and ctors 2024-08-19 14:38:05 +01:00
Andreas Reich
0fb772b5df remove dyn render & compute pass 2024-08-14 17:34:11 +02: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
Mehmet Oguz Derin
34b0df277c
Support texture-compression-bc-sliced-3d in wgpu (#5751) 2024-08-10 12:02:29 +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
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
teoxoy
ed67ff289c [deno] remove assertDeviceMatch 2024-07-18 10:29:08 -04: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
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
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
teoxoy
ed1e8ecf4b remove label getters from Global
Also removes label from `Element::Error` and slightly refactors ContextError.
2024-07-02 18:06:19 +02:00
teoxoy
4a19ac279c introduce MultiError and use it for BGL incompatibility errors 2024-07-02 18:06:19 +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
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
588950110a
Remove lifetime dependency of ComputePass to its parent command encoder (#5620)
* lift encoder->computepass lifetime constraint and add now failing test
* compute passes now take an arc to their parent command encoder, thus removing compile time dependency to it
* Command encoder goes now into locked state while compute pass is open
* changelog entry
* share most of the code between get_encoder and lock_encoder
2024-05-29 22:43:24 +00: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
77a83fb0dd
Remove lifetime constraints from wgpu::ComputePass methods (#5570)
* basic test setup

* remove lifetime and drop resources on test - test fails now just as expected

* compute pass recording is now hub dependent (needs gfx_select)

* compute pass recording now bumps reference count of uses resources directly on recording

TODO:
* bind groups don't work because the Binder gets an id only
* wgpu level error handling is missing

* simplify compute pass state flush, compute pass execution no longer needs to lock bind_group storage

* wgpu sided error handling

* make ComputePass hal dependent, removing command cast hack. Introduce DynComputePass on wgpu side

* remove stray repr(C)

* changelog entry

* fix deno issues -> move DynComputePass into wgc

* split out resources setup from test
2024-05-14 20:05:17 +00:00
Andreas Reich
452cf24fa1
Remove unnecessary Cargo.toml dependencies via cargo machete (#5692) 2024-05-12 19:05:00 -04:00
Leo Kettmeir
d0a5e48aa7
chore: backport deno changes (#5686) 2024-05-11 09:29:09 +00:00
Connor Fitzgerald
4521502da6
Release v0.20.0 (#5619) 2024-04-28 18:06:35 -04:00
Samson
5735f85720
CreateBindGroup validation error on device mismatch (#5596)
* Fix cts_runner command invocation in readme

* Remove assertDeviceMatch from deno_webgpu in createBindGroup

This should be done as verification in wgpu-core.

* Add device mismatched check to create_buffer_binding

* Extract common logic to create_sampler_binding

* Move common logic to create_texture_binding and add device mismatch check
2024-04-25 12:17:00 +02:00
Andreas Reich
ad6774f7bb
Remove exposed C symbols from renderpass/computepass recording (#5409)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-04-17 20:48:45 +00:00
Leo Kettmeir
6a616a5c3b
refactor(deno): simplify error handling (#5479) 2024-04-17 16:25:51 -04:00
Daniel McNab
965b00c06b
Allow configuring whether workgroup memory is zero initialised (#5508) 2024-04-17 15:50:31 -04:00
teoxoy
3bda381812 add pipeline constants plumbing 2024-04-05 18:07:41 +02:00
Chase MacDonnell
3db0e46f7d
Implement Unorm10_10_10_2 VertexFormat (#5477) 2024-04-03 19:43:54 +00:00
Leo Kettmeir
d828f27de4
chore: update deno (#5469)
* chore: update deno

* update spec

* more error handling

* cleanup queue

* fix

* fix byow

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>

* fix

* fix

* fix

* fixes

* fix cts

* clean

---------

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-04-02 14:36:04 -04:00
Leo Kettmeir
c2fb18afb8
Fix deno_webgpu & cts_runner (#5459)
* fix cts_runner

* fix
2024-04-01 12:39:02 -04: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
Connor Fitzgerald
faed98b45c
Add typos to Repository CI (#5191)
Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-02-05 12:30:29 -05:00
andristarr
8afb441ca7
adding internal error filter (#5160)
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-01-29 14:50:35 -05: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
Connor Fitzgerald
8b2098bd4e
Release 0.19 (#5082) 2024-01-17 14:42:11 -05:00
John-John Tedro
90b078f037
Improve ergonomics of gfx_select! (#5069) 2024-01-16 11:15:56 +01: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
Teodor Tanasoaia
0cbabcf229
Update multi-planar texture API (#4837) 2023-12-07 14:06:56 -05:00
Valaphee The Meerkat
a1fafe394f
Remove DX11 backend (#4828) 2023-12-06 15:12:46 -05:00
Almar Klein
32c5a22293
Add feature float32-filterable (#4759) 2023-12-04 14:23:13 +01:00