[osg-users] 3D osg::Image allocation size problem

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Fri Jul 22 10:26:24 PDT 2016


Hi

Josiah



Am 22.07.2016 um 13:00 schrieb Josiah Jideani:
> Hi,
>
> I am developing a scientific visualization application using Qt and Openscenegraph.  I am trying to create a 3D osg::Image to add to an osgVolume.  I am having problems allocating the image data when I call the allocateImage member function (see the code snippet below).
>
> The allocation works for equal dimensions less than 640.
>
> When I try to allocate anything above 640x640x640 but less than 800x800x800, it seems to allocate successfully because image_s, image_t and image_r hold the correct sizes however when I try to write to the image data (the nested for loops) a segmentation fault is thrown at data[0] = 0.0f when s = 0; t = 0; and r = some random but valid number.
Putting the numbers together, 640^3 with 4*4 bytes (float and rgba) hits 
the 4 gig limit.
I believe the image size used internally by OSG is an unsigned int(which 
on most platforms is 32bits) , so that is probably what you're 
hitting.[1] Could you check what the calculated image size returns, when 
you encounter the allocation fails?
Typ

If my theory is right, we would have to change the data type used for 
calculation to long/size_t. (Seems like the calculation and the 
constructor are the only places that fail to use the correct size)


Cheers
Sebastian

[1] 
http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/src/osg/Image.cpp?rev=10890
*unsigned* *int* *Image::getTotalSizeInBytesIncludingMipmaps*() *const


*
>
> I can allocate and write to the image data with sizes between 800x800x800 and 1024x1024x1024, but a segmentation fault is thrown from the object code after the call to the viewer's frame() method.
>
> And finally for sizes above 1024 the allocation completely fails as image_s image_t and image_r all hold 0.
>
> Any clue on how to solve this? It was my understanding that the maximum size of the image is limited by the maximum 3D texture size of the graphics card which for the Quadro K4200 that I'm using is 4096x4096x4096.  So why am I only able to allocate a 640x640x640 image?
>
> These are the specifications of my system:
> Operating system: Opensuse Leap 42.1
> RAM: 128GB
> Graphics Card: Quadro K4200
> Qt: Qt 4.7.1
> OSG version: 3.2.3
Are you trying to compensate something? ;-)

>
>
>
> Thank you!
>
> Cheers,
> Josiah
>
>
> Code:
>
> osg::ref_ptr<osg::Image> image = new osg::Image
> image->allocateImage(1024, 1024, 1024, GL_RGBA, GL_FLOAT);
>
> int image_s = image->s();
> int image_t = image->t();
> int image_r = image->r();
>
> for(int s = 0; s < image_s; s++)
> {
>      for(int t = 0; t < image_t; t++)
>      {
>          for(int r = 0; r < image_r; r++)
>          {
>              float* data = (float*) image->data(s,t,r);
>              data[0] = 0.0f;
>              data[1] = 0.0f;
>              data[2] = 1.0f;
>              data[3] = 0.1f;
>          }
>      }
> }
>
>
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68195#68195
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160722/3a9ec5c6/attachment-0003.htm>


More information about the osg-users mailing list