Work on removing compression from LargeVolume.
This commit is contained in:
@ -91,11 +91,11 @@ public:
|
||||
/// Destructor
|
||||
virtual ~PerlinNoisePager() {};
|
||||
|
||||
virtual void pageIn(const PolyVox::Region& region, CompressedBlock<MaterialDensityPair44>* pBlockData)
|
||||
virtual void pageIn(const PolyVox::Region& region, UncompressedBlock<MaterialDensityPair44>* pBlockData)
|
||||
{
|
||||
// FIXME - this isn't a great example... it's a shame we have to hard clode the block size and also create/destroy
|
||||
// a compressor each time. These could at least be moved outside somewhere if we can't fix it in a better way...
|
||||
UncompressedBlock<MaterialDensityPair44> block(256);
|
||||
//UncompressedBlock<MaterialDensityPair44> block(256);
|
||||
|
||||
Perlin perlin(2,2,1,234);
|
||||
|
||||
@ -133,18 +133,18 @@ public:
|
||||
// Voxel position within a block always start from zero. So if a block represents region (4, 8, 12) to (11, 19, 15)
|
||||
// then the valid block voxels are from (0, 0, 0) to (7, 11, 3). Hence we subtract the lower corner position of the
|
||||
// region from the volume space position in order to get the block space position.
|
||||
block.setVoxelAt(x - region.getLowerX(), y - region.getLowerY(), z - region.getLowerZ(), voxel);
|
||||
pBlockData->setVoxelAt(x - region.getLowerX(), y - region.getLowerY(), z - region.getLowerZ(), voxel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now compress the computed data into the provided block.
|
||||
RLEBlockCompressor<MaterialDensityPair44>* compressor = new RLEBlockCompressor<MaterialDensityPair44>();
|
||||
compressor->compress(&block, pBlockData);
|
||||
delete compressor;
|
||||
//RLEBlockCompressor<MaterialDensityPair44>* compressor = new RLEBlockCompressor<MaterialDensityPair44>();
|
||||
//compressor->compress(&block, pBlockData);
|
||||
//delete compressor;
|
||||
}
|
||||
|
||||
virtual void pageOut(const PolyVox::Region& region, CompressedBlock<MaterialDensityPair44>* /*pBlockData*/)
|
||||
virtual void pageOut(const PolyVox::Region& region, UncompressedBlock<MaterialDensityPair44>* /*pBlockData*/)
|
||||
{
|
||||
std::cout << "warning unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner() << std::endl;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace PolyVox
|
||||
m_vecCreatedFiles.clear();
|
||||
}
|
||||
|
||||
virtual void pageIn(const Region& region, CompressedBlock<VoxelType>* pBlockData)
|
||||
virtual void pageIn(const Region& region, UncompressedBlock<VoxelType>* pBlockData)
|
||||
{
|
||||
POLYVOX_ASSERT(pBlockData, "Attempting to page in NULL block");
|
||||
//POLYVOX_ASSERT(pBlockData->hasUncompressedData() == false, "Block should not have uncompressed data");
|
||||
@ -88,14 +88,16 @@ namespace PolyVox
|
||||
{
|
||||
POLYVOX_LOG_TRACE("Paging in data for " << region);
|
||||
|
||||
fseek(pFile, 0L, SEEK_END);
|
||||
/*fseek(pFile, 0L, SEEK_END);
|
||||
size_t fileSizeInBytes = ftell(pFile);
|
||||
fseek(pFile, 0L, SEEK_SET);
|
||||
|
||||
uint8_t* buffer = new uint8_t[fileSizeInBytes];
|
||||
fread(buffer, sizeof(uint8_t), fileSizeInBytes, pFile);
|
||||
pBlockData->setData(buffer, fileSizeInBytes);
|
||||
delete[] buffer;
|
||||
delete[] buffer;*/
|
||||
|
||||
fread(pBlockData->getData(), sizeof(uint8_t), pBlockData->getDataSizeInBytes(), pFile);
|
||||
|
||||
if(ferror(pFile))
|
||||
{
|
||||
@ -110,7 +112,7 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
virtual void pageOut(const Region& region, CompressedBlock<VoxelType>* pBlockData)
|
||||
virtual void pageOut(const Region& region, UncompressedBlock<VoxelType>* pBlockData)
|
||||
{
|
||||
POLYVOX_ASSERT(pBlockData, "Attempting to page out NULL block");
|
||||
//POLYVOX_ASSERT(pBlockData->hasUncompressedData() == false, "Block should not have uncompressed data");
|
||||
|
@ -571,7 +571,7 @@ namespace PolyVox
|
||||
Vector3DInt32 v3dUpper = v3dLower + Vector3DInt32(m_uBlockSideLength-1, m_uBlockSideLength-1, m_uBlockSideLength-1);
|
||||
|
||||
// Page the data out
|
||||
m_pPager->pageOut(Region(v3dLower, v3dUpper), pCompressedBlock);
|
||||
//m_pPager->pageOut(Region(v3dLower, v3dUpper), pCompressedBlock);
|
||||
|
||||
// The compressed data is no longer modified with respect to the data on disk
|
||||
pCompressedBlock->m_bDataModified = false;
|
||||
@ -591,7 +591,7 @@ namespace PolyVox
|
||||
// This should never happen as blocks are deleted based on being least recently used.
|
||||
// I the case that we are flushing we delete all blocks, but the flush function will
|
||||
// reset the 'm_pLastAccessedBlock' anyway to prevent it being accidentally reused.
|
||||
POLYVOX_ASSERT(pUncompressedBlock != m_pLastAccessedBlock, "Attempted to delete last accessed block.");
|
||||
//POLYVOX_ASSERT(pUncompressedBlock != m_pLastAccessedBlock, "Attempted to delete last accessed block.");
|
||||
|
||||
// Before deleting the block we may need to recompress its data. We
|
||||
// only do this if the data has been modified since it was decompressed.
|
||||
@ -599,9 +599,13 @@ namespace PolyVox
|
||||
{
|
||||
// Get the compressed block which we will copy the data back in to.
|
||||
Vector3DInt32 v3dBlockPos = itUncompressedBlock->first;
|
||||
CompressedBlock<VoxelType>* pCompressedBlock = getCompressedBlock(v3dBlockPos.getX(), v3dBlockPos.getY(), v3dBlockPos.getZ());
|
||||
|
||||
m_pBlockCompressor->compress(pUncompressedBlock, pCompressedBlock);
|
||||
// From the coordinates of the block we deduce the coordinates of the contained voxels.
|
||||
Vector3DInt32 v3dLower(v3dBlockPos.getX() << m_uBlockSideLengthPower, v3dBlockPos.getY() << m_uBlockSideLengthPower, v3dBlockPos.getZ() << m_uBlockSideLengthPower);
|
||||
Vector3DInt32 v3dUpper = v3dLower + Vector3DInt32(m_uBlockSideLength - 1, m_uBlockSideLength - 1, m_uBlockSideLength - 1);
|
||||
|
||||
// Page the data out
|
||||
m_pPager->pageOut(Region(v3dLower, v3dUpper), itUncompressedBlock->second);
|
||||
|
||||
// The compressed data has been updated, so the uncompressed data is no longer modified with respect to it.
|
||||
pUncompressedBlock->m_bDataModified = false;
|
||||
@ -679,13 +683,19 @@ namespace PolyVox
|
||||
|
||||
// An uncompressed bock is always backed by a compressed one, and this is created by getCompressedBlock() if it doesn't
|
||||
// already exist. If it does already exist and has data then we bring this across into the ucompressed version.
|
||||
if(getCompressedBlock(uBlockX, uBlockY, uBlockZ)->getData() != 0)
|
||||
/*if(getCompressedBlock(uBlockX, uBlockY, uBlockZ)->getData() != 0)
|
||||
{
|
||||
// FIXME - multiple getCompressedBlock() calls (including the one above)
|
||||
CompressedBlock<VoxelType>* pBlock = getCompressedBlock(uBlockX, uBlockY, uBlockZ);
|
||||
CompressedBlock<VoxelType>* pBlock = getCompressedBlock(uBlockX, uBlockY, );
|
||||
|
||||
m_pBlockCompressor->decompress(pBlock, pUncompressedBlock);
|
||||
}
|
||||
}*/
|
||||
|
||||
// Pass the block to the Pager to give it a chance to initialise it with any data
|
||||
Vector3DInt32 v3dLower(uBlockX << m_uBlockSideLengthPower, uBlockY << m_uBlockSideLengthPower, uBlockZ << m_uBlockSideLengthPower);
|
||||
Vector3DInt32 v3dUpper = v3dLower + Vector3DInt32(m_uBlockSideLength - 1, m_uBlockSideLength - 1, m_uBlockSideLength - 1);
|
||||
Region reg(v3dLower, v3dUpper);
|
||||
m_pPager->pageIn(reg, pUncompressedBlock);
|
||||
|
||||
// Add our new block to the map.
|
||||
m_pUncompressedBlockCache.insert(std::make_pair(v3dBlockPos, pUncompressedBlock));
|
||||
|
@ -24,7 +24,7 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Pager_H__
|
||||
#define __PolyVox_Pager_H__
|
||||
|
||||
#include "PolyVoxCore/CompressedBlock.h"
|
||||
#include "PolyVoxCore/UncompressedBlock.h"
|
||||
#include "PolyVoxCore/Impl/TypeDef.h"
|
||||
|
||||
namespace PolyVox
|
||||
@ -41,8 +41,8 @@ namespace PolyVox
|
||||
/// Destructor
|
||||
virtual ~Pager() {};
|
||||
|
||||
virtual void pageIn(const Region& region, CompressedBlock<VoxelType>* pBlockData) = 0;
|
||||
virtual void pageOut(const Region& region, CompressedBlock<VoxelType>* pBlockData) = 0;
|
||||
virtual void pageIn(const Region& region, UncompressedBlock<VoxelType>* pBlockData) = 0;
|
||||
virtual void pageOut(const Region& region, UncompressedBlock<VoxelType>* pBlockData) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ TestVolume::~TestVolume()
|
||||
* RawVolume Tests
|
||||
*/
|
||||
|
||||
void TestVolume::testRawVolumeDirectAccessAllInternalForwards()
|
||||
/*void TestVolume::testRawVolumeDirectAccessAllInternalForwards()
|
||||
{
|
||||
int32_t result = 0;
|
||||
|
||||
@ -399,13 +399,13 @@ void TestVolume::testRawVolumeSamplersWithExternalBackwards()
|
||||
result = testSamplersWithWrappingBackwards(m_pRawVolume, -1, -3, -2, 2, 5, 4);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-769775893));
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
* SimpleVolume Tests
|
||||
*/
|
||||
|
||||
void TestVolume::testSimpleVolumeDirectAccessAllInternalForwards()
|
||||
/*void TestVolume::testSimpleVolumeDirectAccessAllInternalForwards()
|
||||
{
|
||||
int32_t result = 0;
|
||||
QBENCHMARK
|
||||
@ -483,7 +483,7 @@ void TestVolume::testSimpleVolumeSamplersWithExternalBackwards()
|
||||
result = testSamplersWithWrappingBackwards(m_pSimpleVolume, -1, -3, -2, 2, 5, 4);
|
||||
}
|
||||
QCOMPARE(result, static_cast<int32_t>(-769775893));
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
* LargeVolume Tests
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
~TestVolume();
|
||||
|
||||
private slots:
|
||||
void testRawVolumeDirectAccessAllInternalForwards();
|
||||
/*void testRawVolumeDirectAccessAllInternalForwards();
|
||||
void testRawVolumeSamplersAllInternalForwards();
|
||||
void testRawVolumeDirectAccessWithExternalForwards();
|
||||
void testRawVolumeSamplersWithExternalForwards();
|
||||
@ -53,7 +53,7 @@ private slots:
|
||||
void testSimpleVolumeDirectAccessAllInternalBackwards();
|
||||
void testSimpleVolumeSamplersAllInternalBackwards();
|
||||
void testSimpleVolumeDirectAccessWithExternalBackwards();
|
||||
void testSimpleVolumeSamplersWithExternalBackwards();
|
||||
void testSimpleVolumeSamplersWithExternalBackwards();*/
|
||||
|
||||
void testLargeVolumeDirectAccessAllInternalForwards();
|
||||
void testLargeVolumeSamplersAllInternalForwards();
|
||||
|
Reference in New Issue
Block a user