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
...@@ -129,8 +129,6 @@ namespace campvis { ...@@ -129,8 +129,6 @@ namespace campvis {
void CampVisPainter::init() { void CampVisPainter::init() {
try { try {
_copyShader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", ""); _copyShader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", "");
_copyShader->setAttributeLocation(0, "in_Position");
_copyShader->setAttributeLocation(1, "in_TexCoords");
} }
catch (cgt::Exception& e) { catch (cgt::Exception& e) {
LFATAL("Encountered cgt::Exception: " << e.what()); LFATAL("Encountered cgt::Exception: " << e.what());
......
...@@ -111,8 +111,6 @@ namespace campvis { ...@@ -111,8 +111,6 @@ namespace campvis {
initAllProperties(); initAllProperties();
_paintShader = ShdrMgr.load("core/glsl/passthrough.vert", "application/glsl/datacontainerinspector.frag", ""); _paintShader = ShdrMgr.load("core/glsl/passthrough.vert", "application/glsl/datacontainerinspector.frag", "");
_paintShader->setAttributeLocation(0, "in_Position");
_paintShader->setAttributeLocation(1, "in_TexCoords");
createQuad(); createQuad();
// set this as painter to get notified when window size changes // set this as painter to get notified when window size changes
......
...@@ -152,11 +152,7 @@ namespace campvis { ...@@ -152,11 +152,7 @@ namespace campvis {
template<class T> template<class T>
void campvis::GenericGeometryTransferFunction<T>::initShader() { void campvis::GenericGeometryTransferFunction<T>::initShader() {
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/passthrough.frag", ""); _shader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/passthrough.frag", "");
if (_shader != 0) { if (_shader == nullptr) {
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(2, "in_Color");
}
else {
LERROR("Could not create Shader for Rendering the TF into the lookup texture!"); LERROR("Could not create Shader for Rendering the TF into the lookup texture!");
} }
} }
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
void main() {
// just pass everything through to fragment shader.
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
gl_FrontColor = gl_Color;
}
\ No newline at end of file
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
// //
// ================================================================================================ // ================================================================================================
in vec3 in_Position; ///< incoming vertex position layout(location = 0) in vec3 in_Position; ///< incoming vertex position
in vec3 in_TexCoord; ///< incoming texture coordinate layout(location = 1) in vec3 in_TexCoord; ///< incoming texture coordinate
in vec4 in_Color; ///< incoming color layout(location = 2) in vec4 in_Color; ///< incoming color
out vec3 ex_TexCoord; ///< outgoing texture coordinate out vec3 ex_TexCoord; ///< outgoing texture coordinate
out vec4 ex_Color; ///< outgoing color out vec4 ex_Color; ///< outgoing color
......
...@@ -70,8 +70,6 @@ namespace campvis { ...@@ -70,8 +70,6 @@ namespace campvis {
void RaycastingProcessor::init() { void RaycastingProcessor::init() {
VisualizationProcessor::init(); VisualizationProcessor::init();
_shader = ShdrMgr.loadWithCustomGlslVersion("core/glsl/passthrough.vert", "", _fragmentShaderFilename, generateHeader(), _customGlslVersion); _shader = ShdrMgr.loadWithCustomGlslVersion("core/glsl/passthrough.vert", "", _fragmentShaderFilename, generateHeader(), _customGlslVersion);
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
_minReduction = new GlReduction(GlReduction::MIN); _minReduction = new GlReduction(GlReduction::MIN);
_maxReduction = new GlReduction(GlReduction::MAX); _maxReduction = new GlReduction(GlReduction::MAX);
......
...@@ -100,8 +100,6 @@ namespace campvis { ...@@ -100,8 +100,6 @@ namespace campvis {
void SliceRenderProcessor::init() { void SliceRenderProcessor::init() {
VisualizationProcessor::init(); VisualizationProcessor::init();
_shader = ShdrMgr.loadWithCustomGlslVersion("core/glsl/passthrough.vert", "", _fragmentShaderFilename, getGlslHeader(), _customGlslVersion); _shader = ShdrMgr.loadWithCustomGlslVersion("core/glsl/passthrough.vert", "", _fragmentShaderFilename, getGlslHeader(), _customGlslVersion);
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
} }
void SliceRenderProcessor::deinit() { void SliceRenderProcessor::deinit() {
......
...@@ -61,8 +61,6 @@ namespace campvis { ...@@ -61,8 +61,6 @@ namespace campvis {
_fbo = new cgt::FramebufferObject(); _fbo = new cgt::FramebufferObject();
_copyShader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", ""); _copyShader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", "");
_copyShader->setAttributeLocation(0, "in_Position");
_copyShader->setAttributeLocation(1, "in_TexCoord");
} }
void ViewportSplitter::deinit() { void ViewportSplitter::deinit() {
......
...@@ -58,13 +58,6 @@ namespace campvis { ...@@ -58,13 +58,6 @@ namespace campvis {
LERROR("Could not load Shader for OpenGL reduction. Reduction will not work!"); LERROR("Could not load Shader for OpenGL reduction. Reduction will not work!");
return; return;
} }
_shader1d->setAttributeLocation(0, "in_Position");
_shader1d->setAttributeLocation(1, "in_TexCoord");
_shader2d->setAttributeLocation(0, "in_Position");
_shader2d->setAttributeLocation(1, "in_TexCoord");
_shader3d->setAttributeLocation(0, "in_Position");
_shader3d->setAttributeLocation(1, "in_TexCoord");
} }
GlReduction::~GlReduction() { GlReduction::~GlReduction() {
......
...@@ -1288,10 +1288,12 @@ void Shader::setAttribute(GLint index, const Vector4<GLuint>& v) { ...@@ -1288,10 +1288,12 @@ void Shader::setAttribute(GLint index, const Vector4<GLuint>& v) {
glVertexAttrib4uiv(index, v.elem); glVertexAttrib4uiv(index, v.elem);
} }
// ATTENTION: This method was deliberately deactivated, since it was not working as expected
// with AMD GPUs.
// Attribute locations // Attribute locations
void Shader::setAttributeLocation(GLuint index, const std::string& name) { //void Shader::setAttributeLocation(GLuint index, const std::string& name) {
glBindAttribLocation(id_, index, name.c_str()); // glBindAttribLocation(id_, index, name.c_str());
} //}
GLint Shader::getAttributeLocation(const string& name) { GLint Shader::getAttributeLocation(const string& name) {
GLint l; GLint l;
......
...@@ -393,7 +393,9 @@ public: ...@@ -393,7 +393,9 @@ public:
static void setAttribute(GLint index, const Vector4<GLuint>& v); static void setAttribute(GLint index, const Vector4<GLuint>& v);
// Attribute locations // Attribute locations
void setAttributeLocation(GLuint index, const std::string& name); // ATTENTION: This method was deliberately deactivated, since it was not working as expected
// with AMD GPUs.
// void setAttributeLocation(GLuint index, const std::string& name);
GLint getAttributeLocation(const std::string& name); GLint getAttributeLocation(const std::string& name);
// Normalized attributes // Normalized attributes
......
...@@ -106,8 +106,6 @@ namespace campvis { ...@@ -106,8 +106,6 @@ namespace campvis {
void AdvancedUsFusion::init() { void AdvancedUsFusion::init() {
VisualizationProcessor::init(); VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/advancedusvis/glsl/advancedusfusion.frag", generateHeader()); _shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/advancedusvis/glsl/advancedusfusion.frag", generateHeader());
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
} }
void AdvancedUsFusion::deinit() { void AdvancedUsFusion::deinit() {
......
...@@ -75,8 +75,6 @@ namespace campvis { ...@@ -75,8 +75,6 @@ namespace campvis {
VisualizationProcessor::init(); VisualizationProcessor::init();
_shader = ShdrMgr.loadWithCustomGlslVersion("core/glsl/passthrough.vert", "", "modules/advancedusvis/glsl/pointpredicateevaluator.frag", generateHeader(), "400"); _shader = ShdrMgr.loadWithCustomGlslVersion("core/glsl/passthrough.vert", "", "modules/advancedusvis/glsl/pointpredicateevaluator.frag", generateHeader(), "400");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
p_histogram.s_headerChanged.connect(this, &PointPredicateEvaluator::onHistogramHeaderChanged); p_histogram.s_headerChanged.connect(this, &PointPredicateEvaluator::onHistogramHeaderChanged);
} }
......
...@@ -67,8 +67,6 @@ namespace campvis { ...@@ -67,8 +67,6 @@ namespace campvis {
VisualizationProcessor::init(); VisualizationProcessor::init();
_shader = ShdrMgr.loadWithCustomGlslVersion("core/glsl/passthrough.vert", "", "modules/advancedusvis/glsl/scanlinedistributioncomputation.frag", generateHeader(), "400"); _shader = ShdrMgr.loadWithCustomGlslVersion("core/glsl/passthrough.vert", "", "modules/advancedusvis/glsl/scanlinedistributioncomputation.frag", generateHeader(), "400");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
_viewportSizeProperty->s_changed.disconnect(this); _viewportSizeProperty->s_changed.disconnect(this);
setPropertyInvalidationLevel(*_viewportSizeProperty, VALID); setPropertyInvalidationLevel(*_viewportSizeProperty, VALID);
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
// //
// ================================================================================================ // ================================================================================================
in vec3 in_Position; ///< incoming vertex position layout(location = 0) in vec3 in_Position; ///< incoming vertex position
in vec3 in_TexCoord; ///< incoming texture coordinate layout(location = 1) in vec3 in_TexCoord; ///< incoming texture coordinate
in vec4 in_Color; ///< incoming color layout(location = 2) in vec4 in_Color; ///< incoming color
out vec3 vert_TexCoord; ///< outgoing texture coordinate out vec3 vert_TexCoord; ///< outgoing texture coordinate
out vec4 vert_Color; ///< outgoing color out vec4 vert_Color; ///< outgoing color
......
...@@ -67,9 +67,6 @@ namespace campvis { ...@@ -67,9 +67,6 @@ namespace campvis {
void GeometryStrainRenderer::init() { void GeometryStrainRenderer::init() {
VisualizationProcessor::init(); VisualizationProcessor::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/geometrystrainrenderer.frag", ""); _shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/geometrystrainrenderer.frag", "");
if (_shader != 0) {
_shader->setAttributeLocation(0, "in_Position");
}
} }
void GeometryStrainRenderer::deinit() { void GeometryStrainRenderer::deinit() {
......
...@@ -75,10 +75,6 @@ namespace campvis { ...@@ -75,10 +75,6 @@ namespace campvis {
void StrainFiberRenderer::init() { void StrainFiberRenderer::init() {
VisualizationProcessor::init(); VisualizationProcessor::init();
_shader = ShdrMgr.load("modules/columbia/glsl/strainfiberrenderer.vert", "modules/columbia/glsl/strainfiberrenderer.geom", "modules/columbia/glsl/strainfiberrenderer.frag", generateGlslHeader()); _shader = ShdrMgr.load("modules/columbia/glsl/strainfiberrenderer.vert", "modules/columbia/glsl/strainfiberrenderer.geom", "modules/columbia/glsl/strainfiberrenderer.frag", generateGlslHeader());
if (_shader != 0) {
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
invalidate(AbstractProcessor::INVALID_SHADER); invalidate(AbstractProcessor::INVALID_SHADER);
} }
......
...@@ -77,8 +77,6 @@ namespace campvis { ...@@ -77,8 +77,6 @@ namespace campvis {
void DevilImageReader::init() { void DevilImageReader::init() {
AbstractImageReader::init(); AbstractImageReader::init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", "#define NO_DEPTH\n"); _shader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", "#define NO_DEPTH\n");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
} }
void DevilImageReader::deinit() { void DevilImageReader::deinit() {
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
// //
// ================================================================================================ // ================================================================================================
in vec3 in_Position; ///< incoming vertex position layout(location = 0) in vec3 in_Position; ///< incoming vertex position
in vec3 in_TexCoord; ///< incoming texture coordinate layout(location = 1) in vec3 in_TexCoord; ///< incoming texture coordinate
in vec4 in_Color; ///< incoming color layout(location = 2) in vec4 in_Color; ///< incoming color
out vec3 vert_TexCoord; ///< outgoing texture coordinate out vec3 vert_TexCoord; ///< outgoing texture coordinate
out vec4 vert_Position; ///< outgoing world coordinates out vec4 vert_Position; ///< outgoing world coordinates
......
...@@ -82,10 +82,6 @@ namespace dti { ...@@ -82,10 +82,6 @@ namespace dti {
void FiberRenderer::init() { void FiberRenderer::init() {
VisualizationProcessor::init(); VisualizationProcessor::init();
_shader = ShdrMgr.load("modules/dti/glsl/fiberrenderer.vert", "modules/dti/glsl/fiberrenderer.geom", "modules/dti/glsl/fiberrenderer.frag", generateGlslHeader()); _shader = ShdrMgr.load("modules/dti/glsl/fiberrenderer.vert", "modules/dti/glsl/fiberrenderer.geom", "modules/dti/glsl/fiberrenderer.frag", generateGlslHeader());
if (_shader != 0) {
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
invalidate(AbstractProcessor::INVALID_SHADER); invalidate(AbstractProcessor::INVALID_SHADER);
} }
......
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