Moved the ArrayDispatchers management so that osg::State now has a ArrayDispatchers object that any osg::Geometry can reuse,
and optimized the implementation to reduce the CPU overhead.
This commit is contained in:
parent
b7ffae25ce
commit
9499b19b43
@ -17,12 +17,12 @@
|
|||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
#include <osg/Array>
|
#include <osg/Array>
|
||||||
#include <osg/Matrixd>
|
#include <osg/Matrixd>
|
||||||
|
#include <osg/GLBeginEndAdapter>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
// forward declare
|
// forward declare
|
||||||
class State;
|
class State;
|
||||||
class GLBeginEndAdapter;
|
|
||||||
class AttributeDispatchMap;
|
class AttributeDispatchMap;
|
||||||
|
|
||||||
struct AttributeDispatch : public osg::Referenced
|
struct AttributeDispatch : public osg::Referenced
|
||||||
@ -36,11 +36,10 @@ class OSG_EXPORT ArrayDispatchers : public osg::Referenced
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ArrayDispatchers(osg::State& state);
|
ArrayDispatchers();
|
||||||
~ArrayDispatchers();
|
~ArrayDispatchers();
|
||||||
|
|
||||||
void assignTexCoordDispatchers(unsigned int unit);
|
void setState(osg::State* state);
|
||||||
void assignVertexAttribDispatchers(unsigned int unit);
|
|
||||||
|
|
||||||
AttributeDispatch* vertexDispatcher(Array* array, IndexArray* indices);
|
AttributeDispatch* vertexDispatcher(Array* array, IndexArray* indices);
|
||||||
AttributeDispatch* normalDispatcher(Array* array, IndexArray* indices);
|
AttributeDispatch* normalDispatcher(Array* array, IndexArray* indices);
|
||||||
@ -55,24 +54,52 @@ class OSG_EXPORT ArrayDispatchers : public osg::Referenced
|
|||||||
void setUseGLBeginEndAdapter(bool flag) { _useGLBeginEndAdapter = flag; }
|
void setUseGLBeginEndAdapter(bool flag) { _useGLBeginEndAdapter = flag; }
|
||||||
bool getUseGLBeginEndAdapter() const { return _useGLBeginEndAdapter; }
|
bool getUseGLBeginEndAdapter() const { return _useGLBeginEndAdapter; }
|
||||||
|
|
||||||
void activate(unsigned int binding, AttributeDispatch* at);
|
void activate(unsigned int binding, AttributeDispatch* at)
|
||||||
|
{
|
||||||
|
if (at) _activeDispatchList[binding].push_back(at);
|
||||||
|
}
|
||||||
|
|
||||||
void activateVertexArray(unsigned int binding, osg::Array* array, osg::IndexArray* indices) { activate(binding, vertexDispatcher(array, indices)); }
|
void activateVertexArray(unsigned int binding, osg::Array* array, osg::IndexArray* indices) { if (binding && array) activate(binding, vertexDispatcher(array, indices)); }
|
||||||
void activateColorArray(unsigned int binding, osg::Array* array, osg::IndexArray* indices) { activate(binding, colorDispatcher(array, indices)); }
|
void activateColorArray(unsigned int binding, osg::Array* array, osg::IndexArray* indices) { if (binding && array) activate(binding, colorDispatcher(array, indices)); }
|
||||||
void activateNormalArray(unsigned int binding, osg::Array* array, osg::IndexArray* indices) { activate(binding, normalDispatcher(array, indices)); }
|
void activateNormalArray(unsigned int binding, osg::Array* array, osg::IndexArray* indices) { if (binding && array) activate(binding, normalDispatcher(array, indices)); }
|
||||||
void activateSecondaryColorArray(unsigned int binding, osg::Array* array, osg::IndexArray* indices) { activate(binding, secondaryColorDispatcher(array, indices)); }
|
void activateSecondaryColorArray(unsigned int binding, osg::Array* array, osg::IndexArray* indices) { if (binding && array) activate(binding, secondaryColorDispatcher(array, indices)); }
|
||||||
void activateFogCoordArray(unsigned int binding, osg::Array* array, osg::IndexArray* indices) { activate(binding, fogCoordDispatcher(array, indices)); }
|
void activateFogCoordArray(unsigned int binding, osg::Array* array, osg::IndexArray* indices) { if (binding && array) activate(binding, fogCoordDispatcher(array, indices)); }
|
||||||
void activateTexCoordArray(unsigned int binding, unsigned int unit, osg::Array* array, osg::IndexArray* indices) { activate(binding, texCoordDispatcher(unit, array, indices)); }
|
void activateTexCoordArray(unsigned int binding, unsigned int unit, osg::Array* array, osg::IndexArray* indices) { if (binding && array) activate(binding, texCoordDispatcher(unit, array, indices)); }
|
||||||
void activateVertexAttribArray(unsigned int binding, unsigned int unit, osg::Array* array, osg::IndexArray* indices) { activate(binding, vertexAttribDispatcher(unit, array, indices)); }
|
void activateVertexAttribArray(unsigned int binding, unsigned int unit, osg::Array* array, osg::IndexArray* indices) { if (binding && array) activate(binding, vertexAttribDispatcher(unit, array, indices)); }
|
||||||
|
|
||||||
void dispatch(unsigned int binding);
|
void dispatch(unsigned int binding, unsigned int index)
|
||||||
void dispatch(unsigned int binding, unsigned int index);
|
{
|
||||||
|
AttributeDispatchList& ad = _activeDispatchList[binding];
|
||||||
|
for(AttributeDispatchList::iterator itr = ad.begin();
|
||||||
|
itr != ad.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
(*(*itr))(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Begin(GLenum mode);
|
bool active(unsigned int binding) const { return !_activeDispatchList[binding].empty(); }
|
||||||
void End();
|
|
||||||
|
void Begin(GLenum mode)
|
||||||
|
{
|
||||||
|
if (_useGLBeginEndAdapter) _glBeginEndAdapter->Begin(mode);
|
||||||
|
else ::glBegin(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void End()
|
||||||
|
{
|
||||||
|
if (_useGLBeginEndAdapter) _glBeginEndAdapter->End();
|
||||||
|
else ::glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
void assignTexCoordDispatchers(unsigned int unit);
|
||||||
|
void assignVertexAttribDispatchers(unsigned int unit);
|
||||||
|
|
||||||
|
bool _initialized;
|
||||||
State* _state;
|
State* _state;
|
||||||
GLBeginEndAdapter* _glBeginEndAdapter;
|
GLBeginEndAdapter* _glBeginEndAdapter;
|
||||||
|
|
||||||
@ -88,19 +115,12 @@ class OSG_EXPORT ArrayDispatchers : public osg::Referenced
|
|||||||
|
|
||||||
typedef std::vector<AttributeDispatch*> AttributeDispatchList;
|
typedef std::vector<AttributeDispatch*> AttributeDispatchList;
|
||||||
|
|
||||||
struct BindingGroup
|
typedef std::vector<AttributeDispatchList> ActiveDispatchList;
|
||||||
{
|
ActiveDispatchList _activeDispatchList;
|
||||||
unsigned int _index;
|
|
||||||
AttributeDispatchList _attributeDispatchList;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::vector<BindingGroup> BindingGroupList;
|
|
||||||
BindingGroupList _bindingGroupList;
|
|
||||||
|
|
||||||
bool _useGLBeginEndAdapter;
|
bool _useGLBeginEndAdapter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,6 +73,7 @@ class Vec4f;
|
|||||||
class Vec4ub;
|
class Vec4ub;
|
||||||
class Geometry;
|
class Geometry;
|
||||||
class NodeVisitor;
|
class NodeVisitor;
|
||||||
|
class ArrayDispatchers;
|
||||||
|
|
||||||
// this is defined to alter the way display lists are compiled inside the
|
// this is defined to alter the way display lists are compiled inside the
|
||||||
// the draw method, it has been found that the NVidia drivers fail completely
|
// the draw method, it has been found that the NVidia drivers fail completely
|
||||||
@ -666,7 +667,9 @@ class OSG_EXPORT Drawable : public Object
|
|||||||
void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) const;
|
void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) const;
|
||||||
void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64EXT *params) const;
|
void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64EXT *params) const;
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
|
|
||||||
|
friend class ArrayDispatchers;
|
||||||
|
|
||||||
typedef void (APIENTRY * FogCoordProc) (const GLfloat* coord);
|
typedef void (APIENTRY * FogCoordProc) (const GLfloat* coord);
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <osg/Polytope>
|
#include <osg/Polytope>
|
||||||
#include <osg/Viewport>
|
#include <osg/Viewport>
|
||||||
#include <osg/GLBeginEndAdapter>
|
#include <osg/GLBeginEndAdapter>
|
||||||
|
#include <osg/ArrayDispatchers>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -1246,6 +1247,8 @@ class OSG_EXPORT State : public Referenced, public Observer
|
|||||||
/** get the GL adapter object used to map OpenGL 1.0 glBegin/glEnd usage to vertex arrays.*/
|
/** get the GL adapter object used to map OpenGL 1.0 glBegin/glEnd usage to vertex arrays.*/
|
||||||
inline GLBeginEndAdapter& getGLBeginEndAdapter() { return _glBeginEndAdapter; }
|
inline GLBeginEndAdapter& getGLBeginEndAdapter() { return _glBeginEndAdapter; }
|
||||||
|
|
||||||
|
/** get the helper class for dispatching osg::Arrays as OpenGL attribute data.*/
|
||||||
|
inline ArrayDispatchers& getArrayDispatchers() { return _arrayDispatchers; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -1558,6 +1561,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
|||||||
osg::ref_ptr<DynamicObjectRenderingCompletedCallback> _completeDynamicObjectRenderingCallback;
|
osg::ref_ptr<DynamicObjectRenderingCompletedCallback> _completeDynamicObjectRenderingCallback;
|
||||||
|
|
||||||
GLBeginEndAdapter _glBeginEndAdapter;
|
GLBeginEndAdapter _glBeginEndAdapter;
|
||||||
|
ArrayDispatchers _arrayDispatchers;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -345,15 +345,62 @@ public:
|
|||||||
AttributeDispatchList _glBeginEndAttributeDispatchWithIndicesList;
|
AttributeDispatchList _glBeginEndAttributeDispatchWithIndicesList;
|
||||||
};
|
};
|
||||||
|
|
||||||
ArrayDispatchers::ArrayDispatchers(osg::State& state):
|
ArrayDispatchers::ArrayDispatchers():
|
||||||
_state(&state),
|
_initialized(false),
|
||||||
_vertexDispatchers(new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()))),
|
_state(0),
|
||||||
_normalDispatchers(new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()))),
|
_glBeginEndAdapter(0),
|
||||||
_colorDispatchers(new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()))),
|
_vertexDispatchers(0),
|
||||||
_secondaryColorDispatchers(new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()))),
|
_normalDispatchers(0),
|
||||||
_fogCoordDispatchers(new AttributeDispatchMap(&(_state->getGLBeginEndAdapter())))
|
_colorDispatchers(0),
|
||||||
|
_secondaryColorDispatchers(0),
|
||||||
|
_fogCoordDispatchers(0),
|
||||||
|
_useGLBeginEndAdapter(false)
|
||||||
{
|
{
|
||||||
Drawable::Extensions* extensions = Drawable::getExtensions(state.getContextID(),true);
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayDispatchers::~ArrayDispatchers()
|
||||||
|
{
|
||||||
|
delete _vertexDispatchers;
|
||||||
|
delete _normalDispatchers;
|
||||||
|
delete _colorDispatchers;
|
||||||
|
delete _secondaryColorDispatchers;
|
||||||
|
delete _fogCoordDispatchers;
|
||||||
|
|
||||||
|
for(AttributeDispatchMapList::iterator itr = _texCoordDispatchers.begin();
|
||||||
|
itr != _texCoordDispatchers.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
delete *itr;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(AttributeDispatchMapList::iterator itr = _vertexAttribDispatchers.begin();
|
||||||
|
itr != _vertexAttribDispatchers.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
delete *itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArrayDispatchers::setState(osg::State* state)
|
||||||
|
{
|
||||||
|
_state = state;
|
||||||
|
_glBeginEndAdapter = &(state->getGLBeginEndAdapter());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArrayDispatchers::init()
|
||||||
|
{
|
||||||
|
if (_initialized) return;
|
||||||
|
|
||||||
|
_initialized = true;
|
||||||
|
|
||||||
|
_vertexDispatchers = new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()));
|
||||||
|
_normalDispatchers = new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()));
|
||||||
|
_colorDispatchers = new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()));
|
||||||
|
_secondaryColorDispatchers = new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()));
|
||||||
|
_fogCoordDispatchers = new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()));
|
||||||
|
|
||||||
|
Drawable::Extensions* extensions = Drawable::getExtensions(_state->getContextID(),true);
|
||||||
_glBeginEndAdapter = &(_state->getGLBeginEndAdapter());
|
_glBeginEndAdapter = &(_state->getGLBeginEndAdapter());
|
||||||
_useGLBeginEndAdapter = false;
|
_useGLBeginEndAdapter = false;
|
||||||
|
|
||||||
@ -378,10 +425,9 @@ ArrayDispatchers::ArrayDispatchers(osg::State& state):
|
|||||||
_secondaryColorDispatchers->assign<GLfloat>(Array::Vec3ArrayType, extensions->_glSecondaryColor3fv, 3);
|
_secondaryColorDispatchers->assign<GLfloat>(Array::Vec3ArrayType, extensions->_glSecondaryColor3fv, 3);
|
||||||
|
|
||||||
_fogCoordDispatchers->assign<GLfloat>(Array::FloatArrayType, extensions->_glFogCoordfv, 1);
|
_fogCoordDispatchers->assign<GLfloat>(Array::FloatArrayType, extensions->_glFogCoordfv, 1);
|
||||||
}
|
|
||||||
|
|
||||||
ArrayDispatchers::~ArrayDispatchers()
|
// pre allocate.
|
||||||
{
|
_activeDispatchList.resize(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributeDispatch* ArrayDispatchers::vertexDispatcher(Array* array, IndexArray* indices) { return _vertexDispatchers->dispatcher(_useGLBeginEndAdapter, array, indices); }
|
AttributeDispatch* ArrayDispatchers::vertexDispatcher(Array* array, IndexArray* indices) { return _vertexDispatchers->dispatcher(_useGLBeginEndAdapter, array, indices); }
|
||||||
@ -452,70 +498,16 @@ void ArrayDispatchers::assignVertexAttribDispatchers(unsigned int unit)
|
|||||||
|
|
||||||
void ArrayDispatchers::reset()
|
void ArrayDispatchers::reset()
|
||||||
{
|
{
|
||||||
|
if (!_initialized) init();
|
||||||
|
|
||||||
_useGLBeginEndAdapter = false;
|
_useGLBeginEndAdapter = false;
|
||||||
|
|
||||||
for(BindingGroupList::iterator itr = _bindingGroupList.begin();
|
for(ActiveDispatchList::iterator itr = _activeDispatchList.begin();
|
||||||
itr != _bindingGroupList.end();
|
itr != _activeDispatchList.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
itr->_index = 0;
|
(*itr).clear();
|
||||||
itr->_attributeDispatchList.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrayDispatchers::activate(unsigned int binding, AttributeDispatch* at)
|
|
||||||
{
|
|
||||||
if (!at) return;
|
|
||||||
|
|
||||||
if (binding>=_bindingGroupList.size()) _bindingGroupList.resize(binding+1);
|
|
||||||
|
|
||||||
BindingGroup& bindingGroup = _bindingGroupList[binding];
|
|
||||||
bindingGroup._attributeDispatchList.push_back(at);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrayDispatchers::dispatch(unsigned int binding, unsigned int index)
|
|
||||||
{
|
|
||||||
if (binding>=_bindingGroupList.size()) return;
|
|
||||||
|
|
||||||
BindingGroup& bg = _bindingGroupList[binding];
|
|
||||||
for(AttributeDispatchList::iterator itr = bg._attributeDispatchList.begin();
|
|
||||||
itr != bg._attributeDispatchList.end();
|
|
||||||
++itr)
|
|
||||||
{
|
|
||||||
AttributeDispatch* at = *itr;
|
|
||||||
(*at)(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArrayDispatchers::dispatch(unsigned int binding)
|
|
||||||
{
|
|
||||||
if (binding>=_bindingGroupList.size()) return;
|
|
||||||
|
|
||||||
BindingGroup& bg = _bindingGroupList[binding];
|
|
||||||
unsigned int index = bg._index;
|
|
||||||
for(AttributeDispatchList::iterator itr = bg._attributeDispatchList.begin();
|
|
||||||
itr != bg._attributeDispatchList.end();
|
|
||||||
++itr)
|
|
||||||
{
|
|
||||||
AttributeDispatch* at = *itr;
|
|
||||||
(*at)(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
// advance the index so that it's ready for the next dispatch
|
|
||||||
++(bg._index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArrayDispatchers::Begin(GLenum mode)
|
|
||||||
{
|
|
||||||
if (_useGLBeginEndAdapter) _glBeginEndAdapter->Begin(mode);
|
|
||||||
else ::glBegin(mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArrayDispatchers::End()
|
|
||||||
{
|
|
||||||
if (_useGLBeginEndAdapter) _glBeginEndAdapter->End();
|
|
||||||
else ::glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ using namespace osg;
|
|||||||
|
|
||||||
const Geometry::ArrayData Geometry::s_InvalidArrayData;
|
const Geometry::ArrayData Geometry::s_InvalidArrayData;
|
||||||
|
|
||||||
|
// #define USE_OLD_DRAW_IMPLEMENTATOIN
|
||||||
|
|
||||||
|
#ifdef USE_OLD_DRAW_IMPLEMENTATOIN
|
||||||
class DrawVertex
|
class DrawVertex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -394,6 +397,8 @@ class DrawFogCoord : public osg::ConstValueVisitor
|
|||||||
|
|
||||||
const Drawable::Extensions * _extensions;
|
const Drawable::Extensions * _extensions;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Geometry::ArrayData::ArrayData(const ArrayData& data,const CopyOp& copyop):
|
Geometry::ArrayData::ArrayData(const ArrayData& data,const CopyOp& copyop):
|
||||||
array(copyop(data.array.get())),
|
array(copyop(data.array.get())),
|
||||||
@ -414,7 +419,7 @@ Geometry::Vec3ArrayData::Vec3ArrayData(const Vec3ArrayData& data,const CopyOp& c
|
|||||||
Geometry::Geometry()
|
Geometry::Geometry()
|
||||||
{
|
{
|
||||||
// temporary test
|
// temporary test
|
||||||
// setSupportsDisplayList(false);
|
setSupportsDisplayList(false);
|
||||||
|
|
||||||
_fastPath = false;
|
_fastPath = false;
|
||||||
_fastPathHint = true;
|
_fastPathHint = true;
|
||||||
@ -431,7 +436,7 @@ Geometry::Geometry(const Geometry& geometry,const CopyOp& copyop):
|
|||||||
_fastPathHint(geometry._fastPathHint)
|
_fastPathHint(geometry._fastPathHint)
|
||||||
{
|
{
|
||||||
// temporary test
|
// temporary test
|
||||||
// setSupportsDisplayList(false);
|
setSupportsDisplayList(false);
|
||||||
|
|
||||||
for(PrimitiveSetList::const_iterator pitr=geometry._primitives.begin();
|
for(PrimitiveSetList::const_iterator pitr=geometry._primitives.begin();
|
||||||
pitr!=geometry._primitives.end();
|
pitr!=geometry._primitives.end();
|
||||||
@ -1279,7 +1284,7 @@ void Geometry::releaseGLObjects(State* state) const
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
#ifndef USE_OLD_DRAW_IMPLEMENTATOIN
|
||||||
void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
||||||
{
|
{
|
||||||
State& state = *renderInfo.getState();
|
State& state = *renderInfo.getState();
|
||||||
@ -1290,34 +1295,26 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
bool usingVertexBufferObjects = _useVertexBufferObjects && state.isVertexBufferObjectSupported();
|
bool usingVertexBufferObjects = _useVertexBufferObjects && state.isVertexBufferObjectSupported();
|
||||||
bool handleVertexAttributes = !_vertexAttribList.empty() && extensions->isVertexProgramSupported();
|
bool handleVertexAttributes = !_vertexAttribList.empty() && extensions->isVertexProgramSupported();
|
||||||
|
|
||||||
osg::ref_ptr<ArrayDispatchers> s_ArrayDispatchers = 0;
|
ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers();
|
||||||
if (!s_ArrayDispatchers) s_ArrayDispatchers = new ArrayDispatchers(state);
|
|
||||||
|
|
||||||
ArrayDispatchers& arrayDispatchers = *s_ArrayDispatchers;
|
|
||||||
|
|
||||||
arrayDispatchers.reset();
|
arrayDispatchers.reset();
|
||||||
arrayDispatchers.setUseGLBeginEndAdapter(!useFastPath);
|
// arrayDispatchers.setUseGLBeginEndAdapter(!useFastPath);
|
||||||
|
|
||||||
arrayDispatchers.activateNormalArray(_normalData.binding, _normalData.array.get(), _normalData.indices.get());
|
arrayDispatchers.activateNormalArray(_normalData.binding, _normalData.array.get(), _normalData.indices.get());
|
||||||
arrayDispatchers.activateColorArray(_colorData.binding, _colorData.array.get(), _colorData.indices.get());
|
arrayDispatchers.activateColorArray(_colorData.binding, _colorData.array.get(), _colorData.indices.get());
|
||||||
arrayDispatchers.activateSecondaryColorArray(_secondaryColorData.binding, _secondaryColorData.array.get(), _secondaryColorData.indices.get());
|
arrayDispatchers.activateSecondaryColorArray(_secondaryColorData.binding, _secondaryColorData.array.get(), _secondaryColorData.indices.get());
|
||||||
arrayDispatchers.activateFogCoordArray(_fogCoordData.binding, _fogCoordData.array.get(), _fogCoordData.indices.get());
|
arrayDispatchers.activateFogCoordArray(_fogCoordData.binding, _fogCoordData.array.get(), _fogCoordData.indices.get());
|
||||||
|
|
||||||
for(unsigned int unit=0;unit<_texCoordList.size();++unit)
|
if (handleVertexAttributes)
|
||||||
{
|
{
|
||||||
arrayDispatchers.activateTexCoordArray(BIND_PER_VERTEX, unit, _texCoordList[unit].array.get(), _texCoordList[unit].indices.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
for(unsigned int unit=0;unit<_vertexAttribList.size();++unit)
|
for(unsigned int unit=0;unit<_vertexAttribList.size();++unit)
|
||||||
{
|
{
|
||||||
arrayDispatchers.activateVertexAttribArray(_vertexAttribList[unit].binding, unit, _vertexAttribList[unit].array.get(), _vertexAttribList[unit].indices.get());
|
arrayDispatchers.activateVertexAttribArray(_vertexAttribList[unit].binding, unit, _vertexAttribList[unit].array.get(), _vertexAttribList[unit].indices.get());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
arrayDispatchers.activateVertexArray(BIND_PER_VERTEX, _vertexData.array.get(), _vertexData.indices.get());
|
|
||||||
|
|
||||||
|
|
||||||
// dispatch any attributes that are bound overall
|
// dispatch any attributes that are bound overall
|
||||||
arrayDispatchers.dispatch(BIND_OVERALL);
|
arrayDispatchers.dispatch(BIND_OVERALL,0);
|
||||||
|
|
||||||
state.lazyDisablingOfVertexAttributes();
|
state.lazyDisablingOfVertexAttributes();
|
||||||
|
|
||||||
@ -1358,21 +1355,34 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(unsigned int unit=0;unit<_texCoordList.size();++unit)
|
||||||
|
{
|
||||||
|
arrayDispatchers.activateTexCoordArray(BIND_PER_VERTEX, unit, _texCoordList[unit].array.get(), _texCoordList[unit].indices.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
arrayDispatchers.activateVertexArray(BIND_PER_VERTEX, _vertexData.array.get(), _vertexData.indices.get());
|
||||||
|
}
|
||||||
|
|
||||||
state.applyDisablingOfVertexAttributes();
|
state.applyDisablingOfVertexAttributes();
|
||||||
|
|
||||||
|
bool bindPerPrimtiveSetActive = arrayDispatchers.active(BIND_PER_PRIMITIVE_SET);
|
||||||
|
bool bindPerPrimtiveActive = arrayDispatchers.active(BIND_PER_PRIMITIVE);
|
||||||
|
|
||||||
|
unsigned int primitiveNum = 0;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// draw the primitives themselves.
|
// draw the primitives themselves.
|
||||||
//
|
//
|
||||||
for(PrimitiveSetList::const_iterator itr=_primitives.begin();
|
for(unsigned int primitiveSetNum=0; primitiveSetNum!=_primitives.size(); ++primitiveSetNum)
|
||||||
itr!=_primitives.end();
|
|
||||||
++itr)
|
|
||||||
{
|
{
|
||||||
// dispatch any attributes that are bound per primitive
|
|
||||||
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE_SET);
|
|
||||||
|
|
||||||
const PrimitiveSet* primitiveset = itr->get();
|
// dispatch any attributes that are bound per primitive
|
||||||
|
if (bindPerPrimtiveSetActive) arrayDispatchers.dispatch(BIND_PER_PRIMITIVE_SET, primitiveSetNum);
|
||||||
|
|
||||||
|
const PrimitiveSet* primitiveset = _primitives[primitiveSetNum].get();
|
||||||
|
|
||||||
if (useFastPath)
|
if (useFastPath)
|
||||||
{
|
{
|
||||||
@ -1409,9 +1419,9 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
vindex<indexEnd;
|
vindex<indexEnd;
|
||||||
++vindex,++primCount)
|
++vindex,++primCount)
|
||||||
{
|
{
|
||||||
if ((primCount%primLength)==0)
|
if (bindPerPrimtiveActive && (primCount%primLength)==0)
|
||||||
{
|
{
|
||||||
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE);
|
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE,++primitiveNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayDispatchers.dispatch(BIND_PER_VERTEX, vindex);
|
arrayDispatchers.dispatch(BIND_PER_VERTEX, vindex);
|
||||||
@ -1438,9 +1448,9 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
primCount<*primItr;
|
primCount<*primItr;
|
||||||
++vindex,++primCount)
|
++vindex,++primCount)
|
||||||
{
|
{
|
||||||
if ((primCount%localPrimLength)==0)
|
if (bindPerPrimtiveActive && (primCount%localPrimLength)==0)
|
||||||
{
|
{
|
||||||
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE);
|
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE, ++primitiveNum);
|
||||||
}
|
}
|
||||||
arrayDispatchers.dispatch(BIND_PER_VERTEX, vindex);
|
arrayDispatchers.dispatch(BIND_PER_VERTEX, vindex);
|
||||||
}
|
}
|
||||||
@ -1463,9 +1473,9 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
++primCount,++primItr)
|
++primCount,++primItr)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((primCount%primLength)==0)
|
if (bindPerPrimtiveActive && (primCount%primLength)==0)
|
||||||
{
|
{
|
||||||
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE);
|
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE, ++primitiveNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int vindex=*primItr;
|
unsigned int vindex=*primItr;
|
||||||
@ -1487,9 +1497,9 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
primItr!=drawElements->end();
|
primItr!=drawElements->end();
|
||||||
++primCount,++primItr)
|
++primCount,++primItr)
|
||||||
{
|
{
|
||||||
if ((primCount%primLength)==0)
|
if (bindPerPrimtiveActive && (primCount%primLength)==0)
|
||||||
{
|
{
|
||||||
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE);
|
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE, ++primitiveNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int vindex=*primItr;
|
unsigned int vindex=*primItr;
|
||||||
@ -1511,9 +1521,9 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
primItr!=drawElements->end();
|
primItr!=drawElements->end();
|
||||||
++primCount,++primItr)
|
++primCount,++primItr)
|
||||||
{
|
{
|
||||||
if ((primCount%primLength)==0)
|
if (bindPerPrimtiveActive && (primCount%primLength)==0)
|
||||||
{
|
{
|
||||||
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE);
|
arrayDispatchers.dispatch(BIND_PER_PRIMITIVE, ++primitiveNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int vindex=*primItr;
|
unsigned int vindex=*primItr;
|
||||||
@ -1643,7 +1653,7 @@ void Geometry::drawImplementation(RenderInfo& renderInfo) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// force the use of the slow path code to test the glBegin/glEnd replacement codes.
|
// force the use of the slow path code to test the glBegin/glEnd replacement codes.
|
||||||
bool forceSlowPath = false;
|
bool forceSlowPath = true;
|
||||||
|
|
||||||
if (areFastPathsUsed() && !forceSlowPath)
|
if (areFastPathsUsed() && !forceSlowPath)
|
||||||
{
|
{
|
||||||
|
@ -120,6 +120,7 @@ State::State():
|
|||||||
_maxBufferObjectPoolSize = 0;
|
_maxBufferObjectPoolSize = 0;
|
||||||
|
|
||||||
_glBeginEndAdapter.setState(this);
|
_glBeginEndAdapter.setState(this);
|
||||||
|
_arrayDispatchers.setState(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
State::~State()
|
State::~State()
|
||||||
|
Loading…
Reference in New Issue
Block a user