From a3d7681b0fad5549138af57746a6cd8fcc9d5fd9 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sat, 21 Jan 2017 14:34:50 +0100 Subject: [PATCH 1/4] GLES2: drop GpuProgram indirection --- .../GLES2/include/OgreGLES2GpuProgram.h | 72 ------ .../GLES2/include/OgreGLES2RenderSystem.h | 7 +- .../src/GLSLES/include/OgreGLSLESGpuProgram.h | 79 ------- .../src/GLSLES/include/OgreGLSLESProgram.h | 16 ++ .../src/GLSLES/src/OgreGLSLESGpuProgram.cpp | 209 ------------------ .../src/GLSLES/src/OgreGLSLESLinkProgram.cpp | 2 +- .../src/OgreGLSLESLinkProgramManager.cpp | 2 +- .../src/GLSLES/src/OgreGLSLESProgram.cpp | 152 ++++++++++++- .../GLSLES/src/OgreGLSLESProgramCommon.cpp | 2 +- .../src/OgreGLSLESProgramManagerCommon.cpp | 2 +- .../GLSLES/src/OgreGLSLESProgramPipeline.cpp | 2 +- .../src/OgreGLSLESProgramPipelineManager.cpp | 2 +- .../GLES2/src/OgreGLES2GpuProgram.cpp | 80 ------- .../GLES2/src/OgreGLES2GpuProgramManager.cpp | 6 +- .../src/OgreGLES2HardwarePixelBuffer.cpp | 1 - .../GLES2/src/OgreGLES2RenderSystem.cpp | 2 +- 16 files changed, 179 insertions(+), 457 deletions(-) delete mode 100644 RenderSystems/GLES2/include/OgreGLES2GpuProgram.h delete mode 100644 RenderSystems/GLES2/src/GLSLES/include/OgreGLSLESGpuProgram.h delete mode 100644 RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESGpuProgram.cpp delete mode 100644 RenderSystems/GLES2/src/OgreGLES2GpuProgram.cpp diff --git a/RenderSystems/GLES2/include/OgreGLES2GpuProgram.h b/RenderSystems/GLES2/include/OgreGLES2GpuProgram.h deleted file mode 100644 index 5c557bb9d8d..00000000000 --- a/RenderSystems/GLES2/include/OgreGLES2GpuProgram.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ------------------------------------------------------------------------------ -This source file is part of OGRE -(Object-oriented Graphics Rendering Engine) -For the latest info, see http://www.ogre3d.org/ - -Copyright (c) 2000-2014 Torus Knot Software Ltd - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. ------------------------------------------------------------------------------ -*/ - -#ifndef __GLES2GpuProgram_H__ -#define __GLES2GpuProgram_H__ - -#include "OgreGLES2Prerequisites.h" -#include "OgreGpuProgram.h" -#include "OgreHardwareVertexBuffer.h" - -namespace Ogre { - - /** Generalised low-level GL program, can be applied to multiple types (eg ARB and NV) */ - class _OgreGLES2Export GLES2GpuProgram : public GpuProgram - { - public: - GLES2GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle, - const String& group, bool isManual = false, ManualResourceLoader* loader = 0); - virtual ~GLES2GpuProgram(); - - /// Execute the binding functions for this program - virtual void bindProgram(void) {} - /// Execute the binding functions for this program - virtual void unbindProgram(void) {} - - /// Execute the param binding functions for this program - virtual void bindProgramParameters(GpuProgramParametersSharedPtr params, uint16 mask) {} - /// Bind just the pass iteration parameters - virtual void bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params) {} - /// Execute the shared param binding functions for this program - virtual void bindProgramSharedParameters(GpuProgramParametersSharedPtr params, uint16 mask) {} - - /// @copydoc Resource::calculateSize - virtual size_t calculateSize(void) const; - - protected: - /** Overridden from GpuProgram, do nothing */ - void loadFromSource(void) {} - /// @copydoc Resource::unloadImpl - void unloadImpl(void) {} - - GLenum mProgramType; - }; - -} // namespace Ogre - -#endif // __GLES2GpuProgram_H__ diff --git a/RenderSystems/GLES2/include/OgreGLES2RenderSystem.h b/RenderSystems/GLES2/include/OgreGLES2RenderSystem.h index 1aea7d8fab1..97ec29d7a2a 100644 --- a/RenderSystems/GLES2/include/OgreGLES2RenderSystem.h +++ b/RenderSystems/GLES2/include/OgreGLES2RenderSystem.h @@ -33,7 +33,7 @@ THE SOFTWARE. #include "OgreMaterialManager.h" #include "OgreRenderSystem.h" -#include "OgreGLES2GpuProgram.h" +#include "OgreGLSLESProgram.h" #include "OgreGLRenderSystemCommon.h" namespace Ogre { @@ -52,7 +52,6 @@ namespace Ogre { #if !OGRE_NO_GLES2_CG_SUPPORT class GLSLESCgProgramFactory; #endif - class GLSLESGpuProgram; class HardwareBufferManager; #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_EMSCRIPTEN class GLES2ManagedResourceManager; @@ -129,8 +128,8 @@ namespace Ogre { GLint getCombinedMinMipFilter(void) const; - GLES2GpuProgram* mCurrentVertexProgram; - GLES2GpuProgram* mCurrentFragmentProgram; + GLSLESProgram* mCurrentVertexProgram; + GLSLESProgram* mCurrentFragmentProgram; GLint getTextureAddressingMode(TextureUnitState::TextureAddressingMode tam) const; GLenum getBlendMode(SceneBlendFactor ogreBlend) const; diff --git a/RenderSystems/GLES2/src/GLSLES/include/OgreGLSLESGpuProgram.h b/RenderSystems/GLES2/src/GLSLES/include/OgreGLSLESGpuProgram.h deleted file mode 100644 index dbb039d34fc..00000000000 --- a/RenderSystems/GLES2/src/GLSLES/include/OgreGLSLESGpuProgram.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ------------------------------------------------------------------------------ -This source file is part of OGRE - (Object-oriented Graphics Rendering Engine) -For the latest info, see http://www.ogre3d.org/ - -Copyright (c) 2000-2014 Torus Knot Software Ltd - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. ------------------------------------------------------------------------------ -*/ - -#ifndef __GLSLESGpuProgram_H__ -#define __GLSLESGpuProgram_H__ - -// Precompiler options -#include "OgreGLSLESExtSupport.h" -#include "OgreGLES2GpuProgram.h" - -namespace Ogre { - class GLSLESProgram; - - /** GLSL ES low level compiled shader object - this class is used to get at the linked program object - and provide an interface for GLES2RenderSystem calls. GLSL ES does not provide access to the - low level code of the shader so this class is really just a dummy place holder. - GLSL ES uses a program object to represent the active vertex and fragment programs used - but Ogre materials maintain separate instances of the active vertex and fragment programs - which creates a small problem for GLSL integration. The GLSLESGpuProgram class provides the - interface between the GLSLESLinkProgramManager, GLSLESProgramPipelineManager , GLES2RenderSystem, - and the active GLSLESProgram instances. - */ - class _OgreGLES2Export GLSLESGpuProgram : public GLES2GpuProgram - { - private: - /// GL Handle for the shader object - GLSLESProgram* mGLSLProgram; - - public: - GLSLESGpuProgram(GLSLESProgram* parent); - ~GLSLESGpuProgram(); - - /// Execute the binding functions for this program - void bindProgram(void); - /// Execute the unbinding functions for this program - void unbindProgram(void); - /// Execute the param binding functions for this program - void bindProgramParameters(GpuProgramParametersSharedPtr params, uint16 mask); - /// Execute the shared param binding functions for this program - void bindProgramSharedParameters(GpuProgramParametersSharedPtr params, uint16 mask); - /// Execute the pass iteration param binding functions for this program - void bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params); - - protected: - /// Overridden from GpuProgram - void loadFromSource(void); - /// @copydoc Resource::unloadImpl - void unloadImpl(void); - /// @copydoc Resource::loadImpl - void loadImpl(void); - }; -} - -#endif // __GLSLESGpuProgram_H__ diff --git a/RenderSystems/GLES2/src/GLSLES/include/OgreGLSLESProgram.h b/RenderSystems/GLES2/src/GLSLES/include/OgreGLSLESProgram.h index 8b0caa9bcec..a3b61680de7 100644 --- a/RenderSystems/GLES2/src/GLSLES/include/OgreGLSLESProgram.h +++ b/RenderSystems/GLES2/src/GLSLES/include/OgreGLSLESProgram.h @@ -97,6 +97,22 @@ namespace Ogre { /// compile source into shader object bool compile( const bool checkErrors = false); + /// Since GLSL has no assembly, use this shader for binding. + GpuProgram* _getBindingDelegate(void) { return this; } + + /// Execute the binding functions for this program + void bindProgram(void); + /// Execute the unbinding functions for this program + void unbindProgram(void); + /// Execute the param binding functions for this program + void bindProgramParameters(GpuProgramParametersSharedPtr params, uint16 mask); + /// Execute the shared param binding functions for this program + void bindProgramSharedParameters(GpuProgramParametersSharedPtr params, uint16 mask); + /// Execute the pass iteration param binding functions for this program + void bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params); + + size_t calculateSize(void) const; + protected: #if !OGRE_NO_GLES2_GLSL_OPTIMISER static CmdOptimisation msCmdOptimisation; diff --git a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESGpuProgram.cpp b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESGpuProgram.cpp deleted file mode 100644 index 9ad158593d2..00000000000 --- a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESGpuProgram.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* ------------------------------------------------------------------------------ -This source file is part of OGRE - (Object-oriented Graphics Rendering Engine) -For the latest info, see http://www.ogre3d.org/ - -Copyright (c) 2000-2014 Torus Knot Software Ltd - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. ------------------------------------------------------------------------------ -*/ - -#include "OgreGLSLESGpuProgram.h" -#include "OgreGLSLESProgram.h" -#include "OgreGLSLESLinkProgramManager.h" -#include "OgreGLSLESProgramPipelineManager.h" -#include "OgreRoot.h" - -namespace Ogre { - //----------------------------------------------------------------------------- - GLSLESGpuProgram::GLSLESGpuProgram(GLSLESProgram* parent) : - GLES2GpuProgram(parent->getCreator(), parent->getName(), parent->getHandle(), - parent->getGroup(), false, 0), mGLSLProgram(parent) - { - mType = parent->getType(); - mSyntaxCode = "glsles"; - - // Transfer skeletal animation status from parent - mSkeletalAnimation = mGLSLProgram->isSkeletalAnimationIncluded(); - // There is nothing to load - mLoadFromFile = false; - } - //----------------------------------------------------------------------- - GLSLESGpuProgram::~GLSLESGpuProgram() - { - // This workaround is needed otherwise we carry on some dangling pointers - GLSLESLinkProgramManager::getSingletonPtr()->destroyAllByProgram(mGLSLProgram); - - // Have to call this here rather than in Resource destructor - // since calling virtual methods in base destructors causes crash - unload(); - } - //----------------------------------------------------------------------------- - void GLSLESGpuProgram::loadImpl(void) - { - // nothing to load - } - - //----------------------------------------------------------------------------- - void GLSLESGpuProgram::unloadImpl(void) - { - // nothing to unload - } - - //----------------------------------------------------------------------------- - void GLSLESGpuProgram::loadFromSource(void) - { - // nothing to load - } - - //----------------------------------------------------------------------------- - void GLSLESGpuProgram::bindProgram(void) - { - if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) - { - // Tell the Program Pipeline Manager what pipeline is to become active - switch (mType) - { - case GPT_VERTEX_PROGRAM: - GLSLESProgramPipelineManager::getSingleton().setActiveVertexLinkProgram( mGLSLProgram ); - break; - case GPT_FRAGMENT_PROGRAM: - GLSLESProgramPipelineManager::getSingleton().setActiveFragmentLinkProgram( mGLSLProgram ); - break; - case GPT_GEOMETRY_PROGRAM: - default: - break; - } - } - else - { - // Tell the Link Program Manager what shader is to become active - switch (mType) - { - case GPT_VERTEX_PROGRAM: - GLSLESLinkProgramManager::getSingleton().setActiveVertexShader( mGLSLProgram ); - break; - case GPT_FRAGMENT_PROGRAM: - GLSLESLinkProgramManager::getSingleton().setActiveFragmentShader( mGLSLProgram ); - break; - case GPT_GEOMETRY_PROGRAM: - default: - break; - } - } - } - - //----------------------------------------------------------------------------- - void GLSLESGpuProgram::unbindProgram(void) - { - if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) - { - // Tell the Program Pipeline Manager what pipeline is to become inactive - if (mType == GPT_VERTEX_PROGRAM) - { - GLSLESProgramPipelineManager::getSingleton().setActiveVertexLinkProgram(NULL); - } - else if (mType == GPT_FRAGMENT_PROGRAM) - { - GLSLESProgramPipelineManager::getSingleton().setActiveFragmentLinkProgram(NULL); - } - } - else - { - // Tell the Link Program Manager what shader is to become inactive - if (mType == GPT_VERTEX_PROGRAM) - { - GLSLESLinkProgramManager::getSingleton().setActiveVertexShader( NULL ); - } - else if (mType == GPT_FRAGMENT_PROGRAM) - { - GLSLESLinkProgramManager::getSingleton().setActiveFragmentShader( NULL ); - } - } - } - - //----------------------------------------------------------------------------- - void GLSLESGpuProgram::bindProgramParameters(GpuProgramParametersSharedPtr params, uint16 mask) - { - // Link can throw exceptions, ignore them at this point - try - { - if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) - { - // Activate the program pipeline object - GLSLESProgramPipeline* programPipeline = GLSLESProgramPipelineManager::getSingleton().getActiveProgramPipeline(); - // Pass on parameters from params to program object uniforms - programPipeline->updateUniforms(params, mask, mType); - } - else - { - // Activate the link program object - GLSLESLinkProgram* linkProgram = GLSLESLinkProgramManager::getSingleton().getActiveLinkProgram(); - // Pass on parameters from params to program object uniforms - linkProgram->updateUniforms(params, mask, mType); - } - } - catch (Exception& e) {} - } - - //----------------------------------------------------------------------------- - void GLSLESGpuProgram::bindProgramSharedParameters(GpuProgramParametersSharedPtr params, uint16 mask) - { - // Link can throw exceptions, ignore them at this point - try - { - if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) - { - // Activate the program pipeline object - GLSLESProgramPipeline* programPipeline = GLSLESProgramPipelineManager::getSingleton().getActiveProgramPipeline(); - // Pass on parameters from params to program object uniforms - programPipeline->updateUniformBlocks(params, mask, mType); - } - else - { - // Activate the link program object - GLSLESLinkProgram* linkProgram = GLSLESLinkProgramManager::getSingleton().getActiveLinkProgram(); - // Pass on parameters from params to program object uniforms - linkProgram->updateUniformBlocks(params, mask, mType); - } - } - catch (Exception& e) {} - } - - //----------------------------------------------------------------------------- - void GLSLESGpuProgram::bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params) - { - if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) - { - // Activate the program pipeline object - GLSLESProgramPipeline* programPipeline = GLSLESProgramPipelineManager::getSingleton().getActiveProgramPipeline(); - // Pass on parameters from params to program object uniforms - programPipeline->updatePassIterationUniforms( params ); - } - else - { - // Activate the link program object - GLSLESLinkProgram* linkProgram = GLSLESLinkProgramManager::getSingleton().getActiveLinkProgram(); - // Pass on parameters from params to program object uniforms - linkProgram->updatePassIterationUniforms( params ); - } - } -} diff --git a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESLinkProgram.cpp b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESLinkProgram.cpp index ff72913b843..cb896bd5c36 100644 --- a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESLinkProgram.cpp +++ b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESLinkProgram.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. */ #include "OgreGLSLESLinkProgram.h" -#include "OgreGLSLESGpuProgram.h" +#include "OgreGLSLESProgram.h" #include "OgreGLSLESProgram.h" #include "OgreGLSLESLinkProgramManager.h" #include "OgreGLES2HardwareUniformBuffer.h" diff --git a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESLinkProgramManager.cpp b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESLinkProgramManager.cpp index 665cf58fe9b..71c9f181d1b 100644 --- a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESLinkProgramManager.cpp +++ b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESLinkProgramManager.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. */ #include "OgreGLSLESLinkProgramManager.h" -#include "OgreGLSLESGpuProgram.h" +#include "OgreGLSLESProgram.h" #include "OgreStringConverter.h" #include "OgreGLSLESProgram.h" diff --git a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgram.cpp b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgram.cpp index 143df7c48e1..21e478cdee4 100644 --- a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgram.cpp +++ b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgram.cpp @@ -36,7 +36,7 @@ THE SOFTWARE. #include "OgreGLES2Support.h" #include "OgreGLSLESProgram.h" -#include "OgreGLSLESGpuProgram.h" +#include "OgreGLSLESProgram.h" #include "OgreGLSLESLinkProgramManager.h" #include "OgreGLSLESProgramPipelineManager.h" #include "OgreGLSLPreprocessor.h" @@ -75,6 +75,9 @@ namespace Ogre { } // Manually assign language now since we use it immediately mSyntaxCode = "glsles"; + + // There is nothing to load + mLoadFromFile = false; } //--------------------------------------------------------------------------- GLSLESProgram::~GLSLESProgram() @@ -234,7 +237,6 @@ namespace Ogre { //----------------------------------------------------------------------- void GLSLESProgram::createLowLevelImpl(void) { - mAssemblerProgram = GpuProgramPtr(OGRE_NEW GLSLESGpuProgram( this )); } //----------------------------------------------------------------------- void GLSLESProgram::unloadHighLevelImpl(void) @@ -366,4 +368,150 @@ namespace Ogre { } } } + + //----------------------------------------------------------------------------- + void GLSLESProgram::bindProgram(void) + { + if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) + { + // Tell the Program Pipeline Manager what pipeline is to become active + switch (mType) + { + case GPT_VERTEX_PROGRAM: + GLSLESProgramPipelineManager::getSingleton().setActiveVertexLinkProgram( this ); + break; + case GPT_FRAGMENT_PROGRAM: + GLSLESProgramPipelineManager::getSingleton().setActiveFragmentLinkProgram( this ); + break; + case GPT_GEOMETRY_PROGRAM: + default: + break; + } + } + else + { + // Tell the Link Program Manager what shader is to become active + switch (mType) + { + case GPT_VERTEX_PROGRAM: + GLSLESLinkProgramManager::getSingleton().setActiveVertexShader( this ); + break; + case GPT_FRAGMENT_PROGRAM: + GLSLESLinkProgramManager::getSingleton().setActiveFragmentShader( this ); + break; + case GPT_GEOMETRY_PROGRAM: + default: + break; + } + } + } + + //----------------------------------------------------------------------------- + void GLSLESProgram::unbindProgram(void) + { + if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) + { + // Tell the Program Pipeline Manager what pipeline is to become inactive + if (mType == GPT_VERTEX_PROGRAM) + { + GLSLESProgramPipelineManager::getSingleton().setActiveVertexLinkProgram(NULL); + } + else if (mType == GPT_FRAGMENT_PROGRAM) + { + GLSLESProgramPipelineManager::getSingleton().setActiveFragmentLinkProgram(NULL); + } + } + else + { + // Tell the Link Program Manager what shader is to become inactive + if (mType == GPT_VERTEX_PROGRAM) + { + GLSLESLinkProgramManager::getSingleton().setActiveVertexShader( NULL ); + } + else if (mType == GPT_FRAGMENT_PROGRAM) + { + GLSLESLinkProgramManager::getSingleton().setActiveFragmentShader( NULL ); + } + } + } + + //----------------------------------------------------------------------------- + void GLSLESProgram::bindProgramParameters(GpuProgramParametersSharedPtr params, uint16 mask) + { + // Link can throw exceptions, ignore them at this point + try + { + if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) + { + // Activate the program pipeline object + GLSLESProgramPipeline* programPipeline = GLSLESProgramPipelineManager::getSingleton().getActiveProgramPipeline(); + // Pass on parameters from params to program object uniforms + programPipeline->updateUniforms(params, mask, mType); + } + else + { + // Activate the link program object + GLSLESLinkProgram* linkProgram = GLSLESLinkProgramManager::getSingleton().getActiveLinkProgram(); + // Pass on parameters from params to program object uniforms + linkProgram->updateUniforms(params, mask, mType); + } + } + catch (Exception& e) {} + } + + //----------------------------------------------------------------------------- + void GLSLESProgram::bindProgramSharedParameters(GpuProgramParametersSharedPtr params, uint16 mask) + { + // Link can throw exceptions, ignore them at this point + try + { + if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) + { + // Activate the program pipeline object + GLSLESProgramPipeline* programPipeline = GLSLESProgramPipelineManager::getSingleton().getActiveProgramPipeline(); + // Pass on parameters from params to program object uniforms + programPipeline->updateUniformBlocks(params, mask, mType); + } + else + { + // Activate the link program object + GLSLESLinkProgram* linkProgram = GLSLESLinkProgramManager::getSingleton().getActiveLinkProgram(); + // Pass on parameters from params to program object uniforms + linkProgram->updateUniformBlocks(params, mask, mType); + } + } + catch (Exception& e) {} + } + + //----------------------------------------------------------------------------- + void GLSLESProgram::bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params) + { + if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS)) + { + // Activate the program pipeline object + GLSLESProgramPipeline* programPipeline = GLSLESProgramPipelineManager::getSingleton().getActiveProgramPipeline(); + // Pass on parameters from params to program object uniforms + programPipeline->updatePassIterationUniforms( params ); + } + else + { + // Activate the link program object + GLSLESLinkProgram* linkProgram = GLSLESLinkProgramManager::getSingleton().getActiveLinkProgram(); + // Pass on parameters from params to program object uniforms + linkProgram->updatePassIterationUniforms( params ); + } + } + + //----------------------------------------------------------------------------- + size_t GLSLESProgram::calculateSize(void) const + { + size_t memSize = 0; + + // Delegate Names + memSize += sizeof(GLuint); + memSize += sizeof(GLenum); + memSize += GpuProgram::calculateSize(); + + return memSize; + } } diff --git a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramCommon.cpp b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramCommon.cpp index 1d55fd92703..ade04eed345 100644 --- a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramCommon.cpp +++ b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramCommon.cpp @@ -27,7 +27,7 @@ */ #include "OgreGLSLESProgramCommon.h" -#include "OgreGLSLESGpuProgram.h" +#include "OgreGLSLESProgram.h" #include "OgreGpuProgramManager.h" #include "OgreGLUtil.h" #include "OgreGLES2RenderSystem.h" diff --git a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramManagerCommon.cpp b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramManagerCommon.cpp index 5fed389d85c..5743f22b7ec 100644 --- a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramManagerCommon.cpp +++ b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramManagerCommon.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. */ #include "OgreGLSLESProgramManagerCommon.h" -#include "OgreGLSLESGpuProgram.h" +#include "OgreGLSLESProgram.h" #include "OgreLogManager.h" #include "OgreStringConverter.h" #include "OgreGpuProgramManager.h" diff --git a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramPipeline.cpp b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramPipeline.cpp index ac4f9a66be5..22fd0bcd4a5 100644 --- a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramPipeline.cpp +++ b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramPipeline.cpp @@ -28,7 +28,7 @@ #include "OgreGLSLESProgramPipeline.h" #include "OgreStringConverter.h" -#include "OgreGLSLESGpuProgram.h" +#include "OgreGLSLESProgram.h" #include "OgreGLSLESProgram.h" #include "OgreGLSLESProgramPipelineManager.h" #include "OgreGpuProgramManager.h" diff --git a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramPipelineManager.cpp b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramPipelineManager.cpp index 3dd37327b35..f4aeeb4c44d 100644 --- a/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramPipelineManager.cpp +++ b/RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESProgramPipelineManager.cpp @@ -27,7 +27,7 @@ */ #include "OgreGLSLESProgramPipelineManager.h" -#include "OgreGLSLESGpuProgram.h" +#include "OgreGLSLESProgram.h" #include "OgreGLSLESProgram.h" namespace Ogre diff --git a/RenderSystems/GLES2/src/OgreGLES2GpuProgram.cpp b/RenderSystems/GLES2/src/OgreGLES2GpuProgram.cpp deleted file mode 100644 index 8f0ddcab1a0..00000000000 --- a/RenderSystems/GLES2/src/OgreGLES2GpuProgram.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* ------------------------------------------------------------------------------ -This source file is part of OGRE -(Object-oriented Graphics Rendering Engine) -For the latest info, see http://www.ogre3d.org/ - -Copyright (c) 2000-2014 Torus Knot Software Ltd - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. ------------------------------------------------------------------------------ -*/ - -#include "OgreGLES2GpuProgram.h" -#include "OgreLogManager.h" - -using namespace Ogre; - -GLenum getGLShaderType(GpuProgramType programType); - -GLenum getGLShaderType(GpuProgramType programType) -{ - switch (programType) - { - case GPT_VERTEX_PROGRAM: - default: - return GL_VERTEX_SHADER; - case GPT_FRAGMENT_PROGRAM: - return GL_FRAGMENT_SHADER; - } -} - -GLES2GpuProgram::GLES2GpuProgram(ResourceManager* creator, const String& name, - ResourceHandle handle, const String& group, bool isManual, - ManualResourceLoader* loader) - : GpuProgram(creator, name, handle, group, isManual, loader) -{ - if (createParamDictionary("GLES2GpuProgram")) - { - setupBaseParamDictionary(); - } -} - -GLES2GpuProgram::~GLES2GpuProgram() -{ - // have to call this here reather than in Resource destructor - // since calling virtual methods in base destructors causes crash - unload(); -} - -//----------------------------------------------------------------------------- -size_t GLES2GpuProgram::calculateSize(void) const -{ - size_t memSize = 0; - - // Delegate Names - memSize += sizeof(GLuint); - memSize += sizeof(GLenum); - memSize += GpuProgram::calculateSize(); - - return memSize; -} - - - \ No newline at end of file diff --git a/RenderSystems/GLES2/src/OgreGLES2GpuProgramManager.cpp b/RenderSystems/GLES2/src/OgreGLES2GpuProgramManager.cpp index 40532bdf41f..b1c2252691d 100644 --- a/RenderSystems/GLES2/src/OgreGLES2GpuProgramManager.cpp +++ b/RenderSystems/GLES2/src/OgreGLES2GpuProgramManager.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. */ #include "OgreGLES2GpuProgramManager.h" -#include "OgreGLES2GpuProgram.h" +#include "OgreGLSLESProgram.h" #include "OgreLogManager.h" namespace Ogre { @@ -77,7 +77,7 @@ namespace Ogre { { // No factory, this is an unsupported syntax code, probably for another rendersystem // Create a basic one, it doesn't matter what it is since it won't be used - return new GLES2GpuProgram(this, name, handle, group, isManual, loader); + return new GLSLESProgram(this, name, handle, group, isManual, loader); } GpuProgramType gpt; @@ -106,7 +106,7 @@ namespace Ogre { { // No factory, this is an unsupported syntax code, probably for another rendersystem // Create a basic one, it doesn't matter what it is since it won't be used - return new GLES2GpuProgram(this, name, handle, group, isManual, loader); + return new GLSLESProgram(this, name, handle, group, isManual, loader); } return (iter->second)(this, name, handle, group, isManual, loader, gptype, syntaxCode); diff --git a/RenderSystems/GLES2/src/OgreGLES2HardwarePixelBuffer.cpp b/RenderSystems/GLES2/src/OgreGLES2HardwarePixelBuffer.cpp index 1ae55c7cd94..5d05144930b 100644 --- a/RenderSystems/GLES2/src/OgreGLES2HardwarePixelBuffer.cpp +++ b/RenderSystems/GLES2/src/OgreGLES2HardwarePixelBuffer.cpp @@ -30,7 +30,6 @@ THE SOFTWARE. #include "OgreGLES2HardwarePixelBuffer.h" #include "OgreGLES2PixelFormat.h" #include "OgreGLES2FBORenderTexture.h" -#include "OgreGLES2GpuProgram.h" #include "OgreGLUtil.h" #include "OgreGLES2RenderSystem.h" #include "OgreGLES2StateCacheManager.h" diff --git a/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp b/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp index fd9215f12a2..6e79bac66f8 100644 --- a/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp +++ b/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp @@ -1936,7 +1936,7 @@ namespace Ogre { "GLES2RenderSystem::bindGpuProgram"); } - GLES2GpuProgram* glprg = static_cast(prg); + GLSLESProgram* glprg = static_cast(prg); // Unbind previous gpu program first. // From 5676cf03cfb45e4bbb9e542819a332ae4e4f7e61 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sat, 21 Jan 2017 15:48:20 +0100 Subject: [PATCH 2/4] HighLevelGpuProgram::loadHighLevel: do not catch Assertions --- OgreMain/src/OgreHighLevelGpuProgram.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OgreMain/src/OgreHighLevelGpuProgram.cpp b/OgreMain/src/OgreHighLevelGpuProgram.cpp index 95e88c4efd0..36a99a4d9ba 100644 --- a/OgreMain/src/OgreHighLevelGpuProgram.cpp +++ b/OgreMain/src/OgreHighLevelGpuProgram.cpp @@ -138,6 +138,10 @@ namespace Ogre } } + catch (const RuntimeAssertionException&) + { + throw; + } catch (const Exception& e) { // will already have been logged From 39083d43d100ac20a3b95e745d1ecfa9da140b2b Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sat, 21 Jan 2017 15:48:41 +0100 Subject: [PATCH 3/4] ResourceGroupManager::openResource: resourceName must not be empty --- OgreMain/src/OgreResourceGroupManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/OgreMain/src/OgreResourceGroupManager.cpp b/OgreMain/src/OgreResourceGroupManager.cpp index 365b0ca13d1..394459fa93f 100644 --- a/OgreMain/src/OgreResourceGroupManager.cpp +++ b/OgreMain/src/OgreResourceGroupManager.cpp @@ -670,6 +670,7 @@ namespace Ogre { const String& resourceName, const String& groupName, bool searchGroupsIfNotFound, Resource* resourceBeingLoaded) const { + OgreAssert(!resourceName.empty(), "resourceName is empty string"); OGRE_LOCK_AUTO_MUTEX; if(mLoadingListener) From b869bb3734762ea469b3ad8efdf7daf218d48c43 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sat, 21 Jan 2017 15:56:34 +0100 Subject: [PATCH 4/4] GL*RenderSystem: forward syntax code to mark shader as unsupported --- RenderSystems/GL/src/OgreGLGpuProgramManager.cpp | 10 ++++++++-- .../GL3Plus/src/GLSL/OgreGLSLShaderManager.cpp | 10 ++++++++-- RenderSystems/GLES2/src/OgreGLES2GpuProgramManager.cpp | 10 ++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/RenderSystems/GL/src/OgreGLGpuProgramManager.cpp b/RenderSystems/GL/src/OgreGLGpuProgramManager.cpp index a17cf8a0a17..59393be21f7 100644 --- a/RenderSystems/GL/src/OgreGLGpuProgramManager.cpp +++ b/RenderSystems/GL/src/OgreGLGpuProgramManager.cpp @@ -78,7 +78,10 @@ Resource* GLGpuProgramManager::createImpl(const String& name, ResourceHandle han { // No factory, this is an unsupported syntax code, probably for another rendersystem // Create a basic one, it doesn't matter what it is since it won't be used - return new GLGpuProgram(this, name, handle, group, isManual, loader); + // we have to forward the syntax code though + GpuProgram* ret = new GLGpuProgram(this, name, handle, group, isManual, loader); + ret->setSyntaxCode(paramSyntax->second); + return ret; } GpuProgramType gpt; @@ -108,7 +111,10 @@ Resource* GLGpuProgramManager::createImpl(const String& name, ResourceHandle han { // No factory, this is an unsupported syntax code, probably for another rendersystem // Create a basic one, it doesn't matter what it is since it won't be used - return new GLGpuProgram(this, name, handle, group, isManual, loader); + // we have to forward the syntax code though + GpuProgram* ret = new GLGpuProgram(this, name, handle, group, isManual, loader); + ret->setSyntaxCode(syntaxCode); + return ret; } return (iter->second)(this, name, handle, group, isManual, loader, gptype, syntaxCode); diff --git a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShaderManager.cpp b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShaderManager.cpp index 68d2f09d873..ef199147afc 100644 --- a/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShaderManager.cpp +++ b/RenderSystems/GL3Plus/src/GLSL/OgreGLSLShaderManager.cpp @@ -83,7 +83,10 @@ namespace Ogre { { // No factory, this is an unsupported syntax code, probably for another rendersystem // Create a basic one, it doesn't matter what it is since it won't be used - return new GLSLShader(this, name, handle, group, isManual, loader); + // we have to forward the syntax code though + GpuProgram* ret = new GLSLShader(this, name, handle, group, isManual, loader); + ret->setSyntaxCode(paramSyntax->second); + return ret; } GpuProgramType gpt; @@ -135,7 +138,10 @@ namespace Ogre { { // No factory, this is an unsupported syntax code, probably for another rendersystem // Create a basic one, it doesn't matter what it is since it won't be used - return new GLSLShader(this, name, handle, group, isManual, loader); + // we have to forward the syntax code though + GpuProgram* ret = new GLSLShader(this, name, handle, group, isManual, loader); + ret->setSyntaxCode(syntaxCode); + return ret; } return (iter->second)(this, name, handle, group, isManual, loader, gptype, syntaxCode); diff --git a/RenderSystems/GLES2/src/OgreGLES2GpuProgramManager.cpp b/RenderSystems/GLES2/src/OgreGLES2GpuProgramManager.cpp index b1c2252691d..5e24de25559 100644 --- a/RenderSystems/GLES2/src/OgreGLES2GpuProgramManager.cpp +++ b/RenderSystems/GLES2/src/OgreGLES2GpuProgramManager.cpp @@ -77,7 +77,10 @@ namespace Ogre { { // No factory, this is an unsupported syntax code, probably for another rendersystem // Create a basic one, it doesn't matter what it is since it won't be used - return new GLSLESProgram(this, name, handle, group, isManual, loader); + // we have to forward the syntax code though + GpuProgram* ret = new GLSLESProgram(this, name, handle, group, isManual, loader); + ret->setSyntaxCode(paramSyntax->second); + return ret; } GpuProgramType gpt; @@ -106,7 +109,10 @@ namespace Ogre { { // No factory, this is an unsupported syntax code, probably for another rendersystem // Create a basic one, it doesn't matter what it is since it won't be used - return new GLSLESProgram(this, name, handle, group, isManual, loader); + // we have to forward the syntax code though + GpuProgram* ret = new GLSLESProgram(this, name, handle, group, isManual, loader); + ret->setSyntaxCode(syntaxCode); + return ret; } return (iter->second)(this, name, handle, group, isManual, loader, gptype, syntaxCode);