Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing 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 fe24467e authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

fixed and adapted OpenCL module

parent aadcad86
......@@ -147,6 +147,15 @@ namespace campvis {
CLRtm.addPath(basePath);
CLRtm.addPath(basePath + "/core/cl");
}
#ifdef CAMPVIS_SOURCE_DIR
{
std::string sourcePath = CAMPVIS_SOURCE_DIR;
CLRtm.addPath(sourcePath);
CLRtm.addPath(sourcePath + "/core/glsl");
}
#endif
#endif
}
......
......@@ -157,7 +157,8 @@ namespace campvis {
}
void RenderData::bind(tgt::Shader* shader, const tgt::TextureUnit& colorTexUnit, const tgt::TextureUnit& depthTexUnit, const std::string& colorTexUniform /*= "_colorTexture"*/, const std::string& depthTexUniform /*= "_depthTexture"*/, const std::string& texParamsUniform /*= "_texParams"*/, size_t index /*= 0*/) const {
bindDepthTexture(shader, depthTexUnit, depthTexUniform, texParamsUniform);
if (hasDepthTexture())
bindDepthTexture(shader, depthTexUnit, depthTexUniform, texParamsUniform);
bindColorTexture(shader, colorTexUnit, colorTexUniform, texParamsUniform, index);
}
......
......@@ -94,6 +94,16 @@ namespace kisscl {
std::vector<ContextProperty> properties = Context::generateGlSharingProperties();
properties.insert(properties.end(), additionalProperties.begin(), additionalProperties.end());
for (std::vector<Device*>::const_iterator it = _gpuDevices.begin(); it != _gpuDevices.end(); ++it) {
toReturn = new Context(*it, properties);
if (toReturn->isValid())
return toReturn;
// else
delete toReturn;
toReturn = 0;
}
for (std::vector<Device*>::const_iterator it = _cpuDevices.begin(); it != _cpuDevices.end(); ++it) {
toReturn = new Context(*it, properties);
if (toReturn->isValid())
......
......@@ -51,7 +51,7 @@ namespace campvis {
{
addProperty(&_camera);
_trackballEH = new TrackballNavigationEventHandler(this, &_camera, _renderTargetSize);
_trackballEH = new TrackballNavigationEventHandler(this, &_camera, _canvasSize.getValue());
_eventHandlers.push_back(_trackballEH);
addProcessor(&_imageReader);
......@@ -75,6 +75,7 @@ namespace campvis {
_imageReader.p_targetImageID.setValue("reader.output");
_imageReader.p_targetImageID.connect(&_pgGenerator.p_sourceImageID);
_imageReader.p_targetImageID.connect(&_eepGenerator.p_sourceImageID);
_imageReader.s_validated.connect(this, &OpenCLPipeline::onProcessorValidated);
_clRaycaster._targetImageID.setValue("cl.output");
_clRaycaster._sourceImageID.setValue("clr.input");
......@@ -97,16 +98,24 @@ namespace campvis {
_effectiveRenderTargetSize.s_changed.connect<OpenCLPipeline>(this, &OpenCLPipeline::onRenderTargetSizeChanged);
}
void OpenCLPipeline::execute() {
{
tbb::spin_mutex::scoped_lock lock(_localMutex);
_invalidationLevel.setValid();
// TODO: think whether we want to lock all processors already here.
}
if (! _imageReader.getInvalidationLevel().isValid()) {
executeProcessor(&_imageReader);
void OpenCLPipeline::deinit() {
_effectiveRenderTargetSize.s_changed.disconnect(this);
VisualizationPipeline::deinit();
}
const std::string OpenCLPipeline::getName() const {
return "OpenCLPipeline";
}
// convert data
void OpenCLPipeline::onRenderTargetSizeChanged(const AbstractProperty* prop) {
_trackballEH->setViewportSize(_canvasSize.getValue());
float ratio = static_cast<float>(_effectiveRenderTargetSize.getValue().x) / static_cast<float>(_effectiveRenderTargetSize.getValue().y);
_camera.setWindowRatio(ratio);
}
void OpenCLPipeline::onProcessorValidated(AbstractProcessor* processor) {
if (processor == &_imageReader) {
// update camera
ImageRepresentationLocal::ScopedRepresentation img(_data, "reader.output");
if (img != 0) {
size_t numElements = img->getNumElements();
......@@ -117,7 +126,7 @@ namespace campvis {
GenericImageRepresentationLocal<float, 1>* imageWithFloats = GenericImageRepresentationLocal<float, 1>::create(id, asFloats);
DataHandle dh = _data.addData("clr.input", id);
tgt::Bounds volumeExtent = img->getParent()->getWorldBounds();
tgt::vec3 pos = volumeExtent.center() - tgt::vec3(0, 0, tgt::length(volumeExtent.diagonal()));
......@@ -125,28 +134,9 @@ namespace campvis {
_trackballEH->setCenter(volumeExtent.center());
_trackballEH->reinitializeCamera(pos, volumeExtent.center(), _camera.getValue().getUpVector());
}
}
if (! _pgGenerator.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(&_pgGenerator);
}
if (! _eepGenerator.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(&_eepGenerator);
}
if (! _clRaycaster.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(&_clRaycaster);
}
}
const std::string OpenCLPipeline::getName() const {
return "OpenCLPipeline";
}
void OpenCLPipeline::onRenderTargetSizeChanged(const AbstractProperty* prop) {
_trackballEH->setViewportSize(_renderTargetSize);
float ratio = static_cast<float>(_effectiveRenderTargetSize.getValue().x) / static_cast<float>(_effectiveRenderTargetSize.getValue().y);
_camera.setWindowRatio(ratio);
}
}
\ No newline at end of file
......@@ -54,18 +54,22 @@ namespace campvis {
/// \see VisualizationPipeline::init()
virtual void init();
/// \see VisualizationPipeline::deinit()
virtual void deinit();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const;
/**
* Execute this pipeline.
**/
virtual void execute();
void onRenderTargetSizeChanged(const AbstractProperty* prop);
protected:
/**
* Slot getting called when one of the observed processors got validated.
* Updates the camera properties, when the input image has changed.
* \param processor The processor that emitted the signal
*/
virtual void onProcessorValidated(AbstractProcessor* processor);
CameraProperty _camera;
MhdImageReader _imageReader;
ProxyGeometryGenerator _pgGenerator;
......
......@@ -42,7 +42,7 @@
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationlocal.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#include "core/datastructures/renderdata.h"
#include "core/classification/simpletransferfunction.h"
......@@ -50,7 +50,7 @@
namespace campvis {
const std::string CLRaycaster::loggerCat_ = "CAMPVis.modules.vis.CLRaycaster";
CLRaycaster::CLRaycaster(GenericProperty<tgt::ivec2>& renderTargetSize)
CLRaycaster::CLRaycaster(IVec2Property& renderTargetSize)
: VisualizationProcessor(renderTargetSize)
, _sourceImageID("sourceImageID", "Input Image", "", DataNameProperty::READ)
, _entryImageID("entryImageID", "Output Entry Points Image", "", DataNameProperty::READ)
......@@ -94,9 +94,10 @@ namespace campvis {
_clContext = CLRtm.createGlSharingContext();
if (_clContext != 0) {
_clProgram = CLRtm.loadProgram(_clContext, "modules/opencl/cl/clraycaster.cl");
_clProgram->setBuildOptions(" -cl-fast-relaxed-math -cl-mad-enable -g -s \"C:\\Users\\Christian\\Documents\\TUM\\code\\campvis\\modules\\opencl\\cl\\clraycaster.cl\"");
_clProgram->setBuildOptions(" -cl-fast-relaxed-math -cl-mad-enable");// -g -s \"C:\\Users\\Christian\\Documents\\TUM\\code\\campvis\\modules\\opencl\\cl\\clraycaster.cl\"");
_clProgram->build();
}
}
void CLRaycaster::deinit() {
......@@ -148,15 +149,15 @@ namespace campvis {
return;
ImageRepresentationLocal::ScopedRepresentation img(data, _sourceImageID.getValue());
ImageRepresentationRenderTarget::ScopedRepresentation entryPoints(data, _entryImageID.getValue());
ImageRepresentationRenderTarget::ScopedRepresentation exitPoints(data, _exitImageID.getValue());
DataContainer::ScopedTypedData<RenderData> entryPoints(data, _entryImageID.getValue());
DataContainer::ScopedTypedData<RenderData> exitPoints(data, _exitImageID.getValue());
if (img != 0 && entryPoints != 0 && exitPoints != 0) {
if (img->getDimensionality() == 3) {
if (entryPoints->getSize() == exitPoints->getSize()) {
tgt::svec3 dims(entryPoints->getColorTexture()->getDimensions());
if (entryPoints->getColorTexture()->getSize() == exitPoints->getColorTexture()->getSize()) {
tgt::svec3 dims(entryPoints->getColorTexture()->getSize());
if (_invalidationLevel.isInvalidShader()) {
if (hasInvalidShader()) {
_clProgram->build();
}
......@@ -221,12 +222,16 @@ namespace campvis {
// bind shared textures
delete _texEntryPointsColor;
_texEntryPointsColor = new kisscl::GLTexture(_clContext, CL_MEM_READ_ONLY, entryPoints->getColorTexture());
_texEntryPointsColor = new kisscl::GLTexture(_clContext, CL_MEM_READ_ONLY, entryPoints->getColorTexture()->getRepresentation<ImageRepresentationGL>()->getTexture());
delete _texExitPointsColor;
_texExitPointsColor = new kisscl::GLTexture(_clContext, CL_MEM_READ_ONLY, exitPoints->getColorTexture());
_texExitPointsColor = new kisscl::GLTexture(_clContext, CL_MEM_READ_ONLY, exitPoints->getColorTexture()->getRepresentation<ImageRepresentationGL>()->getTexture());
delete _texOutColor;
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(dims.xy());
_texOutColor = new kisscl::GLTexture(_clContext, CL_MEM_WRITE_ONLY, rt.second->getColorTexture());
tgt::Texture* ttt = new tgt::Texture(0, dims, GL_RGBA, GL_RGBA8, GL_UNSIGNED_BYTE, tgt::Texture::LINEAR);
ttt->uploadTexture();
ttt->setWrapping(tgt::Texture::CLAMP_TO_EDGE);
_texOutColor = new kisscl::GLTexture(_clContext, CL_MEM_WRITE_ONLY, ttt);
// prepare kernel and stuff command queue
......@@ -255,8 +260,13 @@ namespace campvis {
return;
}
ImageData* id = new ImageData(2, dims, 4);
ImageRepresentationGL::create(id, ttt);
RenderData* rd = new RenderData();
rd->addColorTexture(id);
LGL_ERROR;
data.addData(_targetImageID.getValue(), rt.first);
data.addData(_targetImageID.getValue(), rd);
_targetImageID.issueWrite();
}
else {
......@@ -271,7 +281,7 @@ namespace campvis {
LERROR("No suitable input image found.");
}
_invalidationLevel.setValid();
setValid();
}
std::string CLRaycaster::generateHeader() const {
......
......@@ -63,7 +63,7 @@ namespace campvis {
* \param fragmentShaderFileName Filename for the fragment shader being automatically loaded.
* \param bindEntryExitDepthTextures Flag whether to also bind the depth textures of the entry-/exit points.
*/
CLRaycaster(GenericProperty<tgt::ivec2>& renderTargetSize);
CLRaycaster(IVec2Property& renderTargetSize);
/**
* Destructor
......
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