Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1056 - in trunk: Engine/Display Image Interface
- Date: Wed, 10 May 2006 19:36:24 -0600 (MDT)
Author: sparker
Date: Wed May 10 19:36:22 2006
New Revision: 1056
Modified:
trunk/Engine/Display/PureOpenGLDisplay.cc
trunk/Image/SimpleImage.h
trunk/Image/SimpleImageBase.h
trunk/Interface/Parameters.h
Log:
Fix resizing by padding to a multiple of 16 bytes (actually 32 bytes as
recommended for OpenGL performance too)
Modified: trunk/Engine/Display/PureOpenGLDisplay.cc
==============================================================================
--- trunk/Engine/Display/PureOpenGLDisplay.cc (original)
+++ trunk/Engine/Display/PureOpenGLDisplay.cc Wed May 10 19:36:22 2006
@@ -225,6 +225,7 @@
} else {
return false;
}
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, si->getRowLength());
if(stereo){
glDrawBuffer(GL_BACK_LEFT);
glRasterPos2i(0,0);
@@ -272,7 +273,7 @@
if(have_clientstorage)
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, si->getRowLength());
if(have_texturerange)
glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE,
Modified: trunk/Image/SimpleImage.h
==============================================================================
--- trunk/Image/SimpleImage.h (original)
+++ trunk/Image/SimpleImage.h Wed May 10 19:36:22 2006
@@ -82,7 +82,11 @@
{
valid = false;
int numEyes = stereo?2:1;
- unsigned long totalSize = (xres * yres * numEyes * sizeof(Pixel));
+ int pad = IMAGE_ROW_BYTES/sizeof(Pixel);
+ if(pad < 1)
+ pad = 1;
+ xpad = (xres+pad-1)&~(pad-1);
+ unsigned long totalSize = (xpad * yres * numEyes * sizeof(Pixel));
totalSize += 2*MAXCACHELINESIZE;
data = new char[totalSize];
unsigned long offset = reinterpret_cast<unsigned
long>(data)%MAXCACHELINESIZE;
@@ -91,12 +95,12 @@
eyeStart[0] = new Pixel*[stereo?2*yres:yres];
eyeStart[0][0] = reinterpret_cast<Pixel*>(data+offset);
for(int i=1;i<yres;i++)
- eyeStart[0][i] = eyeStart[0][i-1]+xres;
+ eyeStart[0][i] = eyeStart[0][i-1]+xpad;
if(stereo){
eyeStart[1] = eyeStart[0]+yres;
- eyeStart[1][0] = eyeStart[0][0]+xres*yres;
+ eyeStart[1][0] = eyeStart[0][0]+xpad*yres;
for(int i=1;i<yres;i++)
- eyeStart[1][i] = eyeStart[1][i-1]+xres;
+ eyeStart[1][i] = eyeStart[1][i-1]+xpad;
} else {
eyeStart[1] = 0;
}
Modified: trunk/Image/SimpleImageBase.h
==============================================================================
--- trunk/Image/SimpleImageBase.h (original)
+++ trunk/Image/SimpleImageBase.h Wed May 10 19:36:22 2006
@@ -41,10 +41,15 @@
virtual void getResolution(bool& stereo, int& xres, int& yres) const;
virtual void* getRawData(int which_eye) const = 0;
+ int getRowLength() const {
+ return xpad;
+ }
+
protected:
bool valid;
bool stereo;
int xres, yres;
+ int xpad;
private:
SimpleImageBase(const Image&);
Modified: trunk/Interface/Parameters.h
==============================================================================
--- trunk/Interface/Parameters.h (original)
+++ trunk/Interface/Parameters.h Wed May 10 19:36:22 2006
@@ -34,5 +34,6 @@
#define DENOM_EPSILON ((Real)1.e-6)
#define COLOR_EPSILON ((Real)1.e-4)
#define MAXT ((Real)1.e19)
+#define IMAGE_ROW_BYTES 32
#endif
- [MANTA] r1056 - in trunk: Engine/Display Image Interface, sparker, 05/10/2006
Archive powered by MHonArc 2.6.16.