Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ray tracing compaction #6609

Open
wants to merge 438 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
438 commits
Select commit Hold shift + click to select a range
972d9cb
Merge commit '5b9ade82233deac341c577ec02b70e7b3e518933' into ray-tracing
JMS55 Feb 25, 2024
2bc105d
Add back xtask Cargo.lock
JMS55 Feb 25, 2024
f3fa301
Revert serde path
JMS55 Feb 25, 2024
96877cc
Doc typos
JMS55 Feb 25, 2024
b459f37
Add -diff
JMS55 Feb 25, 2024
4a1080a
Revert more serde
JMS55 Feb 25, 2024
991c2c4
Revert serde again?
JMS55 Feb 25, 2024
e042a86
Fix doc typo
JMS55 Feb 25, 2024
5da071f
add test
Vecvec Mar 25, 2024
a7b90fe
clippy & fmt
Vecvec Mar 25, 2024
6633fae
fix error "blas does not exist"
Vecvec Mar 26, 2024
d9feef7
fix various things
Vecvec Mar 29, 2024
62de7ce
fix unused acceleration structures causing invalid SPIR-V
Vecvec Mar 29, 2024
1e737be
Merge branch 'fix-unused-acceleration-structure' into ray-tracing-tests
Vecvec Mar 30, 2024
fcc1a68
fix merge
Vecvec Mar 30, 2024
ed2b294
fix use after free in a different way (now moved tlas instances to wg…
Vecvec Apr 6, 2024
b6b44da
refactor & fmt
Vecvec Apr 6, 2024
d9b82b3
remove accidentally created file
Vecvec Apr 6, 2024
0a52484
remove accidentally created file (actually)
Vecvec Apr 6, 2024
6a35108
Merge remote-tracking branch 'gfx-rs/trunk' into ray-tracing-tests
Vecvec Apr 13, 2024
f421374
merge & fix
Vecvec Apr 13, 2024
abdbb40
Merge branch 'trunk' into ray-tracing
atlv24 Apr 14, 2024
67710d7
Fix problems
atlv24 Apr 14, 2024
03c00e9
fix validation error
Vecvec Apr 21, 2024
f2511b5
fix validation
Vecvec Apr 26, 2024
6166c86
Merge pull request #1 from Vecvec/ray-tracing-fix-validation
atlv24 May 1, 2024
1aefc53
Merge commit 'fb3b33d09233140533a9e431256a8690bf4c5d42' into ray-trac…
JMS55 May 2, 2024
d0238b2
Merge pull request #2 from JMS55/ray-tracing2
atlv24 May 4, 2024
c013d86
completely re-work compaction to not use a feature nvidia graphics ca…
Vecvec May 24, 2024
395e237
validation
Vecvec May 24, 2024
5547d8a
clippy&fmt
Vecvec May 24, 2024
99dad2f
remove offset
Vecvec May 24, 2024
dc8f13e
fmt
Vecvec May 24, 2024
b8ba5a4
fix
Vecvec May 24, 2024
d767b8e
fmt
Vecvec May 24, 2024
070251b
more validation
Vecvec May 25, 2024
e8e1a63
remember to destroy the query buffer
Vecvec May 25, 2024
0158ac4
fix inconsistent error, and move everything into one function
Vecvec May 25, 2024
2a49f7a
trace, clippy & fmt
Vecvec May 25, 2024
7a51685
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Jun 1, 2024
a63b8d4
fix merge
Vecvec Jun 1, 2024
0c54402
fmt
Vecvec Jun 1, 2024
d079bd0
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Jun 15, 2024
7050d34
fix merge
Vecvec Jun 15, 2024
a5365bf
use staging buffer trackers in creating the ray-tracing staging buffe…
Vecvec Jun 16, 2024
ce64c15
Merge branch 'refs/heads/ray-tracing-updated' into ray-tracing-tests
Vecvec Jun 17, 2024
9aaab3f
change one missed staging buffer's tracker
Vecvec Jun 17, 2024
d2140ea
Merge branch 'refs/heads/ray-tracing-updated' into ray-tracing-tests
Vecvec Jun 17, 2024
9261031
wip: example
Vecvec Jun 25, 2024
518c7fb
finished shadow!
Vecvec Jul 1, 2024
c33de62
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Jul 1, 2024
3ad91f2
fix merge
Vecvec Jul 3, 2024
8555869
clippy
Vecvec Jul 3, 2024
3eb8835
merge & fix
Vecvec Jul 7, 2024
b524bb2
remove some uses of blas ids
Vecvec Jul 8, 2024
f02507d
fmt
Vecvec Jul 8, 2024
4afba3b
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Jul 9, 2024
7cb078b
fix merge
Vecvec Jul 9, 2024
d659a41
Merge pull request #3 from Vecvec/ray-tracing-updated
atlv24 Jul 26, 2024
d40b0fc
deduplicate code shared between command_encoder_build_acceleration_st…
Vecvec Jul 28, 2024
cafc0b0
clippy
Vecvec Jul 29, 2024
0cb14f5
Merge pull request #4 from Vecvec/ray-tracing-refactor
atlv24 Aug 9, 2024
523756a
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Aug 14, 2024
9706f3c
fix merge
Vecvec Aug 14, 2024
49cfa7d
fix warnings
Vecvec Aug 14, 2024
2810f13
clippy & fmt
Vecvec Aug 14, 2024
7866557
re-add matching to get_raw_tlas_instance_size and tlas_instance_into_…
Vecvec Aug 15, 2024
af183c5
fmt
Vecvec Aug 15, 2024
f5db8d7
Merge remote-tracking branch 'refs/remotes/origin/ray-tracing-updated…
Vecvec Aug 15, 2024
3701dd1
fix merge
Vecvec Aug 15, 2024
7611477
emscriptem clippy ( #[allow(clippy::arc_with_non_send_sync)])
Vecvec Aug 15, 2024
a6d78f5
fix command
Vecvec Aug 31, 2024
9ae808a
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Aug 31, 2024
5e2f061
wip: fix merge
Vecvec Sep 1, 2024
dbfbe56
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Sep 14, 2024
fda4ff8
fix merge
Vecvec Sep 14, 2024
d5532b0
fmt & docs
Vecvec Sep 14, 2024
7400129
fix wasm clippy
Vecvec Sep 14, 2024
3b573c8
fix issues with tests
Vecvec Sep 14, 2024
7dccf40
Merge branch 'refs/heads/ray-tracing-updated' into ray-tracing-tests
Vecvec Sep 14, 2024
86f7823
fix issues with tests
Vecvec Sep 16, 2024
93fba52
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Sep 16, 2024
32f9666
Merge branch 'refs/heads/ray-tracing-updated' into ray-tracing-tests
Vecvec Sep 16, 2024
7f69da4
fmt & clippy (wasm)
Vecvec Sep 16, 2024
e8067ff
wip ray-traced-triangle (non hal)
Vecvec Sep 17, 2024
5461327
unify camera location in ray_shadows
Vecvec Sep 18, 2024
c13baf1
fix tests
Vecvec Sep 19, 2024
592270d
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Sep 19, 2024
c137a33
Merge branch 'refs/heads/ray-tracing-new' into ray-tracing-tests
Vecvec Sep 19, 2024
ba098f2
add readme to ray_traced_triangle
Vecvec Sep 19, 2024
8d1c193
note that vertex format must be f32x3 (not yet validated)
Vecvec Sep 19, 2024
ff6988d
changelog
Vecvec Sep 19, 2024
638f4c5
require VertexFormat::Float32x3
Vecvec Sep 19, 2024
cb167a4
fix compile error
Vecvec Sep 19, 2024
e2168e6
when creating and building acceleration structures require Features::…
Vecvec Sep 20, 2024
0fcc749
remove duplicate workaround
Vecvec Sep 20, 2024
c3aa7ba
fix most feedback
Vecvec Sep 20, 2024
9e6bf29
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 20, 2024
9127686
remove all changes from .gitattributes
Vecvec Sep 20, 2024
9133567
fix compile error in test
Vecvec Sep 20, 2024
358a4ec
more changes along same lines
Vecvec Sep 20, 2024
0d67c0a
format
Vecvec Sep 20, 2024
8d1f97b
apply feedback to more places
Vecvec Sep 20, 2024
e7fb920
fix `cargo clippy` not just `cargo clippy --all-features`
Vecvec Sep 20, 2024
86d8801
cache max instances from tlas creation
Vecvec Sep 20, 2024
07b899c
fix clippy
Vecvec Sep 20, 2024
5ced4e6
fix examples
Vecvec Sep 20, 2024
093acad
fix tests
Vecvec Sep 20, 2024
e6eb770
remove now useless docs
Vecvec Sep 21, 2024
41a1181
add more docs
Vecvec Sep 21, 2024
9f808c0
yet more docs
Vecvec Sep 21, 2024
2da9dff
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 21, 2024
6a385da
still more docs
Vecvec Sep 22, 2024
eed7256
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Sep 22, 2024
7c3e070
Merge remote-tracking branch 'origin/ray-tracing-new' into ray-tracin…
Vecvec Sep 22, 2024
31fd7b3
Documentation.
Vecvec Sep 22, 2024
c534106
Running out of unique commit messages to say writing docs.
Vecvec Sep 22, 2024
ae692b0
Add more references to docs.
Vecvec Sep 22, 2024
6eba476
Get BindGroup in scope
Vecvec Sep 22, 2024
27c19fc
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 22, 2024
d32d086
Remove unintentional changes
Vecvec Sep 22, 2024
ff9dc96
Remove #[allow(dead_code)]
Vecvec Sep 22, 2024
3936b8c
Remove old comments
Vecvec Sep 22, 2024
cadec75
Add device.poll
Vecvec Sep 22, 2024
b406903
Merge remote-tracking branch 'origin/ray-tracing-new' into ray-tracin…
Vecvec Sep 22, 2024
cde7c14
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Sep 22, 2024
c2566d4
make ray_scene start right way up
Vecvec Sep 22, 2024
dcb2955
fmt
Vecvec Sep 22, 2024
ab69ac5
move scratch buffer to its own module
Vecvec Sep 22, 2024
82042f1
actually remove intentional changes (turns out wgt is inconsistent)
Vecvec Sep 22, 2024
86adda1
use better names in ray_scene/shader.wgsl
Vecvec Sep 22, 2024
bcd61d0
fmt
Vecvec Sep 22, 2024
1dec1af
remove more unintentional changes.
Vecvec Sep 22, 2024
142f086
work on ray_tracing use after free
Vecvec Sep 22, 2024
dc5293c
spelling
Vecvec Sep 23, 2024
ad7c8ea
grammar
Vecvec Sep 23, 2024
c05d021
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 23, 2024
000a505
move things into struct (should be all vectors with 3 item types or m…
Vecvec Sep 23, 2024
5b7c7c2
Merge remote-tracking branch 'origin/ray-tracing-new' into ray-tracin…
Vecvec Sep 23, 2024
c4f71c7
remove long-standing locks.
Vecvec Sep 23, 2024
77de647
fmt
Vecvec Sep 23, 2024
67bc235
move not using index buffer to test
Vecvec Sep 23, 2024
0a5781f
impl index & index mut for tlas package
Vecvec Sep 23, 2024
5ece2f8
impl index & index mut for tlas package
Vecvec Sep 23, 2024
d7140d8
fix errors
Vecvec Sep 23, 2024
207b97b
fix test errors
Vecvec Sep 23, 2024
f666e28
move everything out of ray_tracing.rs
Vecvec Sep 23, 2024
43c1fbe
more index_mut
Vecvec Sep 23, 2024
4f2e045
fmt
Vecvec Sep 23, 2024
b57b019
fix docs links
Vecvec Sep 23, 2024
0c1db5f
move to separate impl block
Vecvec Sep 23, 2024
546db21
fix older request review
Vecvec Sep 23, 2024
1602222
fmt
Vecvec Sep 23, 2024
a211921
remove missed deref
Vecvec Sep 23, 2024
0d55822
fix wasm clippy
Vecvec Sep 23, 2024
18a8b73
change to suggestions
Vecvec Sep 23, 2024
9b65611
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 23, 2024
75b184f
fmt
Vecvec Sep 23, 2024
2f9e18d
Merge remote-tracking branch 'origin/ray-tracing-new' into ray-tracin…
Vecvec Sep 23, 2024
2088bea
add a note as to why `command_encoder_build_acceleration_structures_u…
Vecvec Sep 23, 2024
a5dfc77
add a todo to reconsider soon `command_encoder_build_acceleration_str…
Vecvec Sep 24, 2024
a8916b0
switch to mat4 in ray-tracing examples
Vecvec Sep 24, 2024
bd07701
Combine RT Tests Under Single Submodule
cwfitzgerald Sep 25, 2024
a507937
Add More Raytracing Tests and Re-Organize
cwfitzgerald Sep 25, 2024
893b8c5
Documentation and Formatting Fixes
cwfitzgerald Sep 25, 2024
84054df
Remove Forced Alignment in wgpu-hal
cwfitzgerald Sep 25, 2024
1143de9
Merge remote-tracking branch 'upstream/trunk' into ray-tracing-new
cwfitzgerald Sep 25, 2024
ca5a64a
work on out_of_order_as_build and add out_of_order_as_build_use
Vecvec Sep 25, 2024
62b01f3
fmt
Vecvec Sep 25, 2024
e6b2fd4
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 25, 2024
f4bfe81
update test label naming
Vecvec Sep 25, 2024
76f4402
fix one validation error
Vecvec Sep 25, 2024
2be625a
Merge remote-tracking branch 'origin/ray-tracing-new' into ray-tracin…
Vecvec Sep 25, 2024
44d108f
fix clippy & fmt
Vecvec Sep 25, 2024
fccf8a2
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 25, 2024
cd0e4c0
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 26, 2024
aef0c64
add acceleration structure creation tests
Vecvec Sep 26, 2024
0e90de9
Merge remote-tracking branch 'origin/ray-tracing-new' into ray-tracin…
Vecvec Sep 26, 2024
9a9ac03
make mis-matched index test use the correct function
Vecvec Sep 26, 2024
311e5ea
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 26, 2024
1504e78
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 27, 2024
bc907c8
move validation into validate_command_buffer
Vecvec Sep 28, 2024
62aa9e6
fix tests
Vecvec Sep 28, 2024
7662d99
Merge remote-tracking branch 'origin/ray-tracing-new' into ray-tracin…
Vecvec Sep 28, 2024
ae371cf
Merge branch 'trunk' into ray-tracing-new
Vecvec Sep 28, 2024
a89c742
add blas and tlas to pending writes to remove (now unneeded) `device.…
Vecvec Sep 28, 2024
cf177af
Merge remote-tracking branch 'origin/ray-tracing-new' into ray-tracin…
Vecvec Sep 28, 2024
0f2baeb
remove commented out code from examples and properly use the constant…
Vecvec Sep 29, 2024
9e205cd
add examples to examples\README.md
Vecvec Sep 29, 2024
568edcc
rename ray tracing to ray queries in readme
Vecvec Sep 29, 2024
66e19c3
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Sep 29, 2024
689ea8b
Merge branch 'trunk' into ray-tracing-new
Vecvec Oct 1, 2024
1e860ca
remove unneeded usage from scratch buffer creation
Vecvec Oct 1, 2024
5c086b0
Merge branch 'trunk' into ray-tracing-new
Vecvec Oct 4, 2024
ab32656
Merge branch 'trunk' into ray-tracing-new
Vecvec Oct 8, 2024
e777b76
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Oct 19, 2024
66c0cbb
use snatchables for raw acceleration structures
Vecvec Oct 20, 2024
17b2d89
format
Vecvec Oct 20, 2024
6c2b6f3
Merge branch 'trunk' into ray-tracing-new
Vecvec Oct 21, 2024
258ef45
Merge branch 'trunk' into ray-tracing-new
Vecvec Oct 25, 2024
b400342
Merge branch 'trunk' into ray-tracing-new
Vecvec Oct 26, 2024
4ac0e8a
Merge branch 'trunk' into ray-tracing-new
Vecvec Oct 29, 2024
17b90a1
Merge branch 'trunk' into ray-tracing-new
Vecvec Nov 1, 2024
2b5f833
Merge branch 'trunk' into ray-tracing-new
Vecvec Nov 4, 2024
90dba73
Merge branch 'trunk' into ray-tracing-new
Vecvec Nov 8, 2024
1ecb65c
Merge branch 'trunk' into ray-tracing-new
Vecvec Nov 8, 2024
27b96fe
add EXPERIMENTAL_ to features
Vecvec Nov 8, 2024
8f803e1
Merge remote-tracking branch 'origin/ray-tracing-new' into ray-tracin…
Vecvec Nov 8, 2024
ac20f02
fix missed comment
Vecvec Nov 9, 2024
523808d
Merge branch 'refs/heads/ray-tracing-new' into ray-tracing-compaction
Vecvec Nov 9, 2024
d8f4de2
poll the device when compacting a BLAS
Vecvec Nov 15, 2024
dba9c83
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Nov 21, 2024
d9acc0f
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Nov 24, 2024
eedc7cb
fix merge
Vecvec Nov 25, 2024
5690d03
use atomic bool instead of RWLock
Vecvec Nov 25, 2024
61a5516
add test and make it work
Vecvec Nov 25, 2024
d6c8e54
fmt
Vecvec Nov 25, 2024
cc6a706
instead of COPY_DST in transition buffers, use added buffer use ACCEL…
Vecvec Nov 25, 2024
bf47301
fmt.
Vecvec Nov 25, 2024
3554f25
changelog
Vecvec Nov 25, 2024
988e8bb
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Nov 25, 2024
3631905
Improve synchronisation.
Vecvec Nov 25, 2024
91c3d6b
Merge remote-tracking branch 'origin/ray-tracing-compaction' into ray…
Vecvec Nov 25, 2024
e094b68
disallow BLASes from being rebuilt when compacting
Vecvec Nov 26, 2024
b164fae
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Nov 27, 2024
513d325
Merge remote-tracking branch 'origin/ray-tracing-compaction' into ray…
Vecvec Nov 27, 2024
366caf7
disallow BLASes from being rebuilt when compacting
Vecvec Nov 27, 2024
ecb8c39
rename command encoders
Vecvec Nov 27, 2024
942351c
try also putting a barrier on hal::AccelerationStructureUses::BUILD_O…
Vecvec Nov 27, 2024
c56b825
fmt
Vecvec Nov 27, 2024
bced6bc
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Nov 28, 2024
fa6beb9
insert blas into hashmap and rename some of the labels
Vecvec Nov 28, 2024
a4d21ee
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Dec 3, 2024
6137b6d
fix merge
Vecvec Dec 3, 2024
c99ecfa
add more usage flags
Vecvec Dec 4, 2024
b4631fd
format
Vecvec Dec 4, 2024
dfa5331
Merge remote-tracking branch 'refs/remotes/gfx-rs/trunk' into ray-tra…
Vecvec Dec 4, 2024
090d7f4
fix merge
Vecvec Dec 4, 2024
54f756d
clippy wasm
Vecvec Dec 4, 2024
60dc37c
format
Vecvec Dec 4, 2024
3a816e5
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Dec 5, 2024
9e7d8db
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Dec 6, 2024
16f3b13
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Dec 10, 2024
ab1957b
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Dec 11, 2024
4090ad9
fix merge
Vecvec Dec 11, 2024
a348e92
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Dec 12, 2024
b6a74c2
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Dec 13, 2024
0cac790
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Dec 15, 2024
959d958
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Dec 16, 2024
a714c7b
Merge branch 'trunk' into ray-tracing-compaction
Vecvec Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148]
- Return submission index in `map_async` and `on_submitted_work_done` to track down completion of async callbacks. By @eliemichel in [#6360](https://github.com/gfx-rs/wgpu/pull/6360).
- Move raytracing alignments into HAL instead of in core. By @Vecvec in [#6563](https://github.com/gfx-rs/wgpu/pull/6563).
- Allow for statically linking DXC rather than including separate `.dll` files. By @DouglasDwyer in [#6574](https://github.com/gfx-rs/wgpu/pull/6574).
- Allow BLASes to be compacted. By @Vecvec in [#6609](https://github.com/gfx-rs/wgpu/pull/6609)

### Changes

Expand Down
49 changes: 29 additions & 20 deletions examples/src/ray_cube_compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bytemuck::{Pod, Zeroable};
use glam::{Affine3A, Mat4, Quat, Vec3};
use wgpu::util::DeviceExt;

use wgpu::StoreOp;
use wgpu::{CommandEncoderDescriptor, StoreOp};

// from cube
#[repr(C)]
Expand Down Expand Up @@ -141,6 +141,7 @@ impl crate::framework::Example for Example {
| wgpu::Features::VERTEX_WRITABLE_STORAGE
| wgpu::Features::EXPERIMENTAL_RAY_QUERY
| wgpu::Features::EXPERIMENTAL_RAY_TRACING_ACCELERATION_STRUCTURE
| wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
}

fn required_downlevel_capabilities() -> wgpu::DownlevelCapabilities {
Expand Down Expand Up @@ -242,7 +243,8 @@ impl crate::framework::Example for Example {
let blas = device.create_blas(
&wgpu::CreateBlasDescriptor {
label: None,
flags: wgpu::AccelerationStructureFlags::PREFER_FAST_TRACE,
flags: wgpu::AccelerationStructureFlags::PREFER_FAST_TRACE
| wgpu::AccelerationStructureFlags::ALLOW_COMPACTION,
update_mode: wgpu::AccelerationStructureUpdateMode::Build,
},
wgpu::BlasGeometrySizeDescriptors::Triangles {
Expand Down Expand Up @@ -343,6 +345,30 @@ impl crate::framework::Example for Example {

let dist = 3.0;

let mut encoder = device.create_command_encoder(&CommandEncoderDescriptor { label: None });

encoder.build_acceleration_structures(
iter::once(&wgpu::BlasBuildEntry {
blas: &blas,
geometry: wgpu::BlasGeometries::TriangleGeometries(vec![
wgpu::BlasTriangleGeometry {
size: &blas_geo_size_desc,
vertex_buffer: &vertex_buf,
first_vertex: 0,
vertex_stride: mem::size_of::<Vertex>() as u64,
index_buffer: Some(&index_buf),
index_buffer_offset: Some(0),
transform_buffer: None,
transform_buffer_offset: None,
},
]),
}),
iter::empty(),
);
queue.submit(Some(encoder.finish()));
let mut encoder = device.create_command_encoder(&CommandEncoderDescriptor { label: None });
let blas = encoder.compact_blas(&blas);
queue.submit(Some(encoder.finish()));
for x in 0..side_count {
for y in 0..side_count {
tlas_package[(x + y * side_count) as usize] = Some(wgpu::TlasInstance::new(
Expand All @@ -364,24 +390,7 @@ impl crate::framework::Example for Example {
let mut encoder =
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });

encoder.build_acceleration_structures(
iter::once(&wgpu::BlasBuildEntry {
blas: &blas,
geometry: wgpu::BlasGeometries::TriangleGeometries(vec![
wgpu::BlasTriangleGeometry {
size: &blas_geo_size_desc,
vertex_buffer: &vertex_buf,
first_vertex: 0,
vertex_stride: mem::size_of::<Vertex>() as u64,
index_buffer: Some(&index_buf),
index_buffer_offset: Some(0),
transform_buffer: None,
transform_buffer_offset: None,
},
]),
}),
iter::once(&tlas_package),
);
encoder.build_acceleration_structures(iter::empty(), iter::once(&tlas_package));

queue.submit(Some(encoder.finish()));

Expand Down
6 changes: 6 additions & 0 deletions player/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ impl GlobalPlay for wgc::global::Global {
)
.unwrap();
}
trace::Command::CompactBlas {
blas,
compacted_blas,
} => {
self.command_encoder_compact_blas(encoder, blas, Some(compacted_blas));
}
}
}
let (cmd_buf, error) =
Expand Down
206 changes: 200 additions & 6 deletions tests/tests/ray_tracing/as_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct AsBuildContext {
}

impl AsBuildContext {
fn new(ctx: &TestingContext) -> Self {
fn new(ctx: &TestingContext, additional_blas_flags: AccelerationStructureFlags) -> Self {
let vertices = ctx.device.create_buffer_init(&BufferInitDescriptor {
label: None,
contents: &[0; mem::size_of::<[[f32; 3]; 3]>()],
Expand All @@ -35,7 +35,7 @@ impl AsBuildContext {
let blas = ctx.device.create_blas(
&CreateBlasDescriptor {
label: Some("BLAS"),
flags: AccelerationStructureFlags::PREFER_FAST_TRACE,
flags: AccelerationStructureFlags::PREFER_FAST_TRACE | additional_blas_flags,
update_mode: AccelerationStructureUpdateMode::Build,
},
BlasGeometrySizeDescriptors::Triangles {
Expand Down Expand Up @@ -95,7 +95,7 @@ static UNBUILT_BLAS: GpuTestConfiguration = GpuTestConfiguration::new()
.run_sync(unbuilt_blas);

fn unbuilt_blas(ctx: TestingContext) {
let as_ctx = AsBuildContext::new(&ctx);
let as_ctx = AsBuildContext::new(&ctx, AccelerationStructureFlags::empty());

// Build the TLAS package with an unbuilt BLAS.
let mut encoder = ctx
Expand Down Expand Up @@ -125,7 +125,7 @@ static OUT_OF_ORDER_AS_BUILD: GpuTestConfiguration = GpuTestConfiguration::new()
.run_sync(out_of_order_as_build);

fn out_of_order_as_build(ctx: TestingContext) {
let as_ctx = AsBuildContext::new(&ctx);
let as_ctx = AsBuildContext::new(&ctx, AccelerationStructureFlags::empty());

//
// Encode the TLAS build before the BLAS build, but submit them in the right order.
Expand Down Expand Up @@ -156,7 +156,7 @@ fn out_of_order_as_build(ctx: TestingContext) {
// Create a clean `AsBuildContext`
//

let as_ctx = AsBuildContext::new(&ctx);
let as_ctx = AsBuildContext::new(&ctx, AccelerationStructureFlags::empty());

//
// Encode the BLAS build before the TLAS build, but submit them in the wrong order.
Expand Down Expand Up @@ -207,7 +207,7 @@ fn out_of_order_as_build_use(ctx: TestingContext) {
// Create a clean `AsBuildContext`
//

let as_ctx = AsBuildContext::new(&ctx);
let as_ctx = AsBuildContext::new(&ctx, AccelerationStructureFlags::empty());

//
// Build in the right order, then rebuild the BLAS so the TLAS is invalid, then use the TLAS.
Expand Down Expand Up @@ -328,3 +328,197 @@ fn empty_build(ctx: TestingContext) {
ctx.queue
.submit([encoder_safe.finish(), encoder_unsafe.finish()]);
}

#[gpu_test]
static COMPACT_BLAS: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
TestParameters::default()
.test_features_limits()
.features(wgpu::Features::EXPERIMENTAL_RAY_TRACING_ACCELERATION_STRUCTURE),
)
.run_sync(compact_blas);

fn compact_blas(ctx: TestingContext) {
//
// Create a clean `AsBuildContext`
//

let as_ctx = AsBuildContext::new(&ctx, AccelerationStructureFlags::ALLOW_COMPACTION);

let mut encoder_blas = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("BLAS 1"),
});

encoder_blas.build_acceleration_structures([&as_ctx.blas_build_entry()], []);

ctx.queue.submit([encoder_blas.finish()]);
let mut encoder_compact = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("Compact 1"),
});

let _ = encoder_compact.compact_blas(&as_ctx.blas);

ctx.queue.submit([encoder_compact.finish()]);
//
// Create a clean `AsBuildContext`
//

let as_ctx = AsBuildContext::new(&ctx, AccelerationStructureFlags::ALLOW_COMPACTION);

let mut encoder_blas = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("BLAS 2"),
});

encoder_blas.build_acceleration_structures([&as_ctx.blas_build_entry()], []);

ctx.queue.submit([encoder_blas.finish()]);
let mut encoder_compact = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("Compact 2"),
});

let _ = encoder_compact.compact_blas(&as_ctx.blas);

let mut encoder_blas = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("BLAS 3"),
});

encoder_blas.build_acceleration_structures([&as_ctx.blas_build_entry()], []);

ctx.queue
.submit([encoder_compact.finish(), encoder_blas.finish()]);
}

#[gpu_test]
static INVALID_COMPACT_BLAS: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
TestParameters::default()
.test_features_limits()
.features(wgpu::Features::EXPERIMENTAL_RAY_TRACING_ACCELERATION_STRUCTURE),
)
.run_sync(invalid_compact_blas);

fn invalid_compact_blas(ctx: TestingContext) {
//
// Create a clean `AsBuildContext`
//

let as_ctx = AsBuildContext::new(&ctx, AccelerationStructureFlags::empty());

let mut encoder_blas = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("BLAS 1"),
});

encoder_blas.build_acceleration_structures([&as_ctx.blas_build_entry()], []);

ctx.queue.submit([encoder_blas.finish()]);
let mut encoder_compact = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("Compact 1"),
});

fail(
&ctx.device,
|| {
let _ = encoder_compact.compact_blas(&as_ctx.blas);
},
None,
);

//
// Create a clean `AsBuildContext`
//

let as_ctx = AsBuildContext::new(&ctx, AccelerationStructureFlags::ALLOW_COMPACTION);

let mut encoder_compact = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("Compact 2"),
});

fail(
&ctx.device,
|| {
let _ = encoder_compact.compact_blas(&as_ctx.blas);
},
None,
);

//
// Create a clean `AsBuildContext`
//

let as_ctx = AsBuildContext::new(&ctx, AccelerationStructureFlags::ALLOW_COMPACTION);

let mut encoder_blas = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("BLAS 2"),
});

encoder_blas.build_acceleration_structures([&as_ctx.blas_build_entry()], []);

ctx.queue.submit([encoder_blas.finish()]);
let mut encoder_compact = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("Compact 3"),
});

let _ = encoder_compact.compact_blas(&as_ctx.blas);

let mut encoder_blas = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("BLAS 3"),
});

encoder_blas.build_acceleration_structures([&as_ctx.blas_build_entry()], []);

fail(
&ctx.device,
|| {
ctx.queue
.submit([encoder_blas.finish(), encoder_compact.finish()]);
},
None,
);

let mut encoder_compact = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("Compact 4"),
});

let blas = encoder_compact.compact_blas(&as_ctx.blas);

let mut encoder_blas = ctx
.device
.create_command_encoder(&CommandEncoderDescriptor {
label: Some("BLAS 4"),
});

let mut entry = as_ctx.blas_build_entry();
entry.blas = &blas;

fail(
&ctx.device,
|| {
encoder_blas.build_acceleration_structures([&entry], []);
},
None,
);
}
Loading
Loading