Skip to content

Commit

Permalink
Fix slow down caused by per-frame update of model size; is only neces…
Browse files Browse the repository at this point in the history
…sary for volumes right now
  • Loading branch information
tribal-tec committed Feb 6, 2019
1 parent b01d1ed commit 6c3433d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion apps/BraynsViewer/BraynsViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ void BraynsViewer::display()
.getApplicationParameters()
.isBenchmarking())
{
ss << " @ " << _timer.perSecondSmoothed() << " FPS";
ss << " @ " << _timer.perSecondSmoothed() << " / "
<< _brayns.getEngine().getStatistics().getFPS() << " FPS";
}
setTitle(ss.str());

Expand Down
14 changes: 10 additions & 4 deletions brayns/engine/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void Model::setMaterialsColorMap(const MaterialsColorMap colorMap)

void Model::logInformation()
{
updateSizeInBytes();
_updateSizeInBytes();

uint64_t nbSpheres = 0;
uint64_t nbCylinders = 0;
Expand Down Expand Up @@ -407,7 +407,7 @@ MaterialPtr Model::getMaterial(const size_t materialId) const
return it->second;
}

void Model::updateSizeInBytes()
void Model::_updateSizeInBytes()
{
_sizeInBytes = 0;
for (const auto& spheres : _geometries->_spheres)
Expand All @@ -425,8 +425,6 @@ void Model::updateSizeInBytes()
_sizeInBytes += mesh.indices.size() * sizeof(Vector3ui);
_sizeInBytes += mesh.textureCoordinates.size() * sizeof(Vector2f);
}
for (const auto& volume : _geometries->_volumes)
_sizeInBytes += volume->getSizeInBytes();
for (const auto& streamline : _geometries->_streamlines)
{
_sizeInBytes += streamline.second.indices.size() * sizeof(int32_t);
Expand Down Expand Up @@ -586,6 +584,14 @@ void Model::setSimulationHandler(AbstractSimulationHandlerPtr handler)
_bindMaterials(_simulationHandler, _materials);
}

size_t Model::getSizeInBytes() const
{
size_t volumeSizeInBytes = 0;
for (const auto& volume : _geometries->_volumes)
volumeSizeInBytes += volume->getSizeInBytes();
return _sizeInBytes + volumeSizeInBytes;
}

AbstractSimulationHandlerPtr Model::getSimulationHandler() const
{
return _simulationHandler;
Expand Down
6 changes: 3 additions & 3 deletions brayns/engine/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,12 @@ class Model
BRAYNS_API void setSimulationHandler(AbstractSimulationHandlerPtr handler);

/** @return the size in bytes of all geometries. */
size_t getSizeInBytes() const { return _sizeInBytes; }
size_t getSizeInBytes() const;
void markInstancesDirty() { _instancesDirty = true; }
void markInstancesClean() { _instancesDirty = false; }
const Volumes& getVolumes() const { return _geometries->_volumes; }
bool isVolumesDirty() const { return _volumesDirty; }
void resetVolumesDirty() { _volumesDirty = false; }
/** @internal */
void updateSizeInBytes();
void setBVHFlags(std::set<BVHFlag> bvhFlags)
{
_bvhFlags = std::move(bvhFlags);
Expand All @@ -442,6 +440,8 @@ class Model
void copyFrom(const Model& rhs);

protected:
void _updateSizeInBytes();

/** Factory method to create an engine-specific material. */
BRAYNS_API virtual MaterialPtr createMaterialImpl(
const PropertyMap& properties = {}) = 0;
Expand Down
1 change: 1 addition & 0 deletions engines/optix/OptiXScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ void OptiXScene::commit()
<< std::endl;

impl.commitGeometry();
impl.logInformation();

if (modelDescriptor->getVisible())
{
Expand Down
3 changes: 1 addition & 2 deletions engines/ospray/OSPRayScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ void OSPRayScene::commit()
<< std::endl;

impl.commitGeometry();
impl.logInformation();

// add volumes to root model, because scivis renderer does not consider
// volumes from instances
Expand Down Expand Up @@ -158,7 +159,6 @@ void OSPRayScene::commit()
}

impl.markInstancesClean();
impl.logInformation();
}
BRAYNS_DEBUG << "Committing root models" << std::endl;

Expand Down Expand Up @@ -251,7 +251,6 @@ bool OSPRayScene::_commitVolumeAndTransferFunction(
markModified(false);
}
}
modelDescriptor->getModel().updateSizeInBytes();
}
return rebuildScene;
}
Expand Down

0 comments on commit 6c3433d

Please sign in to comment.