Hello,
after some debugging I have found the cause of the crash, but no
resolution yet.
What happens goes as follows:
After activating the first shader program the following function is
executed with this call stack:
> OSGSystemD.dll!OSG::osgUniformShaderVariableLocation(OSG::DrawEnv *
pEnv=0x00000000090e8378, OSG::ShaderVariable * pVar=0x00000000109fb4f8,
int & loc=-1, unsigned int uiProgram=1) Line 51 C++
OSGSystemD.dll!OSG::osgUniformShaderVariableSwitch(OSG::DrawEnv *
pEnv=0x00000000090e8378, OSG::ShaderVariable * pVar=0x00000000109fb4f8,
int & loc=-1, unsigned int uiProgram=1, bool warnUnknown=false) Line 58
C++
OSGSystemD.dll!OSG::ShaderExecutableVarChunk::updateVariables(OSG::DrawEnv
* pEnv=0x00000000090e8378) Line 260 C++
OSGSystemD.dll!OSG::ShaderExecutableVarChunk::activate(OSG::DrawEnv *
pEnv=0x00000000090e8378, unsigned int __formal=0) Line 191 C++
OSGSystemD.dll!OSG::DrawEnv::activate(OSG::State *
pState=0x0000000010790768, OSG::StateOverride *
pOverride=0x0000000015117860) Line 438 C++
OSGSystemD.dll!OSG::DrawEnv::activateState(OSG::State *
pNewState=0x0000000010790768, OSG::StateOverride *
pNewStateOverride=0x0000000015117860) Line 392 C++
OSGSystemD.dll!OSG::TreeBuilderBase::drawNode(OSG::RenderTreeNode *
pNode=0x0000000015116c00, OSG::DrawEnv & denv={...},
OSG::RenderPartitionBase * part=0x00000000090e8320) Line 148 C++
in OsgShaderVariables.cpp
=========================
void osgUniformShaderVariableSwitch(DrawEnv *pEnv,
ShaderVariable *pVar,
Int32 &loc,
UInt32 uiProgram,
bool warnUnknown)
{
switch(pVar->getTypeId())
{
case ShaderVariable::SHVTypeBool:
osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
osgUniformShaderVariableBool (pEnv, pVar, loc, uiProgram,
warnUnknown );
break;
...
osgUniformShaderVariableLocation is called with loc = -1 and uiProgram =
1 ...
in OsgShaderVariables.inl
=========================
inline
void osgUniformShaderVariableLocation(DrawEnv *pEnv,
ShaderVariable *pVar,
Int32 &loc,
UInt32 uiProgram)
{
if(loc == -1)
{
OSGGETGLFUNC_GL3_ES(glGetUniformLocation,
osgGlGetUniformLocation,
ShaderProgram::getFuncIdGetUniformLocation());
loc = osgGlGetUniformLocation(uiProgram, pVar->getName().c_str());
}
}
... and therefore the loc is initialized to loc = 108. Then
osgUniformShaderVariableBool is called ...
inline
void osgUniformShaderVariableBool(DrawEnv *pEnv,
ShaderVariable *pVar,
Int32 &loc,
UInt32 uiProgram,
bool warnUnknown)
{
ShaderVariableBool *p = dynamic_cast<ShaderVariableBool *>(pVar);
if(loc != -1)
{
OSGGETGLFUNC_GL3_ES(glUniform1i,
osgGlUniform1i,
ShaderProgram::getFuncIdUniform1i());
osgGlUniform1i(loc, GLint(p->getValue()));
}
else if(warnUnknown == true)
{
SWARNING << "Variable '" << p->getName() << "' type 'bool' "
<< "not found in active uniform "
<< "variables of shader program '" << uiProgram << "'"
<< std::endl;
}
}
... and the osgGlUniform1i(loc, GLint(p->getValue())); takes place
successfully.
However, after switching to the second shader
osgUniformShaderVariableLocation is called with loc = 108 and uiProgram
= 4. Nothing happens in this call. But in the following call to
osgUniformShaderVariableBool osgGlUniform1i(loc, GLint(p->getValue()));
crashes since uiProgram = 4 knows nothing about loc = 108.
So, what can I do from my high level perspective to embed the uniforms
in the new shader?
Sorry, for the lengthy mail, but this is important for me to solve and I
don't know how to describe it more properly.
Best,
Johannes
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users