Commit d79e2dfa authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Merge branch feature/jorgen.lind/2.1.9 with refs/heads/2.1 into refs/merge-requests/503/train

parents 5e0f0a3f 08f803eb
Pipeline #78764 passed with stages
in 22 minutes and 3 seconds
......@@ -128,13 +128,11 @@ inline void fill3DVDSWithBitNoise(OpenVDS::VDS *vds, int32_t channel = 0)
{
for(int x = 0; x < size[0]; x++)
{
int32_t byteIndex = z * pitch[2] + y * pitch[1] + (x / 8);
int32_t bitIndex = z * size[2] * size[1] * size[0] + y * size[1] * size[0] + x;
uint8_t byte = buffer[byteIndex];
bool value = dist(gen);
if (value)
byte |= uint8_t(1) << (bitIndex % 8);
buffer[byteIndex] = byte;
size_t bitIndex = z * pitch[2] + y * pitch[1] + x;
if (dist(gen))
{
buffer[bitIndex / 8] |= uint8_t(1 << (bitIndex % 8));
}
}
}
}
......
......@@ -170,13 +170,11 @@ static void fill3DVDSWithBitNoise(OpenVDS::VDS *vds, int32_t channel = 0)
{
for(int x = 0; x < size[0]; x++)
{
int32_t byteIndex = z * pitch[2] + y * pitch[1] + (x / 8);
int32_t bitIndex = z * size[2] * size[1] * size[0] + y * size[1] * size[0] + x;
uint8_t byte = buffer[byteIndex];
bool value = dist(gen);
if (value)
byte |= uint8_t(1) << (bitIndex % 8);
buffer[byteIndex] = byte;
size_t bitIndex = z * pitch[2] + y * pitch[1] + x;
if (dist(gen))
{
buffer[bitIndex / 8] |= uint8_t(1 << (bitIndex % 8));
}
}
}
}
......
......@@ -214,18 +214,29 @@ VolumeDataPage* VolumeDataPageAccessorImpl::CreatePage(int64_t chunk)
return nullptr;
}
int pitch[Dimensionality_Max] = {};
int pitchND[Dimensionality_Max] = {};
for(int chunkDimension = 0; chunkDimension < m_layer->GetChunkDimensionality(); chunkDimension++)
{
int dimension = DimensionGroupUtil::GetDimension(m_layer->GetChunkDimensionGroup(), chunkDimension);
assert(dimension >= 0 && dimension < Dimensionality_Max);
pitch[dimension] = dataBlock.Pitch[chunkDimension];
pitchND[dimension] = dataBlock.Pitch[chunkDimension];
// Convert pitch to bitpitch for 1-bit data
if(m_layer->GetFormat() == VolumeDataChannelDescriptor::Format_1Bit)
{
assert(chunkDimension > 0 || pitchND[dimension] == 1);
if(chunkDimension > 0)
{
pitchND[chunkDimension] *= 8;
}
}
}
pageListMutexLock.lock();
page->SetBufferData(dataBlock, pitch, std::move(page_data));
page->SetBufferData(dataBlock, pitchND, std::move(page_data));
page->MakeDirty();
m_pageReadCondition.notify_all();
......
......@@ -104,7 +104,7 @@ VolumeDataPageImpl::VolumeDataPageImpl(VolumeDataPageAccessorImpl* volumeDataPag
{
for (int32_t iDimension = 0; iDimension < Dimensionality_Max; iDimension++)
{
m_pitch[iDimension] = 0;
m_pitchND[iDimension] = 0;
m_writtenMin[iDimension] = 0;
m_writtenMax[iDimension] = 0;
}
......@@ -156,12 +156,12 @@ void VolumeDataPageImpl::MakeDirty()
m_isDirty = true;
}
void VolumeDataPageImpl::SetBufferData(const DataBlock &dataBlock, int32_t (&pitch)[Dimensionality_Max], std::vector<uint8_t>&& blob)
void VolumeDataPageImpl::SetBufferData(const DataBlock &dataBlock, int32_t (&pitchND)[Dimensionality_Max], std::vector<uint8_t>&& blob)
{
//assert(m_volumeDataPageAccessor->m_pageListMutex.isLockedByCurrentThread());
m_dataBlock = dataBlock;
static_assert(sizeof(pitch) == sizeof(m_pitch), "Pitch of different size");
memcpy(m_pitch, pitch, sizeof(m_pitch));
static_assert(sizeof(pitchND) == sizeof(m_pitchND), "Pitch of different size");
memcpy(m_pitchND, pitchND, sizeof(m_pitchND));
m_blob = std::move(blob);
}
......@@ -174,13 +174,13 @@ void VolumeDataPageImpl::WriteBack(VolumeDataLayer const* volumeDataLayer, std::
layout->CompletePendingWriteChunkRequests(16);
}
void* VolumeDataPageImpl::GetBufferInternal(int(&anPitch)[Dimensionality_Max], bool isReadWrite)
void* VolumeDataPageImpl::GetBufferInternal(int(&pitchND)[Dimensionality_Max], bool isReadWrite)
{
//assert(m_volumeDataPageAccessor->m_pageListMutex.isLockedByCurrentThread());
for(int32_t iDimension = 0; iDimension < Dimensionality_Max; iDimension++)
{
anPitch[iDimension] = m_pitch[iDimension];
pitchND[iDimension] = m_pitchND[iDimension];
}
if(isReadWrite)
......
......@@ -38,7 +38,7 @@ private:
int64_t m_chunk;
DataBlock m_dataBlock;
int32_t m_pitch[Dimensionality_Max];
int32_t m_pitchND[Dimensionality_Max];
std::vector<uint8_t> m_blob;
std::atomic_int m_pins;
......
......@@ -1548,9 +1548,12 @@ int64_t VolumeDataRequestProcessor::RequestVolumeTraces(void *buffer, VolumeData
{
VolumeDataSamplePos &volumeDataSamplePos = volumeDataSamplePositions->at(tracePos);
std::copy(&tracePositions[tracePos][0], &tracePositions[tracePos][Dimensionality_Max], volumeDataSamplePos.pos.Data);
volumeDataSamplePos.chunkIndex = volumeDataLayer->GetChunkIndexFromNDPos(volumeDataSamplePos.pos);
for(int dimension = 0; dimension < Dimensionality_Max; dimension++)
{
volumeDataSamplePos.pos.Data[dimension] = (dimension != traceDimension) ? tracePositions[tracePos][dimension] : 0;
}
volumeDataSamplePos.originalSample = tracePos;
volumeDataSamplePos.chunkIndex = volumeDataLayer->GetChunkIndexFromNDPos(volumeDataSamplePos.pos);
}
std::sort(volumeDataSamplePositions->begin(), volumeDataSamplePositions->end());
......
......@@ -129,7 +129,7 @@ TEST_F(RequestVolumeSubsetFormat, test1Bit)
}
}
TEST(ReqeustVolumeSubsetFormat, source1Bit)
TEST_F(RequestVolumeSubsetFormat, source1Bit)
{
std::unique_ptr<OpenVDS::VDS, decltype(&OpenVDS::Close)> handle(generateSimpleInMemory3DVDS(60,60,60, OpenVDS::VolumeDataChannelDescriptor::Format_1Bit), OpenVDS::Close);
fill3DVDSWithBitNoise(handle.get());
......
......@@ -131,13 +131,11 @@ inline void fill3DVDSWithBitNoise(OpenVDS::VDS *vds, int32_t channel = 0)
{
for(int x = 0; x < size[0]; x++)
{
int32_t byteIndex = z * pitch[2] + y * pitch[1] + (x / 8);
int32_t bitIndex = z * size[2] * size[1] * size[0] + y * size[1] * size[0] + x;
uint8_t byte = buffer[byteIndex];
bool value = dist(gen);
if (value)
byte |= uint8_t(1) << (bitIndex % 8);
buffer[byteIndex] = byte;
size_t bitIndex = z * pitch[2] + y * pitch[1] + x;
if (dist(gen))
{
buffer[bitIndex / 8] |= uint8_t(1 << (bitIndex % 8));
}
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment