|
| 1 | +/* |
| 2 | + * Pulled from Tracey profiler PR |
| 3 | + * @see https://github.com/HaxeFoundation/haxe/pull/11772 |
| 4 | + */ |
| 5 | + |
| 6 | +package cpp.vm.tracy; |
| 7 | + |
| 8 | +#if (!HXCPP_TRACY) |
| 9 | +#error "This class cannot be used without -D HXCPP_TRACY" |
| 10 | +#end |
| 11 | +enum abstract PlotFormatType(cpp.UInt8) from cpp.UInt8 to cpp.UInt8 |
| 12 | +{ |
| 13 | + var Number = 0; |
| 14 | + var Memory = 1; |
| 15 | + var Percentage = 2; |
| 16 | +} |
| 17 | + |
| 18 | +@:include('hx/TelemetryTracy.h') |
| 19 | +extern class Native_TracyProfiler |
| 20 | +{ |
| 21 | + /** |
| 22 | + Mark a frame. Call this at the end of each frame loop. |
| 23 | + **/ |
| 24 | + @:native('::__hxcpp_tracy_framemark') |
| 25 | + public static function frameMark():Void; |
| 26 | + |
| 27 | + /** |
| 28 | + Print a message into Tracy's log. |
| 29 | + **/ |
| 30 | + @:native('::__hxcpp_tracy_message') |
| 31 | + public static function message(_msg:String, ?_color:Int = 0x000000):Void; |
| 32 | + |
| 33 | + /** |
| 34 | + Tracy can collect additional information about the profiled application, |
| 35 | + which will be available in the trace description. |
| 36 | + This can include data such as the source repository revision, |
| 37 | + the application’s environment (dev/prod), etc. |
| 38 | + **/ |
| 39 | + @:native('::__hxcpp_tracy_message_app_info') |
| 40 | + public static function messageAppInfo(_info:String):Void; |
| 41 | + |
| 42 | + /** |
| 43 | + Plot a named value to tracy. This will generate a graph in the profiler for you. |
| 44 | + **/ |
| 45 | + @:native('::__hxcpp_tracy_plot') |
| 46 | + public static function plot(_name:String, _val:cpp.Float32):Void; |
| 47 | + |
| 48 | + /** |
| 49 | + Configure how values are plotted and displayed. |
| 50 | + **/ |
| 51 | + @:native('::__hxcpp_tracy_plot_config') |
| 52 | + public static function plotConfig(_name:String, _format:PlotFormatType, ?_step:Bool = false, ?_fill:Bool = false, ?_color:Int = 0x000000):Void; |
| 53 | + |
| 54 | + /** |
| 55 | + Set a name for the current thread this function is called in. Supply an optional groupHint so threads become grouped in Tracy's UI. |
| 56 | + **/ |
| 57 | + @:native('::__hxcpp_tracy_set_thread_name_and_group') |
| 58 | + public static function setThreadName(_name:String, ?_groupHint:Int = 1):Void; |
| 59 | + |
| 60 | + /** |
| 61 | + Create a custom named scoped zone in your code. |
| 62 | + **/ |
| 63 | + @:native('HXCPP_TRACY_ZONE') |
| 64 | + public static function zoneScoped(_name:String):Void; |
| 65 | +} |
| 66 | + |
| 67 | +#if (scriptable || cppia) |
| 68 | +class Cppia_TracyProfiler |
| 69 | +{ |
| 70 | + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.frameMark) |
| 71 | + public static function frameMark() |
| 72 | + Native_TracyProfiler.frameMark(); |
| 73 | + |
| 74 | + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.message) |
| 75 | + public static function message(_msg:String, ?_color:Int = 0x000000) |
| 76 | + Native_TracyProfiler.message(_msg, _color); |
| 77 | + |
| 78 | + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.messageAppInfo) |
| 79 | + public static function messageAppInfo(_info:String) |
| 80 | + Native_TracyProfiler.messageAppInfo(_info); |
| 81 | + |
| 82 | + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.plot) |
| 83 | + public static function plot(_name:String, _val:Float) |
| 84 | + Native_TracyProfiler.plot(_name, _val); |
| 85 | + |
| 86 | + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.plotConfig) |
| 87 | + public static function plotConfig(_name:String, _format:PlotFormatType, ?_step:Bool = false, ?_fill:Bool = false, ?_color:Int = 0x000000) |
| 88 | + Native_TracyProfiler.plotConfig(_name, _format, _step, _fill, _color); |
| 89 | + |
| 90 | + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.setThreadName) |
| 91 | + public static function setThreadName(_name:String, ?_groupHint:Int = 1) |
| 92 | + Native_TracyProfiler.setThreadName(_name, _groupHint); |
| 93 | + |
| 94 | + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.zoneScoped) |
| 95 | + public static function zoneScoped(_name:String) |
| 96 | + Native_TracyProfiler.zoneScoped(_name); |
| 97 | +} |
| 98 | + |
| 99 | +typedef TracyProfiler = Cppia_TracyProfiler; |
| 100 | +#else |
| 101 | +typedef TracyProfiler = Native_TracyProfiler; |
| 102 | +#end |
0 commit comments