KhronosGroup / KhronosGroup/Vulkan-Tutorial

Attampt to index refCounts with std::string when std::type_index is expected

Open
#373 0 comments 0 reactions 1 assignee Claimed by @gpx1000 View on GitHub
Game Engine
Dominant language
C++
Stars
418
Forks
126
Avg merge
11d 6h
Merged PRs (30d)
31

Description

Hi,

In the tutorial on Resource management (specifically here: https://docs.vulkan.org/tutorial/latest/Building_a_Simple_Engine/Engine_Architecture/04_resource_management.html#_resource_manager_storage_architecture_and_type_safety), an associative array is created to stored resources' reference counts based on a specific type. But I have a problem with the following section (https://docs.vulkan.org/tutorial/latest/Building_a_Simple_Engine/Engine_Architecture/04_resource_management.html#_resource_manager_resource_loading_and_caching_logic) in the Load method. In my understanding, when we try to increment/initialize the reference counter for a given resource, it does this :

```cpp
refCounts[resourceId]++
```

or this :

```cpp
refCounts[resourceId] = 1;
```

but based on the definition of the refCounts associative array, I would have thought it should have done something more like this :

```cpp
auto& typeReferenceCounters = refCounts[std::type_index(typeid(T))];
typeReferenceCounters[resourceId].refCount++; // or typeReferenceCounters[resourceId].refCount = 1 for the other case
```

Please tell me if I am wrong, I would be glad to learn from my mistakes.

Best regards,

ajvp

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.