Refcount all GPU resources
Right now, only pl_buf_poll
is refcounted, but there are a number of reasons it would be beneficial to extend this refcounting to every object type:
- It would allow us to trivially write
pl_tex_poll
in the same way we currently havepl_buf_poll
, which may help for interop with APIs that don't support semaphores. - It would allow us to free GPU resources as early as possible, rather than deferring the destruction to the latest command. By having e.g.
pl_tex_destroy
just deref thepl_tex
, it will get freed automatically whenever no more commands use it. - It would allow us to move away from the assumption that command buffers can be sequentially ordered, i.e. moving towards a DAG representation of the command queues in the long-term. (With a refcount, the order of dereferencing does not matter)