NcStudios / NcEngine

NcEngine: 3D game engine written in modern C++ and Vulkan
https://ncstudios.itch.io/
MIT License
36 stars 2 forks source link

Load texture after unload all fails #653

Open McCallisterRomer opened 1 month ago

McCallisterRomer commented 1 month ago

Exception is thrown ("invalid vector subscript") when loading textures after calling UnloadAllTextureAssets(). The exception comes from line 437 in ShaderStorage.cpp where we attempt to access a vector element within the static TextureArrayBufferStorage that has been cleared.

Easy to reproduce with the sample test: ./Sample --run-test.

Commenting out texture unloading in the test (line 99 in SmokeTest.cpp) allows the test to pass, so it doesn't look like other handle types are having problems (we clear all asset types). (After looking again, it looks like this ought to an issue for CubeMaps also?).

I haven't fully grokked the flow yet, so I'm uncertain on what correct behavior is. Maybe either the handling of a 'clear' event should be different, or 'clear' shouldn't be sent in the 'unload all' case.

McCallisterRomer commented 4 weeks ago

This is due to incorrect handling of asset clear events. WIP branch here, which includes some other fixes - bug in sparse_map and potential bug with asset ids being cached as std::string_view.