authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-01-08 10:30:08-05:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-02-09 02:24:56-05:00
log2961cf1dac78df07ba14bfee1d3dc1ef94a778c5
tree3a3673c1798b1ffcd18d76b528bce1658c79bfa6
parentf1b255402377b41e47cec65b4dbc2633e1dd7b83

tracy: update API


2 files changed, 29 insertions(+), 33 deletions(-)

build.zig+1-3
...@@ -371,10 +371,8 @@ pub fn build(b: *std.Build) !void {...@@ -371,10 +371,8 @@ pub fn build(b: *std.Build) !void {
371371
372 exe.root_module.addIncludePath(.{ .cwd_relative = tracy_path });372 exe.root_module.addIncludePath(.{ .cwd_relative = tracy_path });
373 exe.root_module.addCSourceFile(.{ .file = .{ .cwd_relative = client_cpp }, .flags = tracy_c_flags });373 exe.root_module.addCSourceFile(.{ .file = .{ .cwd_relative = client_cpp }, .flags = tracy_c_flags });
374 if (!enable_llvm) {
375 exe.root_module.linkSystemLibrary("c++", .{ .use_pkg_config = .no });
376 }
377 exe.root_module.link_libc = true;374 exe.root_module.link_libc = true;
375 exe.root_module.link_libcpp = true;
378376
379 if (target.result.os.tag == .windows) {377 if (target.result.os.tag == .windows) {
380 exe.root_module.linkSystemLibrary("dbghelp", .{});378 exe.root_module.linkSystemLibrary("dbghelp", .{});
src/tracy.zig+28-30
...@@ -9,7 +9,7 @@ pub const callstack_depth = if (enable_callstack and build_options.tracy_callsta...@@ -9,7 +9,7 @@ pub const callstack_depth = if (enable_callstack and build_options.tracy_callsta
99
10const ___tracy_c_zone_context = extern struct {10const ___tracy_c_zone_context = extern struct {
11 id: u32,11 id: u32,
12 active: c_int,12 active: i32,
1313
14 pub inline fn end(self: @This()) void {14 pub inline fn end(self: @This()) void {
15 ___tracy_emit_zone_end(self);15 ___tracy_emit_zone_end(self);
...@@ -197,24 +197,22 @@ pub fn TracyAllocator(comptime name: ?[:0]const u8) type {...@@ -197,24 +197,22 @@ pub fn TracyAllocator(comptime name: ?[:0]const u8) type {
197197
198// This function only accepts comptime-known strings, see `messageCopy` for runtime strings198// This function only accepts comptime-known strings, see `messageCopy` for runtime strings
199pub inline fn message(comptime msg: [:0]const u8) void {199pub inline fn message(comptime msg: [:0]const u8) void {
200 if (!enable) return;200 messageColor(msg, 0);
201 ___tracy_emit_messageL(msg.ptr, if (enable_callstack) callstack_depth else 0);
202}201}
203202
204// This function only accepts comptime-known strings, see `messageColorCopy` for runtime strings203// This function only accepts comptime-known strings, see `messageColorCopy` for runtime strings
205pub inline fn messageColor(comptime msg: [:0]const u8, color: u32) void {204pub inline fn messageColor(comptime msg: [:0]const u8, color: u24) void {
206 if (!enable) return;205 if (!enable) return;
207 ___tracy_emit_messageLC(msg.ptr, color, if (enable_callstack) callstack_depth else 0);206 ___tracy_emit_logStringL(.Info, color, if (enable_callstack) callstack_depth else 0, msg.ptr);
208}207}
209208
210pub inline fn messageCopy(msg: []const u8) void {209pub inline fn messageCopy(msg: []const u8) void {
211 if (!enable) return;210 messageColorCopy(msg, 0);
212 ___tracy_emit_message(msg.ptr, msg.len, if (enable_callstack) callstack_depth else 0);
213}211}
214212
215pub inline fn messageColorCopy(msg: [:0]const u8, color: u32) void {213pub inline fn messageColorCopy(msg: []const u8, color: u24) void {
216 if (!enable) return;214 if (!enable) return;
217 ___tracy_emit_messageC(msg.ptr, msg.len, color, if (enable_callstack) callstack_depth else 0);215 ___tracy_emit_logString(.Info, color, if (enable_callstack) callstack_depth else 0, msg.len, msg.ptr);
218}216}
219217
220pub inline fn frameMark() void {218pub inline fn frameMark() void {
...@@ -293,32 +291,32 @@ inline fn freeNamed(ptr: [*]u8, comptime name: [:0]const u8) void {...@@ -293,32 +291,32 @@ inline fn freeNamed(ptr: [*]u8, comptime name: [:0]const u8) void {
293 }291 }
294}292}
295293
296extern fn ___tracy_emit_zone_begin(294pub const MessageSeverity = enum(i8) {
297 srcloc: *const ___tracy_source_location_data,295 Trace, // Broadly track variable states and events in the software program.
298 active: c_int,296 Debug, // Describes variable states and details about specific internal events in the software, that are useful for investigations.
299) ___tracy_c_zone_context;297 Info, // Describes normal events, which inform on the expected progress and state of your software.
300extern fn ___tracy_emit_zone_begin_callstack(298 Warning, // Describes potentially dangerous situations caused by unexpected events and states.
301 srcloc: *const ___tracy_source_location_data,299 Error, // Describes the occurance of unexpected behavior. Does not interrupt the execution of the software.
302 depth: c_int,300 Fatal, // Describes a critical event that will lead to a software failure/crash.
303 active: c_int,301};
304) ___tracy_c_zone_context;302
303extern fn ___tracy_emit_zone_begin(srcloc: *const ___tracy_source_location_data, active: i32) ___tracy_c_zone_context;
304extern fn ___tracy_emit_zone_begin_callstack(srcloc: *const ___tracy_source_location_data, depth: i32, active: i32) ___tracy_c_zone_context;
305extern fn ___tracy_emit_zone_text(ctx: ___tracy_c_zone_context, txt: [*]const u8, size: usize) void;305extern fn ___tracy_emit_zone_text(ctx: ___tracy_c_zone_context, txt: [*]const u8, size: usize) void;
306extern fn ___tracy_emit_zone_name(ctx: ___tracy_c_zone_context, txt: [*]const u8, size: usize) void;306extern fn ___tracy_emit_zone_name(ctx: ___tracy_c_zone_context, txt: [*]const u8, size: usize) void;
307extern fn ___tracy_emit_zone_color(ctx: ___tracy_c_zone_context, color: u32) void;307extern fn ___tracy_emit_zone_color(ctx: ___tracy_c_zone_context, color: u32) void;
308extern fn ___tracy_emit_zone_value(ctx: ___tracy_c_zone_context, value: u64) void;308extern fn ___tracy_emit_zone_value(ctx: ___tracy_c_zone_context, value: u64) void;
309extern fn ___tracy_emit_zone_end(ctx: ___tracy_c_zone_context) void;309extern fn ___tracy_emit_zone_end(ctx: ___tracy_c_zone_context) void;
310extern fn ___tracy_emit_memory_alloc(ptr: *const anyopaque, size: usize, secure: c_int) void;310extern fn ___tracy_emit_memory_alloc(ptr: *const anyopaque, size: usize, secure: i32) void;
311extern fn ___tracy_emit_memory_alloc_callstack(ptr: *const anyopaque, size: usize, depth: c_int, secure: c_int) void;311extern fn ___tracy_emit_memory_alloc_callstack(ptr: *const anyopaque, size: usize, depth: i32, secure: i32) void;
312extern fn ___tracy_emit_memory_free(ptr: *const anyopaque, secure: c_int) void;312extern fn ___tracy_emit_memory_free(ptr: *const anyopaque, secure: i32) void;
313extern fn ___tracy_emit_memory_free_callstack(ptr: *const anyopaque, depth: c_int, secure: c_int) void;313extern fn ___tracy_emit_memory_free_callstack(ptr: *const anyopaque, depth: i32, secure: i32) void;
314extern fn ___tracy_emit_memory_alloc_named(ptr: *const anyopaque, size: usize, secure: c_int, name: [*:0]const u8) void;314extern fn ___tracy_emit_memory_alloc_named(ptr: *const anyopaque, size: usize, secure: i32, name: [*:0]const u8) void;
315extern fn ___tracy_emit_memory_alloc_callstack_named(ptr: *const anyopaque, size: usize, depth: c_int, secure: c_int, name: [*:0]const u8) void;315extern fn ___tracy_emit_memory_alloc_callstack_named(ptr: *const anyopaque, size: usize, depth: i32, secure: i32, name: [*:0]const u8) void;
316extern fn ___tracy_emit_memory_free_named(ptr: *const anyopaque, secure: c_int, name: [*:0]const u8) void;316extern fn ___tracy_emit_memory_free_named(ptr: *const anyopaque, secure: i32, name: [*:0]const u8) void;
317extern fn ___tracy_emit_memory_free_callstack_named(ptr: *const anyopaque, depth: c_int, secure: c_int, name: [*:0]const u8) void;317extern fn ___tracy_emit_memory_free_callstack_named(ptr: *const anyopaque, depth: i32, secure: i32, name: [*:0]const u8) void;
318extern fn ___tracy_emit_message(txt: [*]const u8, size: usize, callstack: c_int) void;318extern fn ___tracy_emit_logString(severity: MessageSeverity, color: i32, callstack_depth: i32, size: usize, txt: [*]const u8) void;
319extern fn ___tracy_emit_messageL(txt: [*:0]const u8, callstack: c_int) void;319extern fn ___tracy_emit_logStringL(severity: MessageSeverity, color: i32, callstack_depth: i32, txt: [*:0]const u8) void;
320extern fn ___tracy_emit_messageC(txt: [*]const u8, size: usize, color: u32, callstack: c_int) void;
321extern fn ___tracy_emit_messageLC(txt: [*:0]const u8, color: u32, callstack: c_int) void;
322extern fn ___tracy_emit_frame_mark(name: ?[*:0]const u8) void;320extern fn ___tracy_emit_frame_mark(name: ?[*:0]const u8) void;
323321
324const ___tracy_source_location_data = extern struct {322const ___tracy_source_location_data = extern struct {