Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto determine scalar based on version #2561

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/vapor/OSPRay.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace VOSP {
RENDER_API int Initialize(int *argc, char **argv);
RENDER_API int Shutdown();
RENDER_API std::string Version();
RENDER_API bool IsVersionAtLeast(int major, int minor);

#ifdef BUILD_OSPRAY
OSPData NewCopiedData(const void *data, OSPDataType type, uint64_t numItems1, uint64_t numItems2=1, uint64_t numItems3=1);
Expand Down
16 changes: 16 additions & 0 deletions lib/render/OSPRay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ std::string VOSP::Version()
#endif
}

bool VOSP::IsVersionAtLeast(int testMajor, int testMinor)
{
#ifdef BUILD_OSPRAY
long major = ospDeviceGetProperty(ospGetCurrentDevice(), OSP_DEVICE_VERSION_MAJOR);
long minor = ospDeviceGetProperty(ospGetCurrentDevice(), OSP_DEVICE_VERSION_MINOR);

if (major > testMajor || (major == testMajor && minor >= testMinor))
return true;

return false;

#else
return false;
#endif
}

#ifdef BUILD_OSPRAY

OSPData VOSP::NewCopiedData(const void *data, OSPDataType type, uint64_t numItems1, uint64_t numItems2, uint64_t numItems3)
Expand Down
13 changes: 10 additions & 3 deletions lib/render/VolumeOSPRay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ int VolumeOSPRay::LoadData(const Grid *grid)

if (dynamic_cast<const RegularGrid *>(grid))
_ospSampleRateScalar = 1.f;
else if (VOSP::IsVersionAtLeast(2, 5))
_ospSampleRateScalar = 1.f;
else
_ospSampleRateScalar = _guessSamplingRateScalar(grid);

Expand Down Expand Up @@ -728,18 +730,21 @@ OSPVolume VolumeOSPRay::_loadVolumeStructured(const Grid *grid)
ospCommit(data);
ospSetObject(volume, "index", data);
ospRelease(data);
indices.clear();
Progress::Update(3);

data = VOSP::NewCopiedData(startIndex.data(), OSP_UINT, startIndex.size());
ospCommit(data);
ospSetObject(volume, "cell.index", data);
ospRelease(data);
startIndex.clear();
Progress::Update(4);

data = VOSP::NewCopiedData(cellType.data(), OSP_UCHAR, cellType.size());
ospCommit(data);
ospSetObject(volume, "cell.type", data);
ospRelease(data);
cellType.clear();
Progress::Update(5);
Progress::Finish();

Expand Down Expand Up @@ -964,33 +969,35 @@ OSPVolume VolumeOSPRay::_loadVolumeUnstructured(const Grid *grid)
ospCommit(data);
ospSetObject(volume, "vertex.data", data);
ospRelease(data);
delete [] vdata;
Progress::Update(1);

data = VOSP::NewCopiedData(cdata, OSP_VEC3F, nVerts);
ospCommit(data);
ospSetObject(volume, "vertex.position", data);
ospRelease(data);
delete [] cdata;
Progress::Update(2);

data = VOSP::NewCopiedData(cellIndices.data(), OSP_UINT, cellIndices.size());
ospCommit(data);
ospSetObject(volume, "index", data);
ospRelease(data);
cellIndices.clear();
Progress::Update(3);

data = VOSP::NewCopiedData(cellStarts.data(), OSP_UINT, cellStarts.size());
ospCommit(data);
ospSetObject(volume, "cell.index", data);
ospRelease(data);
cellStarts.clear();
Progress::Update(4);

data = VOSP::NewCopiedData(cellTypes.data(), OSP_UCHAR, cellTypes.size());
ospCommit(data);
ospSetObject(volume, "cell.type", data);
ospRelease(data);

delete [] vdata;
delete [] cdata;
cellTypes.clear();
Progress::Update(5);
Progress::Finish();

Expand Down
1 change: 1 addition & 0 deletions lib/render/VolumeRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ int VolumeRenderer::_loadData()
CheckCache(_cache.compression, RP->GetCompressionLevel());
CheckCache(_cache.minExt, minExt);
CheckCache(_cache.maxExt, maxExt);
CheckCache(_cache.ospMaxCells, RP->GetValueLong("osp_max_cells", 1));
if (!_cache.needsUpdate)
return 0;

Expand Down