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 

fix for osgWrappers/serializers/ShaderBinary


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission
View previous topic :: View next topic  
Author Message
jbaeuerle
User


Joined: 27 Sep 2010
Posts: 22

PostPosted: Wed Feb 09, 2011 9:46 am    Post subject:
fix for osgWrappers/serializers/ShaderBinary
Reply with quote

Hi Robert,

I experienced problems using binary shaders in osgt files (=the osg-serializer plugins). At runtime std::bad_alloc errors were thrown when using binary shaders.

The reason is that the .osgt text files do not provide size information about the contained binary shader hence leading to a bad allocation when reading the shader data, probably size 0 ? The reader method in the responsible serializer class (serializers/osg/ShaderBinary) is correct and does not need to be changed as it queries the size as expected. The writer method supports two paths(binary output .osgb and text output .osgt/.osgx). Only the text path is affected as the binary path writes the size.

I extended the writer in the text path by the size information. The results before and after the fix are shown below:

Erroneous code for binary shader in osgt file before fix:

Data {
0a
0d
0
...
}

Corrected code for binary shader in osgt file after fix:

Data 524 {
0a
0d
0
...
}

After my fix the the thrown error disappeared.

Thank you!

Cheers,
Johannes
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12321

PostPosted: Mon Feb 14, 2011 1:54 pm    Post subject:
fix for osgWrappers/serializers/BinaryShader
Reply with quote

Thanks Johannes, fix now merged and submitted to svn/trunk.

On Wed, Feb 9, 2011 at 9:46 AM, Johannes Bäuerle <> wrote:
Quote:
Hi Robert,

I experienced problems using binary shaders in osgt files (=the osg-serializer plugins). At runtime std::bad_alloc errors were thrown when using binary shaders.

The reason is that the .osgt text files do not provide size information about the contained binary shader hence leading to a bad allocation when reading the shader data, probably size 0 ? The reader method in the responsible serializer class (serializers/osg/BinaryShader) is correct and does not need to be changed as it queries the size as expected. The writer method supports two paths(binary output .osgb and text output .osgt/.osgx). Only the text path is affected as the binary path writes the size.

I extended the writer in the text path by the size information. The results before and after the fix are shown below:

Erroneous code for binary shader in osgt file before fix:

Data {
    0a
    0d
    0
    ...
}

Corrected code for binary shader in osgt file after fix:

Data 524 {
   0a
   0d
   0
   ...
}

After my fix the the thrown error disappeared.

Thank you!

Cheers,
Johannes

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




Attachments:
http://forum.openscenegraph.org//files/binaryshader_656.zip






------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission 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 How to use osg::ShaderBinary qiaokun General 1 Mon Jul 24, 2017 7:16 am View latest post
No new posts optimization to serializers robertosfield Submission 0 Tue May 31, 2016 10:37 am View latest post
No new posts added missing serializers for riggeom... Pjotr Submission 3 Thu Apr 17, 2014 12:05 pm View latest post
No new posts Fix for the new Geometry serializers Wang Rui Submission 1 Sat Jun 22, 2013 3:11 am View latest post
No new posts Custom Serializers danielperaza General 0 Sun Mar 03, 2013 3:08 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