Work on compression interface.
This commit is contained in:
parent
36676433be
commit
a81ec68714
@ -129,9 +129,6 @@ namespace PolyVox
|
||||
const uint32_t uNoOfVoxels = m_uSideLength * m_uSideLength * m_uSideLength;
|
||||
std::fill(m_tUncompressedData, m_tUncompressedData + uNoOfVoxels, VoxelType());
|
||||
m_bIsUncompressedDataModified = true;
|
||||
|
||||
//For some reason blocks start out compressed. We should probably change this.
|
||||
compress(0);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -159,8 +156,8 @@ namespace PolyVox
|
||||
uint32_t uDstLength = 1000000;
|
||||
|
||||
//MinizCompressor compressor;
|
||||
RLECompressor<VoxelType, uint16_t> compressor;
|
||||
uint32_t uCompressedLength = compressor.compress(pSrcData, uSrcLength, pDstData, uDstLength);
|
||||
//RLECompressor<VoxelType, uint16_t> compressor;
|
||||
uint32_t uCompressedLength = pCompressor->compress(pSrcData, uSrcLength, pDstData, uDstLength);
|
||||
|
||||
m_pCompressedData = reinterpret_cast<void*>( new uint8_t[uCompressedLength] );
|
||||
memcpy(m_pCompressedData, pDstData, uCompressedLength);
|
||||
@ -178,7 +175,7 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
void Block<VoxelType>::uncompress(Compressor* pCompressor)
|
||||
{
|
||||
//POLYVOX_ASSERT(pCompressor, "Compressor is not valid");
|
||||
POLYVOX_ASSERT(pCompressor, "Compressor is not valid");
|
||||
POLYVOX_ASSERT(m_bIsCompressed == true, "Attempted to uncompress block which is not flagged as compressed.");
|
||||
POLYVOX_ASSERT(m_tUncompressedData == 0, "Uncompressed data already exists.");
|
||||
|
||||
@ -190,8 +187,8 @@ namespace PolyVox
|
||||
uint32_t uDstLength = m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType);
|
||||
|
||||
//MinizCompressor compressor;
|
||||
RLECompressor<VoxelType, uint16_t> compressor;
|
||||
uint32_t uUncompressedLength = compressor.decompress(pSrcData, uSrcLength, pDstData, uDstLength);
|
||||
//RLECompressor<VoxelType, uint16_t> compressor;
|
||||
uint32_t uUncompressedLength = pCompressor->decompress(pSrcData, uSrcLength, pDstData, uDstLength);
|
||||
|
||||
POLYVOX_ASSERT(uUncompressedLength == m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType), "Destination length has changed.");
|
||||
|
||||
|
@ -618,6 +618,10 @@ namespace PolyVox
|
||||
|
||||
// create the new block
|
||||
LoadedBlock newBlock(m_uBlockSideLength);
|
||||
|
||||
//Blocks start out compressed - should we change this?
|
||||
newBlock.block.compress(m_pCompressor);
|
||||
|
||||
itBlock = m_pBlocks.insert(std::make_pair(v3dBlockPos, newBlock)).first;
|
||||
|
||||
//We have created the new block. If paging is enabled it should be used to
|
||||
|
@ -60,6 +60,11 @@ namespace PolyVox
|
||||
typedef Array<3,int32_t> Array3DInt32;
|
||||
typedef Array<3,uint32_t> Array3DUint32;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Compressor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class Compressor;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// CubicSurfaceExtractor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -25,6 +25,7 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
#include "PolyVoxCore/RawVolume.h"
|
||||
#include "PolyVoxCore/RLECompressor.h"
|
||||
#include "PolyVoxCore/SimpleVolume.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
@ -269,10 +270,12 @@ TestVolume::TestVolume()
|
||||
{
|
||||
Region region(-57, -31, 12, 64, 96, 131); // Deliberatly awkward size
|
||||
|
||||
m_pCompressor = new RLECompressor<int32_t, uint16_t>;
|
||||
|
||||
//Create the volumes
|
||||
m_pRawVolume = new RawVolume<int32_t>(region);
|
||||
m_pSimpleVolume = new SimpleVolume<int32_t>(region);
|
||||
m_pLargeVolume = new LargeVolume<int32_t>(region);
|
||||
m_pLargeVolume = new LargeVolume<int32_t>(region, m_pCompressor);
|
||||
|
||||
// LargeVolume currently fails a test if compression is enabled. It
|
||||
// may be related to accessing the data through more than one sampler?
|
||||
@ -299,6 +302,8 @@ TestVolume::~TestVolume()
|
||||
delete m_pRawVolume;
|
||||
delete m_pSimpleVolume;
|
||||
delete m_pLargeVolume;
|
||||
|
||||
delete m_pCompressor;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -65,6 +65,7 @@ private slots:
|
||||
void testLargeVolumeSamplersWithExternalBackwards();
|
||||
|
||||
private:
|
||||
PolyVox::Compressor* m_pCompressor;
|
||||
PolyVox::RawVolume<int32_t>* m_pRawVolume;
|
||||
PolyVox::SimpleVolume<int32_t>* m_pSimpleVolume;
|
||||
PolyVox::LargeVolume<int32_t>* m_pLargeVolume;
|
||||
|
Loading…
x
Reference in New Issue
Block a user