mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1622327. Add support for adding profiling event markers to WebRender. r=kvark
I plan on using this to add texture cache reallocation events. Differential Revision: https://phabricator.services.mozilla.com/D66792 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e938695219
commit
68bc5d8e20
@ -72,6 +72,14 @@ void gecko_profiler_end_marker(const char* name) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void gecko_profiler_event_marker(const char* name) {
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
profiler_tracing_marker("WebRender", name,
|
||||
JS::ProfilingCategoryPair::GRAPHICS,
|
||||
TRACING_EVENT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void gecko_profiler_add_text_marker(const char* name, const char* text_bytes,
|
||||
size_t text_len, uint64_t microseconds) {
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
|
@ -819,6 +819,7 @@ pub unsafe extern "C" fn wr_renderer_flush_pipeline_info(renderer: &mut Renderer
|
||||
extern "C" {
|
||||
pub fn gecko_profiler_start_marker(name: *const c_char);
|
||||
pub fn gecko_profiler_end_marker(name: *const c_char);
|
||||
pub fn gecko_profiler_event_marker(name: *const c_char);
|
||||
pub fn gecko_profiler_add_text_marker(
|
||||
name: *const c_char,
|
||||
text_bytes: *const c_char,
|
||||
@ -845,6 +846,12 @@ impl ProfilerHooks for GeckoProfilerHooks {
|
||||
}
|
||||
}
|
||||
|
||||
fn event_marker(&self, label: &CStr) {
|
||||
unsafe {
|
||||
gecko_profiler_event_marker(label.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
fn add_text_marker(&self, label: &CStr, text: &str, duration: Duration) {
|
||||
unsafe {
|
||||
// NB: This can be as_micros() once we require Rust 1.33.
|
||||
|
@ -33,6 +33,7 @@ void gecko_profiler_unregister_thread();
|
||||
|
||||
void gecko_profiler_start_marker(const char* name);
|
||||
void gecko_profiler_end_marker(const char* name);
|
||||
void gecko_profiler_event_marker(const char* name);
|
||||
void gecko_profiler_add_text_marker(const char* name, const char* text_ptr,
|
||||
size_t text_len, uint64_t microseconds);
|
||||
bool gecko_profiler_thread_is_being_profiled();
|
||||
|
@ -82,6 +82,10 @@ pub trait ProfilerHooks : Send + Sync {
|
||||
/// be a C string (null terminated).
|
||||
fn end_marker(&self, label: &CStr);
|
||||
|
||||
/// Called to mark an event happening. The label must
|
||||
/// be a C string (null terminated).
|
||||
fn event_marker(&self, label: &CStr);
|
||||
|
||||
/// Called with a duration to indicate a text marker that just ended. Text
|
||||
/// markers allow different types of entries to be recorded on the same row
|
||||
/// in the timeline, by adding labels to the entry.
|
||||
@ -123,6 +127,15 @@ pub fn add_text_marker(label: &CStr, text: &str, duration: Duration) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Records a marker of the given duration that just ended.
|
||||
pub fn add_event_marker(label: &CStr) {
|
||||
unsafe {
|
||||
if let Some(ref hooks) = PROFILER_HOOKS {
|
||||
hooks.event_marker(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the current thread is being profiled.
|
||||
pub fn thread_is_being_profiled() -> bool {
|
||||
unsafe {
|
||||
|
Loading…
Reference in New Issue
Block a user