Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Optimize And/Or Replace crap_hash #29

Closed
GudBoiNero opened this issue Sep 21, 2023 · 0 comments
Closed

Optimize And/Or Replace crap_hash #29

GudBoiNero opened this issue Sep 21, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@GudBoiNero
Copy link
Owner

Currently we have a system for our texture cache, using the file path to the texture plus all of the shader file paths concatenated together. We store that in a map, this ensures that apple.png is different than apple.png with shine.glsl applied to it.

Tex GetTextureID(const std::string file_path, std::vector<std::string> shader_paths)
{
std::string crap_hash = file_path;
if (&shader_paths)
{
for (const auto& shader_path : shader_paths) {
crap_hash += ";" + shader_path;
}
}
if (auto& t = tex_cache[crap_hash]; !&t.id)
return t;
else
{
LoadTextureFromFile(file_path.data(), (GLuint*)(void*)&t.id, &t.width, &t.height, shader_paths);
tex_cache[crap_hash] = t;
return t;
}
}

It's quite clear that this is not efficient, it works for now, and that's all that matters. However eventually we will need this fixed if we would like to use more textures and shaders. Seeing as our keys will be at least 30-40 characters long each. Nobody wants that. It's called crap_hash for a reason...

@GudBoiNero GudBoiNero added the enhancement New feature or request label Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant