void Renderer::printRendererStatus(RendererStatusVerbosity verbosity, const StringIdMap & stringMap, std::ostream & out) const { out << "Renderer status" << std::endl; out << "---------------" << std::endl; out << "Model count: " << models.size() << std::endl; out << "Shaders: "; for (auto i = shaders.begin(); i != shaders.end(); i++) { if (i != shaders.begin()) out << ", "; out << i->first; if (!i->second.defines.empty()) { out << "("; for (auto d = i->second.defines.begin(); d != i->second.defines.end(); d++) { if (d != i->second.defines.begin()) out << "/"; out << *d; } out << ")"; } } out << std::endl; std::string passPrefix = " "; // Print shared textures. if (verbosity >= VERBOSITY_MODELS_TEXTURES) { out << "Global textures: " << sharedTextures.size() << std::endl; for (const auto & st : sharedTextures) out << passPrefix << stringMap.getString(st.first) << ", handle " << st.second.handle << std::endl; } out << "Passes: " << passes.size() << std::endl; int passcount = 0; for (const auto & pass : passes) { out << "Pass \"" << pass.getName() << "\"" << std::endl; out << passPrefix << "Draw groups: "; int dgcount = 0; for (const auto & dg : drawGroupToPasses) if (std::find(dg.second.begin(), dg.second.end(), passcount) != dg.second.end()) { if (dgcount != 0) out << ", "; out << stringMap.getString(dg.first); dgcount++; } out << std::endl; pass.printRendererStatus(verbosity, stringMap, out); passcount++; } }
void Renderer::printRendererStatus(RendererStatusVerbosity verbosity, const StringIdMap & stringMap, std::ostream & out) const { out << "Renderer status" << std::endl; out << "---------------" << std::endl; out << "Model count: " << models.size() << std::endl; out << "Shaders: "; for (std::map <std::string, RenderShader>::const_iterator i = shaders.begin(); i != shaders.end(); i++) { if (i != shaders.begin()) out << ", "; out << i->first; if (!i->second.defines.empty()) { out << "("; for (std::set <std::string>::const_iterator d = i->second.defines.begin(); d != i->second.defines.end(); d++) { if (d != i->second.defines.begin()) out << "/"; out << *d; } out << ")"; } } out << std::endl; std::string passPrefix = " "; // Print shared textures. if (verbosity >= VERBOSITY_MODELS_TEXTURES) { out << "Global textures: " << sharedTextures.size() << std::endl; for (NameTexMap::const_iterator i = sharedTextures.begin(); i != sharedTextures.end(); i++) out << passPrefix << stringMap.getString(i->first) << ", handle " << i->second.handle << std::endl; } out << "Passes: " << passes.size() << std::endl; int passcount = 0; for (std::vector <RenderPass>::const_iterator i = passes.begin(); i != passes.end(); i++,passcount++) { out << "Pass \"" << i->getName() << "\"" << std::endl; out << passPrefix << "Draw groups: "; int dgcount = 0; for (NameIdVecMap::const_iterator dg = drawGroupToPasses.begin(); dg != drawGroupToPasses.end(); dg++) if (std::find(dg->second.begin(), dg->second.end(), passcount) != dg->second.end()) { if (dgcount != 0) out << ", "; out << stringMap.getString(dg->first); dgcount++; } out << std::endl; i->printRendererStatus(verbosity, stringMap, out); } }
void string_id_test() { typedef std::map<StringId, std::vector<int> > StringIdMap; StringIdMap map; StringId tjong_id("tjong"); StringId bong_id("bong"); map[StringId("tjong")].push_back(10); map[StringId("bong")].push_back(20); map[StringId("tjong")].push_back(20); BOOST_CHECK(map.size() == 2); BOOST_CHECK(map[tjong_id].size() == 2); BOOST_CHECK(map[bong_id].size() == 1); }
bool Renderer::initialize(const std::vector <RealtimeExportPassInfo> & config, StringIdMap & stringMap, const std::string & shaderPath, unsigned int w,unsigned int h, const std::set <std::string> & globalDefines, std::ostream & errorOutput) { // Clear existing passes. clear(); // Add new passes. int passCount = 0; for (std::vector <RealtimeExportPassInfo>::const_iterator i = config.begin(); i != config.end(); i++, passCount++) { // Create unique names based on the path and define list. std::string vertexShaderName = i->vertexShader; if (!i->vertexShaderDefines.empty()) vertexShaderName += " "+UTILS::implode(i->vertexShaderDefines," "); std::string fragmentShaderName = i->fragmentShader; if (!i->fragmentShaderDefines.empty()) fragmentShaderName += " "+UTILS::implode(i->fragmentShaderDefines," "); // Load shaders from the pass if necessary. if ((shaders.find(vertexShaderName) == shaders.end()) && (!loadShader(shaderPath.empty() ? i->vertexShader : shaderPath+"/"+i->vertexShader, vertexShaderName, mergeSets(i->vertexShaderDefines, globalDefines), GL_VERTEX_SHADER, errorOutput))) return false; if ((shaders.find(fragmentShaderName) == shaders.end()) && (!loadShader(shaderPath.empty() ? i->fragmentShader : shaderPath+"/"+i->fragmentShader, fragmentShaderName, mergeSets(i->fragmentShaderDefines, globalDefines), GL_FRAGMENT_SHADER, errorOutput))) return false; // Note which draw groups the pass uses. for (std::vector <std::string>::const_iterator g = i->drawGroups.begin(); g != i->drawGroups.end(); g++) drawGroupToPasses[stringMap.addStringId(*g)].push_back(passes.size()); // Initialize the pass. int passIdx = passes.size(); passes.push_back(RenderPass()); if (!passes.back().initialize(passCount, *i, stringMap, gl, shaders.find(vertexShaderName)->second, shaders.find(fragmentShaderName)->second, sharedTextures, w, h, errorOutput)) return false; // Put the pass's output render targets into a map so we can feed them to subsequent passes. const std::map <StringId, RenderTexture> & passRTs = passes.back().getRenderTargets(); for (std::map <StringId, RenderTexture>::const_iterator rt = passRTs.begin(); rt != passRTs.end(); rt++) { StringId nameId = rt->first; sharedTextures.insert(std::make_pair(nameId, RenderTextureEntry(nameId, rt->second.handle, rt->second.target))); } // Remember the pass index. passIndexMap[stringMap.addStringId(i->name)] = passIdx; } return true; }