bombomby / optick

C++ Profiler For Games
https://optick.dev
MIT License
2.95k stars 296 forks source link

Improvements to the C API #130

Closed Honeybunch closed 6 months ago

Honeybunch commented 3 years ago

I've been finding myself in the situation where I'm working with C code and I really want to instrument it with Optick. However there were some features in the C API that I thought could be improved. I also wanted to create some sort of document of how the C API is currently intended to be used. Just to make it a bit easier for people to grok in the future.

I made a fairly substantial change to OptickAPI_CreateEventDescription which I imagine may be unpopular. Using null-terminated C strings felt a bit more convenient for this method. But if optick maintainers consider this code-smell I can revert this change to the API.

Another decision that may be contentious in this change is the way I implemented the Categories for the C API. C has no way to make a 64-bit enum so I had to settle for crafting static 64-bit values with macros like some sort of caveman. I imagine the idea of having to maintain default categories in two different source files feels like a fragile idea but I couldn't come up with a better one.

RobertLemmens commented 2 years ago

Ive been using your C branch and it works like a charm. Had troubles getting the master capi to work on my project. Hope these changes make it in.

Honeybunch commented 6 months ago

Sorry I haven't had time to tackle this and I don't know if I'll be able to get back to it so I'm closing this.