Here is the repro code. I made it as simple as I could. Please note that it
only shows the core of the problem. One may argue that with this limit I
set here in example, we have no room for last RTT texture anyway. But the
problem will show up too if I increase the TEX_POOL limit to store 3 RTT
textures, but will initially fill the memory with other textures (with
images of different resolution or format). Once memory size of these
initial textures + newly added RTT passes TEXTURE_POOL_SIZE, the problem
will show up when one of the RTTs is added later...
Cheers,
Wojtek
2016-10-09 20:17 GMT+02:00 Wojciech Lewandowski <[email protected]>:
> Could you modify one to OSG examples to illustrate the problem so
>> others can reproduce it. I have paged databases to test against, but
>> not the particular FBO usage that you are using along with it.
>
>
> Ok. I'll try to make a repro. I do believe however that in our case we do
> not attach images to FBO but empty textures. And those textures are
> scraped. I wrote 'I believe' because its not all my code, maybe someone
> attached images somewhere to debug. I will double check and include this
> case in repro if its true.
>
> Wojtek
>
> 2016-10-09 14:47 GMT+02:00 Robert Osfield <[email protected]>:
>
>> On 9 October 2016 at 11:27, Wojciech Lewandowski
>> <[email protected]> wrote:
>> > Hi, Robert. Thanks for quick response.
>> >
>> >> Perhaps a flag in osg::Texture might be appropriate to declare whether
>> >> this Texture is
>> >> suitable for reuse or not.
>> >
>> >
>> > Perhaps. However, I have the feeling that this flag would be equivalent
>> to
>> > checking if (image != NULL) in current 3.5.5 OSG code base context. I
>> don't
>> > see how already assigned and active image-less texture coud survive such
>> > Take operation without a callback (or similar mechanism) to let texture
>> > owner refresh it before apply.
>>
>> In design of the texture pool assumes that if the image is NULL then
>> the texture can't be taken. If this isn't being upheld then it looks
>> like a bug.
>>
>> > Considering need for supporting multiple
>> > contexts and fact that such refresh callback would require action in
>> draw
>> > stage, I see this postulate (for a refresh callback) as hard to
>> implement
>> > and probably not used by users in practice. So I conclude that (image !=
>> > NULL) is probably a sufficient check for now ;-). Did I skip some use
>> case ?
>>
>> One case would be people assigning an osg::Image to textures that are
>> assigned to an FBO.
>>
>> FYI, I'm just quickly checking posts, I'm not working at a dev
>> computer so I can't review code or spend long things deeply about a
>> topic. so my response are really preliminary :-)
>>
>> Could you modify one to OSG examples to illustrate the problem so
>> others can reproduce it. I have paged databases to test against, but
>> not the particular FBO usage that you are using along with it.
>>
>> Robert.
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
>
#include <osg/Group>
#include <osg/Geode>
#include <osg/Texture2D>
#include <osgViewer/Viewer>
osg::ref_ptr< osg::Group > BuildRTTQuad( osg::Vec4 clearColor, float posx = 0.f, float posy = 0.f, float size = 0.3f, int texture_size = 1024)
{
osg::ref_ptr< osg::Group > group = new osg::Group;
osg::ref_ptr< osg::Texture2D > texture = new osg::Texture2D;
texture->setTextureSize(texture_size, texture_size);
texture->setInternalFormat(GL_RGBA);
osg::ref_ptr< osg::Camera > camera = new osg::Camera;
camera->setClearColor(clearColor);
camera->setViewport(0, 0, texture_size, texture_size);
// Interesting observation: removing next line "makes" the view correct
// probably attching texture to FBO before drawing with it somehow affects the problem
camera->setRenderOrder(osg::Camera::PRE_RENDER);
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
camera->attach(osg::Camera::COLOR_BUFFER, texture);
group->addChild(camera);
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(osg::createTexturedQuadGeometry(osg::Vec3(posx, posy, 0), osg::Vec3(size, 0, 0), osg::Vec3(0, size, 0)));
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture);
group->addChild(geode);
return group;
}
// Run without setting OSG_TEXTURE_POOL_SIZE to see how it should look
// ( correct view shows red, green, blue quad on typical osg background )
//
// To see the bug in action: run with OSG_TEXTURE_POOL_SIZE = 10000000
// or set the limit in code with this line
// osg::DisplaySettings::instance()->setMaxTexturePoolSize(10000000);
// ( incorrect view on my machine shows white, red, green quad
// but I believe your incorrects results may vary because I cannot explain
// where white quad comes from. It may be some other undefined color... )
int main(int argc, char** argv)
{
osgViewer::Viewer viewer( osg::ArgumentParser(&argc, argv) );
// osg::DisplaySettings::instance()->setMaxTexturePoolSize(10000000);
osg::ref_ptr< osg::Group > scene = new osg::Group();
viewer.setSceneData(scene);
viewer.getCamera()->setProjectionMatrix(osg::Matrixd::ortho2D(0, 1, 0, 1));
viewer.getCamera()->setViewMatrix(osg::Matrixd::identity());
for (int frame = 0; !viewer.done(); frame++)
{
// Single quad is added per frame in first 3 frames
if (frame == 0)
scene->addChild(BuildRTTQuad(osg::Vec4(1, 0, 0, 1), 0.00, 0.33, 0.33));
if (frame == 1)
scene->addChild(BuildRTTQuad(osg::Vec4(0, 1, 0, 1), 0.33, 0.33, 0.33));
if (frame == 2)
scene->addChild(BuildRTTQuad(osg::Vec4(0, 0, 1, 1), 0.66, 0.33, 0.33));
viewer.frame();
}
}_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org