Skip to content

Commit

Permalink
sort the uniforms list deterministically (by name instead of by address)
Browse files Browse the repository at this point in the history
  • Loading branch information
aras-p committed Mar 8, 2013
1 parent 838e841 commit a959287
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hlslang/GLSLCodeGen/hlslLinker.cpp
Expand Up @@ -711,6 +711,11 @@ bool HlslLinker::buildFunctionLists(HlslCrossCompiler* comp, EShLanguage lang, c
return true;
}

struct GlslSymbolSorter {
bool operator()(const GlslSymbol* a, const GlslSymbol* b) {
return a->getName() < b->getName();
}
};

void HlslLinker::buildUniformsAndLibFunctions(const FunctionSet& calledFunctions, std::vector<GlslSymbol*>& constants, std::set<TOperator>& libFunctions)
{
Expand All @@ -730,7 +735,7 @@ void HlslLinker::buildUniformsAndLibFunctions(const FunctionSet& calledFunctions
}

// std::unique only removes contiguous duplicates, so vector must be sorted to remove them all
std::sort(constants.begin(), constants.end());
std::sort(constants.begin(), constants.end(), GlslSymbolSorter());

// Remove duplicates
constants.resize(std::unique(constants.begin(), constants.end()) - constants.begin());
Expand Down

0 comments on commit a959287

Please sign in to comment.