00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org 00006 00007 Copyright (c) 2000-2013 Torus Knot Software Ltd 00008 Permission is hereby granted, free of charge, to any person obtaining a copy 00009 of this software and associated documentation files (the "Software"), to deal 00010 in the Software without restriction, including without limitation the rights 00011 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00012 copies of the Software, and to permit persons to whom the Software is 00013 furnished to do so, subject to the following conditions: 00014 00015 The above copyright notice and this permission notice shall be included in 00016 all copies or substantial portions of the Software. 00017 00018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00019 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00020 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00021 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00022 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00024 THE SOFTWARE. 00025 ----------------------------------------------------------------------------- 00026 */ 00027 #ifndef _ShaderProgramManager_ 00028 #define _ShaderProgramManager_ 00029 00030 #include "OgreShaderPrerequisites.h" 00031 #include "OgreShaderProgram.h" 00032 #include "OgreShaderProgramWriter.h" 00033 00034 namespace Ogre { 00035 namespace RTShader { 00036 00046 class _OgreRTSSExport ProgramManager : public Singleton<ProgramManager>, public RTShaderSystemAlloc 00047 { 00048 // Interface. 00049 public: 00050 00052 ProgramManager(); 00053 00055 ~ProgramManager(); 00056 00057 00073 static ProgramManager& getSingleton(); 00074 00090 static ProgramManager* getSingletonPtr(); 00091 00096 void acquirePrograms(Pass* pass, TargetRenderState* renderState); 00097 00102 void releasePrograms(Pass* pass, TargetRenderState* renderState); 00103 00106 void flushGpuProgramsCache(); 00107 00108 protected: 00109 00110 //----------------------------------------------------------------------------- 00111 typedef map<String, GpuProgramPtr>::type GpuProgramsMap; 00112 typedef GpuProgramsMap::iterator GpuProgramsMapIterator; 00113 typedef GpuProgramsMap::const_iterator GpuProgramsMapConstIterator; 00114 00115 //----------------------------------------------------------------------------- 00116 typedef set<Program*>::type ProgramList; 00117 typedef ProgramList::iterator ProgramListIterator; 00118 typedef map<String, ProgramWriter*>::type ProgramWriterMap; 00119 typedef ProgramWriterMap::iterator ProgramWriterIterator; 00120 typedef vector<ProgramWriterFactory*>::type ProgramWriterFactoryList; 00121 00122 //----------------------------------------------------------------------------- 00123 typedef map<String, ProgramProcessor*>::type ProgramProcessorMap; 00124 typedef ProgramProcessorMap::iterator ProgramProcessorIterator; 00125 typedef ProgramProcessorMap::const_iterator ProgramProcessorConstIterator; 00126 typedef vector<ProgramProcessor*>::type ProgramProcessorList; 00127 00128 00129 protected: 00131 void createDefaultProgramProcessors(); 00132 00134 void destroyDefaultProgramProcessors(); 00135 00137 void createDefaultProgramWriterFactories(); 00138 00140 void destroyDefaultProgramWriterFactories(); 00141 00143 void destroyProgramWriters(); 00144 00148 Program* createCpuProgram(GpuProgramType type); 00149 00153 void destroyCpuProgram(Program* shaderProgram); 00154 00158 bool createGpuPrograms(ProgramSet* programSet); 00159 00165 String generateGUID(const String& programString); 00166 00175 GpuProgramPtr createGpuProgram(Program* shaderProgram, 00176 ProgramWriter* programWriter, 00177 const String& language, 00178 const String& profiles, 00179 const StringVector& profilesList, 00180 const String& cachePath); 00181 00186 void addProgramProcessor(ProgramProcessor* processor); 00187 00192 void removeProgramProcessor(ProgramProcessor* processor); 00193 00197 void destroyGpuProgram(GpuProgramPtr& gpuProgram); 00198 00202 void flushGpuProgramsCache(GpuProgramsMap& gpuProgramsMap); 00203 00205 size_t getVertexShaderCount() const { return mVertexShaderMap.size(); } 00206 00208 size_t getFragmentShaderCount() const { return mFragmentShaderMap.size(); } 00209 00211 void synchronizePixelnToBeVertexOut(ProgramSet* programSet); 00212 00214 void bindUniformParameters(Program* pCpuProgram, const GpuProgramParametersSharedPtr& passParams); 00215 00216 00217 protected: 00218 00219 00220 protected: 00221 // CPU programs list. 00222 ProgramList mCpuProgramsList; 00223 // Map between target language and shader program writer. 00224 ProgramWriterMap mProgramWritersMap; 00225 // Map between target language and shader program processor. 00226 ProgramProcessorMap mProgramProcessorsMap; 00227 // Holds standard shader writer factories 00228 ProgramWriterFactoryList mProgramWriterFactories; 00229 // The generated vertex shaders. 00230 GpuProgramsMap mVertexShaderMap; 00231 // The generated fragment shaders. 00232 GpuProgramsMap mFragmentShaderMap; 00233 // The default program processors. 00234 ProgramProcessorList mDefaultProgramProcessors; 00235 00236 private: 00237 friend class ProgramSet; 00238 friend class TargetRenderState; 00239 friend class ShaderGenerator; 00240 }; 00241 00245 } 00246 } 00247 00248 #endif 00249
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:47