Discussion:
[osg-users] About Interleaved Array Support
Julien Valentin
2018-10-09 23:13:59 UTC
Permalink
Hi,
I have an implementation of InterleavedGeometry : public Drawable
I think it's really something missing for a long time in osg
Would it worse a pr...?

here's a sample usage to review chosen api

Code:

///test interleavedGeometry
InterleavedGeometry * igeom=new InterleavedGeometry();
igeom->setUseDisplayList(false);
igeom->setUseVertexBufferObjects(true);
igeom->setUseVertexArrayObject(true);

struct example{
float pos[3],norm[3],texcoor[3],padding[3];//add 3 float padding for mem alignement
};
unsigned int stride=sizeof(struct example);
osg::ref_ptr<osg::BufferTemplate< std::vector<example> > > hostarray=new osg::BufferTemplate< std::vector<example> >;
hostarray->resize(4);
hostarray->setBinding(osg::Array::BIND_PER_VERTEX);
hostarray->setBufferObject(new osg::VertexBufferObject);
InterleavedGeometry::RangedBufferData *rbd=new InterleavedGeometry::RangedBufferData;
InterleavedGeometry::RangeDesc interleaveddesc;
interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,0));
interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,3*sizeof(GLfloat)));
interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,6*sizeof(GLfloat)));
igeom->addRangedBufferData(0,2,hostarray,interleaveddesc,stride );

for(int j=0;j<2;j++){
for(int i=0;i<2;i++){
for(int k=0;k<3;k++){
float * fdata=igeom->getRangedBufferData(0)->data<float>(i*2+j,k);
*fdata++=float(i)*1.0f;
*fdata++=float(j)*1.0f;
*fdata++=0;
}
}
}



Julien[/code]

------------------------
Twirling twirling twirling toward freedom

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75058#75058
Robert Osfield
2018-10-10 11:20:52 UTC
Permalink
Hi Julien,

I considered interleaved support in the past and decided against it as
the value it provided isn't that great and it limits how many classes
can process the geometry as it's an non standard form.

Modern graphics card cope just fine with non interleaved data so what
is your motivation?

Cheers,
Robert.
On Wed, 10 Oct 2018 at 10:50, Julien Valentin
Post by Julien Valentin
Hi,
I have an implementation of InterleavedGeometry : public Drawable
I think it's really something missing for a long time in osg
Would it worse a pr...?
here's a sample usage to review chosen api
///test interleavedGeometry
InterleavedGeometry * igeom=new InterleavedGeometry();
igeom->setUseDisplayList(false);
igeom->setUseVertexBufferObjects(true);
igeom->setUseVertexArrayObject(true);
struct example{
float pos[3],norm[3],texcoor[3],padding[3];//add 3 float padding for mem alignement
};
unsigned int stride=sizeof(struct example);
osg::ref_ptr<osg::BufferTemplate< std::vector<example> > > hostarray=new osg::BufferTemplate< std::vector<example> >;
hostarray->resize(4);
hostarray->setBinding(osg::Array::BIND_PER_VERTEX);
hostarray->setBufferObject(new osg::VertexBufferObject);
InterleavedGeometry::RangedBufferData *rbd=new InterleavedGeometry::RangedBufferData;
InterleavedGeometry::RangeDesc interleaveddesc;
interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,0));
interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,3*sizeof(GLfloat)));
interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,6*sizeof(GLfloat)));
igeom->addRangedBufferData(0,2,hostarray,interleaveddesc,stride );
for(int j=0;j<2;j++){
for(int i=0;i<2;i++){
for(int k=0;k<3;k++){
float * fdata=igeom->getRangedBufferData(0)->data<float>(i*2+j,k);
*fdata++=float(i)*1.0f;
*fdata++=float(j)*1.0f;
*fdata++=0;
}
}
}
Julien[/code]
------------------------
Twirling twirling twirling toward freedom
------------------
http://forum.openscenegraph.org/viewtopic.php?p=75058#75058
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Julien Valentin
2018-10-10 11:34:16 UTC
Permalink
AFAIK Memory alignement compliance yield in greater performance..No?
Post by Robert Osfield
Hi Julien,
I considered interleaved support in the past and decided against it as
the value it provided isn't that great and it limits how many classes
can process the geometry as it's an non standard form.
Modern graphics card cope just fine with non interleaved data so what
is your motivation?
Cheers,
Robert.
On Wed, 10 Oct 2018 at 10:50, Julien Valentin
Post by Julien Valentin
Hi,
I have an implementation of InterleavedGeometry : public Drawable
I think it's really something missing for a long time in osg
Would it worse a pr...?
here's a sample usage to review chosen api
///test interleavedGeometry
InterleavedGeometry * igeom=new InterleavedGeometry();
igeom->setUseDisplayList(false);
igeom->setUseVertexBufferObjects(true);
igeom->setUseVertexArrayObject(true);
struct example{
float pos[3],norm[3],texcoor[3],padding[3];//add 3 float padding for mem alignement
};
unsigned int stride=sizeof(struct example);
osg::ref_ptr<osg::BufferTemplate< std::vector<example> > > hostarray=new osg::BufferTemplate< std::vector<example> >;
hostarray->resize(4);
hostarray->setBinding(osg::Array::BIND_PER_VERTEX);
hostarray->setBufferObject(new osg::VertexBufferObject);
InterleavedGeometry::RangedBufferData *rbd=new InterleavedGeometry::RangedBufferData;
InterleavedGeometry::RangeDesc interleaveddesc;
interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,0));
interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,3*sizeof(GLfloat)));
interleaveddesc.push_back(InterleavedGeometry::SubDataDesc(GL_FLOAT,3,6*sizeof(GLfloat)));
igeom->addRangedBufferData(0,2,hostarray,interleaveddesc,stride );
for(int j=0;j<2;j++){
for(int i=0;i<2;i++){
for(int k=0;k<3;k++){
float * fdata=igeom->getRangedBufferData(0)->data<float>(i*2+j,k);
*fdata++=float(i)*1.0f;
*fdata++=float(j)*1.0f;
*fdata++=0;
}
}
}
Julien[/code]
------------------------
Twirling twirling twirling toward freedom
------------------
http://forum.openscenegraph.org/viewtopic.php?p=75058#75058
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
------------------
Post generated by Mail2Forum
------------------------
Twirling twirling twirling toward freedom

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75062#75062
Robert Osfield
2018-10-10 12:55:27 UTC
Permalink
On Wed, 10 Oct 2018 at 12:40, Julien Valentin
Post by Julien Valentin
AFAIK Memory alignement compliance yield in greater performance..No?
On some GPU architectures it might do, others it will be little or no
difference.

One must always benchmark with proper scenes and across a range of
platforms to know whether it's worthwhile.

When judging the balance of cost vs benefit you have to consider the
whole usage chain - how do you get data in and out, how do you process
it. With an InterleavedGeometry implementation you are limited to
just applications that explicitly create and can process
InterleavedGeometry.

With features like this you also need to consider the support burden,
but maintaining it and helping users learn how to use it properly and
what happens when it's not compatible with the existing functionality
that assumes osg::Geometry.

For the OSG I'm focused on maintainability and streamlining support,
not inviting lots of new features and support associated with it. For
bleeding edge features I'm focused on the VSG - here we have greater
freedom of introducing new ways of doing things as there isn't
compatibility and big code base and community to worry about.

Robert.
Julien Valentin
2018-10-10 15:35:16 UTC
Permalink
Hi Robert
I understand... it would be wiser for compatibitlity with codebase not to integrate it in core osg.
As there's no interaction with core osg I'll keep it in an external nodekit.
Cheers
Post by Robert Osfield
On Wed, 10 Oct 2018 at 12:40, Julien Valentin
AFAIK Memory alignement compliance yields in better performances...No?
https://stackoverflow.com/questions/18853713/does-interleaving-in-vbos-speed-up-performance-when-using-vaos
On some GPU architectures it might do, others it will be little or no
difference.
One must always benchmark with proper scenes and across a range of
platforms to know whether it's worthwhile.
When judging the balance of cost vs benefit you have to consider the
whole usage chain - how do you get data in and out, how do you process
it. With an InterleavedGeometry implementation you are limited to
just applications that explicitly create and can process
InterleavedGeometry.
With features like this you also need to consider the support burden,
but maintaining it and helping users learn how to use it properly and
what happens when it's not compatible with the existing functionality
that assumes osg::Geometry.
For the OSG I'm focused on maintainability and streamlining support,
not inviting lots of new features and support associated with it. For
bleeding edge features I'm focused on the VSG - here we have greater
freedom of introducing new ways of doing things as there isn't
compatibility and big code base and community to worry about.
Robert.
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
------------------
Post generated by Mail2Forum
------------------------
Twirling twirling twirling toward freedom

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75065#75065

Continue reading on narkive:
Loading...