Delayed texture deletion (Fixes #28) #71
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since I ran into a crash a few times already by now, here's a patch that delays the "real" deletion of the texture until a swap operation (or until
vita2d_gc_textures()
is called manually).This way, a library user can just allocate and free textures normally and not have to worry about freeing textures too early, vita2d will take care of delaying the deletion until the next swap. Note that right now all free texture operations are delayed, even in cases where a texture wasn't used in the current frame (and could potentially be freed immediately).
Apart from the linked list overhead, the only situation when this would be bad is if an application allocates and frees textures while drawing, and these free operations are delayed until the swap. But for this case, the application developer can use
vita2d_gc_textures()
to explicitly flush the free operations beforevita2d_swap_buffers()
.