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

Resource System Rewrite #34

Open
8 of 10 tasks
JessyDL opened this issue Jan 30, 2022 · 1 comment
Open
8 of 10 tasks

Resource System Rewrite #34

JessyDL opened this issue Jan 30, 2022 · 1 comment

Comments

@JessyDL
Copy link
Owner

JessyDL commented Jan 30, 2022

Investigate an alternative approach, and then wholesale replace the existing resource loading system.

The alternative will have these constraints and goals:

  • support async loading
  • protect disk based assets (i.e. fresh copy should always be possible or immutable authoritive source)*
  • complex interaction (such as waiting for a GPU based event to signal) before the resource is available
  • support both reference tracking, as well as manual tracked modes (not needed to be mixed support)
  • safe resource destruction (i.e. resources are protected as long as they are in use)
  • support both shared and weak handles
  • alias handles, we should be able to contain all graphics API related resources in a single handle, which forwards into the actual active handle. Support for multiple to be active is unnecesairy. Support for mixed operations is unnecesairy as well (i.e. we can pre-assume the active index)
  • internally protected from race conditions from scheduled operations (but not externally, i.e. all public methods make no threading guarantees)
  • ability to forward arbitrary arguments to the to-be-constructed type.
  • all points need to have unit tests verifying these constraints and goals

* immutable authoritive source seems to be impossible without large efforts in architecture as when f.e. a buffer is loaded we obviously need to be able to write to it if it's used for those purposes.

Notes:

protect disk based assets:

The current approach selects the "last loaded" to be the authoritive source of what is the disk based assets (for the find method), but allows load to be called N times and get a fresh version as if just loaded from disk

complex interaction:

As the system has been implemented using coroutines, you can simply use co_await in the construct method and await for you relevant signal to fire, or to switch to other threads.

reference tracked/manual resource management:

All resources are always tracked by default. This isn't toggleable for now (this is to satisfy the safe resource destruction requirement). However, you can control when resources get destroyed if it's safe to do so (i.e. the last references are held by the cache, and the caller). The try_destroy method will verify if it's safe, and will destroy the resource within the given scope.

Alternatively, the unsafe_destroy will forcibly destroy the resource. This functionality is hidden behind the RESOURCE_ALLOW_UNSAFE define.

consider renaming construct to co_construct /s

@JessyDL
Copy link
Owner Author

JessyDL commented Feb 12, 2022

Task will be put on hold, and delayed till clear indicator when clang supports coroutines fully.

@JessyDL JessyDL removed this from the 0.2.0 milestone Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant