Commit Graph

40 Commits

Author SHA1 Message Date
Vecvec
79a6f2cd31
Ray Queries (#6291)
* fix more compile errors

* fix err

* fix all compile errors

* fix clippy errors

* fix issues in ray-traced-triangle example

* fix clippy warnings

* fix wasm not compiling

* fix test

* fix clippy (again)

* fix some rustfmt issues

* fix more rustfmt issues

* fix even more rustfmt issues

* fix yet more rustfmt issues

* add #[allow(dead_code)] to some structs to fix clippy on web assembly

* more format fixes

* even more format fixes

* close to final format fixes

* final format fixes (hopefully)

* actual final format fixes (hopefully)

* move ray_cube_cube example and fix bugs

* move other examples

* fix crash when dropping

* fix test

* apply clippy and rustfmt changes

* fix some memory leaks

* fix incompatibility with new wgpu trunk changes

* fix clippy & fmt

* fix clippy errors on github

* update to trunk

* remove a line that printed log "Created blas ..." in device create tlas

* fix merge issues

* fix merge

* fix fmt

* restored example ray scene functionality

* WIP fix rebase

* Fix compile issues

* More fixes

* Fix rebase

* Add wgls backend write_value_type AccelerationStructure

* Add back xtask Cargo.lock

* Revert serde path

* Doc typos

* Add -diff

* Revert more serde

* Revert serde again?

* Fix doc typo

* add test

* clippy & fmt

* fix error "blas does not exist"

* fix various things

* fix unused acceleration structures causing invalid SPIR-V

* fix merge

* fix use after free in a different way (now moved tlas instances to wgpu_core)

* refactor & fmt

* remove accidentally created file

* remove accidentally created file (actually)

* merge & fix

* Fix problems

* fix validation error

* fix validation

* fix merge

* fmt

* fix merge

* use staging buffer trackers in creating the ray-tracing staging buffers (not the tlas_s)

* change one missed staging buffer's tracker

* wip: example

* finished shadow!

* fix merge

* clippy

* remove some uses of blas ids

* fmt

* fix merge

* deduplicate code shared between command_encoder_build_acceleration_structures and command_encoder_build_acceleration_structures_unsafe_tlas

* clippy

* fix merge

* fix warnings

* clippy & fmt

* re-add matching to get_raw_tlas_instance_size and tlas_instance_into_bytes

* fmt

* fix command

* wip: fix merge

* fix merge

* fmt & docs

* fix wasm clippy

* fix issues with tests

* fix issues with tests

* fmt & clippy (wasm)

* wip ray-traced-triangle (non hal)

* unify camera location in ray_shadows

* fix tests

* add readme to ray_traced_triangle

* note that vertex format must be f32x3 (not yet validated)

* changelog

* require VertexFormat::Float32x3

* fix compile error

* when creating and building acceleration structures require Features::RAY_TRACING_ACCELERATION_STRUCTURE is enabled

* remove duplicate workaround

* fix most feedback

* remove all changes from .gitattributes

* fix compile error in test

* more changes along same lines

* format

* apply feedback to more places

* fix `cargo clippy` not just `cargo clippy --all-features`

* cache max instances from tlas creation

* fix clippy

* fix examples

* fix tests

* remove now useless docs

* add more docs

* yet more docs

* still more docs

* Documentation.

* Running out of unique commit messages to say writing docs.

* Add more references to docs.

* Get BindGroup in scope

* Remove unintentional changes

* Remove #[allow(dead_code)]

* Remove old comments

* Add device.poll

* make ray_scene start right way up

* fmt

* move scratch buffer to its own module

* actually remove intentional changes (turns out wgt is inconsistent)

* use better names in ray_scene/shader.wgsl

* fmt

* remove more unintentional changes.

* work on ray_tracing use after free

* spelling

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* grammar

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* move things into struct (should be all vectors with 3 item types or more)

* remove long-standing locks.

* fmt

* move not using index buffer to test

* impl index & index mut for tlas package

* impl index & index mut for tlas package

* fix errors

* fix test errors

* move everything out of ray_tracing.rs

* more index_mut

* fmt

* fix docs links

* move to separate impl block

* fix older request review

* fmt

* remove missed deref

* fix wasm clippy

* change to suggestions

* fmt

* add a note as to why `command_encoder_build_acceleration_structures_unsafe_tlas` and `command_encoder_build_acceleration_structures` are currently separate

* add a todo to reconsider soon `command_encoder_build_acceleration_structures_unsafe_tlas`

* switch to mat4 in ray-tracing examples

* Combine RT Tests Under Single Submodule

* Add More Raytracing Tests and Re-Organize

* Documentation and Formatting Fixes

* Remove Forced Alignment in wgpu-hal

* work on out_of_order_as_build and add out_of_order_as_build_use

* fmt

* update test label naming

* fix one validation error

* fix clippy & fmt

* add acceleration structure creation tests

* make mis-matched index test use the correct function

* move validation into validate_command_buffer

* fix tests

* add blas and tlas to pending writes to remove (now unneeded) `device.poll()`s

* remove commented out code from examples and properly use the constants in ray_shadow

* add examples to examples\README.md

* rename ray tracing to ray queries in readme

* remove unneeded usage from scratch buffer creation

* use snatchables for raw acceleration structures

* format

* add EXPERIMENTAL_ to features

* fix missed comment

---------

Co-authored-by: Daniel Keitel <daniel.mg.keitel@fau.de>
Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
Co-authored-by: atlas dostal <rodol@rivalrebels.com>
Co-authored-by: vero <email@atlasdostal.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-11-09 17:59:48 +00:00
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
Erich Gubler
2b15a2b24b
refactor: fully qual. size_of usage (#6401) 2024-10-12 00:48:57 +00: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
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
Deep Vora
50b71287ce
fix: 5890 set upper bound for vertical jump (#6034) 2024-09-06 16:00:42 +00: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
mfluehr
070f760940
Fix missing word in comment (#6168) 2024-08-27 14:56:35 +00:00
renshuncui
62333a573e
chore: fix some comments (#6033)
Signed-off-by: renshuncui <renshun@111.com>
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-07-24 16:48:51 +02:00
Erich Gubler
e216566e48 feat(shader)!: make ProgrammableStage::entry_point optional 2024-07-24 07:40:00 -04:00
Bruce Mitchener
ee16de1c63
clippy: Fix doc_lazy_continuation lints (#5935)
These are in nightly builds.
2024-07-11 08:44:43 +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
Jim Blandy
37f283688a [example hello] Produce output when run in the usual way.
Fixes #3503.
2024-07-04 00:24:59 -07:00
Andreas Reich
7b89b6d959
Fix web example build (#5832)
* Ensure webgl example build only contains webgl and webgpu example build only contains webgpu
* fix ip printed on run-wasm
* Update examples on running examples on the web
2024-06-20 15:52:49 +02:00
Teodor Tanasoaia
1904822084
mark timestamp query inside encoders/passes tests as flaky (#5838) 2024-06-19 12:45:14 +02:00
Bruce Mitchener
7368e5107c
chore: Fix legacy_numeric_constants lints (#5747)
These are being deprecated in the future in favor of the associated
constants (which are already being used in some code here), so this
consistently uses the preferred forms.
2024-05-26 08:36:19 +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
Daniel McNab
965b00c06b
Allow configuring whether workgroup memory is zero initialised (#5508) 2024-04-17 15:50:31 -04:00
Jim Blandy
cc0ee7bcbd
water test: Expect additional error from GPU validation. (#5511)
Expand the `water` test's expected error message substring to cover
new validation errors reported by GPU-based validation starting in
Fedora's vulkan-validation-layers-1.3.275.0-1.fc39.x86_64:

```
[2024-04-09T21:02:01Z ERROR wgpu_test::expectations] Validation Error: Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0x7f2fb53d44e0, type = VK_OBJECT_TYPE_QUEUE; | MessageID = 0x5c0ec5d6 | vkQueueSubmit():  Hazard WRITE_AFTER_WRITE for entry 7, VkCommandBuffer 0x7f2fb6fd5b40[], Submitted access info (submitted_usage: SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_WRITE, command: vkCmdEndRenderPass, seq_no: 3, renderpass: VkRenderPass 0x2d000000002d[], reset_no: 1). Access info (prior_usage: SYNC_IMAGE_LAYOUT_TRANSITION, write_barriers: SYNC_VERTEX_SHADER_SHADER_SAMPLED_READ|SYNC_VERTEX_SHADER_SHADER_STORAGE_READ|SYNC_VERTEX_SHADER_UNIFORM_READ|SYNC_FRAGMENT_SHADER_DEPTH_STENCIL_ATTACHMENT_READ|SYNC_FRAGMENT_SHADER_SHADER_SAMPLED_READ|SYNC_FRAGMENT_SHADER_SHADER_STORAGE_READ|SYNC_FRAGMENT_SHADER_UNIFORM_READ|SYNC_EARLY_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_READ|SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_READ|SYNC_COMPUTE_SHADER_SHADER_SAMPLED_READ|SYNC_COMPUTE_SHADER_SHADER_STORAGE_READ|SYNC_COMPUTE_SHADER_UNIFORM_READ, queue: VkQueue 0x7f2fb53d44e0[], submit: 0, batch: 0, batch_tag: 28, command: vkCmdPipelineBarrier, command_buffer: VkCommandBuffer 0x7f2fb6fd43c0[Main Command Encoder], seq_no: 1, VkImage 0x1c000000001c[Reflection Render Texture], VkImage 0x1f000000001f[Depth Buffer], reset_no: 1).
```

See also #5231.
2024-04-10 03:53:43 -04:00
teoxoy
3bda381812 add pipeline constants plumbing 2024-04-05 18:07:41 +02:00
matt rice
b731495e05
Fix output args for render_to_texture example (#5338)
* Fix output args for render_to_texture example

* Fix output args for storage_texture example

* Fix dashes to underscore in example names.

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-03-09 10:04:38 +00:00
dependabot[bot]
744454b9e2
Bump Many Dependencies and MSRV (#5241)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-02-27 14:43:05 -05:00
Andreas Reich
f350f28c35
Separate native-only feature for wgpu::CommandEncoder::write_timestamp (#5188)
* split out TIMESTAMP_QUERY_INSIDE_ENCODERS from TIMESTAMP_QUERY

* changelog entry

* update changelog change number

* fix web warnings

* single line changelog

* note on followup issue
2024-02-13 16:03:33 +00:00
Erich Gubler
31ac63ce3e feat(vulkan): enable GPU-based validation for Vulkan backend
If [`VK_LAYER_KHRONOS_validation`] is present, and it supports
[`VK_EXT_validation_features`], we can configure it with another instance
creation info. element of type [`VkValidationFeaturesEXT`] to enable
GPU-based validation. Wire `InstanceFlags::GPU_BASED_VALIDATION` to do
this in the Vulkan backend. It's even already finding issues in our
`examples` and other tests! But…we'd like to handle those later, since
this is so important for users. So, I've broken that out to separate
issues. The instances we're aware of:

* `water` is running into sync. validation issues: see
  <https://github.com/gfx-rs/wgpu/issues/5231>
* `wgpu_test::shader::struct_layout::uniform_input` is failing to
    instrument shaders now; see
    <https://github.com/gfx-rs/wgpu/issues/5245>

It is apparent from this and the [DX12 implementation of GPU-based
validation] that we will need to communicate clearly to users that
`InstanceFlags::GPU_BASED_VALIDATION` implies
`InstanceFlags::VALIDATION`. Not all backends enforce this yet; I have
[split out this work][follow-up for flag implication].

Note that `VK_EXT_validation_features` has been deprecated in favor of
the more general layer configuration mechanism offered by
[`VK_EXT_layer_settings`].

[DX12 implementation of GPU-based validation]: https://github.com/gfx-rs/wgpu/pull/5146
[`VK_EXT_layer_settings`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_layer_settings.html
[`VK_EXT_validation_features`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_validation_features.html
[`VK_LAYER_KHRONOS_validation`]:https://vulkan.lunarg.com/doc/sdk/1.3.275.0/linux/khronos_validation_layer.html
[`VkValidationFeaturesEXT`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkValidationFeaturesEXT.html
[follow-up for flag implication]: https://github.com/gfx-rs/wgpu/pull/5232
2024-02-12 10:23:07 -05: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
Jim Blandy
6440af03a6
Join threads in MULTITHREADED_COMPUTE example. (#5129)
Join all threads before returning from the test case, to ensure that
we don't return from `main` until all open `Device`s have been
dropped.

This avoids a race condition in glibc in which a thread calling
`dlclose` can unmap a shared library's code even while the main thread
is still running its finalization functions. (See #5084 for details.)
Joining all threads before returning from the test ensures that the
Vulkan loader has finished `dlclose`-ing the Vulkan validation layer
shared library before `main` returns.

Remove `skip` for this test on GL/llvmpipe. With this change, that has
not been observed to crash. Without it, the test crashes within ten
runs or so.

Fixes #5084.
Fixed #4285.
2024-01-23 22:18:21 -05:00
Andreas Reich
b8f27c7284
Expose maximum_frame_latency (#4899)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-01-17 12:46:34 -05: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
Martin Vilcans
8e0b715954
hello_compute: check for missing command-line args (#4939)
* hello_compute: check for missing command-line args

Fixes off-by-one error when checking for missing arguments.
Before this, running the example gave this scary looking error message:

```
$ cargo run --bin wgpu-examples hello_compute
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/wgpu-examples hello_compute`
[2023-12-27T22:14:26Z ERROR wgpu::backend::direct] Handling wgpu errors as fatal by default
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_bind_group
    Buffer binding size 0 is less than minimum 4
      note: buffer = `Storage Buffer`

', wgpu/src/backend/direct.rs:3139:5
```

As this was the first example I tried to run, it almost scared me
away, thinking it was a driver issue.

Instead, without arguments the example should use defaults.

* Add PR #4939 to changelog as instructed
2024-01-02 21:08:41 +00:00
Nathan Adams
aa48558e3f
Change examples page menu on smaller screens (#4958) 2024-01-02 13:27:39 -05:00
Teodor Tanasoaia
0cbabcf229
Update multi-planar texture API (#4837) 2023-12-07 14:06:56 -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
Xiaopeng Li
a6503e59c9
Support nv12 texture format (#4573)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2023-11-28 16:11:26 +00:00
Connor Fitzgerald
4f24c31765
Fixes for Skybox and All Examples (#4780) 2023-11-27 11:40:37 +01:00
Gerard Fabregó
12ee31d6f9
Update examples readme files (#4774)
* Fix indentation in main examples readme file

* Update examples readme files

* Update hello_compute example readme and fix example not running with new command

* Fix srgb_blend example not working correctly and set readme accordingly
2023-11-25 22:59:40 +00:00
Connor Fitzgerald
7a37229630
Revamp Examples to Match Website (#4765)
* Revamp examples to match website

* Small fixes

* Fix stencil_triangles on resize

* Fix

* Fix everything
2023-11-25 17:20:11 -05:00
Nicolas Silva
ebcfd25b58
Downgrade resource lifetime management log level to trace. (#4772)
* Downgrade resource lifetime management log level to trace.

Allow promoting it back to info via an feature flag.

* Don't filter out info and warning log in the examples.

* Changelog entry.
2023-11-25 17:33:02 +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