It is currently Sat Aug 22, 2020 5:02 am


All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Simple Volume unusual memory usage
PostPosted: Thu Jun 20, 2013 5:25 pm 

Joined: Thu Jun 20, 2013 4:41 pm
Posts: 3
Evening :)

I've got a quick question since this has been baffling me.

I've created a simple volume of 65x65x257 using int32 (4 bytes) per voxel.
Using that logic, the SimpleVolume.calculateSizeInBytes() function should be returning: 4,343,300
Give or take a small (in relative terms) margin to accommodate additional data.

Simple cration code is below:
Code:
///In class header/////
PolyVox::SimpleVolume<uint32_t> volData;
/////////////////////////

CubeNode::CubeNode() :
volData(PolyVox::Region(PolyVox::Vector3DInt32(0,0,0),
      PolyVox::Vector3DInt32(64, 256, 64)))
{
   int k = volData.calculateSizeInBytes();
   int h = 0;
}


I put a breakpoint at (int h = 0) to show me the value of K.

However, k = 10,748,000
The memory actually stored is more than double the specified number of bytes.
I can confirm the number is accurate from Task manager.

Is there something I'm doing wrong here? Is there a better storage medium than SimpleVolume?

Essentially my main interest in polyvox lies in the mesh optimization, so if there's an unconventional solution to maintain that element in particular I'm all ears.

Cheers!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Simple Volume unusual memory usage
PostPosted: Thu Jun 20, 2013 8:58 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Hi, and welcone to PolyVox :-)

Internally the SimpleVolume stores it's data as a set of blocks, and by default these blocks are 32x32x32. This means your volume dimensions will be rounded up to the nearest multiple of 32, which in your case makes the volume 96*288*96 voxels. With four bytes per vertex this explains the size you are seeing.

Probably this extra overhead doesn't matter, and it becomes less significant as the volumes get larger. But if you want to avoid it then you can use RawVolume instead as this simply stores a single large chunk of data which should be the expected size.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Simple Volume unusual memory usage
PostPosted: Fri Jun 21, 2013 12:06 am 

Joined: Thu Jun 20, 2013 4:41 pm
Posts: 3
Ah, that makes sense. many thanks for the reply!
I'll admit I'm pedantic to a flaw when it comes to the memory management and predictability aspects of development. RawVolume looks to be precisely what I'm looking for. Still relatively fast at mesh generation too, which is nice! :)

On a side note since I'm here, I'm really looking for a fixed size of 64x64x256 (0,0,0 to 63,63,255), but two if the edges end up not being created for the mesh unless I add that additional +1

Is there a way to tell it to always assume that an out of bounds vertex will be 0?
I tried volData.setBorderValue(0); but I suspect I'm misinterpreting the point of that function ;)

Thanks for the welcome, too :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Simple Volume unusual memory usage
PostPosted: Fri Jun 21, 2013 12:07 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Panic wrote:
Still relatively fast at mesh generation too, which is nice! :)


Yes, for small volumes like yours it is fine. For larger volumes the block-based nature of the SimpleVolume is more cache-friendly.

Panic wrote:
On a side note since I'm here, I'm really looking for a fixed size of 64x64x256 (0,0,0 to 63,63,255), but two if the edges end up not being created for the mesh unless I add that additional +1


There's some useful information in the CubicSurfaceExtractor documentation, but do ask if it's still not clear.


Panic wrote:
Is there a way to tell it to always assume that an out of bounds vertex will be 0?
I tried volData.setBorderValue(0); but I suspect I'm misinterpreting the point of that function ;)


That should work (in conjuntion with setting the region size correctly as in the previous link), though in the lasest (develop) branch of PolyVox there is a new approach described here: https://bitbucket.org/volumesoffun/poly ... at=develop


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Simple Volume unusual memory usage
PostPosted: Fri Jun 21, 2013 4:56 pm 

Joined: Thu Jun 20, 2013 4:41 pm
Posts: 3
Makes sense. Since I explicitly want the regions to remain separate I'll stick with the +1 method, at least for now.

If the new method uses getVoxel() to determine borders I assume that would be included to some degree in the mesh extractor?

Cheers for replying again :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Simple Volume unusual memory usage
PostPosted: Fri Jun 21, 2013 6:34 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Yes, one of the reasons for making these wrap modes be passed as a parameter (rather than using a different function as in the getVoxelAt() case) is that they can then be passed to the various algorithms. The CubicSurfaceExtractor does take such a parameter but I'm not sure if it's hooked up internally at the moment.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net