Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

Commit 29f542ae authored by Jakob Weiss's avatar Jakob Weiss

Timing, ImageMappingInformation, OptionProperty

* AbstractPipeline now does explicit GPU timing, implying a Flush of the OpenGL pieline after every processor
* OptionProperty has an extended constructor directly using initializer lists of GenericOption<>'s
* ImageMappingInformation has somehow extended / more complete interface allowing copies and default construction
parent 3c537e12
......@@ -30,6 +30,15 @@
namespace campvis {
ImageMappingInformation::ImageMappingInformation()
: _size(1.f)
, _offset(0.f)
, _voxelSize(1)
, _customTransformation(cgt::mat4::identity)
{
updateMatrices();
}
ImageMappingInformation::ImageMappingInformation(const cgt::vec3& size, const cgt::vec3& offset, const cgt::vec3& voxelSize, const cgt::mat4& customTransformation /*= LinearMapping<float>::identity*/)
: _size(size)
, _offset(offset)
......@@ -40,7 +49,7 @@ namespace campvis {
if (! _customTransformation.invert(invTrafo)) {
LERRORC("CAMPVis.core.ImageMappingInformation", "Custom transformation is not invertable! Resetting to identity tranformation.");
_customTransformation = cgt::mat4::identity;
}
}
updateMatrices();
}
......
......@@ -41,6 +41,11 @@ namespace campvis {
*/
class CAMPVIS_CORE_API ImageMappingInformation {
public:
/**
* Default Mapping is for a 1x1 image with 1mm voxels at the origin
*/
ImageMappingInformation();
/**
* Creates a new default ImageMappingInformation.
* \param size Image size (number of elements, redundant...)
......@@ -54,6 +59,13 @@ namespace campvis {
const cgt::vec3& voxelSize,
const cgt::mat4& customTransformation = cgt::mat4::identity);
// We're ok with the default implementations so we are explicit about it
ImageMappingInformation(const ImageMappingInformation&) = default;
ImageMappingInformation(ImageMappingInformation&&) = default;
ImageMappingInformation& operator= (const ImageMappingInformation&) = default;
ImageMappingInformation& operator= (ImageMappingInformation&&) = default;
~ImageMappingInformation() = default;
/**
* Returns the position of LLF corner in world coordinates (mm).
* \return _offset
......
......@@ -25,7 +25,7 @@
#include "abstractpipeline.h"
#include <tbb/tick_count.h>
#include <chrono>
#include "cgt/exception.h"
#include "cgt/glcanvas.h"
......@@ -179,9 +179,22 @@ namespace campvis {
// execute processor if needed
if (processor->getEnabled() && !processor->isLocked()) {
if (! processor->isValid()) {
tbb::tick_count startTime;
if (processor->getClockExecutionTime())
startTime = tbb::tick_count::now();
static GLuint timerQuery = 0;
std::chrono::high_resolution_clock::time_point startTime;
if (processor->getClockExecutionTime()) {
startTime = std::chrono::high_resolution_clock::now();
//if (dynamic_cast<VisualizationProcessor*>(processor))
{
glGenQueries(1, &timerQuery);
LGL_ERROR;
glBeginQuery(GL_TIME_ELAPSED, timerQuery); LGL_ERROR;
}
}
// Log any leftover OpenGL errors not caught by previous processors
if (dynamic_cast<VisualizationProcessor*>(processor))
LGL_ERROR;
try {
processor->process(*_dataContainer);
......@@ -193,9 +206,23 @@ namespace campvis {
LERROR("Caught unhandled exception while executing processor " << processor->getName() << ": unknown exception");
}
// Log any leftover OpenGL errors not caught by the processor itself
if (dynamic_cast<VisualizationProcessor*>(processor))
LGL_ERROR;
if (processor->getClockExecutionTime()) {
tbb::tick_count endTime = tbb::tick_count::now();
LINFO("Executed processor " << processor->getName() << " duration: " << (endTime - startTime).seconds());
GLint64 gpuTimeElapsed = 0;
//if (dynamic_cast<VisualizationProcessor*>(processor))
{
glEndQuery(GL_TIME_ELAPSED); LGL_ERROR;
glGetQueryObjecti64v(timerQuery, GL_QUERY_RESULT, &gpuTimeElapsed); LGL_ERROR;
glDeleteQueries(1, &timerQuery);
}
std::chrono::high_resolution_clock::time_point endTime = std::chrono::high_resolution_clock::now();
auto dT = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime);
double dTms = double(dT.count()) / 1000.;
LINFO("Executed processor " << processor->getName() << " GPU duration: \t" << double(gpuTimeElapsed)/1e6 << ", total: \t" << dTms << " ms");
}
}
}
......
......@@ -151,7 +151,7 @@ namespace campvis {
if (hasInvalidShader()) {
updateShader();
validate(INVALID_SHADER);
}
};
if (hasInvalidProperties()) {
updateProperties(data);
validate(INVALID_PROPERTIES);
......
......@@ -30,6 +30,7 @@
#include <string>
#include <vector>
#include <initializer_list>
namespace campvis {
......@@ -128,6 +129,11 @@ namespace campvis {
const GenericOption<T>* options,
int count);
GenericOptionProperty(
const std::string& name,
const std::string& title,
const std::initializer_list<GenericOption<T>>& options);
/**
* Destructor
*/
......@@ -232,6 +238,16 @@ namespace campvis {
setMinValue(0);
}
template<typename T>
campvis::GenericOptionProperty<T>::GenericOptionProperty(const std::string& name, const std::string& title, const std::initializer_list<GenericOption<T>>& options)
: AbstractOptionProperty(name, title)
, _options(options)
{
setMaxValue(static_cast<int>(std::distance(options.begin(), options.end())));
setValue(0);
setMinValue(0);
}
template<typename T>
campvis::GenericOptionProperty<T>::~GenericOptionProperty() {
......
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