Skip to content

Using RenderDoc as a Global #79

@cwfitzgerald

Description

@cwfitzgerald

When I first started using this crate, I thought the easiest way to use it was to throw it in a once_cell::sync::Lazy and then call it from in there, that way the DLL only gets loaded once, and only if I actually use it, so if I never use it it never gets loaded.

I noticed that because RenderDoc is neither Send nor Sync it's impossible to put it in a global at all, even behind a mutex. From what I can tell the renderdoc api requires that some things are single threaded, but not necessarily accessed from the same thread. This should, in theory, allow it to be marked Send, so it could be put globally behind a mutex.

With clone gone, it shouldn't be possible to get more than one handle to renderdoc at a time, which would mean that I believe it would be safe to mark it as Send. I don't know if there are other confounding factors though.

In the mean time, I was able to still use it by creating a new RenderDoc instance every time I needed something done in renderdoc, but this is clunky, and I'd only imagine, slow. I can't store this in any of my state (my renderer is multithreaded behind Arcs and Mutexes) because I need it to all be at least Send.

Besides this comparatively minor issue, things work well, thank you for making these bindings!

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions