<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi <br>
    <pre wrap="">Josiah</pre>
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">Am 22.07.2016 um 13:00 schrieb Josiah
      Jideani:<br>
    </div>
    <blockquote cite="mid:1469185204.m2f.68195@forum.openscenegraph.org"
      type="cite">
      <pre wrap="">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.</pre>
    </blockquote>
    Putting the numbers together, 640^3 with 4*4 bytes (float and rgba)
    hits the 4 gig limit.<br>
    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?<br>
    Typ<br>
    <br>
    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)<br>
    <br>
    <br>
    Cheers<br>
    Sebastian <br>
    <br>
    [1]
<a class="moz-txt-link-freetext" href="http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/src/osg/Image.cpp?rev=10890">http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/src/osg/Image.cpp?rev=10890</a><br>
    <b><span class="code-type">unsigned</span></b> <b><span
        class="code-type">int</span></b> <b><span class="code-func">Image::getTotalSizeInBytesIncludingMipmaps</span></b>()
    <b><span class="code-type">const <br>
        <br>
        <br>
      </span></b>
    <blockquote cite="mid:1469185204.m2f.68195@forum.openscenegraph.org"
      type="cite">
      <pre wrap="">

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</pre>
    </blockquote>
    Are you trying to compensate something? ;-)<br>
    <br>
    <blockquote cite="mid:1469185204.m2f.68195@forum.openscenegraph.org"
      type="cite">
      <pre wrap="">



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:
<a class="moz-txt-link-freetext" href="http://forum.openscenegraph.org/viewtopic.php?p=68195#68195">http://forum.openscenegraph.org/viewtopic.php?p=68195#68195</a>





_______________________________________________
osg-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>
<a class="moz-txt-link-freetext" href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>