Skip to content

Commit

Permalink
Order shaders before caching to avoid re-caching due to order changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthayhurst committed Jul 4, 2024
1 parent c6c0106 commit b970313
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ammonite/graphics/shaders.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <algorithm>
#include <cstddef>
#include <cstring>
#include <filesystem>
Expand Down Expand Up @@ -359,6 +360,7 @@ namespace ammonite {
/*
- Take an array of shader paths, create a program and return the ID
- Shaders with unidentifiable types will be ignored
- The order of shaders may be changed without re-caching
- If possible, load and store a cache
- Writes 'false' to externalSuccess on failure and returns -1
*/
Expand Down Expand Up @@ -421,6 +423,9 @@ namespace ammonite {
}
}

//Ensure shaders don't get rebuilt due to a file order change
std::sort(shaderPaths.begin(), shaderPaths.end());

//Create the program and return the ID
return createProgramCached(&shaderPaths[0], &shaderTypes[0], shaderPaths.size(),
externalSuccess);
Expand Down

0 comments on commit b970313

Please sign in to comment.