pub struct GpuContext { /* private fields */ }
Expand description

Context for creating gpu spans.

Generally corresponds to a single hardware queue.

The flow of creating and using gpu context generally looks like this:

// The period of the gpu clock in nanoseconds, as provided by your GPU api.
// This value corresponds to 1GHz.
let period: f32 = 1_000_000_000.0;

// GPU API: Record writing a timestamp and resolve that to a mappable buffer.
// GPU API: Submit the command buffer writing the timestamp.
// GPU API: Immediately block until the submission is finished.
// GPU API: Map buffer, get timestamp value.
let starting_timestamp: i64 = /* whatever you get from this timestamp */ 0;

// Create the gpu context
let gpu_context = client.new_gpu_context(
    Some("MyContext"),
    tracy_client::GpuContextType::Vulkan,
    starting_timestamp,
    period
).unwrap();

// Now you have some work that you want to time on the gpu.

// GPU API: Record writing a timestamp before the work.
let mut span = gpu_context.span_alloc("MyGpuSpan1", "My::Work", "myfile.rs", 12).unwrap();

// GPU API: Record work.

// GPU API: Record writing a timestamp after the work.
span.end_zone();

// Some time later, once the written timestamp values are available on the cpu.

// Consumes span.
span.upload_timestamp(starting_timestamp, ending_timestamp);

Implementations§

source§

impl GpuContext

source

pub fn span( &self, span_location: &'static SpanLocation ) -> Result<GpuSpan, GpuSpanCreationError>

Creates a new gpu span with the given source location.

This should be called right next to where you record the corresponding gpu timestamp. This allows tracy to correctly associate the cpu time with the gpu timestamp.

§Errors
  • If there are more than 32767 spans waiting for gpu data at once.
source

pub fn span_alloc( &self, name: &str, function: &str, file: &str, line: u32 ) -> Result<GpuSpan, GpuSpanCreationError>

Creates a new gpu span with the given name, function, file, and line.

This should be called right next to where you record the corresponding gpu timestamp. This allows tracy to correctly associate the cpu time with the gpu timestamp.

§Errors
  • If there are more than 32767 spans waiting for gpu data at once.

Trait Implementations§

source§

impl Clone for GpuContext

source§

fn clone(&self) -> GpuContext

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.