From 3a7b7fdddc2abb4ecd2aa712f168576148f156a9 Mon Sep 17 00:00:00 2001 From: Stanislaw Jaroszynski Date: Wed, 9 Dec 2020 15:04:45 -0700 Subject: [PATCH] Auto determine scalar based on version --- include/vapor/OSPRay.h | 1 + lib/render/OSPRay.cpp | 16 ++++++++++++++++ lib/render/VolumeOSPRay.cpp | 13 ++++++++++--- lib/render/VolumeRenderer.cpp | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/vapor/OSPRay.h b/include/vapor/OSPRay.h index 24acf83b31..fbefd74536 100644 --- a/include/vapor/OSPRay.h +++ b/include/vapor/OSPRay.h @@ -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); diff --git a/lib/render/OSPRay.cpp b/lib/render/OSPRay.cpp index 8f5a54b27e..b44bae5e85 100644 --- a/lib/render/OSPRay.cpp +++ b/lib/render/OSPRay.cpp @@ -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) diff --git a/lib/render/VolumeOSPRay.cpp b/lib/render/VolumeOSPRay.cpp index ace367885e..050cb11432 100644 --- a/lib/render/VolumeOSPRay.cpp +++ b/lib/render/VolumeOSPRay.cpp @@ -224,6 +224,8 @@ int VolumeOSPRay::LoadData(const Grid *grid) if (dynamic_cast(grid)) _ospSampleRateScalar = 1.f; + else if (VOSP::IsVersionAtLeast(2, 5)) + _ospSampleRateScalar = 1.f; else _ospSampleRateScalar = _guessSamplingRateScalar(grid); @@ -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(); @@ -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(); diff --git a/lib/render/VolumeRenderer.cpp b/lib/render/VolumeRenderer.cpp index 1274d897f1..b7ab1f5a2b 100644 --- a/lib/render/VolumeRenderer.cpp +++ b/lib/render/VolumeRenderer.cpp @@ -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;