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>

source

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);
        });
source

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);
        });
source

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.

source

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);
        });
source

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.

See vkCmdTraceRaysIndirectKHR.

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more