diff --git a/source/picasso.h b/source/picasso.h index fc0bed9..9ef344a 100644 --- a/source/picasso.h +++ b/source/picasso.h @@ -110,6 +110,11 @@ struct Uniform int pos, size; int type; + inline bool operator <(const Uniform& rhs) + { + return pos < rhs.pos; + } + void init(const char* name, int pos, int size, int type) { this->name = name; diff --git a/source/picasso_assembler.cpp b/source/picasso_assembler.cpp index 385e300..71e4ab7 100644 --- a/source/picasso_assembler.cpp +++ b/source/picasso_assembler.cpp @@ -177,7 +177,7 @@ static bool validateIdentifier(const char* id) for (int i = 0; valid && i < len; i ++) { int c = id[i]; - valid = isalpha(c) || c == '_' || c == '.' || (i > 0 && isdigit(c)); + valid = isalpha(c) || c == '_' || c == '$' || (i > 0 && isdigit(c)); } return valid; } diff --git a/source/picasso_frontend.cpp b/source/picasso_frontend.cpp index db0e713..d865cfa 100644 --- a/source/picasso_frontend.cpp +++ b/source/picasso_frontend.cpp @@ -195,6 +195,9 @@ int main(int argc, char* argv[]) u32 temp = f.Tell(); f.WriteWord(dvle->symbolSize); // size of symbol table + // Sort uniforms by position + std::sort(dvle->uniformTable, dvle->uniformTable + dvle->uniformCount); + // Write constants for (int i = 0; i < dvle->constantCount; i ++) { @@ -241,7 +244,8 @@ int main(int argc, char* argv[]) // Write symbols for (int i = 0; i < dvle->uniformCount; i ++) { - std::string& u = dvle->uniformTable[i].name; + std::string u(dvle->uniformTable[i].name); + std::replace(u.begin(), u.end(), '$', '.'); size_t l = u.length()+1; f.WriteRaw(u.c_str(), l); }