VertexArrayState's lazy disabling of vertex attributes mechanism major fix: _vertexAttribArrays must be 'shared'
This commit is contained in:
parent
cbb9fd4218
commit
be6bc39016
@ -553,7 +553,19 @@ bool VertexArrayState::correctArrayDispatchAssigned(const ArrayDispatch* ad)
|
|||||||
#else
|
#else
|
||||||
return ad!=0;
|
return ad!=0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
VertexArrayState::ArrayDispatch* getOrCreateVertexAttributeDispatch(VertexArrayState::ArrayDispatchList& list, int slot)
|
||||||
|
{
|
||||||
|
list.resize(slot + 1);
|
||||||
|
osg::ref_ptr<VertexArrayState::ArrayDispatch>& ad = list[slot];
|
||||||
|
if (!ad.valid())
|
||||||
|
ad = new VertexAttribArrayDispatch(slot);
|
||||||
|
|
||||||
|
return ad.get();
|
||||||
|
}
|
||||||
|
}// anonumous namespace
|
||||||
|
|
||||||
void VertexArrayState::assignVertexArrayDispatcher()
|
void VertexArrayState::assignVertexArrayDispatcher()
|
||||||
{
|
{
|
||||||
@ -567,9 +579,9 @@ void VertexArrayState::assignVertexArrayDispatcher()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (_vertexArray.valid()) return;
|
int slot = _state->getVertexAlias()._location;
|
||||||
VAS_NOTICE<<"VertexArrayState::assignVertexArrayDispatcher() _state->getVertexAlias()._location="<<_state->getVertexAlias()._location<<std::endl;
|
VAS_NOTICE << "VertexArrayState::assignVertexArrayDispatcher() _state->getVertexAlias()._location = " << slot << std::endl;
|
||||||
_vertexArray = new VertexAttribArrayDispatch(_state->getVertexAlias()._location);
|
_vertexArray = getOrCreateVertexAttributeDispatch(_vertexAttribArrays, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,8 +597,9 @@ void VertexArrayState::assignNormalArrayDispatcher()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
VAS_NOTICE<<"VertexArrayState::assignNormalArrayDispatcher() _state->getNormalAlias()._location="<<_state->getNormalAlias()._location<<std::endl;
|
int slot = _state->getNormalAlias()._location;
|
||||||
_normalArray = new VertexAttribArrayDispatch(_state->getNormalAlias()._location);
|
VAS_NOTICE << "VertexArrayState::assignNormalArrayDispatcher() _state->getNormalAlias()._location = " << slot << std::endl;
|
||||||
|
_normalArray = getOrCreateVertexAttributeDispatch(_vertexAttribArrays, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,8 +615,9 @@ void VertexArrayState::assignColorArrayDispatcher()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
VAS_NOTICE<<"VertexArrayState::assignColorArrayDispatcher() _state->getColorAlias()._location="<<_state->getColorAlias()._location<<std::endl;
|
int slot = _state->getColorAlias()._location;
|
||||||
_colorArray = new VertexAttribArrayDispatch(_state->getColorAlias()._location);
|
VAS_NOTICE << "VertexArrayState::assignColorArrayDispatcher() _state->getColorAlias()._location = " << slot << std::endl;
|
||||||
|
_colorArray = getOrCreateVertexAttributeDispatch(_vertexAttribArrays, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,7 +633,9 @@ void VertexArrayState::assignSecondaryColorArrayDispatcher()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
_secondaryColorArray = new VertexAttribArrayDispatch(_state->getSecondaryColorAlias()._location);
|
int slot = _state->getSecondaryColorAlias()._location;
|
||||||
|
VAS_NOTICE << "VertexArrayState::assignSecondaryColorArrayDispatcher() _state->getSecondaryColorAlias()._location = " << slot << std::endl;
|
||||||
|
_secondaryColorArray = getOrCreateVertexAttributeDispatch(_vertexAttribArrays, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,7 +651,9 @@ void VertexArrayState::assignFogCoordArrayDispatcher()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
_fogCoordArray = new VertexAttribArrayDispatch(_state->getFogCoordAlias()._location);
|
int slot = _state->getFogCoordAlias()._location;
|
||||||
|
VAS_NOTICE << "VertexArrayState::assignFogCoordArrayDispatcher() _state->getFogCoordAlias()._location = " << slot << std::endl;
|
||||||
|
_fogCoordArray = getOrCreateVertexAttributeDispatch(_vertexAttribArrays, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,7 +673,9 @@ void VertexArrayState::assignTexCoordArrayDispatcher(unsigned int numUnits)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
_texCoordArrays[i] = new VertexAttribArrayDispatch(_state->getTexCoordAliasList()[i]._location);
|
int slot = _state->getTexCoordAliasList()[i]._location;
|
||||||
|
VAS_NOTICE << "VertexArrayState::assignTexCoordArrayDispatcher() _state->getTexCoordAliasList()[" << i << "]._location = " << slot << std::endl;
|
||||||
|
_texCoordArrays[i] = getOrCreateVertexAttributeDispatch(_vertexAttribArrays, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -677,13 +697,14 @@ void VertexArrayState::assignAllDispatchers()
|
|||||||
unsigned int numUnits = 8;
|
unsigned int numUnits = 8;
|
||||||
unsigned int numVertexAttrib = 16;
|
unsigned int numVertexAttrib = 16;
|
||||||
|
|
||||||
|
assignVertexAttribArrayDispatcher(numVertexAttrib);
|
||||||
|
|
||||||
assignVertexArrayDispatcher();
|
assignVertexArrayDispatcher();
|
||||||
assignNormalArrayDispatcher();
|
assignNormalArrayDispatcher();
|
||||||
assignColorArrayDispatcher();
|
assignColorArrayDispatcher();
|
||||||
assignSecondaryColorArrayDispatcher();
|
assignSecondaryColorArrayDispatcher();
|
||||||
assignFogCoordArrayDispatcher();
|
assignFogCoordArrayDispatcher();
|
||||||
assignTexCoordArrayDispatcher(numUnits);
|
assignTexCoordArrayDispatcher(numUnits);
|
||||||
assignVertexAttribArrayDispatcher(numVertexAttrib);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexArrayState::release()
|
void VertexArrayState::release()
|
||||||
|
Loading…
Reference in New Issue
Block a user