Commit 083a730a authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Major fix for AMD GPUs.

Apparently, glBindAttribLocation() does not work as planned with AMD GPUs. Therefore, all Shaders yielded black images. Replaced all attribute locations with hard-coded ones in the vertex shader and removed corresponding convenience function from cgt::Shader.

refs #382
parent fef9f926
......@@ -117,8 +117,6 @@ namespace campvis {
LDEBUG("Generated a " << w << " x "<< h << " texture atlas");
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/fontrendering/glsl/fontatlas.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
LGL_ERROR;
}
......
......@@ -64,8 +64,6 @@ namespace campvis {
void IxpvCompositor::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/ixpv/glsl/ixpvcompositor.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
void IxpvCompositor::deinit() {
......
......@@ -122,8 +122,6 @@ namespace campvis {
void ManualTissueSegmenter::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/manualsegmentation/glsl/manualtissuesegmenter.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
_controlPoints.push_back(std::map< int, std::vector< ControlPoint > >());
_segmentation.addLayer(TissueSegmentation::Layer());
......
......@@ -93,12 +93,7 @@ namespace neuro {
void MultiVolumeMprRenderer::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.load("modules/vis/glsl/geometryrenderer.vert", "modules/vis/glsl/geometryrenderer.geom", "modules/neuro/glsl/multivolumemprrenderer.frag", generateHeader());
if (_shader != nullptr) {
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
}
void MultiVolumeMprRenderer::deinit() {
......
......@@ -90,16 +90,7 @@ namespace neuro {
VisualizationProcessor::init();
_eepShader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/neuro/glsl/multivolumeraycaster_eep.frag", generateHeader());
if (_eepShader != nullptr) {
_eepShader->setAttributeLocation(0, "in_Position");
_eepShader->setAttributeLocation(1, "in_TexCoord");
}
_rcShader = ShdrMgr.loadWithCustomGlslVersion("core/glsl/passthrough.vert", "", "modules/neuro/glsl/multivolumeraycaster_rc.frag", generateHeader(), "400");
if (_rcShader != nullptr) {
_rcShader->setAttributeLocation(0, "in_Position");
_rcShader->setAttributeLocation(1, "in_TexCoord");
}
_vhm1 = new VoxelHierarchyMapper();
_vhm2 = new VoxelHierarchyMapper();
......
......@@ -67,12 +67,7 @@ namespace campvis {
VisualizationProcessor::init();
_shader2D = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glgaussianfilter.frag", "#define GAUSSIAN_2D\n");
_shader2D->setAttributeLocation(0, "in_Position");
_shader2D->setAttributeLocation(1, "in_TexCoord");
_shader3D = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glgaussianfilter.frag", "#define GAUSSIAN_3D\n");
_shader3D->setAttributeLocation(0, "in_Position");
_shader3D->setAttributeLocation(1, "in_TexCoord");
// create kernel buffer
cgt::TextureUnit inputUnit;
......
......@@ -64,8 +64,6 @@ namespace campvis {
VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glgradientvolumegenerator.frag", generateHeader());
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
void GlGradientVolumeGenerator::deinit() {
......
......@@ -63,12 +63,7 @@ namespace campvis {
VisualizationProcessor::init();
_shader2D = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glimagecrop.frag", "#define GLIMAGECROP_2D\n");
_shader2D->setAttributeLocation(0, "in_Position");
_shader2D->setAttributeLocation(1, "in_TexCoord");
_shader3D = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glimagecrop.frag", "#define GLIMAGECROP_3D\n");
_shader3D->setAttributeLocation(0, "in_Position");
_shader3D->setAttributeLocation(1, "in_TexCoord");
}
void GlImageCrop::deinit() {
......
......@@ -62,12 +62,7 @@ namespace campvis {
VisualizationProcessor::init();
_shader2D = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glimageresampler.frag", "#define GLRESAMPLER_2D\n");
_shader2D->setAttributeLocation(0, "in_Position");
_shader2D->setAttributeLocation(1, "in_TexCoord");
_shader3D = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glimageresampler.frag", "#define GLRESAMPLER_3D\n");
_shader3D->setAttributeLocation(0, "in_Position");
_shader3D->setAttributeLocation(1, "in_TexCoord");
}
void GlImageResampler::deinit() {
......
......@@ -67,8 +67,6 @@ namespace campvis {
VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glintensityquantizer.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
void GlIntensityQuantizer::deinit() {
......
......@@ -71,12 +71,7 @@ namespace campvis {
VisualizationProcessor::init();
_erosionFilter = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/GlMorphologyFilter.frag", generateGlslHeader("min"));
_erosionFilter->setAttributeLocation(0, "in_Position");
_erosionFilter->setAttributeLocation(1, "in_TexCoord");
_dilationFilter = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/GlMorphologyFilter.frag", generateGlslHeader("max"));
_dilationFilter->setAttributeLocation(0, "in_Position");
_dilationFilter->setAttributeLocation(1, "in_TexCoord");
}
void GlMorphologyFilter::deinit() {
......
......@@ -62,8 +62,6 @@ namespace campvis {
VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glsignaltonoiseratiofilter.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
void GlSignalToNoiseRatioFilter::deinit() {
......
......@@ -74,8 +74,6 @@ namespace campvis {
VisualizationProcessor::init();
_shader = ShdrMgr.loadWithCustomGlslVersion("core/glsl/passthrough.vert", "", "modules/preprocessing/glsl/glvesselnessfilter.frag", "", "400");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
void GlVesselnessFilter::deinit() {
......
......@@ -26,14 +26,13 @@
#include "cgt/event/keyevent.h"
#include "cgt/openglgarbagecollector.h"
#include "cgt/opengljobprocessor.h"
#include "cgt/painter.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
#include "core/datastructures/renderdata.h"
#include "core/tools/glreduction.h"
#include "core/tools/job.h"
#include "core/tools/opengljobprocessor.h"
namespace campvis {
static const GenericOption<nlopt::algorithm> optimizers[3] = {
......@@ -117,7 +116,8 @@ namespace campvis {
void NloptRegistration::onPerformOptimizationClicked() {
// Evaluation of the similarity measure needs an OpenGL context, so we need to create an OpenGL job for this.
GLJobProc.enqueueJob(_canvas, makeJobOnHeap(this, &NloptRegistration::performOptimization), OpenGLJobProcessor::SerialJob);
cgt::GLContextScopedLock lockGuard(_canvas);
performOptimization();
}
void NloptRegistration::performOptimization() {
......
......@@ -97,16 +97,8 @@ namespace campvis {
void SimilarityMeasure::init() {
VisualizationProcessor::init();
_sadssdCostFunctionShader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/registration/glsl/similaritymeasuresadssd.frag", "");
_sadssdCostFunctionShader->setAttributeLocation(0, "in_Position");
_sadssdCostFunctionShader->setAttributeLocation(1, "in_TexCoord");
_nccsnrCostFunctionShader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/registration/glsl/similaritymeasurenccsnr.frag", "");
_nccsnrCostFunctionShader->setAttributeLocation(0, "in_Position");
_nccsnrCostFunctionShader->setAttributeLocation(1, "in_TexCoord");
_differenceShader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/registration/glsl/differenceimage.frag", "");
_differenceShader->setAttributeLocation(0, "in_Position");
_differenceShader->setAttributeLocation(1, "in_TexCoord");
_glr = new GlReduction(GlReduction::PLUS);
}
......@@ -168,13 +160,11 @@ namespace campvis {
cgt::Shader* leShader = _sadssdCostFunctionShader;
cgt::Texture* similarityTex = 0;
cgt::Texture* similarityTex2 = 0;
similarityTex = new cgt::Texture(0, cgt::ivec3(p_viewportSize.getValue(), 1), GL_RGBA, GL_RGBA32F, GL_FLOAT, cgt::Texture::NEAREST);
similarityTex->uploadTexture();
similarityTex = new cgt::Texture(GL_TEXTURE_2D, cgt::ivec3(p_viewportSize.getValue(), 1), GL_RGBA32F, cgt::Texture::NEAREST);
similarityTex->setWrapping(cgt::Texture::CLAMP);
// NCC and SNR need a second texture and a different shader...
if (p_metric.getOptionValue() == "NCC" || p_metric.getOptionValue() == "SNR") {
similarityTex2 = new cgt::Texture(0, cgt::ivec3(p_viewportSize.getValue(), 1), GL_RGBA, GL_RGBA32F, GL_FLOAT, cgt::Texture::NEAREST);
similarityTex2->uploadTexture();
similarityTex2 = new cgt::Texture(GL_TEXTURE_2D, cgt::ivec3(p_viewportSize.getValue(), 1), GL_RGBA32F, cgt::Texture::NEAREST);
similarityTex2->setWrapping(cgt::Texture::CLAMP);
leShader = _nccsnrCostFunctionShader;
}
......@@ -293,8 +283,7 @@ namespace campvis {
referenceUnit.activate();
// create temporary texture for result
cgt::Texture* differenceImage = new cgt::Texture(0, cgt::ivec3(size), GL_RED, GL_R32F, GL_FLOAT, cgt::Texture::LINEAR);
differenceImage->uploadTexture();
cgt::Texture* differenceImage = new cgt::Texture(GL_TEXTURE_3D, cgt::ivec3(size), GL_R32F, cgt::Texture::LINEAR);
differenceImage->setWrapping(cgt::Texture::CLAMP_TO_EDGE);
// bind input images
......
......@@ -67,9 +67,6 @@ namespace campvis {
void DepthDarkening::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/depthdarkening.frag", generateHeader());
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
_glReduction = new GlReduction(GlReduction::MIN_MAX_DEPTH_ONLY);
}
......
......@@ -75,10 +75,6 @@ namespace campvis {
void EEPGenerator::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/eepgenerator.frag", generateHeader());
if (_shader != 0) {
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
}
void EEPGenerator::deinit() {
......
......@@ -75,8 +75,6 @@ namespace campvis {
void MprRenderer::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/mprrenderer.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
void MprRenderer::deinit() {
......
......@@ -73,12 +73,7 @@ namespace campvis {
void OrientationOverlay::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/orientationoverlay.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
_passthroughShader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/quadview.frag", "");
_passthroughShader->setAttributeLocation(0, "in_Position");
_passthroughShader->setAttributeLocation(1, "in_TexCoord");
createCube();
......
......@@ -60,8 +60,6 @@ namespace campvis {
void QuadView::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/quadview.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
void QuadView::deinit() {
......
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