Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

52
vendor/profiling/src/empty_impl.rs vendored Normal file
View File

@@ -0,0 +1,52 @@
/// Opens a scope. Two variants:
/// - profiling::scope!(name: &str) - Opens a scope with the given name
/// - profiling::scope!(name: &str, data: &str) - Opens a scope with the given name and an extra
/// datafield. Details of this depend on the API, but it should be a &str. If the extra data is
/// named, it will be named "tag". Some APIs support adding more data (for example, `optic::tag!`)
///
/// ```
/// profiling::scope!("outer");
/// for _ in 0..10 {
/// profiling::scope!("inner", format!("iteration {}").as_str());
/// }
/// ```
#[macro_export]
macro_rules! scope {
($name:expr) => {};
($name:expr, $data:expr) => {};
}
/// Opens a scope automatically named after the current function.
/// - profiling::function_scope!() - Opens a scope with the current function name
/// - profiling::function_scope!(data: &str) - Opens a scope with the current function name and an extra data field.
///
/// ```
/// fn function_a(){
/// profiling::function_scope!();
/// }
/// fn function_b(iteration: u32){
/// profiling::function_scope!(format!("iteration {}", iteration).as_str());
/// }
/// ```
#[macro_export]
macro_rules! function_scope {
() => {};
($data:expr) => {};
}
/// Registers a thread with the profiler API(s). This is usually setting a name for the thread.
/// Two variants:
/// - register_thread!() - Tries to get the name of the thread, or an ID if no name is set
/// - register_thread!(name: &str) - Registers the thread using the given name
#[macro_export]
macro_rules! register_thread {
() => {};
($name:expr) => {};
}
/// Finishes the frame. This isn't strictly necessary for some kinds of applications but a pretty
/// normal thing to track in games.
#[macro_export]
macro_rules! finish_frame {
() => {};
}

167
vendor/profiling/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,167 @@
//
// To use this library, enable one of the feature flags. Each backend implementation provides the
// exact same interface. Only one may be active at a time.
//
// This library itself does not require std, but if any features are enabled, the upstream crate
// likely will bring in std.
#![no_std]
/// Proc macro for creating a scope around each function under struct impl block
/// ```
/// pub struct Foo {
/// // some data...
/// }
///
/// #[profiling::all_functions]
/// impl Foo {
/// pub fn do_something(&self) {
/// // some code...
/// }
///
/// pub fn do_otherthing(&self) {
/// // some code...
/// }
/// }
/// ```
///
/// The following will generate the same code
///
/// ```
/// pub struct Foo {
/// // some data...
/// }
///
/// impl Foo {
/// #[profiling::function]
/// pub fn do_something(&self) {
/// // some code...
/// }
///
/// #[profiling::function]
/// pub fn do_otherthing(&self) {
/// // some code...
/// }
/// }
/// ```
#[cfg(feature = "procmacros")]
pub use profiling_procmacros::all_functions;
/// Proc macro for creating a scope around the function, using the name of the function for the
/// scope's name
///
/// This must be done as a proc macro because tracing requires a const string
///
/// ```
/// #[profiling::function]
/// fn my_function() {
///
/// }
/// ```
#[cfg(feature = "procmacros")]
pub use profiling_procmacros::function;
/// Proc macro to skip the auto_impl for the function
/// ```
/// pub struct Foo {
/// // some data...
/// }
///
/// #[profiling::all_functions]
/// impl Foo {
/// pub fn do_something(&self) {
/// // some code...
/// }
///
/// #[profiling::skip]
/// pub fn do_otherthing(&self) {
/// // some code...
/// }
/// }
/// ```
///
/// The following will generate the same code
///
/// ```
/// pub struct Foo {
/// // some data...
/// }
///
/// impl Foo {
/// #[profiling::function]
/// pub fn do_something(&self) {
/// // some code...
/// }
///
/// pub fn do_otherthing(&self) {
/// // some code...
/// }
/// }
/// ```
#[cfg(feature = "procmacros")]
pub use profiling_procmacros::skip;
#[cfg(feature = "profile-with-puffin")]
pub use puffin;
#[cfg(feature = "profile-with-puffin")]
mod puffin_impl;
#[cfg(feature = "profile-with-puffin")]
#[allow(unused_imports)]
pub use puffin_impl::*;
#[cfg(feature = "profile-with-optick")]
pub use optick;
#[cfg(feature = "profile-with-optick")]
mod optick_impl;
#[cfg(feature = "profile-with-optick")]
#[allow(unused_imports)]
pub use optick_impl::*;
#[cfg(feature = "profile-with-superluminal")]
pub use superluminal_perf;
#[cfg(feature = "profile-with-superluminal")]
mod superluminal_impl;
#[cfg(feature = "profile-with-superluminal")]
#[allow(unused_imports)]
pub use superluminal_impl::*;
#[cfg(feature = "profile-with-tracing")]
pub use tracing;
#[cfg(feature = "profile-with-tracing")]
mod tracing_impl;
#[cfg(feature = "profile-with-tracing")]
#[allow(unused_imports)]
pub use tracing_impl::*;
#[cfg(feature = "profile-with-tracy")]
pub use tracy_client;
#[cfg(feature = "profile-with-tracy")]
mod tracy_impl;
#[cfg(feature = "profile-with-tracy")]
#[allow(unused_imports)]
pub use tracy_impl::*;
#[cfg(feature = "type-check")]
mod type_check_impl;
#[cfg(feature = "type-check")]
#[allow(unused_imports)]
pub use type_check_impl::*;
#[cfg(not(any(
feature = "profile-with-puffin",
feature = "profile-with-optick",
feature = "profile-with-superluminal",
feature = "profile-with-tracing",
feature = "profile-with-tracy",
feature = "type-check"
)))]
mod empty_impl;
#[cfg(not(any(
feature = "profile-with-puffin",
feature = "profile-with-optick",
feature = "profile-with-superluminal",
feature = "profile-with-tracing",
feature = "profile-with-tracy",
feature = "type-check"
)))]
#[allow(unused_imports)]
pub use empty_impl::*;

46
vendor/profiling/src/optick_impl.rs vendored Normal file
View File

@@ -0,0 +1,46 @@
#[macro_export]
macro_rules! scope {
($name:expr) => {
$crate::optick::event!($name);
};
// NOTE: I've not been able to get attached data to work with optick
($name:expr, $data:expr) => {
$crate::optick::event!($name);
$crate::optick::tag!("tag", $data);
};
}
#[macro_export]
macro_rules! function_scope {
() => {
$crate::optick::event!();
};
($data:expr) => {
$crate::optick::event!();
$crate::optick::tag!("tag", $data);
};
}
#[macro_export]
macro_rules! register_thread {
() => {
let thread_name = std::thread::current()
.name()
.map(|x| x.to_string())
.unwrap_or_else(|| format!("Thread {:?}", std::thread::current().id()));
$crate::register_thread!(&thread_name);
};
($name:expr) => {
$crate::optick::register_thread($name);
};
}
/// Finishes the frame. This isn't strictly necessary for some kinds of applications but a pretty
/// normal thing to track in games.
#[macro_export]
macro_rules! finish_frame {
() => {
$crate::optick::next_frame();
};
}

36
vendor/profiling/src/puffin_impl.rs vendored Normal file
View File

@@ -0,0 +1,36 @@
#[macro_export]
macro_rules! scope {
($name:expr) => {
$crate::puffin::profile_scope!($name);
};
($name:expr, $data:expr) => {
$crate::puffin::profile_scope!($name, $data);
};
}
#[macro_export]
macro_rules! function_scope {
() => {
$crate::puffin::profile_function!();
};
($data:expr) => {
$crate::puffin::profile_function!($data);
};
}
#[macro_export]
macro_rules! register_thread {
() => {};
($name:expr) => {
// puffin uses the thread name
};
}
/// Finishes the frame. This isn't strictly necessary for some kinds of applications but a pretty
/// normal thing to track in games.
#[macro_export]
macro_rules! finish_frame {
() => {
$crate::puffin::GlobalProfiler::lock().new_frame();
};
}

View File

@@ -0,0 +1,85 @@
#[macro_export]
macro_rules! scope {
($name:expr) => {
let _superluminal_guard = $crate::superluminal::SuperluminalGuard::new($name);
};
($name:expr, $data:expr) => {
let _superluminal_guard =
$crate::superluminal::SuperluminalGuard::new_with_data($name, $data);
};
}
#[macro_export]
macro_rules! function_scope {
() => {
let _function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
$crate::scope!(_function_name);
};
($data:expr) => {
let _function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
$crate::scope!(_function_name, $data);
};
}
#[macro_export]
macro_rules! register_thread {
() => {
let thread_name = std::thread::current()
.name()
.map(|x| x.to_string())
.unwrap_or_else(|| format!("Thread {:?}", std::thread::current().id()));
$crate::register_thread!(&thread_name);
};
($name:expr) => {
$crate::superluminal_perf::set_current_thread_name($name);
};
}
#[macro_export]
macro_rules! finish_frame {
() => {
// superluminal does not have a frame end function
};
}
//
// RAII wrappers to support superluminal. These are public as they need to be callable from macros
// but are not intended for direct use.
//
#[doc(hidden)]
pub mod superluminal {
pub struct SuperluminalGuard;
// 0xFFFFFFFF means "use default color"
const DEFAULT_SUPERLUMINAL_COLOR: u32 = 0xFFFFFFFF;
impl SuperluminalGuard {
pub fn new(name: &'static str) -> Self {
superluminal_perf::begin_event(name);
SuperluminalGuard
}
pub fn new_with_data(
name: &'static str,
data: &str,
) -> Self {
superluminal_perf::begin_event_with_data(name, data, DEFAULT_SUPERLUMINAL_COLOR);
SuperluminalGuard
}
}
impl Drop for SuperluminalGuard {
fn drop(&mut self) {
superluminal_perf::end_event();
}
}
}

57
vendor/profiling/src/tracing_impl.rs vendored Normal file
View File

@@ -0,0 +1,57 @@
#[macro_export]
macro_rules! scope {
($name:expr) => {
let _span = $crate::tracing::span!($crate::tracing::Level::INFO, $name);
let _span_entered = _span.enter();
};
($name:expr, $data:expr) => {
let _span = $crate::tracing::span!($crate::tracing::Level::INFO, $name, tag = $data);
let _span_entered = _span.enter();
};
}
#[macro_export]
macro_rules! function_scope {
() => {
let function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
let _span = $crate::tracing::span!(
$crate::tracing::Level::INFO,
"function_scope",
"{}",
function_name
);
let _span_entered = _span.enter();
};
($data:expr) => {
let function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
let _span = $crate::tracing::span!(
$crate::tracing::Level::INFO,
"function_scope",
tag = $data,
"{}",
function_name
);
let _span_entered = _span.enter();
};
}
#[macro_export]
macro_rules! register_thread {
() => {};
($name:expr) => {};
}
#[macro_export]
macro_rules! finish_frame {
() => {
$crate::tracing::event!($crate::tracing::Level::INFO, tracy.frame_mark = true);
};
}

82
vendor/profiling/src/tracy_impl.rs vendored Normal file
View File

@@ -0,0 +1,82 @@
#[macro_export]
macro_rules! scope {
// Note: literal patterns provided as an optimization since they can skip an allocation.
($name:literal) => {
// Note: callstack_depth is 0 since this has significant overhead
let _tracy_span = $crate::tracy_client::span!($name, 0);
};
($name:literal, $data:expr) => {
// Note: callstack_depth is 0 since this has significant overhead
let _tracy_span = $crate::tracy_client::span!($name, 0);
_tracy_span.emit_text($data);
};
($name:expr) => {
let _function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
let _tracy_span = $crate::tracy_client::Client::running()
.expect("scope! without a running tracy_client::Client")
// Note: callstack_depth is 0 since this has significant overhead
.span_alloc(Some($name), _function_name, file!(), line!(), 0);
};
($name:expr, $data:expr) => {
let _function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
let _tracy_span = $crate::tracy_client::Client::running()
.expect("scope! without a running tracy_client::Client")
// Note: callstack_depth is 0 since this has significant overhead
.span_alloc(Some($name), _function_name, file!(), line!(), 0);
_tracy_span.emit_text($data);
};
}
#[macro_export]
macro_rules! function_scope {
() => {
let _tracy_span = $crate::tracy_client::span!();
};
($data:expr) => {
let _location = $crate::tracy_client::span_location!();
let _tracy_span = $crate::tracy_client::Client::running()
.expect("function_scope! without a running tracy_client::Client")
.span(_location, 0);
_tracy_span.emit_text($data);
};
}
/// Registers a thread with the profiler API(s). This is usually setting a name for the thread.
/// Two variants:
/// - register_thread!() - Tries to get the name of the thread, or an ID if no name is set
/// - register_thread!(name: &str) - Registers the thread using the given name
#[macro_export]
macro_rules! register_thread {
() => {
let thread_name = std::thread::current()
.name()
.map(|x| x.to_string())
.unwrap_or_else(|| format!("Thread {:?}", std::thread::current().id()));
$crate::register_thread!(&thread_name);
};
($name:expr) => {
$crate::tracy_client::Client::running()
.expect("register_thread! without a running tracy_client::Client")
.set_thread_name($name);
};
}
/// Finishes the frame. This isn't strictly necessary for some kinds of applications but a pretty
/// normal thing to track in games.
#[macro_export]
macro_rules! finish_frame {
() => {
$crate::tracy_client::Client::running()
.expect("finish_frame! without a running tracy_client::Client")
.frame_mark();
};
}

33
vendor/profiling/src/type_check_impl.rs vendored Normal file
View File

@@ -0,0 +1,33 @@
// This backend is intended to force type checking
#[macro_export]
macro_rules! scope {
($name:expr) => {
let _: &str = $name;
};
($name:expr, $data:expr) => {
let _: &str = $name;
let _: &str = $data;
};
}
#[macro_export]
macro_rules! function_scope {
() => {};
($data:expr) => {
let _: &str = $data;
};
}
#[macro_export]
macro_rules! register_thread {
() => {};
($name:expr) => {
let _: &str = $name;
};
}
#[macro_export]
macro_rules! finish_frame {
() => {};
}