The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 94cfeb0e authored by schultezub's avatar schultezub
Browse files

* added AbstractData::getLocalMemoryFootprint() and AbstractData::getVideoMemoryFootprint()

 * added memory footprint analysis to DataContainerInspectorWidget

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@306 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 8345ab92
......@@ -29,6 +29,7 @@
#include "datacontainerinspectorwidget.h"
#include "tgt/assert.h"
#include "core/datastructures/abstractdata.h"
#include "core/datastructures/datacontainer.h"
#include "core/datastructures/datahandle.h"
#include "application/gui/datacontainertreewidget.h"
......@@ -108,6 +109,12 @@ namespace TUMVis {
_lblName = new QLabel(QString("Name: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblName);
_lblLocalMemoryFootprint = new QLabel(QString("Local Memory Footprint: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblLocalMemoryFootprint);
_lblVideoMemoryFootprint = new QLabel(QString("Video Memory Footprint: "), _infoWidget);
_infoWidgetLayout->addWidget(_lblVideoMemoryFootprint);
_lblTimestamp = new QLabel("Timestamp: ", _infoWidget);
_infoWidgetLayout->addWidget(_lblTimestamp);
......@@ -125,6 +132,8 @@ namespace TUMVis {
if (_selectedDataHandle != 0) {
_lblTimestamp->setText("Timestamp: " + QString::number(_selectedDataHandle->getTimestamp()));
_lblName->setText("Name: " + _selectedDataHandleName);
_lblLocalMemoryFootprint->setText("Local Memory Footprint: " + humanizeBytes(_selectedDataHandle->getData()->getLocalMemoryFootprint()));
_lblVideoMemoryFootprint->setText("Video Memory Footprint: " + humanizeBytes(_selectedDataHandle->getData()->getVideoMemoryFootprint()));
}
else {
_lblTimestamp->setText("Timestamp: ");
......@@ -132,4 +141,21 @@ namespace TUMVis {
}
}
QString DataContainerInspectorWidget::humanizeBytes(size_t numBytes) const {
QString units[5] = { tr(" Bytes"), tr(" KB"), tr(" MB"), tr(" GB"), tr(" TB") };
size_t index = 0;
size_t remainder = 0;
while (numBytes > 1024 && index < 5) {
remainder = numBytes % 1024;
numBytes /= 1024;
++index;
}
if (remainder != 0)
return QString::number(numBytes) + "." + QString::number(remainder) + units[index];
else
return QString::number(numBytes) + units[index];
}
}
\ No newline at end of file
......@@ -104,6 +104,13 @@ namespace TUMVis {
*/
void updateInfoWidget();
/**
* Returns a string with \a numBytes humanized (i.e. "numBytes/1024^n [KMG]Byte")
* \param numBytes Number of bytes to be converted.
* \return "numBytes/1024^n [KMG]Bytes
*/
QString humanizeBytes(size_t numBytes) const;
DataContainer* _dataContainer; ///< The DataContainer this widget is inspecting
const DataHandle* _selectedDataHandle; ///< The currently selected DataHandle
QString _selectedDataHandleName; ///< The name of the currently selected DataHandle
......@@ -116,6 +123,8 @@ namespace TUMVis {
QVBoxLayout* _infoWidgetLayout; ///< Layout for the _infoWidget
QLabel* _lblName;
QLabel* _lblLocalMemoryFootprint;
QLabel* _lblVideoMemoryFootprint;
QLabel* _lblTimestamp;
};
}
......
......@@ -39,12 +39,35 @@ namespace TUMVis {
*/
class AbstractData : public ReferenceCounted {
public:
/**
* Constructor, simply calles ReferenceCounted ctor.
*/
AbstractData();
/**
* Virtual destructor
*/
virtual ~AbstractData();
/**
* Prototype - clone method, some people call this virtual constructor...
* \return A copy of this object.
*/
virtual AbstractData* clone() const = 0;
/**
* Returns the local memory footprint of the data in bytes.
* \return Number of bytes occupied in local memory by the data.
*/
virtual size_t getLocalMemoryFootprint() const = 0;
/**
* Returns the video memory footprint of the data in bytes.
* \return Number of bytes occupied in video memory by the data.
*/
virtual size_t getVideoMemoryFootprint() const = 0;
protected:
};
......
......@@ -64,6 +64,20 @@ namespace TUMVis {
return new FaceGeometry(_vertices, _textureCoordinates, _colors, _normals);
}
size_t FaceGeometry::getLocalMemoryFootprint() const {
size_t sum = 0;
if (_verticesBuffer != 0)
sum += sizeof(tgt::BufferObject);
if (_texCoordsBuffer != 0)
sum += sizeof(tgt::BufferObject);
if (_colorsBuffer != 0)
sum += sizeof(tgt::BufferObject);
if (_normalsBuffer != 0)
sum += sizeof(tgt::BufferObject);
return sizeof(*this) + sum + (sizeof(tgt::vec3) * (_vertices.size() + _textureCoordinates.size() + _normals.size())) + (sizeof(tgt::vec4) * _colors.size());
}
size_t FaceGeometry::size() const {
return _vertices.size();
}
......
......@@ -72,6 +72,9 @@ namespace TUMVis {
/// \see AbstractData::clone()
virtual FaceGeometry* clone() const;
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/**
* Returns the number of vertices of this face.
* \return _vertices.size()
......
......@@ -70,9 +70,20 @@ namespace TUMVis {
/// \see AbstractData::clone()
virtual ThisType* clone() const;
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/// \see ImageData::getSubImage
virtual ThisType* getSubImage(const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
* Returns a WeaklyTypedPointer to the image data.
* \note The pointer is still owned by this ImageDataLocal. If you want a copy, use clone().
* \return A WeaklyTypedPointer to the image data.
*/
virtual const WeaklyTypedPointer getWeaklyTypedPointer() const;
/// \see ImageDataLocal::getElementNormalized
......@@ -181,6 +192,16 @@ namespace TUMVis {
return new ThisType(_dimensionality, _size, newData);
}
template<typename BASETYPE, size_t NUMCHANNELS>
size_t TUMVis::GenericImageDataLocal<BASETYPE, NUMCHANNELS>::getLocalMemoryFootprint() const {
return sizeof(*this) + _numElements * sizeof(ElementType);
}
template<typename BASETYPE, size_t NUMCHANNELS>
size_t TUMVis::GenericImageDataLocal<BASETYPE, NUMCHANNELS>::getVideoMemoryFootprint() const {
return 0;
}
template<typename BASETYPE, size_t NUMCHANNELS>
GenericImageDataLocal<BASETYPE, NUMCHANNELS>* TUMVis::GenericImageDataLocal<BASETYPE, NUMCHANNELS>::getSubImage(const tgt::svec3& llf, const tgt::svec3& urb) const {
tgtAssert(tgt::hor(tgt::lessThan(llf, urb)), "Coordinates in LLF must be component-wise smaller than the ones in URB!");
......
......@@ -83,6 +83,21 @@ namespace TUMVis {
return *this;
}
size_t GeometryData::getVideoMemoryFootprint() const {
size_t sum = 0;
if (_verticesBuffer != 0)
sum += _verticesBuffer->getBufferSize();
if (_texCoordsBuffer != 0)
sum += _texCoordsBuffer->getBufferSize();
if (_colorsBuffer != 0)
sum += _colorsBuffer->getBufferSize();
if (_normalsBuffer != 0)
sum += _normalsBuffer->getBufferSize();
return sum;
}
const tgt::BufferObject* GeometryData::getVerticesBuffer() const {
return _verticesBuffer;
}
......
......@@ -56,6 +56,9 @@ namespace TUMVis {
virtual AbstractData* clone() const = 0;
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/**
* Renders this GeometryData.
* Must be called from a valid OpenGL context.
......
......@@ -194,6 +194,14 @@ namespace TUMVis {
return new ImageDataDisk(_url, _dimensionality, _size, _type, _numChannels, _offset, _endianess, _stride);
}
size_t ImageDataDisk::getLocalMemoryFootprint() const {
return sizeof(*this);
}
size_t ImageDataDisk::getVideoMemoryFootprint() const {
return 0;
}
WeaklyTypedPointer::BaseType ImageDataDisk::getBaseType() const {
return _type;
}
......
......@@ -82,6 +82,12 @@ namespace TUMVis {
**/
virtual ImageDataDisk* clone() const;
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/**
* \see ImageData::getSubImage
*/
......
......@@ -135,4 +135,20 @@ namespace TUMVis {
return _texture;
}
size_t ImageDataGL::getLocalMemoryFootprint() const {
size_t sum = 0;
if (_texture != 0) {
sum += sizeof(tgt::Texture);
if (_texture->getPixelData() != 0) {
sum += _texture->getBpp() + _texture->getArraySize();
}
}
return sizeof(*this) + sum;
}
size_t ImageDataGL::getVideoMemoryFootprint() const {
return _texture->getSizeOnGPU();
}
}
\ No newline at end of file
......@@ -82,6 +82,12 @@ namespace TUMVis {
**/
virtual ImageDataGL* clone() const;
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/**
* \see ImageData::getSubImage
*/
......
......@@ -63,17 +63,17 @@ namespace TUMVis {
*/
virtual ~ImageDataLocal();
/**
* \see AbstractData::clone()
**/
/// \see AbstractData::clone()
virtual ImageDataLocal* clone() const = 0;
/**
* \see ImageData::getSubImage
*/
/// \see ImageData::getSubImage()
virtual ImageDataLocal* getSubImage(const tgt::svec3& llf, const tgt::svec3& urb) const = 0;
/**
* Returns a WeaklyTypedPointer to the image data.
* \note The pointer is still owned by this ImageDataLocal. If you want a copy, use clone().
* \return A WeaklyTypedPointer to the image data.
*/
virtual const WeaklyTypedPointer getWeaklyTypedPointer() const = 0;
/**
......
......@@ -237,4 +237,31 @@ namespace TUMVis {
_fbo->deactivate();
}
size_t ImageDataRenderTarget::getLocalMemoryFootprint() const {
size_t sum = 0;
sum += sizeof(tgt::FramebufferObject);
sum += sizeof(tgt::Texture) * _colorTextures.size();
for (std::vector<tgt::Texture*>::const_iterator it = _colorTextures.begin(); it != _colorTextures.end(); ++it)
sum += (*it)->getBpp() * (*it)->getArraySize();
if (_depthTexture != 0) {
sum += sizeof(tgt::Texture);
sum += _depthTexture->getBpp() * _depthTexture->getArraySize();
}
return sizeof(*this) + sum;
}
size_t ImageDataRenderTarget::getVideoMemoryFootprint() const {
size_t sum = 0;
for (std::vector<tgt::Texture*>::const_iterator it = _colorTextures.begin(); it != _colorTextures.end(); ++it)
sum += (*it)->getSizeOnGPU();
if (_depthTexture != 0)
sum += _depthTexture->getSizeOnGPU();
return sum;
}
}
\ No newline at end of file
......@@ -75,6 +75,12 @@ namespace TUMVis {
**/
virtual ImageDataRenderTarget* clone() const;
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/**
* \see ImageData::getSubImage
*/
......
......@@ -55,6 +55,23 @@ namespace TUMVis {
return new MeshGeometry(_faces);
}
size_t MeshGeometry::getLocalMemoryFootprint() const {
size_t sum = 0;
for (std::vector<FaceGeometry>::const_iterator it = _faces.begin(); it != _faces.end(); ++it)
sum += it->getLocalMemoryFootprint();
if (_verticesBuffer != 0)
sum += sizeof(tgt::BufferObject);
if (_texCoordsBuffer != 0)
sum += sizeof(tgt::BufferObject);
if (_colorsBuffer != 0)
sum += sizeof(tgt::BufferObject);
if (_normalsBuffer != 0)
sum += sizeof(tgt::BufferObject);
return sizeof(*this) + sum;
}
size_t MeshGeometry::size() const {
return _faces.size();
}
......
......@@ -60,6 +60,9 @@ namespace TUMVis {
/// \see AbstractData::clone()
virtual MeshGeometry* clone() const;
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/**
* Returns the number of faces of this mesh.
* \return _faces.size()
......
......@@ -56,4 +56,8 @@ namespace tgt {
return _elementSize;
}
size_t BufferObject::getBufferSize() const {
return _size;
}
}
\ No newline at end of file
......@@ -68,6 +68,11 @@ namespace tgt {
*/
size_t getElementSize() const;
/**
* Gets the buffer size in bytes on the GPU.
* \return _size
*/
size_t getBufferSize() const;
/**
* Binds the buffer object to the current OpenGL context.
......
Markdown is supported
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