Skip to content

Commit

Permalink
Bug 1641704 - vendor tracy-rs 0.1.1 r=gw
Browse files Browse the repository at this point in the history
  • Loading branch information
bpeersmoz committed May 29, 2020
1 parent a4568d4 commit f41b9eb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion third_party/rust/tracy-rs/.cargo-checksum.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"files":{"Cargo.toml":"1a5ee82b9780670fd91717f2256cea4a2dec911c00d262bf5c53e2c704d50e80","LICENSE":"d82f358a1e02cb205b9a29ada979df5c7a315a29cc73e58f557ae4f33bfd1777","README.md":"c694e1a34230f1b965713ca41df396314025b103cde1acbfc9c168932b59e548","src/disabled.rs":"0f6cd68e22275fd03c0e3c57934f1602700b24806cc1451c4a1ced0ab791ab6b","src/lib.rs":"f6caf42bdb534baa29996e384c79f28b6f462b68cd7ab2bd0f968c28f5612b7a","src/profiler.rs":"bf3673bef9e56dd2d8520cc8b6193036d43a9c3a8e115d3df104c381f4505bec"},"package":"e3aa118469b61af5fead107a4882dc4661a05591b6653bbc546c1c8bbc181047"}
{"files":{"Cargo.toml":"5b7632de436d52dbb8011c64eddaacceda6c6558536820d06b647569802e9f19","LICENSE":"d82f358a1e02cb205b9a29ada979df5c7a315a29cc73e58f557ae4f33bfd1777","README.md":"c694e1a34230f1b965713ca41df396314025b103cde1acbfc9c168932b59e548","src/disabled.rs":"22a64e44ce27656217951a6306e312c4e1288daff8871a426ac07aa13f1408ec","src/lib.rs":"f6caf42bdb534baa29996e384c79f28b6f462b68cd7ab2bd0f968c28f5612b7a","src/profiler.rs":"59992178392aaa09879e4830eaf5f005fe0d24f2163382f56f4df779994f3110"},"package":"dbbb439715d4c258415c7cbf137be32a4f54f7348724076145ede565ee2142e8"}
2 changes: 1 addition & 1 deletion third_party/rust/tracy-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "tracy-rs"
version = "0.1.0"
version = "0.1.1"
authors = ["Glenn Watson <[email protected]>"]
description = "Rust bindings for the tracy realtime profiler"
license = "MPL-2.0"
Expand Down
5 changes: 5 additions & 0 deletions third_party/rust/tracy-rs/src/disabled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ macro_rules! tracy_end_frame {
($name:expr) => {}
}

#[macro_export]
macro_rules! tracy_plot {
($name:expr, $value:expr) => {}
}

pub unsafe fn load(_: &str) -> bool {
println!("Can't load the tracy profiler unless enable_profiler feature is enabled!");
false
Expand Down
13 changes: 13 additions & 0 deletions third_party/rust/tracy-rs/src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ extern "C" fn unimpl_zone_begin(_: *const SourceLocation, _: i32) -> ZoneContext
extern "C" fn unimpl_zone_end(_: ZoneContext) {}
extern "C" fn unimpl_zone_text(_: ZoneContext, _: *const u8, _: usize) {}

extern "C" fn unimpl_plot(_: *const u8, _: f64) {}

// Function pointers to the tracy API functions (if loaded), or the no-op functions above.
pub static mut MARK_FRAME: extern "C" fn(name: *const u8) = unimpl_mark_frame;
pub static mut MARK_FRAME_START: extern "C" fn(name: *const u8) = unimpl_mark_frame_start;
pub static mut MARK_FRAME_END: extern "C" fn(name: *const u8) = unimpl_mark_frame_end;
pub static mut EMIT_ZONE_BEGIN: extern "C" fn(srcloc: *const SourceLocation, active: i32) -> ZoneContext = unimpl_zone_begin;
pub static mut EMIT_ZONE_END: extern "C" fn(ctx: ZoneContext) = unimpl_zone_end;
pub static mut EMIT_ZONE_TEXT: extern "C" fn(ctx: ZoneContext, txt: *const u8, size: usize) = unimpl_zone_text;
pub static mut EMIT_PLOT: extern "C" fn(name: *const u8, val: f64) = unimpl_plot;

// Load the tracy library, and get function pointers. This is unsafe since:
// - It must not be called while other threads are calling the functions.
Expand All @@ -57,6 +60,7 @@ pub unsafe fn load(path: &str) -> bool {
EMIT_ZONE_BEGIN = lib.sym("___tracy_emit_zone_begin\0").unwrap();
EMIT_ZONE_END = lib.sym("___tracy_emit_zone_end\0").unwrap();
EMIT_ZONE_TEXT = lib.sym("___tracy_emit_zone_text\0").unwrap();
EMIT_PLOT = lib.sym("___tracy_emit_plot\0").unwrap();

true
}
Expand Down Expand Up @@ -137,6 +141,15 @@ macro_rules! tracy_end_frame {
}
}

#[macro_export]
macro_rules! tracy_plot {
($name:expr, $value:expr) => {
unsafe {
$crate::profiler::EMIT_PLOT(concat!($name, "\0").as_ptr(), $value)
}
}
}

// Provide a name for this thread to the profiler
pub fn register_thread_with_profiler(_: String) {
// TODO(gw): Add support for passing this to the tracy api
Expand Down

0 comments on commit f41b9eb

Please sign in to comment.