[osg-users] Most efficient way to use osg::DrawElementsUInt?
Hi all, I'm developing an application where I have to create up to 1000 osg:geometry objects per frame during certain interaction modes. I'm using osg::DrawElementsUInt push_back() to define the geometry primitive sets, and this push_back() seems to be the primary bottleneck for my applications graphical performance. Is there a more efficient way to define the primitive sets than to fill a osg::DrawElementsUInt by push_back and add it to the geometry? This is currently bringing me down to about 1 second per frame, which is kind of a roadblock. regards, Jesper D. Thomsen ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Most efficient way to use osg::DrawElementsUInt?
Hi Jesper, Jesper D. Thomsen schrieb: Hi all, I'm developing an application where I have to create up to 1000 osg:geometry objects per frame during certain interaction modes. I'm using osg::DrawElementsUInt push_back() to define the geometry primitive sets, and this push_back() seems to be the primary bottleneck for my applications graphical performance. Is there a more efficient way to define the primitive sets than to fill a osg::DrawElementsUInt by push_back and add it to the geometry? This is currently bringing me down to about 1 second per frame, which is kind of a roadblock. You can use reserve() to pre-allocate the needed memory. After that push_back() will not perform any reallocations/copies until the limit is reached. regards, Jesper D. Thomsen Cheers, Peter -- Vorstand/Board of Management: Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board: Michel Lepert Sitz/Registered Office: Tuebingen Registergericht/Registration Court: Stuttgart Registernummer/Commercial Register No.: HRB 382196 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Most efficient way to use osg::DrawElementsUInt?
Hi, and thank you. I naturally tried to use reserve() (but thanks for suggesting it) and this of course helped somewhat, but it still seems to be the primary bottleneck. I've changed most of the rest of the per-frame geometry generation code to use static arrays rather than std::vector and this caused a major speedup (factor 10 or more) of my own part of the code, but I'm still stuck with the push_backs on osg::DrawElementsUInt. Maybe there's just no faster way to do it, or maybe I'm just using OSG in a somewhat un-intended way. Jesper D. Thomsen From: osg-users-boun...@lists.openscenegraph.org [osg-users-boun...@lists.openscenegraph.org] On Behalf Of Peter Hrenka [p.hre...@science-computing.de] Sent: Thursday, March 26, 2009 12:00 PM To: OpenSceneGraph Users Subject: Re: [osg-users] Most efficient way to use osg::DrawElementsUInt? Hi Jesper, Jesper D. Thomsen schrieb: Hi all, I'm developing an application where I have to create up to 1000 osg:geometry objects per frame during certain interaction modes. I'm using osg::DrawElementsUInt push_back() to define the geometry primitive sets, and this push_back() seems to be the primary bottleneck for my applications graphical performance. Is there a more efficient way to define the primitive sets than to fill a osg::DrawElementsUInt by push_back and add it to the geometry? This is currently bringing me down to about 1 second per frame, which is kind of a roadblock. You can use reserve() to pre-allocate the needed memory. After that push_back() will not perform any reallocations/copies until the limit is reached. regards, Jesper D. Thomsen Cheers, Peter -- Vorstand/Board of Management: Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board: Michel Lepert Sitz/Registered Office: Tuebingen Registergericht/Registration Court: Stuttgart Registernummer/Commercial Register No.: HRB 382196 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Most efficient way to use osg::DrawElementsUInt?
Hi Jesper, Jesper D. Thomsen schrieb: Hi, and thank you. I naturally tried to use reserve() (but thanks for suggesting it) and this of course helped somewhat, but it still seems to be the primary bottleneck. I've changed most of the rest of the per-frame geometry generation code to use static arrays rather than std::vector and this caused a major speedup (factor 10 or more) of my own part of the code, but I'm still stuck with the push_backs on osg::DrawElementsUInt. Maybe there's just no faster way to do it, or maybe I'm just using OSG in a somewhat un-intended way. Jesper D. Thomsen Just some more ideas/comments: Are you testing a release build? Debug-Verions (especially on Windows) are known to have dramatically slower implementations. What profiling tool are you using? Sometimes the output is misleading and can point you in the wrong direction. As from my experience push_back() on an pre-reserved() vector should not be a performace issue. If you can spare the memory you could also try swap(), implementing your own double-buffering for your osg::DrawElements. Cheers, Peter From: osg-users-boun...@lists.openscenegraph.org [osg-users-boun...@lists.openscenegraph.org] On Behalf Of Peter Hrenka [p.hre...@science-computing.de] Sent: Thursday, March 26, 2009 12:00 PM To: OpenSceneGraph Users Subject: Re: [osg-users] Most efficient way to use osg::DrawElementsUInt? Hi Jesper, Jesper D. Thomsen schrieb: Hi all, I'm developing an application where I have to create up to 1000 osg:geometry objects per frame during certain interaction modes. I'm using osg::DrawElementsUInt push_back() to define the geometry primitive sets, and this push_back() seems to be the primary bottleneck for my applications graphical performance. Is there a more efficient way to define the primitive sets than to fill a osg::DrawElementsUInt by push_back and add it to the geometry? This is currently bringing me down to about 1 second per frame, which is kind of a roadblock. You can use reserve() to pre-allocate the needed memory. After that push_back() will not perform any reallocations/copies until the limit is reached. regards, Jesper D. Thomsen Cheers, Peter -- Vorstand/Board of Management: Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board: Michel Lepert Sitz/Registered Office: Tuebingen Registergericht/Registration Court: Stuttgart Registernummer/Commercial Register No.: HRB 382196 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Most efficient way to use osg::DrawElementsUInt?
FYI push_back() on an pre-reserved() vector/container should not be a performance issue. Under debug in visual studio, if you are storing anything other than a pointer, then a push_back etc will still incure a 'new and a copy' and this can get expensive if your doing a lot of them, under release this handled more efficiently Gordon Product Manager 3d __ Gordon Tomlinson Email : gtomlinson @ overwatch.textron.com __ -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Peter Hrenka Sent: Thursday, March 26, 2009 8:16 AM To: OpenSceneGraph Users Subject: Re: [osg-users] Most efficient way to use osg::DrawElementsUInt? Hi Jesper, Jesper D. Thomsen schrieb: Hi, and thank you. I naturally tried to use reserve() (but thanks for suggesting it) and this of course helped somewhat, but it still seems to be the primary bottleneck. I've changed most of the rest of the per-frame geometry generation code to use static arrays rather than std::vector and this caused a major speedup (factor 10 or more) of my own part of the code, but I'm still stuck with the push_backs on osg::DrawElementsUInt. Maybe there's just no faster way to do it, or maybe I'm just using OSG in a somewhat un-intended way. Jesper D. Thomsen Just some more ideas/comments: Are you testing a release build? Debug-Verions (especially on Windows) are known to have dramatically slower implementations. What profiling tool are you using? Sometimes the output is misleading and can point you in the wrong direction. As from my experience push_back() on an pre-reserved() vector should not be a performace issue. If you can spare the memory you could also try swap(), implementing your own double-buffering for your osg::DrawElements. Cheers, Peter From: osg-users-boun...@lists.openscenegraph.org [osg-users-boun...@lists.openscenegraph.org] On Behalf Of Peter Hrenka [p.hre...@science-computing.de] Sent: Thursday, March 26, 2009 12:00 PM To: OpenSceneGraph Users Subject: Re: [osg-users] Most efficient way to use osg::DrawElementsUInt? Hi Jesper, Jesper D. Thomsen schrieb: Hi all, I'm developing an application where I have to create up to 1000 osg:geometry objects per frame during certain interaction modes. I'm using osg::DrawElementsUInt push_back() to define the geometry primitive sets, and this push_back() seems to be the primary bottleneck for my applications graphical performance. Is there a more efficient way to define the primitive sets than to fill a osg::DrawElementsUInt by push_back and add it to the geometry? This is currently bringing me down to about 1 second per frame, which is kind of a roadblock. You can use reserve() to pre-allocate the needed memory. After that push_back() will not perform any reallocations/copies until the limit is reached. regards, Jesper D. Thomsen Cheers, Peter -- Vorstand/Board of Management: Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board: Michel Lepert Sitz/Registered Office: Tuebingen Registergericht/Registration Court: Stuttgart Registernummer/Commercial Register No.: HRB 382196 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or g ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Most efficient way to use osg::DrawElementsUInt?
Jesper, I've encountered similar issues when managing 1000's of particle systems (bullet splashes in the water). The problem is the constant allocating/deallocation of memory when you create new primitive sets and then remove them. I ended up caching the primitive sets when the particle system ended and then reusing them. This along with using reserve() to preallocate the required number of elements, resize(0) to reset the element counter - without releasing the memory, and the primitive set setCount() method to adjust the number of prims being drawn each time the particle system was updated. This only works of the things you're creating all similar. It's comparable to what you're doing with the static memory - but within the osg framework. Brian This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. • -osg-users-boun...@lists.openscenegraph.org wrote: - To: OpenSceneGraph Users osg-users@lists.openscenegraph.org From: Tomlinson, Gordon gtomlin...@overwatch.textron.com Sent by: osg-users-boun...@lists.openscenegraph.org Date: 03/26/2009 08:22AM Subject: Re: [osg-users] Most efficient way to use osg::DrawElementsUInt? FYI push_back() on an pre-reserved() vector/container should not be a performance issue. Under debug in visual studio, if you are storing anything other than a pointer, then a push_back etc will still incure a 'new and a copy' and this can get expensive if your doing a lot of them, under release this handled more efficiently Gordon Product Manager 3d __ Gordon Tomlinson Email : gtomlinson @ overwatch.textron.com __ -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Peter Hrenka Sent: Thursday, March 26, 2009 8:16 AM To: OpenSceneGraph Users Subject: Re: [osg-users] Most efficient way to use osg::DrawElementsUInt? Hi Jesper, Jesper D. Thomsen schrieb: Hi, and thank you. I naturally tried to use reserve() (but thanks for suggesting it) and this of course helped somewhat, but it still seems to be the primary bottleneck. I've changed most of the rest of the per-frame geometry generation code to use static arrays rather than std::vector and this caused a major speedup (factor 10 or more) of my own part of the code, but I'm still stuck with the push_backs on osg::DrawElementsUInt. Maybe there's just no faster way to do it, or maybe I'm just using OSG in a somewhat un-intended way. Jesper D. Thomsen Just some more ideas/comments: Are you testing a release build? Debug-Verions (especially on Windows) are known to have dramatically slower implementations. What profiling tool are you using? Sometimes the output is misleading and can point you in the wrong direction. As from my experience push_back() on an pre-reserved() vector should not be a performace issue. If you can spare the memory you could also try swap(), implementing your own double-buffering for your osg::DrawElements. Cheers, Peter From: osg-users-boun...@lists.openscenegraph.org [osg-users-boun...@lists.openscenegraph.org] On Behalf Of Peter Hrenka [p.hre...@science-computing.de] Sent: Thursday, March 26, 2009 12:00 PM To: OpenSceneGraph Users Subject: Re: [osg-users] Most efficient way to use osg::DrawElementsUInt? Hi Jesper, Jesper D. Thomsen schrieb: Hi all, I'm developing an application where I have to create up to 1000 osg:geometry objects per frame during certain interaction modes. I'm using osg::DrawElementsUInt push_back() to define the geometry primitive sets, and this push_back() seems to be the primary bottleneck for my applications graphical performance. Is there a more efficient way to define the primitive sets than to fill a osg::DrawElementsUInt by push_back and add it to the geometry? This is currently bringing me down to about 1 second per frame, which is kind of a roadblock. You can use reserve() to pre-allocate the needed memory. After that push_back() will not perform any reallocations/copies until the limit is reached. regards, Jesper D. Thomsen Cheers, Peter -- Vorstand/Board of Management: Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board: Michel Lepert Sitz/Registered Office: Tuebingen Registergericht/Registration Court: Stuttgart Registernummer/Commercial Register No.: HRB 382196 ___ osg-users mailing list osg-users
Re: [osg-users] Most efficient way to use osg::DrawElementsUInt?
Hi Jasper, Adding lots of objects in any one frame can easily become a bottleneck unless you are very careful about it. I wouldn't expect the push_back on a DrawElementsUInt to be the primary bottleneck. Make sure you do all your benchmarking in release mode as this makes a huge difference. As to what is your best route forward will depend entirely on what you are actually trying to do in your application, so perhaps you can explain at a high level what these geometries represent and why that have to be introduced on mass on particular frames. Perhaps then others will be able to recommend what the best course of action is to take. Robert. 2009/3/26 Jesper D. Thomsen j...@anybodytech.com Hi all, I'm developing an application where I have to create up to 1000 osg:geometry objects per frame during certain interaction modes. I'm using osg::DrawElementsUInt push_back() to define the geometry primitive sets, and this push_back() seems to be the primary bottleneck for my applications graphical performance. Is there a more efficient way to define the primitive sets than to fill a osg::DrawElementsUInt by push_back and add it to the geometry? This is currently bringing me down to about 1 second per frame, which is kind of a roadblock. regards, Jesper D. Thomsen * * ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org