Hi Colin, Yikes, I never realized that the new serializers didn't have a proper functioning endian handling. I had previously seem references to byte swap so trusted that Rui had completed the work on endian support. A quick review of your changes prompted me to look deeper into the endian support in the new serializers and it's as you've found out rather lacking in completeness. This clearly needs to be fixed.
Normally for binary support I would suggest putting an endian marker into the file and then reading this to determine if the file is big or little endian then decide whether to swap depending on the system reading the file. As the file format is already out there adding this is not ideal as it'd break the format so I think it reasonable to assume that all binary .osga files will be little endian. Performance wise I do rather the ability to choose which endian the data will be written out as so one can make sure it's optimal for the target hardware. If I am correct you've assumed little endian for all files which is appropriate for x86 and some ARM systems so as a default is a reasonable assumption. One thing I'm less comfortable with is removing the optimization of reading an array and then doing the byte swap. For reading binary files performance is crucial and it's the large arrays, such as geometry and images that consume most of the space, these we don't want to have to byte swap at a low level, or even check for the need for byte swapping. Thoughts? Robert. On 3 February 2012 14:17, Colin McDonald <[email protected]> wrote: > Hi Robert, > > Byte swapping for the osgb binary file format was not fully implemented, > meaning that the files were not portable between big & little endian > systems. > > I have fully implemented the byte swapping in > osgPlugins/osg/BinaryStreamOperator.h. I have set the file format to > little endian, so that 99% of users should see no difference. I have > also added some code to handle different "long" sizes. > > Some binary file reading was done directly in osgDB/InputStream.cpp, > bypassing the BinaryInputOperator for arrays. Presumably this was a > performance optimisation. But there was no linkage to turn byte > swapping on or off, and I thought it preferable to have all of the > byte-swapping in one place, in the BinaryInputOperator. > > Regards > > Colin McDonald > > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
