I have a 2D texture placed over rectangular area - it's a dynamic texture image (640x480).
tex = new osg::Texture2D;
tex->setDataVariance( osg::Object::DYNAMIC );
tex->setResizeNonPowerOfTwoHint( false );
tex->setFilter( osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST );
tex->setFilter( osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST );
tex->setImage(myImage);
My image data is updated in other thread often (each N milliseconds):
myImage->setImage(
width,
height,
1,
3,
GL_BGR,
gl_data_size,
(BYTE *)newImageData,
osg::Image::AllocationMode::USE_MALLOC_FREE
);
And after that I want to update rendered image, if I use dirty( thought this was a best way for update ) on image set to texture, e.g.
// Update callback
...
myImage->dirty();
...
My performance is about 7-8 times slower than if I use just image replacement with same pointer.
// Update callback
...
tex->setImage(myImage);
...
Reading documentation and gidelines of OSG makes me think the correct way is - 'dirty()'. But it's extremly slow. Do I missunderstand something or there is a mistake in my code?