Commits

Assaf Raman committed dddea00

GLES2 render system: added a cmake compile flag - "Enable GLSL optimiser use in GLES 2 render system".

  • Participants
  • Parent commits bfcef80

Comments (0)

Files changed (6)

 cmake_dependent_option(OGRE_BUILD_RENDERSYSTEM_GLES "Build OpenGL ES 1.x RenderSystem" FALSE "OPENGLES_FOUND" FALSE)
 cmake_dependent_option(OGRE_BUILD_RENDERSYSTEM_GLES2 "Build OpenGL ES 2.x RenderSystem" FALSE "OPENGLES2_FOUND" FALSE)
 cmake_dependent_option(OGRE_CG_SUPPORT_FOR_GLES2 "Enable Cg support to ES 2 render system" FALSE "OGRE_BUILD_RENDERSYSTEM_GLES2" FALSE)
+cmake_dependent_option(OGRE_USE_GLES2_GLSL_OPTIMISER "Enable GLSL optimiser use in GLES 2 render system" TRUE "OGRE_BUILD_RENDERSYSTEM_GLES2" FALSE)
 cmake_dependent_option(OGRE_BUILD_PLATFORM_APPLE_IOS "Build Ogre for iOS" FALSE "iPhoneSDK_FOUND;OPENGLES_FOUND;OPENGLES2_FOUND" FALSE)
 cmake_dependent_option(OGRE_BUILD_PLATFORM_TEGRA2 "Build Ogre for NVIDIA Tegra 2 with Linux" FALSE "OGRE_BUILD_PLATFORM_TEGRA2;OPENGLES2_FOUND" FALSE)
 option(OGRE_BUILD_PLUGIN_BSP "Build BSP SceneManager plugin" TRUE)

RenderSystems/GLES2/src/GLSLES/include/OgreGLSLESLinkProgramManager.h

 #include "OgreGLSLESExtSupport.h"
 #include "OgreGLSLESLinkProgram.h"
 
-#include "glsl_optimizer.h"
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
+#   include "glsl_optimizer.h"
+#endif
 
 namespace Ogre {
 
 
 		typedef map<String, GLenum>::type StringToEnumMap;
 		StringToEnumMap mTypeEnumMap;
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
         struct glslopt_ctx *mGLSLOptimiserContext;
-
+#endif
 		/// Use type to complete other information
 		void completeDefInfo(GLenum gltype, GpuConstantDefinition& defToUpdate);
 		/// Find where the data for a specific uniform should come from, populate
 		*/
 		void setActiveVertexShader(GLSLESGpuProgram* vertexGpuProgram);
 
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
         /**
          
         */
         void optimiseShaderSource(GLSLESGpuProgram* gpuProgram);
+#endif
 
 		/** Populate a list of uniforms based on a program object.
 		@param programObject Handle to the program object to query

RenderSystems/GLES2/src/GLSLES/include/OgreGLSLESProgram.h

     class _OgreGLES2Export GLSLESProgram : public HighLevelGpuProgram
     {
     public:
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
         /// Command object for running the GLSL optimiser 
         class CmdOptimisation : public ParamCommand
         {
             String doGet(const void* target) const;
 			void doSet(void* target, const String& val);
         };
-
+#endif
 		/// Command object for setting macro defines
 		class CmdPreprocessorDefines : public ParamCommand
 		{
 		/// Sets the preprocessor defines use to compile the program.
 		const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
 
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
         /// Sets if the GLSL optimiser is enabled.
 		void setOptimiserEnabled(bool enabled) { mOptimiserEnabled = enabled; }
 		/// Gets if the GLSL optimiser is enabled.
         void setIsOptimised(bool flag) { mIsOptimised = flag; }
         /// Gets if the GLSL source has been optimised successfully
         bool getIsOptimised(void) { return mIsOptimised; }
+#endif
 
         /// Overridden from GpuProgram
         const String& getLanguage(void) const;
 
 	protected:
 		static CmdPreprocessorDefines msCmdPreprocessorDefines;
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
 		static CmdOptimisation msCmdOptimisation;
+#endif
 
         /** Internal load implementation, must be implemented by subclasses.
         */
         bool mIsOptimised;
 		/// Preprocessor options
 		String mPreprocessorDefines;
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
         bool mOptimiserEnabled;
+#endif
     };
 }
 

RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESLinkProgram.cpp

 			}
 			else
 			{
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
                 // check CmdParams for each shader type to see if we should optimize
                 String paramStr = mVertexProgram->getGLSLProgram()->getParameter("use_optimiser");
                 if((paramStr == "true") || paramStr.empty())
                 {
                     GLSLESLinkProgramManager::getSingleton().optimiseShaderSource(mFragmentProgram);
                 }
+#endif
 				compileAndLink();
 			}
 

RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESLinkProgramManager.cpp

 		mTypeEnumMap.insert(StringToEnumMap::value_type("mat3", GL_FLOAT_MAT3));
 		mTypeEnumMap.insert(StringToEnumMap::value_type("mat4", GL_FLOAT_MAT4));
         
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
         mGLSLOptimiserContext = glslopt_initialize(true);
+#endif
 	}
 
 	//-----------------------------------------------------------------------
 		{
 			OGRE_DELETE currentProgram->second;
 		}
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
         if(mGLSLOptimiserContext)
         {
             glslopt_cleanup(mGLSLOptimiserContext);
             mGLSLOptimiserContext = NULL;
         }
+#endif
 	}
 
 	//-----------------------------------------------------------------------
 		return false;
 	}
 
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
     void GLSLESLinkProgramManager::optimiseShaderSource(GLSLESGpuProgram* gpuProgram)
     {
         if(!gpuProgram->getGLSLProgram()->getIsOptimised())
             glslopt_shader_delete(shader);
         }
     }
+#endif
 
 	//---------------------------------------------------------------------
 	void GLSLESLinkProgramManager::extractUniforms(GLuint programObject, 

RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgram.cpp

 
     //-----------------------------------------------------------------------
 	GLSLESProgram::CmdPreprocessorDefines GLSLESProgram::msCmdPreprocessorDefines;
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
     GLSLESProgram::CmdOptimisation GLSLESProgram::msCmdOptimisation;
-
+#endif
     //-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
     GLSLESProgram::GLSLESProgram(ResourceManager* creator, 
 		, mGLHandle(0)
         , mCompiled(0)
         , mIsOptimised(false)
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
         , mOptimiserEnabled(true)
+#endif
     {
         if (createParamDictionary("GLSLESProgram"))
         {
 			dict->addParameter(ParameterDef("preprocessor_defines", 
                                             "Preprocessor defines use to compile the program.",
                                             PT_STRING),&msCmdPreprocessorDefines);
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
 			dict->addParameter(ParameterDef("use_optimiser", 
                                             "Should the GLSL optimiser be used. Default is true.",
                                             PT_BOOL),&msCmdOptimisation);
+#endif
         }
         // Manually assign language now since we use it immediately
         mSyntaxCode = "glsles";
 		return true;
 	}
 	//-----------------------------------------------------------------------
+#ifdef OGRE_USE_GLES2_GLSL_OPTIMISER
 	String GLSLESProgram::CmdOptimisation::doGet(const void *target) const
 	{
         return StringConverter::toString(static_cast<const GLSLESProgram*>(target)->getOptimiserEnabled());
 	{
         static_cast<GLSLESProgram*>(target)->setOptimiserEnabled(StringConverter::parseBool(val));
 	}
+#endif
 	//-----------------------------------------------------------------------
 	String GLSLESProgram::CmdPreprocessorDefines::doGet(const void *target) const
 	{