floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.94k stars 488 forks source link

set metal resource labels - sokol_gfx.h #889

Closed danielchasehooper closed 1 year ago

danielchasehooper commented 1 year ago

It would be useful if all the .label strings were passed on to the underlying MTLResource's label property, for easier debugging in the Metal Debugger.

floooh commented 1 year ago

Yes good idea, question is: only in debug mode, or also for release? I tend towards 'only in debug mode'.

floooh commented 1 year ago

Ok, I'll only do it in debug mode. I also implemented sg_push/pop_debug_group(), but only inside a render pass (because these are MTLCommandEncoder methods in Metal).

In some cases I'm adding a post-fix to the label (where sokol-gfx may create multiple Metal objects for a single sokol-gfx object). For the texcube-sapp it looks like this:

Screenshot 2023-09-17 at 16 26 48

PS: also make sure to run your sokol-gfx frame inside an @autoreleasepool, not sure if I have mentioned that anywhere (sokol_app.h does this automatically).

I'll put the changes into a PR and close this ticket when merged.

floooh commented 1 year ago

PR: https://github.com/floooh/sokol/pull/890

floooh commented 1 year ago

Ok, fixed in a4d1119d09c3f1a54f851d9af32e974ab2a56a2b

danielchasehooper commented 1 year ago

Awesome! Thank you! I was also thinking only in debug mode.