Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a2d4a5c
basic rt pipelines types
Vecvec Feb 19, 2026
47da696
add creation and destruction support for ray tacing pipelines
Vecvec Feb 23, 2026
1cc5779
Support getting the raytracing pipeline data
Vecvec Feb 23, 2026
6249819
Wip: core rt pipelines
Vecvec Feb 23, 2026
daf577f
Add testing
Vecvec Feb 24, 2026
a74978b
Fix rebase etc.
Vecvec Feb 28, 2026
2bd3ad4
More work on tests
Vecvec Feb 28, 2026
e9765e2
Add ray tracing pipelines to wgpu.
Vecvec Mar 1, 2026
22b10dd
Actually enable rt pipelines on when required
Vecvec Mar 1, 2026
c61f1ac
Initial test works
Vecvec Mar 1, 2026
f613824
Gte the shader binding table out of the pipeline
Vecvec Mar 2, 2026
7bad92e
begining pass impl
Vecvec Mar 2, 2026
275cf80
Support set_bind_group
Vecvec Mar 2, 2026
6270ae5
Format
Vecvec Mar 2, 2026
7660425
Support the other general operations
Vecvec Mar 3, 2026
458e878
Implement trace rays command and fix bugs,
Vecvec Mar 3, 2026
78daece
expose pipeline intersection data offset
Vecvec Mar 4, 2026
d7e51e6
add (unused) intersection shader index to TlasInstance
Vecvec Mar 4, 2026
8d20f67
Use intersection group index
Vecvec Mar 4, 2026
de19646
Add first limit
Vecvec Mar 5, 2026
d3ee9da
Clippy
Vecvec Mar 5, 2026
61520ee
format
Vecvec Mar 5, 2026
e682d6e
add more limits
Vecvec Mar 5, 2026
ae38362
Improve test
Vecvec Mar 5, 2026
5610b16
Further improve validation
Vecvec Mar 5, 2026
94e855d
Remv dyn error
Vecvec Mar 5, 2026
63eb914
Fix more builds
Vecvec Mar 7, 2026
aeea1ce
Format
Vecvec Mar 7, 2026
84590a0
Fix docs
Vecvec Mar 7, 2026
19b5f8b
Fix another piece of broken docs
Vecvec Mar 7, 2026
778f6a9
Fix some docs
Vecvec Mar 7, 2026
84ec97b
Fix web
Vecvec Mar 7, 2026
d554e94
more imports
Vecvec Mar 7, 2026
55745cb
Fix experimental features
Vecvec Mar 7, 2026
f62e5f1
See if this changes things
Vecvec Mar 8, 2026
bdf0a3b
Fix added tests.
Vecvec Mar 12, 2026
3b3db4c
Pad pipeline data
Vecvec Mar 12, 2026
592fe40
Format
Vecvec Mar 13, 2026
11d19c6
Fix doctests
Vecvec Mar 13, 2026
39be19f
fmt
Vecvec Mar 13, 2026
2506878
Fix issues
Vecvec Apr 20, 2026
68bd679
Fix test issues
Vecvec Apr 20, 2026
8471142
Fix ci (Hopefully)
Vecvec Apr 20, 2026
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 examples/features/src/ray_aabb_compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ impl crate::framework::Example for Example {
)),
0,
0xff,
wgpu::IntersectionShaderIndex::QueryData(0),
));

let mut encoder =
Expand Down
1 change: 1 addition & 0 deletions examples/features/src/ray_cube_compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ impl crate::framework::Example for Example {
)),
0,
0xff,
wgpu::IntersectionShaderIndex::QueryData(0),
));
}
}
Expand Down
8 changes: 7 additions & 1 deletion examples/features/src/ray_cube_fragment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,13 @@ impl crate::framework::Example for Example {
.try_into()
.unwrap();

*instance = Some(wgpu::TlasInstance::new(&self.blas, transform, 0, 0xff));
*instance = Some(wgpu::TlasInstance::new(
&self.blas,
transform,
0,
0xff,
wgpu::IntersectionShaderIndex::QueryData(0),
));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/features/src/ray_cube_normals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ impl crate::framework::Example for Example {
)),
0,
0xff,
wgpu::IntersectionShaderIndex::QueryData(0),
));
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/features/src/ray_scene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ impl crate::framework::Example for Example {
transform,
blas_index as u32,
0xff,
wgpu::IntersectionShaderIndex::QueryData(0),
));
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/features/src/ray_shadows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ impl crate::framework::Example for Example {
[1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0],
0,
0xFF,
wgpu::IntersectionShaderIndex::QueryData(0),
));

let mut encoder =
Expand Down
3 changes: 3 additions & 0 deletions examples/features/src/ray_traced_triangle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ impl crate::framework::Example for Example {
.unwrap(),
0,
0xff,
wgpu::IntersectionShaderIndex::QueryData(0),
));

tlas[1] = Some(TlasInstance::new(
Expand All @@ -180,6 +181,7 @@ impl crate::framework::Example for Example {
.unwrap(),
0,
0xff,
wgpu::IntersectionShaderIndex::QueryData(0),
));

tlas[2] = Some(TlasInstance::new(
Expand All @@ -195,6 +197,7 @@ impl crate::framework::Example for Example {
.unwrap(),
0,
0xff,
wgpu::IntersectionShaderIndex::QueryData(0),
));

let uniforms = {
Expand Down
7 changes: 7 additions & 0 deletions examples/standalone/custom_backend/src/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ impl DeviceInterface for CustomDevice {
wgpu::custom::DispatchComputePipeline::custom(CustomComputePipeline(module.0.clone()))
}

fn create_ray_tracing_pipeline(
&self,
_desc: &wgpu::RayTracingPipelineDescriptor<'_>,
) -> wgpu::custom::DispatchRayTracingPipeline {
unimplemented!()
}

unsafe fn create_pipeline_cache(
&self,
_desc: &wgpu::PipelineCacheDescriptor<'_>,
Expand Down
155 changes: 155 additions & 0 deletions player/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pub struct Player {
wgc::id::PointerId<wgc::id::markers::ComputePipeline>,
Arc<wgc::pipeline::ComputePipeline>,
>,
ray_tracing_pipelines: HashMap<
wgc::id::PointerId<wgc::id::markers::RayTracingPipeline>,
Arc<wgc::pipeline::RayTracingPipeline>,
>,
pipeline_caches: HashMap<
wgc::id::PointerId<wgc::id::markers::PipelineCache>,
Arc<wgc::pipeline::PipelineCache>,
Expand Down Expand Up @@ -75,6 +79,7 @@ impl Default for Player {
render_bundles: HashMap::new(),
render_pipelines: HashMap::new(),
compute_pipelines: HashMap::new(),
ray_tracing_pipelines: HashMap::new(),
pipeline_caches: HashMap::new(),
query_sets: HashMap::new(),
buffers: HashMap::new(),
Expand Down Expand Up @@ -230,6 +235,17 @@ impl Player {
.expect("invalid compute pipeline");
self.bind_group_layouts.insert(id, bgl);
}
Action::GetRayTracingPipelineBindGroupLayout {
id,
pipeline,
index,
} => {
let pipeline = self.resolve_ray_tracing_pipeline_id(pipeline);
let bgl = pipeline
.get_bind_group_layout(index)
.expect("invalid ray tracing pipeline");
self.bind_group_layouts.insert(id, bgl);
}
Action::DestroyBindGroupLayout(id) => {
self.bind_group_layouts
.remove(&id)
Expand Down Expand Up @@ -481,6 +497,18 @@ impl Player {
Action::DestroyTlas(id) => {
self.tlas_s.remove(&id).expect("invalid tlas");
}
Action::CreateRayTracingPipeline { id, desc } => {
let descriptor = self.resolve_ray_tracing_pipeline_descriptor(desc);
let rt_pipeline = device
.create_ray_tracing_pipeline(descriptor)
.expect("create_ray_tracing_pipeline error");
self.ray_tracing_pipelines.insert(id, rt_pipeline);
}
Action::DestroyRayTracingPipeline(id) => {
self.ray_tracing_pipelines
.remove(&id)
.expect("invalid ray tracing pipeline");
}
}
}

Expand Down Expand Up @@ -600,6 +628,16 @@ impl Player {
.clone()
}

fn resolve_ray_tracing_pipeline_id(
&self,
id: wgc::id::PointerId<wgc::id::markers::RayTracingPipeline>,
) -> Arc<wgc::pipeline::RayTracingPipeline> {
self.ray_tracing_pipelines
.get(&id)
.expect("invalid ray tracing pipeline")
.clone()
}

fn resolve_pipeline_cache_id(
&self,
id: wgc::id::PointerId<wgc::id::markers::PipelineCache>,
Expand Down Expand Up @@ -744,6 +782,61 @@ impl Player {
}
}

fn resolve_ray_tracing_pipeline_descriptor<'a>(
&self,
desc: wgc::device::trace::TraceRayTracingPipelineDescriptor<'a>,
) -> wgc::pipeline::ResolvedRayTracingPipelineDescriptor<'a> {
let layout = desc.layout.map(|id| self.resolve_pipeline_layout_id(id));

wgc::pipeline::ResolvedRayTracingPipelineDescriptor {
label: desc.label,
layout,
cache: desc.cache.map(|id| self.resolve_pipeline_cache_id(id)),
ray_generation: wgc::pipeline::ResolvedProgrammableStageDescriptor {
module: self.resolve_shader_module_id(desc.ray_generation.module),
entry_point: desc.ray_generation.entry_point,
constants: desc.ray_generation.constants,
zero_initialize_workgroup_memory: desc
.ray_generation
.zero_initialize_workgroup_memory,
},
miss: wgc::pipeline::ResolvedProgrammableStageDescriptor {
module: self.resolve_shader_module_id(desc.miss.module),
entry_point: desc.miss.entry_point,
constants: desc.miss.constants,
zero_initialize_workgroup_memory: desc.miss.zero_initialize_workgroup_memory,
},
intersections: desc
.intersections
.into_iter()
.map(|intersections| match intersections {
wgc::pipeline::RayTracingIntersectionDescriptor::Triangle {
closest_hit,
any_hit,
} => wgc::pipeline::RayTracingIntersectionDescriptor::Triangle {
closest_hit: wgc::pipeline::ResolvedProgrammableStageDescriptor {
module: self.resolve_shader_module_id(closest_hit.module),
entry_point: closest_hit.entry_point,
constants: closest_hit.constants,
zero_initialize_workgroup_memory: closest_hit
.zero_initialize_workgroup_memory,
},
any_hit: any_hit.map(|any_hit| {
wgc::pipeline::ResolvedProgrammableStageDescriptor {
module: self.resolve_shader_module_id(any_hit.module),
entry_point: any_hit.entry_point,
constants: any_hit.constants,
zero_initialize_workgroup_memory: any_hit
.zero_initialize_workgroup_memory,
}
}),
},
})
.collect(),
max_recursion_depth: desc.max_recursion_depth,
}
}

fn resolve_bind_group_descriptor<'a>(
&self,
desc: wgc::device::trace::TraceBindGroupDescriptor<'a>,
Expand Down Expand Up @@ -936,6 +1029,9 @@ impl Player {
occlusion_query_set: occlusion_query_set.map(|qs| self.resolve_query_set_id(qs)),
multiview_mask,
},
Command::RunRayTracingPass { pass } => Command::RunRayTracingPass {
pass: self.resolve_ray_tracing_pass(pass),
},
Command::BuildAccelerationStructures { blas, tlas } => {
Command::BuildAccelerationStructures {
blas: blas
Expand Down Expand Up @@ -1031,6 +1127,32 @@ impl Player {
}
}

fn resolve_ray_tracing_pass(
&self,
pass: BasePass<wgc::command::RayTracingCommand<PointerReferences>, Infallible>,
) -> BasePass<wgc::command::RayTracingCommand<ArcReferences>, Infallible> {
let BasePass {
label,
error,
commands,
dynamic_offsets,
immediates_data,
string_data,
} = pass;

BasePass {
label,
error,
commands: commands
.into_iter()
.map(|cmd| self.resolve_ray_tracing_command(cmd))
.collect(),
dynamic_offsets,
immediates_data,
string_data,
}
}

fn resolve_compute_command(
&self,
command: wgc::command::ComputeCommand<PointerReferences>,
Expand Down Expand Up @@ -1248,6 +1370,38 @@ impl Player {
}
}

fn resolve_ray_tracing_command(
&self,
command: wgc::command::RayTracingCommand<PointerReferences>,
) -> wgc::command::RayTracingCommand<ArcReferences> {
use wgc::command::RayTracingCommand as C;
match command {
C::SetBindGroup {
index,
num_dynamic_offsets,
bind_group,
} => C::SetBindGroup {
index,
num_dynamic_offsets,
bind_group: bind_group.map(|bg| self.resolve_bind_group_id(bg)),
},
C::SetPipeline(id) => C::SetPipeline(self.resolve_ray_tracing_pipeline_id(id)),
C::SetImmediate {
offset,
size_bytes,
values_offset,
} => C::SetImmediate {
offset,
size_bytes,
values_offset,
},
C::TraceRays(groups) => C::TraceRays(groups),
C::PushDebugGroup { color, len } => C::PushDebugGroup { color, len },
C::PopDebugGroup => C::PopDebugGroup,
C::InsertDebugMarker { color, len } => C::InsertDebugMarker { color, len },
}
}

fn resolve_pass_timestamp_writes(
&self,
writes: wgc::command::PassTimestampWrites<PointerId<wgc::id::markers::QuerySet>>,
Expand Down Expand Up @@ -1380,6 +1534,7 @@ impl Player {
transform: instance.transform,
custom_data: instance.custom_data,
mask: instance.mask,
intersection_index: instance.intersection_index,
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/tests/wgpu-gpu/binding_array/tlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ async fn binding_array_tlas(ctx: TestingContext) {
[1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0],
0,
0xff,
wgpu::IntersectionShaderIndex::QueryData(0),
));
tlas_b[0] = Some(wgpu::TlasInstance::new(
&blas,
[1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0],
0,
0xff,
wgpu::IntersectionShaderIndex::QueryData(0),
));

// Build BLAS and TLASes.
Expand Down
1 change: 1 addition & 0 deletions tests/tests/wgpu-gpu/ray_tracing/as_aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ fn aabb_blas_build_and_trace(ctx: TestingContext) {
[1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0],
0,
0xFF,
wgpu::IntersectionShaderIndex::QueryData(0),
));

let mut encoder = ctx
Expand Down
Loading