OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

About Interleaved Array Support


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 484
Location: France

PostPosted: Tue Oct 09, 2018 11:13 pm    Post subject:
About Interleaved Array Support
Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Wed Oct 10, 2018 11:21 am    Post subject:
About Interleaved Array Support
Reply with quote

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
<> wrote:
Quote:

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








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 484
Location: France

PostPosted: Wed Oct 10, 2018 11:33 am    Post subject:
Re: About Interleaved Array Support
Reply with quote

AFAIK Memory alignement compliance yields in better performances...No?
https://stackoverflow.com/questions/18853713/does-interleaving-in-vbos-speed-up-performance-when-using-vaos

robertosfield wrote:
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
<> wrote:
Quote:

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








------------------
Post generated by Mail2Forum

_________________
Twirling twirling twirling toward freedom
Back to top
View user's profile Send private message Visit poster's website
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Wed Oct 10, 2018 12:56 pm    Post subject:
About Interleaved Array Support
Reply with quote

On Wed, 10 Oct 2018 at 12:40, Julien Valentin
<> wrote:
Quote:
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.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 484
Location: France

PostPosted: Wed Oct 10, 2018 3:35 pm    Post subject:
Re: About Interleaved Array Support
Reply with quote

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

robertosfield wrote:
On Wed, 10 Oct 2018 at 12:40, Julien Valentin
<> wrote:
Quote:

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.


------------------
Post generated by Mail2Forum

_________________
Twirling twirling twirling toward freedom
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts osgDB::OutputStream write array optim... Farshid Lashkari Submission 2 Thu Sep 20, 2018 11:17 pm View latest post
No new posts axis / axes with color array doesn't ... Steal General 0 Wed Sep 05, 2018 4:07 pm View latest post
No new posts Support for paletted images in dds pl... psi29a Plugins [osgPlugins] 1 Fri Jun 22, 2018 10:14 am View latest post
No new posts ANGLE/UWP support checked into OSG gi... robertosfield General 5 Fri Jun 01, 2018 2:08 pm View latest post
No new posts Support for loading cubemap images in... Farshid Lashkari Submission 7 Wed May 09, 2018 5:56 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP