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 be1fea67 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Cleaned up CampVisPainter:

Introducing nifty error texture in case that there is nothing to render. Updated copyimage.frag to use texture coordinates instead of viewport pixels.
parent 6e2073bc
......@@ -30,6 +30,7 @@
#include "tgt/glcontextmanager.h"
#include "tgt/gpucapabilities.h"
#include "tgt/shadermanager.h"
#include "tgt/texturereadertga.h"
#include "tgt/qt/qtapplication.h"
#include "tgt/qt/qtthreadedcanvas.h"
#include "tbb/compat/thread"
......@@ -53,6 +54,7 @@ namespace campvis {
: QApplication(argc, argv)
, _localContext(0)
, _mainWindow(0)
, _errorTexture(nullptr)
, _initialized(false)
, _argc(argc)
, _argv(argv)
......@@ -137,6 +139,10 @@ namespace campvis {
GLJobProc.start();
GLJobProc.registerContext(_localContext);
// load textureData from file
tgt::TextureReaderTga trt;
_errorTexture = trt.loadTexture(CAMPVIS_SOURCE_DIR "/application/data/no_input.tga", tgt::Texture::LINEAR);
// parse argument list and create pipelines
QStringList pipelinesToAdd = this->arguments();
for (int i = 1; i < pipelinesToAdd.size(); ++i) {
......@@ -158,6 +164,8 @@ namespace campvis {
// Deinit everything OpenGL related using the local context.
tgt::GLContextScopedLock lock(_localContext);
delete _errorTexture;
// Deinit pipeline first
for (std::vector<AbstractPipeline*>::iterator it = _pipelines.begin(); it != _pipelines.end(); ++it) {
(*it)->deinit();
......@@ -213,6 +221,7 @@ namespace campvis {
CampVisPainter* painter = new CampVisPainter(canvas, pipeline);
canvas->setPainter(painter, false);
pipeline->setCanvas(canvas);
painter->setErrorTexture(_errorTexture);
_visualizations.push_back(std::make_pair(pipeline, painter));
_pipelines.push_back(pipeline);
......
......@@ -38,6 +38,7 @@
namespace tgt {
class GLCanvas;
class QtThreadedCanvas;
class Texture;
}
namespace campvis {
......@@ -152,6 +153,8 @@ namespace campvis {
/// Main window hosting GUI stuff
MainWindow* _mainWindow;
tgt::Texture* _errorTexture;
/// Flag, whether CampVisApplication was correctly initialized
bool _initialized;
......
......@@ -28,6 +28,7 @@
#include "tgt/camera.h"
#include "tgt/quadric.h"
#include "tgt/shadermanager.h"
#include "tgt/texture.h"
#include "tgt/textureunit.h"
#include "tgt/qt/qtthreadedcanvas.h"
......@@ -45,8 +46,9 @@ namespace campvis {
CampVisPainter::CampVisPainter(tgt::GLCanvas* canvas, AbstractPipeline* pipeline)
: tgt::Painter(canvas)
, _pipeline(0)
, _copyShader(0)
, _pipeline(nullptr)
, _copyShader(nullptr)
, _errorTexture(nullptr)
{
tgtAssert(getCanvas() != 0, "The given canvas must not be 0!");
_dirty = true;
......@@ -68,13 +70,14 @@ namespace campvis {
ScopedTypedData<RenderData> rd(_pipeline->getDataContainer(), _pipeline->getRenderTargetID());
ImageRepresentationGL::ScopedRepresentation repGL(_pipeline->getDataContainer(), _pipeline->getRenderTargetID());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// activate the shader
_copyShader->activate();
tgt::Shader::IgnoreUniformLocationErrorGuard guard(_copyShader);
// render whatever there is to render
if (rd != 0 || (repGL != 0 && repGL->getDimensionality() == 2)) {
// activate shader
_copyShader->activate();
_copyShader->setIgnoreUniformLocationError(true);
_copyShader->setUniform("_viewportSize", size);
_copyShader->setUniform("_viewportSizeRCP", 1.f / tgt::vec2(size));
_copyShader->setIgnoreUniformLocationError(false);
_copyShader->setUniform("_viewMatrix", tgt::mat4::identity);
// bind input textures
tgt::TextureUnit colorUnit;
......@@ -82,41 +85,30 @@ namespace campvis {
rd->bindColorTexture(_copyShader, colorUnit);
else if (repGL)
repGL->bind(_copyShader, colorUnit);
LGL_ERROR;
// execute the shader
_copyShader->setAttributeLocation(0, "in_Position");
_copyShader->setAttributeLocation(1, "in_TexCoords");
QuadRdr.renderQuad();
_copyShader->deactivate();
LGL_ERROR;
}
// if there is nothing to render, render the error texture
else if (_errorTexture != nullptr) {
float ratioRatio = static_cast<float>(size.y) / size.x;
tgt::mat4 viewMatrix = (ratioRatio > 1) ? tgt::mat4::createScale(tgt::vec3(1.f, 1.f / ratioRatio, 1.f)) : tgt::mat4::createScale(tgt::vec3(ratioRatio, 1.f, 1.f));
_copyShader->setUniform("_viewMatrix", viewMatrix);
// bind input textures
tgt::TextureUnit colorUnit;
colorUnit.activate();
_errorTexture->bind();
_copyShader->setUniform("_colorTexture", colorUnit.getUnitNumber());
// execute the shader
QuadRdr.renderQuad();
}
else {
// TODO: render some nifty error texture
// so long, we do some dummy rendering
tgt::Camera c(tgt::vec3(0.f,0.f,2.f));
c.look();
glColor3f(1.f, 0.f, 0.f);
tgt::Sphere sphere(.5f, 64, 32);
sphere.render();
/*
// render error texture
if (!errorTex_) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
return;
}
glClear(GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
errorTex_->bind();
errorTex_->enable();
glColor3f(1.f, 1.f, 1.f);
renderQuad();
errorTex_->disable();*/
LERROR("Nothing to render but could not load error texture either.");
}
_copyShader->deactivate();
LGL_ERROR;
getCanvas()->swap();
......@@ -130,6 +122,8 @@ namespace campvis {
try {
// TODO: Remove hardcoded paths, and use ShdrMgr.addPath() at some central location
_copyShader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", "");
_copyShader->setAttributeLocation(0, "in_Position");
_copyShader->setAttributeLocation(1, "in_TexCoords");
}
catch (tgt::Exception& e) {
LERRORC("main.cpp", "Encountered tgt::Exception: " << e.what());
......@@ -174,4 +168,9 @@ namespace campvis {
tgtAssert(dynamic_cast<tgt::QtThreadedCanvas*>(canvas) != 0, "Canvas must be of type QtThreadedCanvas!");
Painter::setCanvas(canvas);
}
void CampVisPainter::setErrorTexture(tgt::Texture* texture) {
_errorTexture = texture;
}
}
......@@ -35,6 +35,7 @@
namespace tgt {
class Shader;
class QtThreadedCanvas;
class Texture;
}
namespace campvis {
......@@ -87,6 +88,8 @@ namespace campvis {
*/
void setPipeline(AbstractPipeline* pipeline);
void setErrorTexture(tgt::Texture* texture);
/**
* Slot being notified when the pipeline's render target changed.
*/
......@@ -104,6 +107,8 @@ namespace campvis {
tgt::Shader* _copyShader; ///< Shader for copying the render target to the framebuffer.
tbb::atomic<bool> _dirty; ///< Flag whether render result is dirty and needs to be rerendered.
std::condition_variable _renderCondition; ///< conditional wait condition for rendering
tgt::Texture* _errorTexture;
};
}
......
......@@ -22,12 +22,11 @@
//
// ================================================================================================
in vec3 ex_TexCoord;
out vec4 out_Color;
#include "tools/texture2d.frag"
uniform vec2 _viewportSize;
uniform vec2 _viewportSizeRCP;
uniform sampler2D _colorTexture;
uniform TextureParameters2D _texParams;
......@@ -36,10 +35,9 @@ uniform sampler2D _depthTexture;
#endif
void main() {
vec2 fragCoord = gl_FragCoord.xy * _viewportSizeRCP;
out_Color = texture(_colorTexture, fragCoord);
out_Color = texture(_colorTexture, ex_TexCoord.xy);
#ifndef NO_DEPTH
gl_FragDepth = texture(_depthTexture, fragCoord).r;
gl_FragDepth = texture(_depthTexture, ex_TexCoord.xy).r;
#endif
}
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