pub struct RayTrace<'a> { /* private fields */ }
Expand description
Recording interface for ray tracing commands.
This structure provides a strongly-typed set of methods which allow ray trace shader code to be
executed. An instance of RayTrace
is provided to the closure parameter of
PipelinePassRef::record_ray_trace
which may be accessed by binding a RayTracePipeline
to
a render pass.
§Examples
Basic usage:
[Shader::new_miss(my_miss_code.as_slice())],
[RayTraceShaderGroup::new_general(0)],
)?);
my_graph.begin_pass("my ray trace pass")
.bind_pipeline(&my_ray_trace_pipeline)
.record_ray_trace(move |ray_trace, bindings| {
// During this closure we have access to the ray trace methods!
});
Implementations§
source§impl<'a> RayTrace<'a>
impl<'a> RayTrace<'a>
sourcepub fn push_constants(&self, data: &[u8]) -> &Self
pub fn push_constants(&self, data: &[u8]) -> &Self
Updates push constants.
Push constants represent a high speed path to modify constant data in pipelines that is expected to outperform memory-backed resource updates.
Push constant values can be updated incrementally, causing shader stages to read the new data for push constants modified by this command, while still reading the previous data for push constants not modified by this command.
§Device limitations
See
device.physical_device.props.limits.max_push_constants_size
for the limits of the current device. You may also check gpuinfo.org for a listing of
reported limits on other devices.
§Examples
Basic usage:
#version 460
layout(push_constant) uniform PushConstants {
layout(offset = 0) uint some_val;
} push_constants;
void main()
{
// TODO: Add bindings to write things!
}
my_graph.begin_pass("draw a cornell box")
.bind_pipeline(&my_ray_trace_pipeline)
.record_ray_trace(move |ray_trace, bindings| {
ray_trace.push_constants(&[0xcb])
.trace_rays(&rgen_sbt, &hit_sbt, &miss_sbt, &call_sbt, 320, 200, 1);
});
sourcepub fn push_constants_offset(&self, offset: u32, data: &[u8]) -> &Self
pub fn push_constants_offset(&self, offset: u32, data: &[u8]) -> &Self
Updates push constants starting at the given offset
.
Behaves similary to RayTrace::push_constants
except that offset
describes the position
at which data
updates the push constants of the currently bound pipeline. This may be used
to update a subset or single field of previously set push constant data.
§Device limitations
See
device.physical_device.props.limits.max_push_constants_size
for the limits of the current device. You may also check gpuinfo.org for a listing of
reported limits on other devices.
§Examples
Basic usage:
#version 460
layout(push_constant) uniform PushConstants {
layout(offset = 0) uint some_val1;
layout(offset = 4) uint some_val2;
} push_constants;
void main()
{
// TODO: Add bindings to write things!
}
my_graph.begin_pass("draw a cornell box")
.bind_pipeline(&my_ray_trace_pipeline)
.record_ray_trace(move |ray_trace, bindings| {
ray_trace.push_constants(&[0xcb, 0xff])
.trace_rays(&rgen_sbt, &hit_sbt, &miss_sbt, &call_sbt, 320, 200, 1)
.push_constants_offset(4, &[0xae])
.trace_rays(&rgen_sbt, &hit_sbt, &miss_sbt, &call_sbt, 320, 200, 1);
});
sourcepub fn set_stack_size(&self, pipeline_stack_size: u32) -> &Self
pub fn set_stack_size(&self, pipeline_stack_size: u32) -> &Self
Set the stack size dynamically for a ray trace pipeline.
See
RayTracePipelineInfo::dynamic_stack_size
and
vkCmdSetRayTracingPipelineStackSizeKHR
.
sourcepub fn trace_rays(
&self,
raygen_shader_binding_table: &StridedDeviceAddressRegionKHR,
miss_shader_binding_table: &StridedDeviceAddressRegionKHR,
hit_shader_binding_table: &StridedDeviceAddressRegionKHR,
callable_shader_binding_table: &StridedDeviceAddressRegionKHR,
width: u32,
height: u32,
depth: u32
) -> &Self
pub fn trace_rays( &self, raygen_shader_binding_table: &StridedDeviceAddressRegionKHR, miss_shader_binding_table: &StridedDeviceAddressRegionKHR, hit_shader_binding_table: &StridedDeviceAddressRegionKHR, callable_shader_binding_table: &StridedDeviceAddressRegionKHR, width: u32, height: u32, depth: u32 ) -> &Self
Ray traces using the currently-bound RayTracePipeline
and the given shader binding
tables.
Shader binding tables must be constructed according to this example.
§Examples
Basic usage:
my_graph.begin_pass("draw a cornell box")
.bind_pipeline(&my_ray_trace_pipeline)
.record_ray_trace(move |ray_trace, bindings| {
ray_trace.trace_rays(&rgen_sbt, &hit_sbt, &miss_sbt, &call_sbt, 320, 200, 1);
});
sourcepub fn trace_rays_indirect(
&self,
raygen_shader_binding_table: &StridedDeviceAddressRegionKHR,
miss_shader_binding_table: &StridedDeviceAddressRegionKHR,
hit_shader_binding_table: &StridedDeviceAddressRegionKHR,
callable_shader_binding_table: &StridedDeviceAddressRegionKHR,
indirect_device_address: DeviceAddress
) -> &Self
pub fn trace_rays_indirect( &self, raygen_shader_binding_table: &StridedDeviceAddressRegionKHR, miss_shader_binding_table: &StridedDeviceAddressRegionKHR, hit_shader_binding_table: &StridedDeviceAddressRegionKHR, callable_shader_binding_table: &StridedDeviceAddressRegionKHR, indirect_device_address: DeviceAddress ) -> &Self
Ray traces using the currently-bound RayTracePipeline
and the given shader binding
tables.
indirect_device_address
is a buffer device address which is a pointer to a
vk::TraceRaysIndirectCommandKHR
structure containing the trace ray parameters.
Auto Trait Implementations§
impl<'a> RefUnwindSafe for RayTrace<'a>
impl<'a> Send for RayTrace<'a>
impl<'a> Sync for RayTrace<'a>
impl<'a> Unpin for RayTrace<'a>
impl<'a> UnwindSafe for RayTrace<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.