Skip to content

Implement reference counting in ResourceManager (#320) - #461

Open
gpx1000 wants to merge 1 commit into
KhronosGroup:mainfrom
gpx1000:fix/320-resourcemanager-refcounting
Open

Implement reference counting in ResourceManager (#320)#461
gpx1000 wants to merge 1 commit into
KhronosGroup:mainfrom
gpx1000:fix/320-resourcemanager-refcounting

Conversation

@gpx1000

@gpx1000 gpx1000 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

refCount was documented as part of the resource management design but never implemented: LoadResource never incremented it and UnloadResource unloaded and erased a resource unconditionally, even with other outstanding handles to it.

Also drop the final on Resource and ResourceManager: as written, neither could ever be subclassed, so none of the concrete resource types the tutorial documents (Texture, Mesh, Shader) could actually exist.

Fixes #320

refCount was documented as part of the resource management design but
never implemented: LoadResource never incremented it and UnloadResource
unloaded and erased a resource unconditionally, even with other
outstanding handles to it.

Also drop the `final` on Resource and ResourceManager: as written,
neither could ever be subclassed, so none of the concrete resource
types the tutorial documents (Texture, Mesh, Shader) could actually
exist.
@asuessenbach

Copy link
Copy Markdown
Contributor

Why do you implement your own ref counting, instead of just using a std::shared_ptr?

@gpx1000

gpx1000 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Simply for the purposes of educational content showing specifically how ref counting works. shared_ptr naturally is a better use so I can be convinced to reimplement as shared_ptr.

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.

ResourceManager doesn't implement Reference Counting.

2 participants