Thank you so much for your response! You saved me a LOT of time. I thought you had to call dirty() on the image associated with the texture in order for it to trigger the callback. Based on your comment that I was using both an image and a callback, I tried removing the image (which makes sense since I want to handle uploading sub-tiles myself), everything started working. Looks like the callback gets invoked at every frame which simplifies things a great deal. It even fixed a host of other artifacts and blending issues (I wrote a megatexturing engine that blends between tiles of different LOD and these tiles get uploaded via the subload() callback). Funny how everything looks better now.

Anyhow, if anyone tries to incorrectly use an image and a subload callback at the same time, it won't work with mipmap count of 0. But even with a mipmap count of 1, there are other artifacts that will crop up.

BTW, are there any docs for the callback? I could only find one or two forum threads about it. Actually, where would one find docs in general? The doxygen ones are rather lacking in some areas.

Thanks again,
Cléo

On 25/11/2014 2:23 PM, Robert Osfield wrote:
Hi Cleo,

There isn't any way I can determine what the problem from the information given. I can't rule out an OSG bug, but the only way to be able to find this out would be to have a compilable application that reproduces the bug so that I can test it first hand. It could very easily be a bug in what you doing, or simply be that a bug in 2.6.1 hid this problem.

The only oddity I can spot from a review is why you are assigning an Image and subload callback, also the NO_DELETE on the Image, this means that the OSG doesn't take any responsibility for deleting the data and it's entirely down to your app.

You don't specify what you are trying to achieve so there is no way I can say whether it's appropriate or not,

As things stand there is nothing we can do to help until we have a bit more information about what you are tying to achieve, and a small example to reproduce the problem.

Robert.


On 25 November 2014 at 18:11, Cleo Saulnier <[email protected] <mailto:[email protected]>> wrote:

    Hi,

    I recently upgraded from osg 2.6 to 3.2.1. I noticed that the
    SubloadCallback::load() now gets called exclusively and eats up
    all memory until the machine crashes. subload() never gets called
    anymore. I changed my Texture2D instance to use 1 mipmap level and
    forced it have zero levels with opengl directly in the load()
    method and this seems to work. Why can I not set the number of
    mipmap levels to be zero when using SubloadCallback? I only use
    this to upload tiles in the texture. Only the one texture has the
    callback.

    I thought it had something to do with the TextureObject, but it
    seems to make no difference what the mipmap count is in the
    TextureObject when I override generateTextureObject().

    This is the code I'm using:

            m_tileTexture = new osg::Texture2D();
            // Apparent bug in OSG where only SubloadCallback::load()
    will be called.
            // This should be set to 0 when fixed.
            m_tileTexture->setNumMipmapLevels(1); // When 0, runs out
    of RAM
            m_tileTexture->setTextureSize(kTileNum * kTileSize,
    kTileNum * kTileSize); // 4096x4096
            m_tileTexture->setFilter(osg::Texture::MIN_FILTER,
    osg::Texture::LINEAR);
            m_tileTexture->setFilter(osg::Texture::MAG_FILTER,
    osg::Texture::LINEAR);
            m_tileTexture->setWrap(osg::Texture::WRAP_S,
    osg::Texture::CLAMP_TO_EDGE);
            m_tileTexture->setWrap(osg::Texture::WRAP_T,
    osg::Texture::CLAMP_TO_EDGE);

            m_tileData = // custom allocation code omitted. Allocates
    4096x4096x4 bytes.
            m_tileImage = new osg::Image();
            m_tileImage->setImage(kTileNum * kTileSize, kTileNum *
    kTileSize, 1, GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE,
                reinterpret_cast<unsigned
    char*>(m_tileData->getDataPtr()), osg::Image::NO_DELETE);
            m_tileTexture->setImage(m_tileImage.get());
            m_tileTexture->setSubloadCallback(new SubLoadCallback(*this));

    SubloadCallback::load() just calls glTexImage2D() with the
    settings obtained from the texture's image.

    Thanks,
    Cléo

    _______________________________________________
    osg-users mailing list
    [email protected]
    <mailto:[email protected]>
    http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to