The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated 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 56724724 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Fixing commit 5f72759e:

C++ implicit conversion rules made ShaderManager::loadSeparate() ambiguous in some cases. So I decided to cut loose ends and completely refactored loading with standard version into ShaderManager::load() and loading with custom version into ShaderManager::loadWithCustomGlslVersion().
ShaderManager::loadSeparate() is no longer available!
parent 5f72759e
......@@ -124,7 +124,7 @@ namespace campvis {
void CampVisPainter::init() {
try {
// TODO: Remove hardcoded paths, and use ShdrMgr.addPath() at some central location
_copyShader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", "", false);
_copyShader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", "");
}
catch (tgt::Exception& e) {
LERRORC("main.cpp", "Encountered tgt::Exception: " << e.what());
......
......@@ -88,8 +88,8 @@ namespace campvis {
_widget = _pWidget;
GLJobProc.registerContext(this);
_paintShader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "application/glsl/datacontainerinspector.frag", "", false);
_geometryRenderingShader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "application/glsl/datacontainerinspector_geometryrenderer.frag", "", false);
_paintShader = ShdrMgr.load("core/glsl/passthrough.vert", "application/glsl/datacontainerinspector.frag", "");
_geometryRenderingShader = ShdrMgr.load("core/glsl/passthrough.vert", "application/glsl/datacontainerinspector_geometryrenderer.frag", "");
_paintShader->setAttributeLocation(0, "in_Position");
_paintShader->setAttributeLocation(1, "in_TexCoords");
......
......@@ -127,7 +127,7 @@ namespace campvis {
template<class T>
void campvis::GenericGeometryTransferFunction<T>::initShader() {
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "core/glsl/passthrough.frag", "", false);
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/passthrough.frag", "");
if (_shader != 0) {
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(2, "in_Color");
......
......@@ -64,7 +64,7 @@ namespace campvis {
void RaycastingProcessor::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", _fragmentShaderFilename, generateHeader(), false);
_shader = ShdrMgr.load("core/glsl/passthrough.vert", _fragmentShaderFilename, generateHeader());
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
......
......@@ -50,9 +50,9 @@ namespace campvis {
, _shader3d(0)
, _fbo(0)
{
_shader1d = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "core/glsl/tools/glreduction.frag", generateGlslHeader(_reductionOperator) + "#define REDUCTION_1D\n", false);
_shader2d = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "core/glsl/tools/glreduction.frag", generateGlslHeader(_reductionOperator) + "#define REDUCTION_2D\n", false);
_shader3d = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "core/glsl/tools/glreduction.frag", generateGlslHeader(_reductionOperator) + "#define REDUCTION_3D\n", false);
_shader1d = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/tools/glreduction.frag", generateGlslHeader(_reductionOperator) + "#define REDUCTION_1D\n");
_shader2d = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/tools/glreduction.frag", generateGlslHeader(_reductionOperator) + "#define REDUCTION_2D\n");
_shader3d = ShdrMgr.load("core/glsl/passthrough.vert", "core/glsl/tools/glreduction.frag", generateGlslHeader(_reductionOperator) + "#define REDUCTION_3D\n");
if (_shader1d == 0 || _shader2d == 0 || _shader3d == 0) {
LERROR("Could not load Shader for OpenGL reduction. Reduction will not work!");
return;
......
......@@ -1308,33 +1308,23 @@ ShaderManager::ShaderManager()
: ResourceManager<Shader>(false)
{}
Shader* ShaderManager::load(const string& filename, const string& customHeader,
bool activate, const std::string& customGlslVersion /*= ""*/)
throw (Exception)
{
return loadSeparate(filename + ".vert", filename + ".frag", customHeader, activate, customGlslVersion);
Shader* ShaderManager::load(const std::string& vertFilename, const std::string& fragFilename, const std::string& customHeader) throw (Exception) {
return loadWithCustomGlslVersion(vertFilename, "", fragFilename, customHeader, "");
}
Shader* ShaderManager::loadSeparate(const string& vert_filename, const string& frag_filename,
const string& customHeader, bool activate, const std::string& customGlslVersion /*= ""*/)
throw (Exception)
{
return loadSeparate(vert_filename, "", frag_filename, customHeader, activate, customGlslVersion);
Shader* ShaderManager::load(const std::string& vertFilename, const std::string& geomFilename, const std::string& fragFilename, const std::string& customHeader) throw(Exception) {
return loadWithCustomGlslVersion(vertFilename, geomFilename, fragFilename, customHeader, "");
}
Shader* ShaderManager::loadSeparate(const string& vert_filename, const string& geom_filename,
const string& frag_filename,
const string& customHeader, bool activate, const std::string& customGlslVersion /*= ""*/)
throw (Exception)
{
LDEBUG("Loading files " << vert_filename << " and " << frag_filename);
Shader* ShaderManager::loadWithCustomGlslVersion(const std::string& vertFilename, const std::string& geomFilename, const std::string& fragFilename, const std::string& customHeader, const std::string& customGlslVersion) throw(Exception) {
LDEBUG("Loading files " << vertFilename << " and " << fragFilename);
if (!GpuCaps.areShadersSupported()) {
LERROR("Shaders are not supported.");
throw Exception("Shaders are not supported.");
}
// create a somewhat unique identifier for this shader triple
string identifier = vert_filename + "#" + frag_filename + "#" + geom_filename;
string identifier = vertFilename + "#" + fragFilename + "#" + geomFilename;
if (isLoaded(identifier)) {
LDEBUG("Shader already loaded. Increase usage count.");
......@@ -1346,27 +1336,25 @@ Shader* ShaderManager::loadSeparate(const string& vert_filename, const string& g
// searching in all paths for every shader
string vert_completeFilename;
if (!vert_filename.empty())
vert_completeFilename = completePath(vert_filename);
if (!vertFilename.empty())
vert_completeFilename = completePath(vertFilename);
string geom_completeFilename;
if (!geom_filename.empty())
geom_completeFilename = completePath(geom_filename);
if (!geomFilename.empty())
geom_completeFilename = completePath(geomFilename);
string frag_completeFilename;
if (!frag_filename.empty())
frag_completeFilename = completePath(frag_filename);
if (!fragFilename.empty())
frag_completeFilename = completePath(fragFilename);
// loading and linking found shaders
try {
shdr->loadSeparate(vert_completeFilename, geom_completeFilename,
frag_completeFilename, customHeader);
frag_completeFilename, customHeader, customGlslVersion);
// register even when caching is disabled, needed for rebuildFromFile()
reg(shdr, identifier);
if (activate)
shdr->activate();
return shdr;
}
catch (const Exception& /*e*/) {
......@@ -1387,4 +1375,5 @@ bool ShaderManager::rebuildAllShadersFromFile() {
return result;
}
} // namespace
......@@ -424,54 +424,52 @@ public:
ShaderManager();
/**
* Load filename.vert and filename.frag (vertex and fragment shader), link shader and
* activate it by default.
*
* @param customHeader Header to be put in front of the shader source
* @param activate activate the shader after loading
*
* @return The loaded shader
*
* @throw Exception if loading failed
* Load given shaders from file and link them.
* Empty file names will be ignored (not loaded and linked). You have to pass the complete
* file names, inclusive file extensions (".vert", ".geom", frag").
*
* \param vertFilename Vertex shader file name
* \param fragFilename Fragment shader file name
* \param customHeader Custom header to add to all shaders (may be empty)
* \throw Exception if loading failed.
* \return The newly created shader.
*/
Shader* load(const std::string& filename, const std::string& customHeader = "",
bool activate = true, const std::string& customGlslVersion = "")
Shader* load(const std::string& vertFilename, const std::string& fragFilename,
const std::string& customHeader)
throw (Exception);
/**
* Load vertex shader \p vertFilename and fragment shader \p fragFilename,
* link shader and activate it by default.
*
* You have to pass the complete filenames, inclusive file extensions (".vert", ".frag").
*
* @param customHeader header to be put in front of the shader source
* @param activate activate the shader after loading
*
* @return The loaded shader
*
* @throw Exception if loading failed
* Load given shaders from file and link them.
* Empty file names will be ignored (not loaded and linked). You have to pass the complete
* file names, inclusive file extensions (".vert", ".geom", frag").
*
* \param vertFilename Vertex shader file name
* \param geomFilename Geometry shader file name (leave empty to disable geometry shader)
* \param fragFilename Fragment shader file name
* \param customHeader Custom header to add to all shaders (may be empty)
* \throw Exception if loading failed.
* \return The newly created shader.
*/
Shader* loadSeparate(const std::string& vertFilename, const std::string& fragFilename,
const std::string& customHeader = "", bool activate = true, const std::string& customGlslVersion = "")
throw (Exception);
Shader* load(const std::string& vertFilename, const std::string& geomFilename, const std::string& fragFilename,
const std::string& customHeader)
throw(Exception);
/**
* Load vertex shader \p vertFilename, geometry shader \p geomFilename,
* fragment shader \p fragFilename, link shader and activate it by default.
*
* You have to pass the complete filenames, inclusive file extensions (".vert", ".geom", frag").
*
* @param customHeader header to be put in front of the shader source
* @param activate activate the shader after loading
*
* @return The loaded shader
*
* @throw Exception if loading failed
* Load given shaders from file and link them.
* Empty file names will be ignored (not loaded and linked). You have to pass the complete
* file names, inclusive file extensions (".vert", ".geom", frag").
*
* \param vertFilename Vertex shader file name
* \param geomFilename Geometry shader file name (leave empty to disable geometry shader)
* \param fragFilename Fragment shader file name
* \param customHeader Custom header to add to all shaders (may be empty)
* \param customGlslVersion Custom GLSL version for all shaders (leave empty to use default GLSL version from ShaderManager).
* \throw Exception if loading failed.
* \return The newly created shader.
*/
Shader* loadSeparate(const std::string& vertFilename, const std::string& geomFilename,
const std::string& fragFilename,
const std::string& customHeader, bool activate = true, const std::string& customGlslVersion = "")
throw(Exception);
Shader* loadWithCustomGlslVersion(const std::string& vertFilename, const std::string& geomFilename, const std::string& fragFilename,
const std::string& customHeader, const std::string& customGlslVersion)
throw(Exception);
bool rebuildAllShadersFromFile();
......
......@@ -98,7 +98,7 @@ namespace campvis {
void AdvancedUsFusion::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/advancedusvis/glsl/advancedusfusion.frag", generateHeader(), false);
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/advancedusvis/glsl/advancedusfusion.frag", generateHeader());
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
......
......@@ -63,7 +63,7 @@ namespace campvis {
void GeometryStrainRenderer::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/glsl/geometrystrainrenderer.frag", "", false);
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/geometrystrainrenderer.frag", "");
if (_shader != 0) {
_shader->setAttributeLocation(0, "in_Position");
}
......
......@@ -72,7 +72,7 @@ namespace campvis {
void StrainFiberRenderer::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("modules/columbia/glsl/strainfiberrenderer.vert", "modules/columbia/glsl/strainfiberrenderer.geom", "modules/columbia/glsl/strainfiberrenderer.frag", "", false);
_shader = ShdrMgr.load("modules/columbia/glsl/strainfiberrenderer.vert", "modules/columbia/glsl/strainfiberrenderer.geom", "modules/columbia/glsl/strainfiberrenderer.frag", "");
if (_shader != 0) {
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
......
......@@ -71,7 +71,7 @@ namespace campvis {
void DevilImageReader::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "core/glsl/copyimage.frag", "#define NO_DEPTH\n", false);
_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");
}
......
......@@ -63,7 +63,7 @@ namespace campvis {
void IxpvCompositor::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/ixpv/glsl/ixpvcompositor.frag", "", false);
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/ixpv/glsl/ixpvcompositor.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
......
......@@ -63,7 +63,7 @@ namespace campvis {
void GlGradientVolumeGenerator::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glgradientvolumegenerator.frag", generateHeader(), false);
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glgradientvolumegenerator.frag", generateHeader());
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
......
......@@ -58,7 +58,7 @@ namespace campvis {
void GlImageResampler::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glimageresampler.frag", "", false);
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/preprocessing/glsl/glimageresampler.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
......
......@@ -96,15 +96,15 @@ namespace campvis {
void SimilarityMeasure::init() {
VisualizationProcessor::init();
_sadssdCostFunctionShader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/registration/glsl/similaritymeasuresadssd.frag", "", false);
_sadssdCostFunctionShader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/registration/glsl/similaritymeasuresadssd.frag", "");
_sadssdCostFunctionShader->setAttributeLocation(0, "in_Position");
_sadssdCostFunctionShader->setAttributeLocation(1, "in_TexCoord");
_nccsnrCostFunctionShader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/registration/glsl/similaritymeasurenccsnr.frag", "", false);
_nccsnrCostFunctionShader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/registration/glsl/similaritymeasurenccsnr.frag", "");
_nccsnrCostFunctionShader->setAttributeLocation(0, "in_Position");
_nccsnrCostFunctionShader->setAttributeLocation(1, "in_TexCoord");
_differenceShader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/registration/glsl/differenceimage.frag", "", false);
_differenceShader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/registration/glsl/differenceimage.frag", "");
_differenceShader->setAttributeLocation(0, "in_Position");
_differenceShader->setAttributeLocation(1, "in_TexCoord");
......
......@@ -66,7 +66,7 @@ namespace campvis {
void DepthDarkening::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/glsl/depthdarkening.frag", generateHeader(), false);
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/depthdarkening.frag", generateHeader());
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
......
......@@ -73,7 +73,7 @@ namespace campvis {
void EEPGenerator::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/glsl/eepgenerator.frag", generateHeader(), false);
_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");
......
......@@ -87,8 +87,8 @@ namespace campvis {
void GeometryRenderer::init() {
VisualizationProcessor::init();
_pointShader = ShdrMgr.loadSeparate("modules/vis/glsl/geometryrenderer.vert", "modules/vis/glsl/geometryrenderer.frag", generateGlslHeader(false), false);
_meshShader = ShdrMgr.loadSeparate("modules/vis/glsl/geometryrenderer.vert", "modules/vis/glsl/geometryrenderer_faces.geom", "modules/vis/glsl/geometryrenderer.frag", generateGlslHeader(true), false);
_pointShader = ShdrMgr.load("modules/vis/glsl/geometryrenderer.vert", "modules/vis/glsl/geometryrenderer.frag", generateGlslHeader(false));
_meshShader = ShdrMgr.load("modules/vis/glsl/geometryrenderer.vert", "modules/vis/glsl/geometryrenderer_faces.geom", "modules/vis/glsl/geometryrenderer.frag", generateGlslHeader(true));
}
void GeometryRenderer::deinit() {
......
......@@ -59,7 +59,7 @@ namespace campvis {
void QuadView::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/glsl/quadview.frag", "", false);
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/quadview.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
......
......@@ -72,7 +72,7 @@ namespace campvis {
void RenderTargetCompositor::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/glsl/rendertargetcompositor.frag", "", false);
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/rendertargetcompositor.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
......
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