Skip to content

Commit 3552da5

Browse files
authored
Merge pull request #145 from alicevision/fix/largeImages
Fix errors with large images
2 parents fd21d35 + dc7302e commit 3552da5

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

src/popsift/common/device_prop.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ bool device_prop_t::checkLimit_2DsurfLayered( int& width, int& height, int& laye
274274
std::cerr << __FILE__ << ":" << __LINE__
275275
<< ": CUDA device " << currentDevice << std::endl
276276
<< " does not support layered 2D surfaces " << width
277-
<< " bytes wide." << endl;
277+
<< " pixels wide." << endl;
278278
}
279279
width = ptr->maxSurface2DLayered[0];
280280
returnSuccess = false;

src/popsift/common/device_prop.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ class device_prop_t
9191
/**
9292
* @brief Check if a request exceeds the current CUDA device's limit in
9393
* surface2DLayered dimensions. surface2DLayered is the writable equivalent
94-
* to texture2DLayered, but the width must be given in bytes, not elements.
95-
* Since we use float, images cannot be as wide as expected.
94+
* to texture2DLayered.
9695
* @param[in,out] width Desired width of the texture.
9796
* @param[in,out] height Desired height of the texture.
9897
* @param[in,out] layers Desired depth of the texture.

src/popsift/common/plane_2d.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ template <typename T> struct PitchPlane2D : public PlaneT<T>
168168
PlaneBase::freeHost2D( this->data, mode );
169169
}
170170
__host__ __device__
171-
inline short getPitchInBytes( ) const { return _pitchInBytes; }
171+
inline size_t getPitchInBytes( ) const { return _pitchInBytes; }
172172

173173
protected:
174-
int _pitchInBytes; // pitch width in bytes
174+
size_t _pitchInBytes; // pitch width in bytes
175175
};
176176

177177
/*************************************************************
@@ -338,7 +338,7 @@ template <typename T> class Plane2D : public PitchPlane2D<T>
338338
__host__ __device__
339339
inline short getHeight( ) const { return _rows; }
340340
__host__ __device__
341-
inline short getByteSize( ) const { return this->_pitchInBytes*_rows; }
341+
inline size_t getByteSize( ) const { return this->_pitchInBytes * _rows; }
342342

343343
__host__ inline void allocDev( int w, int h ) {
344344
_cols = w;

src/popsift/popsift.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,7 @@ PopSift::AllocTest PopSift::testTextureFit( int width, int height )
184184
*/
185185
int depth = _config.levels + 3;
186186

187-
/* Surfaces have a limited width in bytes, not in elements.
188-
* Our DOG pyramid stores 4/byte floats, so me must check for
189-
* that width.
190-
*/
191-
int byteWidth = width * sizeof(float);
192-
retval = _device_properties.checkLimit_2DsurfLayered( byteWidth,
187+
retval = _device_properties.checkLimit_2DsurfLayered( width,
193188
height,
194189
depth,
195190
warn );
@@ -216,13 +211,13 @@ std::string PopSift::testTextureFitErrorString( AllocTest err, int width, int he
216211
{
217212
const float upscaleFactor = _config.getUpscaleFactor();
218213
const float scaleFactor = 1.0f / powf( 2.0f, -upscaleFactor );
219-
int w = ceilf( width * scaleFactor ) * sizeof(float);
214+
int w = ceilf( width * scaleFactor );
220215
int h = ceilf( height * scaleFactor );
221216
int d = _config.levels + 3;
222217

223218
_device_properties.checkLimit_2DsurfLayered( w, h, d, false );
224219

225-
w = w / scaleFactor / sizeof(float);
220+
w = w / scaleFactor;
226221
h = h / scaleFactor;
227222
ostr << "E Cannot use"
228223
<< (upscaleFactor==1 ? " default " : " ")

0 commit comments

Comments
 (0)