From 214491dd94289afd320365666a321deade7a8019 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 27 Jun 2008 16:47:43 +0000 Subject: [PATCH] From Mathias Froehlich, "Update to the configure check for msvc 7.1. MemoryBarrier() is used in the implementation, so it should be checked. This in effect disables the faster atomic ops on msvc 7.1 and older, even if only the MemoryBarrier() call is missing. But it ensures for the fist cut that it will build everywhere. If somebody cares for msvc 7.1 enough and has one for testing installed, he might provide the apropriate defines to guard that MemoryBarrier() call. I tested that msvc8 32/64bit still passes the configure tests and compiles. " --- CMakeModules/CheckAtomicOps.cmake | 1 + src/osg/Image.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeModules/CheckAtomicOps.cmake b/CMakeModules/CheckAtomicOps.cmake index 71c7eb788..3cd1876d8 100644 --- a/CMakeModules/CheckAtomicOps.cmake +++ b/CMakeModules/CheckAtomicOps.cmake @@ -77,6 +77,7 @@ int main(int, const char**) long* volatile ptr = &data; InterlockedIncrement(&value); + MemoryBarrier(); InterlockedDecrement(&value); if (0 != InterlockedCompareExchange(&value, 1, 0)) diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index d410345bc..9dc9f61c8 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -553,7 +553,10 @@ void Image::allocateImage(int s,int t,int r, _pixelFormat = format; _dataType = type; _packing = packing; - _internalTextureFormat = format; + + // preserve internalTextureFormat if already set, otherwise + // use the pixelFormat as the source for the format. + if (_internalTextureFormat==0) _internalTextureFormat = format; } else { @@ -565,7 +568,10 @@ void Image::allocateImage(int s,int t,int r, _pixelFormat = 0; _dataType = 0; _packing = 0; - _internalTextureFormat = 0; + + // commenting out reset of _internalTextureFormat as we are changing + // policy so that allocateImage honours previous settings of _internalTextureFormat. + //_internalTextureFormat = 0; } dirty();