Skip to content

Fixed small bug with RefCount - #504

Open
wpsimon09 wants to merge 5 commits into
KhronosGroup:mainfrom
wpsimon09:patch-3
Open

wpsimon09 wants to merge 5 commits into
KhronosGroup:mainfrom
wpsimon09:patch-3

Conversation

@wpsimon09

@wpsimon09 wpsimon09 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

since refCounts member contains object with type Resource calling: refCount[id]++ was incorrect.

This PR fixes this issue. However it also rises a question if we want to keep ref count within the Resource object or simply use int as a value of the refCounts member variable.

so basically there are two choices either we`ll have:

    std::unordered_map<std::type_index, std::unordered_map<std::string, ResourceData>>  refCounts;

or

    std::unordered_map<std::type_index, std::unordered_map<std::string, int>>  refCounts;

The second approach would work with what was initially in the tutorial. Either way is fine so if you have time please let me know which version is better and I will alter this PR respectively.

Based on the rest of the tutorial it seems that niether of those types are correct and instead it is supposed to be

std::unordered_map<std::string, ResourceData>  refCounts;

Thank you !

since `refCounts` member contains object with type `Resource` calling: `refCount[id]++` was incorrect. 

This PR fixes this issue.  However it also rises a question if we want to keep ref count within the `Resource` object or simply use `int` as a value of the `refCounts` member variable.
@CLAassistant

CLAassistant commented Sep 5, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Update resource existence check to verify resource ID.
Updated resource management implementation to improve type safety and reference counting. Made the code more coherent and cleared some ambiguities
@wpsimon09

Copy link
Copy Markdown
Contributor Author

The rest of the code in the tutorial is structured with assumption that refTypes is

    std::unordered_map<std::string, ResourceData>  refCounts;

I have altered the tutorial where it mattered to match this assumption.

Furthermore some clarification was needed like for example why one needs ResrouceHandle if one can easily call ResrouceManager::GetResrouce(). This was fixed by using private specifier on those methods.

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