asahi: Lazily initialize batch state, fix cross-context races
The current batch tracking code is centered around a single context/thread, but the writer syncobj tracking leaks from our single-threaded utopia into the messy multithreaded world.
We only really care about that for post-facto BO export, and the app is responsible for not having crazy races there, so it's fine to just switch to tracking the last submitted writer via atomics, which makes this multithread/multicontext safe. We also drop the assert that was firing in #20 (closed) (this condition does not hold when multiple contexts write the same BO, so it was incorrect to begin with).
However, a hack in the batch tracking code (ab)used the writer syncobj tracking to manage writer batches when batches are reset without being submitted. This works in the single-threaded case, but obviously breaks when multiple contexts are involved, since we can't rely on data stored along the BO then...
So let's get rid of the hack, and instead move things around so a batch can never be marked as a writer for any resources until we have a draw or clear, which means the batch is not empty. Then assert in the reset codepath that the batch is indeed not a writer for any of its BOs.
Fixes: #20 (closed)