Struct tracy_client::GpuContext
source · 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
impl GpuContext
sourcepub fn span(
&self,
span_location: &'static SpanLocation,
) -> Result<GpuSpan, GpuSpanCreationError>
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.
sourcepub fn span_alloc(
&self,
name: &str,
function: &str,
file: &str,
line: u32,
) -> Result<GpuSpan, GpuSpanCreationError>
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
impl Clone for GpuContext
source§fn clone(&self) -> GpuContext
fn clone(&self) -> GpuContext
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for GpuContext
impl RefUnwindSafe for GpuContext
impl Send for GpuContext
impl Sync for GpuContext
impl Unpin for GpuContext
impl UnwindSafe for GpuContext
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)