Reuse existing scope ids in register_user_scopes#269
Reuse existing scope ids in register_user_scopes#269emilk merged 1 commit intoEmbarkStudios:mainfrom
Conversation
|
See Wumpf/wgpu-profiler#104 for what motivated this pull request. |
|
On a side note, this is out of scope for this PR and probably for puffin as well, but since the GPU timings are available late, the current solution is to add another puffin profiler to app using gpu timings with puffin. Is there a way to retrospectively add scopes to a previous frame or would that be too much of a change in design / not the puffin philosophy? |
Isn't this a breaking change? :/ |
|
hmmmmmm I suppose technically it is since the returned ids are different |
Checklist
Description of Changes
Currently,
GlobalProfiler::register_user_scopesrequires users to track the scopes details to avoid bad memory leaking. This is effectively asking the users to keep their ownScopeCollectionwhen the data is already stored internally.I'm aware that the
GlobalProfilerscope_collectionis private and the design is here intentionally but the comment mentions the frame views and, as far as I know, external applications can't create frames without first creating the ids.To make the api nicer for external applications, I make
register_user_scopesfirst check if the scope name is already in the collection, and only create a new id if this is the first time encountering the scope label. Another solution would be to make the scope collection accessible (read only) from outside.Note: I'm not super familiar with the puffin codebase and overall architecture, I might be missing some subtleties.