From 8f39d7a2b20155bb3513e7bbc888d01565689a3b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 21 Jul 2014 13:43:11 +0000 Subject: [PATCH] From Jaap Gas, "I want to submit a bugfix for a crash occurring in osgText/Glyph.cpp if the scene tree contains (large) 2D textures from images with STRIDE. ============================================================================ #0 0x00007fffe8ea4350 in __memmove_ssse3 () from /lib64/libc.so.6 #1 0x00007fffe52ced76 in ?? () from /usr/lib64/libnvidia-glcore.so.310.44 #2 0x00007fffe52d8e86 in ?? () from /usr/lib64/libnvidia-glcore.so.310.44 #3 0x00007fffe53dd8be in ?? () from /usr/lib64/libnvidia-glcore.so.310.44 #4 0x00007fffe53c2643 in ?? () from /usr/lib64/libnvidia-glcore.so.310.44 #5 0x00007fffe53c7fdd in ?? () from /usr/lib64/libnvidia-glcore.so.310.44 #6 0x00007fffe53cbabf in ?? () from /usr/lib64/libnvidia-glcore.so.310.44 #7 0x00007fffe53cc1fa in ?? () from /usr/lib64/libnvidia-glcore.so.310.44 #8 0x00007ffff30092fd in osgText::GlyphTexture::apply (this=0x1bb8cf0, state= ...) at /d43/jaap/dev/jaapOSG/build/OpenSceneGraph3.3.1/src/osgText/Glyph.cpp:234 #9 0x00007ffff56c30b6 in osg::State::applyAttributeOnTexUnit (this=0x125f180, unit=0, attribute=0x1bb8cf0, as=...) at /d43/jaap/dev/jaapOSG/build/OpenSceneGraph3.3.1/include/osg/State:1713 #10 0x00007ffff56c2f3f in osg::State::applyTextureAttribute (this=0x125f180, unit=0, attribute=0x1bb8cf0) at /d43/jaap/dev/jaapOSG/build/OpenSceneGraph3.3.1/include/osg/State:411 #11 0x00007ffff30204da in osgText::Text::drawTextWithBackdrop (this=0x1baed70, state=..., colorMultiplier=...) ============================================================================== The crash disappears if I either (1) disable the use of images with stride in the (public) osgGeo-library, or (2) add the following bugfix to Glyph.cpp. This combination gives me the confidence that I understand where this problem originates from, without trying to understand the full OpenGL details. =============================================================================== @@ -221,7 +223,12 @@ imageData[i] = 0; } + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + glPixelStorei(GL_UNPACK_ROW_LENGTH,getTextureWidth()); + #endif + // allocate the texture memory. glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA, getTextureWidth(), getTextureHeight(), 0, ================================================================================ I have copied (and adapted) the added lines above from the same source file, where they were used in front of a similar call to glTexSubImage2D(.) around line 515. " git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14372 16af8721-9629-0410-8352-f15c8da7e697 --- src/osgText/Glyph.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/osgText/Glyph.cpp b/src/osgText/Glyph.cpp index 9f4be5be5..339b47f8f 100644 --- a/src/osgText/Glyph.cpp +++ b/src/osgText/Glyph.cpp @@ -221,6 +221,11 @@ void GlyphTexture::apply(osg::State& state) const imageData[i] = 0; } + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + glPixelStorei(GL_UNPACK_ROW_LENGTH,getTextureWidth()); + #endif // allocate the texture memory. glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA,