Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sg_dealloc_xxx() and sg_uninit_xxx() suite of functions #435

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

oviano
Copy link
Contributor

@oviano oviano commented Nov 25, 2020

These are the equivalent to the sg_alloc/init functions and allow async destruction of resources. This is useful when using sokol in a multithreaded scenario; the render thread does the sg_init/sg_uninit while a separate resource/api/update thread can call the sg_alloc/sg_dealloc.

These are the equivalent to the sg_alloc/init functions and allow async destruction of resources. This is useful when using sokol in a multithreaded scenario; the render thread does the sg_init/sg_uninit while a separate resource/api/update thread can call the sg_alloc/sg_dealloc.
@floooh
Copy link
Owner

floooh commented Nov 26, 2020

Looks good! I'll try to do a "merge day" soon where I'll focus on pending PRs.

@floooh
Copy link
Owner

floooh commented Dec 2, 2020

I'm starting to look into this PR now. I think there's two small problem:

  • the uninit-functions should put the resource slot back into the SG_RESOURCESTATE_ALLOC state
  • ...and the dealloc-functions need to check whether the resource slot in in the SG_RESOURCESTATE_ALLOC state

I think those changes are trivial, and I'll try to do them during the merge.

@oviano
Copy link
Contributor Author

oviano commented Dec 2, 2020

Yes, you are right of course, I remember wondering about that when I did it, and I think the only reason I didn't at the time was that in all cases the uninit should be followed by a dealloc anyway so it seemed like it wasn't too critical for my testing.....and then I forgot to go back to it :)

@floooh floooh merged commit 648a8ce into floooh:master Dec 2, 2020
@floooh
Copy link
Owner

floooh commented Dec 2, 2020

Ok merged, many thanks for the PR!

As described above, I've added the correct "state unwinding". I've also added a couple new tests to sokol-gfx-test.c in the sokol-samples repository:

https://github.com/floooh/sokol-samples/blob/4cf2a1ef723207e6d7a9b1500f79eb048a2f4ce6/tests/sokol-gfx-test.c#L674-L742

Another minor thing you missed is adding new entries to the sg_trace_hooks struct (this only shows up when compiling with SOKOL_TRACE_HOOKS enabled).

@oviano
Copy link
Contributor Author

oviano commented Dec 2, 2020

Great, thank you and also if there is a next time I'll be sure to look out for the sg_trace_hooks!

@oviano oviano deleted the sokol-gfx-async-dealloc branch December 8, 2020 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants