const std::map<std::string, std::string> *ShGetNameHashingMap( const ShHandle handle) { TCompiler *compiler = GetCompilerFromHandle(handle); ASSERT(compiler); return &(compiler->getNameMap()); }
void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t* params) { if (!handle || !params) return; TShHandleBase* base = static_cast<TShHandleBase*>(handle); TCompiler* compiler = base->getAsCompiler(); if (!compiler) return; switch(pname) { case SH_INFO_LOG_LENGTH: *params = compiler->getInfoSink().info.size() + 1; break; case SH_OBJECT_CODE_LENGTH: *params = compiler->getInfoSink().obj.size() + 1; break; case SH_ACTIVE_UNIFORMS: *params = compiler->getUniforms().size(); break; case SH_ACTIVE_UNIFORM_MAX_LENGTH: *params = 1 + MAX_SYMBOL_NAME_LEN; break; case SH_ACTIVE_ATTRIBUTES: *params = compiler->getAttribs().size(); break; case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH: *params = 1 + MAX_SYMBOL_NAME_LEN; break; case SH_VARYINGS: *params = compiler->getVaryings().size(); break; case SH_VARYING_MAX_LENGTH: *params = 1 + MAX_SYMBOL_NAME_LEN; break; case SH_MAPPED_NAME_MAX_LENGTH: // Use longer length than MAX_SHORTENED_IDENTIFIER_SIZE to // handle array and struct dereferences. *params = 1 + MAX_SYMBOL_NAME_LEN; break; case SH_NAME_MAX_LENGTH: *params = 1 + MAX_SYMBOL_NAME_LEN; break; case SH_HASHED_NAME_MAX_LENGTH: if (compiler->getHashFunction() == NULL) { *params = 0; } else { // 64 bits hashing output requires 16 bytes for hex // representation. const char HashedNamePrefix[] = HASHED_NAME_PREFIX; *params = 16 + sizeof(HashedNamePrefix); } break; case SH_HASHED_NAMES_COUNT: *params = compiler->getNameMap().size(); break; default: UNREACHABLE(); } }
void ShGetNameHashingEntry(const ShHandle handle, int index, char* name, char* hashedName) { if (!handle || !name || !hashedName || index < 0) return; TShHandleBase* base = static_cast<TShHandleBase*>(handle); TCompiler* compiler = base->getAsCompiler(); if (!compiler) return; const NameMap& nameMap = compiler->getNameMap(); if (index >= static_cast<int>(nameMap.size())) return; NameMap::const_iterator it = nameMap.begin(); for (int i = 0; i < index; ++i) ++it; size_t len = it->first.length() + 1; size_t max_len = 0; ShGetInfo(handle, SH_NAME_MAX_LENGTH, &max_len); if (len > max_len) { ASSERT(false); len = max_len; } strncpy(name, it->first.c_str(), len); // To be on the safe side in case the source is longer than expected. name[len - 1] = '\0'; len = it->second.length() + 1; max_len = 0; ShGetInfo(handle, SH_HASHED_NAME_MAX_LENGTH, &max_len); if (len > max_len) { ASSERT(false); len = max_len; } strncpy(hashedName, it->second.c_str(), len); // To be on the safe side in case the source is longer than expected. hashedName[len - 1] = '\0'; }