Commit Graph

686 Commits

Author SHA1 Message Date
teoxoy
f62090ed71 use StatelessTracker for acceleration structures 2025-01-13 20:52:55 +01:00
teoxoy
362e440552 add temp_resources to CommandBufferMutable, BakedCommands & EncoderInFlight, remove it from ActiveSubmission
Use `CommandBufferMutable.temp_resources` to store the ray tracing related staging buffers and scratch buffers. These shouldn't have been stored in `PendingWrites.temp_resources` because they can get destroyed early (before the command buffer that uses them has been submitted) if any other command buffer gets submitted first.
2025-01-13 20:52:55 +01:00
teoxoy
43e0ebde9f [wgpu-core] ray tracing: remove acceleration structures from pending writes
The acceleration structures are already being kept alive by the tracker in the command encoder.
2025-01-13 20:52:55 +01:00
teoxoy
fb9f91a668 [wgpu-core] ray tracing: use error handling helpers 2025-01-13 20:52:55 +01:00
Connor Fitzgerald
fabcba8f9a Refine Multi-Draw-Indirect (#6870) 2025-01-07 13:52:42 +01:00
Vecvec
658052885a Use transform_buffer_offset when initialising transform_buffer. (#6864)
* use `transform_buffer_offset` instead of `index_buffer_offset` in part of the initialisation of transform_buffer.

* Format.

* Changelog.

* Only unwrap transform alignment once.
2025-01-07 03:01:50 -05:00
Samson
ee3ae0e549 [core] Use higher level LoadOp,StoreOp (#6785) 2024-12-22 21:48:11 -05:00
teoxoy
a5c3be575e remove device arg from all CommandEncoder methods 2024-12-20 15:44:15 +01:00
teoxoy
973def4c53 remove old todo 2024-12-20 15:44:15 +01:00
teoxoy
7b2a561402 make open_pass panic if the encoder is open 2024-12-20 15:44:15 +01:00
teoxoy
0fed4dbc16 make close_and_swap panic if the encoder is not open 2024-12-20 15:44:15 +01:00
teoxoy
486967632c rename close to close_if_open and add close that panics if the encoder is not open 2024-12-20 15:44:15 +01:00
teoxoy
7a476fcbf4 use open_pass in some more places 2024-12-20 15:44:15 +01:00
teoxoy
062999658a let open_pass handle hal label mapping 2024-12-20 15:44:15 +01:00
teoxoy
38e09d02cc update code that opens and closes the encoder to
go through `CommandEncoder`'s methods

So that `CommandEncoder.is_open` is always accurate.
2024-12-20 15:44:15 +01:00
Samson
f6fec82853 [core] Allow depthClearValue to be empty (#6753) 2024-12-16 16:21:06 -05:00
Samson
4da7c263ed [core] Support optional ops in PassChannel (#6716)
* Support optional ops in PassChannel

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* respect view format aspect

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2024-12-16 12:20:20 +01:00
Samson
8f82992b9f Inline PassChannel into ColorAttachment (#6704)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2024-12-12 15:57:05 +01:00
Erich Gubler
727992e844 chore: satisfy clippy::unused_qualification (#6712) 2024-12-12 00:47:48 -05:00
atlv
5543961a71 Replace Range<T> with StateTransition<T> (#6703)
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-12-11 16:11:39 +01:00
Erich Gubler
f8b67a752a docs: remove last paragraph from CommandBuffer::data (#6680) 2024-12-07 01:30:09 -05:00
atlv
0b6571a68d Align Storage Access enums to spec (#6642) 2024-12-03 17:37:23 +01:00
teoxoy
02b28e28f0 use EncoderGuard for the other command encoder operations
The spec requires us to invalidate the encoder if there was any error during the body of these operations.
2024-12-02 15:59:14 -08:00
teoxoy
5e1fbd7176 move CommandEncoderStatus on the CommandBuffer and change its variants to hold CommandBufferMutable
This makes the code more straightforward, we were previously holding invalidity state in 2 places: `CommandBuffer::data` could hold `None` and in `CommandEncoderStatus::Error`.

This commit also implements `Drop` for `CommandEncoder` which makes the destruction/reclamation code automatic. We were previously not reclaiming all command encoders (`CommandBufferMutable::destroy` didn't call `release_encoder`) even though all encoders are coming from a pool.
2024-12-02 15:59:14 -08:00
teoxoy
68d336ef79 use CommandEncoder for BakedCommands & EncoderInFlight 2024-12-02 15:59:14 -08:00
teoxoy
ba416c1dad remove hal::Device::destroy_command_encoder, use Drop implementations instead
Co-Authored-By: Erich Gubler <erichdongubler@gmail.com>
2024-12-02 15:59:14 -08:00
Erich Gubler
9436d56271 feat(types): add deprecated type aliases for idents. in 2024-08 spec. rename 2024-11-26 23:16:35 -05:00
Erich Gubler
c05aa105f2 refactor!: handle 2024-08 spec. rename of image copy APIs
This commit was authored by running the following Nushell script, using
the `nu` binary and the lovely `fastmod` tool:

```nushell
# Copy-pasted from the OP in [`gpuweb`#4838](https://github.com/gpuweb/gpuweb/pull/4838).
let renames_table = '
Type 	Old 	New 	Used in
dict 	GPUImageDataLayout 	GPUTexelCopyBufferLayout 	"writeTexture,
parent type of ↙"
dict 	GPUImageCopyBuffer 	"GPUTexelCopyBufferInfo
extends ↑" 	T2B, B2T
dict 	GPUImageCopyTexture 	GPUTexelCopyTextureInfo 	T2B, B2T, T2T, writeTexture
dict 	GPUImageCopyTextureTagged 	"GPUCopyExternalImageDestInfo
extends ↑" 	copyExternalImageToTexture
dict 	GPUImageCopyExternalImage 	GPUCopyExternalImageSourceInfo 	copyExternalImageToTexture
union 	GPUImageCopyExternalImageSource 	GPUCopyExternalImageSource 	member of ↖
'

let renames_table = $renames_table
  | from tsv
  | select 'Old ' 'New '
  | rename old new
  | update new { $in | lines | get 0 } # only the first line has the renamed symbol identifier
  | update old { strip_gpu_prefix | str trim }
  | update new { strip_gpu_prefix | str trim }
  | sort-by old | reverse # Replace most specific symbol names first (some have the same "word segments" but with fewer segments)

def strip_gpu_prefix []: string -> string {
  $in | str replace --regex '^GPU' ''
}

# Rename image APIs.
for entry in $renames_table {
  fastmod --accept-all --fixed-strings $entry.old $entry.new --iglob '!CHANGELOG.md' --iglob "!xtask/src/vendor_web_sys.rs" --iglob '!wgpu/src/backend/webgpu/webgpu_sys/' --iglob '!deno_webgpu/' --iglob '!wgpu/src/backend/webgpu.rs'
}
cargo fmt
```

…and cleaning up `deno_webgpu/`'s Rust compilation errors.
2024-11-26 23:16:35 -05:00
Erich Gubler
96c855b7ed chore: satisfy elided_named_lifetimes lint 2024-11-25 03:36:18 -05:00
Erich Gubler
ca410afb5f chore: satisfy clippy::assigning_clones
Started firing with Rust 1.78.0, but we can preempt it with our current
MSRV.
2024-11-25 03:36:18 -05:00
Erich Gubler
19d80fe229 refactor(core): extract Global::validate_pass_timestamp_writes 2024-11-22 13:50:29 -05:00
Erich Gubler
29e7fe3fe2 fix(core): validate that at least one pass timestamp write index is specified 2024-11-22 13:50:29 -05:00
Erich Gubler
6365e2dd75 fix(core): validate dst_buffer isn't destroyed when resolving query sets 2024-11-21 23:23:15 -05:00
Erich Gubler
f1ec934dbc fix(core): validate that begin and end indices of pass timestamp writes are not equal 2024-11-21 23:22:15 -05:00
Erich Gubler
be50bdfc18 fix(core): validate bounds of pass timestamp writes' indices 2024-11-21 23:22:15 -05:00
Erich Gubler
ce1d6e4173 refactor: destructure timestamp writes in command_encoder_create_{compute,render}_pass 2024-11-21 23:22:15 -05:00
Erich Gubler
b17c30338d fix(core): validate TIMESTAMP_QUERY feature before other query set validation in pass creation 2024-11-21 23:22:15 -05:00
Vecvec
6f5014f0a3 [wgpu-core/-hal] move raytracing alignments into hal (#6563) 2024-11-19 11:57:48 +01:00
fyellin
2389106a75 Fix set_push_constants for render bundles (#6540) 2024-11-19 11:12:21 +01:00
Teodor Tanasoaia
1abf3fe90e remove unused enum variants (#6550) 2024-11-15 14:25:18 +01:00
teoxoy
6c7dbba399 move PendingWrites into the Queue
The `Device` should not contain any `Arc`s to resources as that creates cycles (since all resources hold strong references to the `Device`).
Note that `PendingWrites` internally has `Arc`s to resources.

I think this change also makes more sense conceptually since most operations that use `PendingWrites` are on the `Queue`.
2024-11-14 06:27:37 -08:00
Erich Gubler
d0fd6a231c chore: satisfy unused_qualifications (again) 2024-11-14 07:56:22 -05:00
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
Erich Gubler
5936fe58f4 fix: check for device mismatch in create_{render,compute}_pass 2024-11-06 01:33:32 -05:00
Erich Gubler
2e46a6c9c9 fix: req. TIMESTAMP_QUERY feat. for <pass desc.>::timestamp_writes 2024-11-06 01:33:32 -05: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
teoxoy
952ba3e12c move queue methods on the Queue type 2024-10-14 13:24:44 +02:00
teoxoy
71b4f361e2 chore(core): more detail on TODO for push constants 2024-10-02 04:41:34 -04:00
teoxoy
7ac533a312 add missing indirect buffer offset validation 2024-10-02 04:41:34 -04:00
teoxoy
76af20348d remove old comment 2024-10-02 04:41:34 -04:00