Commit Graph

162 Commits

Author SHA1 Message Date
Andreas Reich
e23146aa3e
Avoid breaking change: set_bind_group now takes Into<Option<...>> rather than Option<...> (#6452) 2024-10-23 15:29:42 -04:00
teoxoy
207747cab5 [hlsl-out] add support for restricting indexing to avoid OOB accesses 2024-10-23 16:51:44 +02:00
teoxoy
b32574b368 add OOB indexing test 2024-10-23 16:51:44 +02:00
teoxoy
94e040bc8a avoid creating the bind group for indirect validation if buffer size is 0 2024-10-17 18:41:24 +02:00
teoxoy
bbee35b145 [d3d12] get num_workgroups builtin working for indirect dispatches 2024-10-14 15:22:18 +02:00
Teodor Tanasoaia
7f708edd1f
Ensure safety of indirect dispatch (#5714)
by injecting a compute shader that validates the content of the indirect buffer
2024-10-14 15:02:01 +02:00
Erich Gubler
765c20235e
refactor: use include_wgsl!(…) more (#6326)
This change uses `include_wgsl!(…)` in usages where an
`include_str!("….wgsl")` was used to construct
a `ShaderModuleDescriptor`'s `source, but the `label` was set to `None`.
This should (1) showcase a nice idiomatic convenience we offer in our
examples better, (2) make code more concise, and (3) get some
automatically generated labels in diagnostics where it seems it won't
hurt.
2024-09-26 08:47:57 +02:00
Hamir Mahal
8e787eb70a
style: simplify string formatting for readability (#6316) 2024-09-24 23:40:53 -04:00
Erich Gubler
fc2fd95a98
fix: handle Queue::submit non-fatally (#6318)
* Change the signature of `wgpu_core::Global::queue_submit` to return
  a `(SubmissionIndex, …)` in addition to its current error type.
* Change the control flow of errors in `Queue::submit` to break to the
  end of a block. This is similar to what we already do in many APIs in
  `wgpu_core`.
* Hoist the scope of the local `submit_index` binding so it can be used
  at the point where we need to convert current error paths to also
  return the submission index.

Later, we will likely want to avoid actually retrieving a new submission
index so we can minimize the critical section of code. We'll need to
figure out a strategy for returning a valid (but not necessarily unique)
index in the case of failures that prevent successful submission.
2024-09-25 02:52:25 +00:00
Connor Fitzgerald
859dd8817e
Only Initialize a Single Backend in Tests (#6315)
* Only Initialize a Single Backend in Tests

* Update tests/tests/create_surface_error.rs
2024-09-23 14:21:11 +00:00
Ben Reeves
9f85f8aeea
fix(wgpu): Raise validation error instead of panicking in get_bind_group_layout. (#6280) 2024-09-20 09:32:01 +02:00
teoxoy
82ce2ea747 [wgpu-core] use Fallible for ComputePipeline 2024-09-10 11:58:54 +02:00
teoxoy
c630821f1d [wgpu-core] use Fallible for Texture 2024-09-10 11:58:54 +02:00
teoxoy
68e8b7d4a8 [wgpu-core] introduce Fallible and use it for Buffer (first step of invalidity internalization) 2024-09-10 11:58:54 +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
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
teoxoy
07becfe5b5 [tests] don't create a new instance/adapter for DEVICE_LIFETIME_CHECK & MULTIPLE_DEVICES tests
The test harness creates the instance and adapter that a test should use. Tests should not create these with default configurations or configs from the environment.
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
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
Jim Blandy
15d64c362e
Make wgpu_test::valid print errors it detects. (#6136)
* Make `wgpu_test::valid` print errors it detects.

When a block passed to `wgpu_test::valid` actually raises validation
errors, include the full error in the panic message.

---------

Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-08-23 14:17:28 +00:00
Kornel
a87c8d77ba chore: #[must_use] annotations on getters and ctors 2024-08-19 14:38:05 +01:00
Deep Vora
9972d2c18a chore: [wgpu-tests] use concrete error messages for failures
resolves #5727
2024-08-16 10:52:35 +01: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
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
Mehmet Oguz Derin
34b0df277c
Support texture-compression-bc-sliced-3d in wgpu (#5751) 2024-08-10 12:02:29 +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
a4e7a293d7 [tests] remove Arc around device field of TestingContext 2024-08-03 11:23:59 +02:00
teoxoy
b145250ebc [test] remove the workaround that keeps resources alive from the poll test
The workaround is no longer needed with aade481bdf.
2024-07-29 11:29:53 +02:00
teoxoy
03f6d24ea6 deduplicate derived BGLs 2024-07-25 18:15:29 +02:00
Nicolas Silva
7446790354 Fix a few entry_point parameters 2024-07-24 14:31:23 +02:00
Erich Gubler
e216566e48 feat(shader)!: make ProgrammableStage::entry_point optional 2024-07-24 07:40:00 -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
teoxoy
205f1e3ab6 [wgpu-core] fix length of copy in queue_write_texture #2
Follow-up to 6f16ea460a & 7e112ca4c0.
2024-07-22 12:25:07 +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
Jim Blandy
aeb2067e81 [core] Make poll(Wait) not hang after bad command submission.
Add `wgpu_core::device::Device::last_successful_submission_index`,
which records the fence value that `Maintain::Wait` should actually
wait for. See comments for details.

Fixes #5969.
2024-07-17 16:11:04 -07:00
Teodor Tanasoaia
a3d2d31d3d
[test] allow WARP to run the zero-init workgroup memory test (#5968)
I pinpointed this to 438d6394ef (https://github.com/gfx-rs/wgpu/pull/3512).
I'm not sure why I didn't remove this one in 30064ead9f (https://github.com/gfx-rs/wgpu/pull/3515) as well, maybe I thought it was still failing due to early frees.
2024-07-16 12:30:53 -04:00
Teodor Tanasoaia
167f005c17
[tests] delete outdated comment on DEVICE_DESTROY_THEN_MORE test (#5967)
This was fixed by 6e21f7a929.
2024-07-16 12:30:35 -04:00
Jim Blandy
d02e2949b2 [core] Correctly check mipmap-filtering samplers against the layout.
Ensure that samplers using non-`Nearest` mipmap filtering are
considered "filtering samplers" when deciding bind group layout
compatibility.

Add tests for layout `NonFiltering` validation.

Fixes #5948.
2024-07-15 10:03:49 +02:00
dependabot[bot]
586215ab2e
build(deps): bump crate-ci/typos from 1.22.9 to 1.23.1 (#5922)
* build(deps): bump crate-ci/typos from 1.22.9 to 1.23.1

Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.22.9 to 1.23.1.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.22.9...v1.23.1)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* typo fixes

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-07-14 22:13:25 +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
Erich Gubler
f02ec0e4e8
test: fix wgpu-test building by itself (#5912) 2024-07-04 23:31:37 -04:00
Erich Gubler
5c29ad548b refactor: vertex_index_common: use size_of_val instead of magic number 2024-07-04 16:40:34 -06:00
Erich Gubler
764b15a556 refactor: vertex_index_common: elide tests alloc. w/ Itertools::cartesian_product 2024-07-04 16:40:34 -06:00
Erich Gubler
7600c61b72 refactor: vertex_index_common: use strum enum iter.
Replace manual enumerations of various `enum`s with `derive`d ones via
`strum::{EnumIter, IntoEnumIterator}`.
2024-07-04 16:40:34 -06: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
Jim Blandy
b9b7050bb9 Give wgpu_test::compute_pass_ownership buffers unique labels.
Give each buffer in the
`wgpu_test::compute_pass_ownership::compute_pass_resource_ownership`
test a unique label, for easier debugging.
2024-06-13 12:25:05 +02:00
Jim Blandy
93c6fbe8ba
Skip compute_pass_resource_ownership on GL/AMD Radeon Pro WX 3200. (#5801)
Skip
`wgpu_test::compute_pass_ownership::compute_pass_resource_ownership`
on the GL backend on AMD Radeon Pro WX 3200, to avoid the kernel crash
described in #5800.
2024-06-12 21:27:34 +00:00