Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

Commit 9a834357 authored by Jakob Weiss's avatar Jakob Weiss

Merge branch 'campvis-nx' of gitlab.lrz.de:weiss/campvis-nx into campvis-nx

# Conflicts:
#	ext/cgt/texture.cpp
parents 1e8bb380 609563e6
......@@ -98,7 +98,7 @@ namespace campvis {
// converting from GL representation
GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* toReturn = nullptr;
GLJobProc.enqueueJobBlocking([&]() {
if (cgt::Texture::calcMatchingDataType(tester->getTexture()->getInternalFormat()) != TypeTraits<BASETYPE, NUMCHANNELS>::glDataType)
if (cgt::Texture::calcMatchingPixelDataType(tester->getTexture()->getInternalFormat()) != TypeTraits<BASETYPE, NUMCHANNELS>::glDataType)
LDEBUGC("CAMPVis.core.datastructures.GenericLocalConversion", "Performing conversion between data types, you may lose information or the resulting data may show other unexpected features.");
WeaklyTypedPointer wtp = tester->getWeaklyTypedPointerConvert(TypeTraits<BASETYPE, NUMCHANNELS>::glDataType);
......
......@@ -201,15 +201,15 @@ namespace campvis {
}
const WeaklyTypedPointer ImageRepresentationGL::getWeaklyTypedPointerCopy() const {
GLint format = cgt::Texture::calcMatchingFormat(_texture->getInternalFormat());
GLenum dataType = cgt::Texture::calcMatchingDataType(_texture->getInternalFormat());
GLint format = cgt::Texture::calcMatchingPixelFormat(_texture->getInternalFormat());
GLenum dataType = cgt::Texture::calcMatchingPixelDataType(_texture->getInternalFormat());
GLubyte* data = _texture->downloadTextureToBuffer(format, dataType);
return WeaklyTypedPointer(WeaklyTypedPointer::baseType(dataType), _texture->getNumChannels(), data);
}
const WeaklyTypedPointer ImageRepresentationGL::getWeaklyTypedPointerConvert(GLenum dataType) const {
GLint format = cgt::Texture::calcMatchingFormat(_texture->getInternalFormat());
GLint format = cgt::Texture::calcMatchingPixelFormat(_texture->getInternalFormat());
GLubyte* data = _texture->downloadTextureToBuffer(format, dataType);
return WeaklyTypedPointer(WeaklyTypedPointer::baseType(dataType), _texture->getNumChannels(), data);
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2015, 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.
//
// ================================================================================================
// (c) 2016 Jakob Weiss <jakob.weiss@tum.de>
#include "cshelper.h"
#include <sstream>
#include <cgt/texture.h>
#include <cgt/imageunit.h>
#include <cgt/gltextureformattraits.h>
namespace campvis {
namespace CSHelper {
//const std::string loggerCat_ = "CAMPVis.core.tools.CSHelper";
CAMPVIS_CORE_API std::string generateGLSLImageDefinition(const cgt::Texture & tex, const std::string& uniformName, const cgt::ImageUnit& imgUnit)
{
std::stringstream ss;
auto fmtTraits = cgt::GLTextureFormatTraits::get(tex.getInternalFormat());
ss << "layout(" << fmtTraits.glslFormatQualifier() << ", binding = " << imgUnit.getUnitNumber() << ") uniform "; // "layout( (r8|r16|rgba16|...) uniform"
ss << (fmtTraits.isIntegerFormat() ? (fmtTraits.isSignedFormat() ? "iimage" : "uimage") : "image"); // "(i|u|_)image"
ss << ( (tex.getType() == GL_TEXTURE_1D) ? 1 : ( (tex.getType() == GL_TEXTURE_2D) ? 2 : 3) ) << "D "; // "(1|2|3)D"
ss << uniformName << ";" << std::endl;
return ss.str();
}
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2015, 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.
//
// ================================================================================================
// (c) 2016 Jakob Weiss <jakob.weiss@tum.de>
#ifndef CSHELPER_H__
#define CSHELPER_H__
#include <string>
#include "core/coreapi.h"
namespace cgt {
class Texture;
class ImageUnit;
}
namespace campvis {
/**
* CSHelper namespace
* Collection of various helper classes and functions to simplify using Compute Shaders for various applications
*/
namespace CSHelper {
/// Loggin category for the LDEBUG macros
//const std::string loggerCat_;
/**
* Generates a glsl image definition that matches the texture type and layout
*/
CAMPVIS_CORE_API std::string generateGLSLImageDefinition(const cgt::Texture& tex, const std::string& uniformName, const cgt::ImageUnit& imgUnit);
}
}
#endif // CSHELPER_H__
......@@ -176,7 +176,7 @@ namespace campvis {
}
// read back stuff
GLenum readBackFormat = cgt::Texture::calcMatchingFormat(outputTex->getInternalFormat());
GLenum readBackFormat = cgt::Texture::calcMatchingPixelFormat(outputTex->getInternalFormat());
size_t channels = outputTex->getNumChannels();
toReturn.resize(channels);
glReadBuffer(GL_COLOR_ATTACHMENT0);
......
......@@ -31,6 +31,7 @@ SET(CGT_SOURCES
glcontextmanager.cpp
gpucapabilities.cpp
gpucapabilitieswindows.cpp
imageunit.cpp
init.cpp
logmanager.cpp
job.cpp
......
This diff is collapsed.
......@@ -107,6 +107,11 @@ bool GpuCapabilities::areShadersSupported() {
return shaderSupport_;
}
bool GpuCapabilities::areComputeShadersSupported()
{
return computeShaderSupport_;
}
bool GpuCapabilities::areShadersSupportedARB() {
return shaderSupportARB_;
}
......@@ -139,6 +144,11 @@ int GpuCapabilities::getNumTextureUnits() {
return numTextureUnits_;
}
int GpuCapabilities::getNumImageUnits()
{
return numImageUnits_;
}
bool GpuCapabilities::isNpotSupported() {
return npotTextures_;
}
......@@ -291,6 +301,7 @@ void GpuCapabilities::detectCapabilities() {
shaderSupport_ = (glVersion_ >= GlVersion::CGT_GL_VERSION_2_0);
shaderSupportARB_ = (isExtensionSupported("GL_ARB_vertex_program") &&
isExtensionSupported("GL_ARB_fragment_program"));
computeShaderSupport_ = (glVersion_ >= GlVersion::CGT_GL_VERSION_4_3);
if (!shaderVersion_.parseVersionString(glslVersionString_)) {
LERROR("Malformed GLSL version string: " << glslVersionString_);
......@@ -336,6 +347,8 @@ void GpuCapabilities::detectCapabilities() {
if (numTextureUnits_ < 0)
glGetIntegerv(GL_MAX_TEXTURE_UNITS, (GLint *) &numTextureUnits_);
glGetIntegerv(GL_MAX_IMAGE_UNITS, (GLint*)&numImageUnits_);
npotTextures_ = (isExtensionSupported("GL_ARB_texture_non_power_of_two"));
#if defined(__APPLE__) || defined(__linux__)
// No NPOT support on older ATI Macs and Linux.
......
......@@ -258,13 +258,19 @@ public:
std::string getShadingLanguageVersionString();
/**
* Returns wether shaders are supported, which
* Returns whether shaders are supported, which
* is true for OpenGL version 2.0 or later.
*/
bool areShadersSupported();
/**
* Returns wether the ARB shader extensions
* Returns whether shaders are supported, which
* is true for OpenGL version 4.3 or later.
*/
bool areComputeShadersSupported();
/**
* Returns whether the ARB shader extensions
* are supported (GL_ARB_vertex_program and
* GL_ARB_fragment_program).
*
......@@ -326,6 +332,12 @@ public:
*/
int getNumTextureUnits();
/**
* Returns the number of image units
* provided by the GPU.
*/
int getNumImageUnits();
/**
* Returns wether non-power-of-two textures
* are supported (extension GL_ARB_texture_non_power_of_two).
......@@ -429,6 +441,7 @@ private:
bool shaderSupport_;
bool shaderSupportARB_;
bool computeShaderSupport_;
GlVersion shaderVersion_;
ShaderModel shaderModel_;
......@@ -436,6 +449,7 @@ private:
bool texturing3D_;
int max3DTexSize_;
int numTextureUnits_;
int numImageUnits_;
bool npotTextures_;
bool textureRectangles_;
bool anisotropicFiltering_;
......
#include "imageunit.h"
#include "imageunit.h"
/**********************************************************************
* *
* cgt - CAMP Graphics Toolbox, Copyright (C) 2012-2015 *
* Chair for Computer Aided Medical Procedures *
* Technische Universitaet Muenchen, Germany. *
* <http://campar.in.tum.de/> *
* *
* forked from tgt - Tiny Graphics Toolbox, Copyright (C) 2006-2011 *
* Visualization and Computer Graphics Group, Department of *
* Computer Science, University of Muenster, Germany. *
* <http://viscg.uni-muenster.de> *
* *
* This file is part of the cgt library. This library is free *
* software; you can redistribute it and/or modify it under the terms *
* of the GNU Lesser General Public License version 2.1 as published *
* by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License in the file "LICENSE.txt" along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
**********************************************************************/
#include "cgt/imageunit.h"
#include "cgt/gpucapabilities.h"
#include "cgt/assert.h"
namespace cgt {
bool ImageUnit::initialized_ = false;
unsigned short ImageUnit::totalActive_ = 0;
unsigned short ImageUnit::maxTexUnits_ = 0;
unsigned short ImageUnit::numKeptUnits_ = 0;
std::vector<bool> ImageUnit::busyUnits_ = std::vector<bool>();
tbb::spin_mutex ImageUnit::mutex_ = tbb::spin_mutex();
ImageUnit::ImageUnit(bool keep)
: number_(0)
, assigned_(false)
{
if (!initialized_)
init();
}
void ImageUnit::init() {
tbb::spin_mutex::scoped_lock lock(mutex_);
if (initialized_)
return;
maxTexUnits_ = GpuCaps.getNumImageUnits();
busyUnits_ = std::vector<bool>(maxTexUnits_, false);
numKeptUnits_ = 0;
initialized_ = true;
}
ImageUnit::~ImageUnit() {
if(assigned_)
releaseUnit();
}
ImageUnit::ImageUnit(ImageUnit && other)
{
*this = std::move(other);
}
ImageUnit & ImageUnit::operator=(ImageUnit && rhs)
{
if (this == &rhs)
return *this;
if (assigned_)
releaseUnit();
assigned_ = rhs.assigned_;
number_ = rhs.number_;
rhs.assigned_ = false;
rhs.number_ = 0;
return *this;
}
GLint ImageUnit::getUnitNumber() const {
if (!assigned_)
assignUnit();
return number_;
}
void ImageUnit::cleanup() {
tbb::spin_mutex::scoped_lock lock(mutex_);
for (size_t i = 0; i < maxTexUnits_; i++) {
if (busyUnits_.at(i))
busyUnits_.at(i) = false;
}
totalActive_ = 0;
numKeptUnits_ = 0;
}
bool ImageUnit::unused() {
return (totalActive_ == 0);
}
unsigned short ImageUnit::numLocalActive() {
return (totalActive_ - numKeptUnits_);
}
void ImageUnit::assignUnit() const {
tbb::spin_mutex::scoped_lock lock(mutex_);
cgtAssert(totalActive_ <= maxTexUnits_, "No more texture units available");
assigned_ = true;
for (size_t i = 0; i < maxTexUnits_; i++) {
if (!busyUnits_.at(i)) {
number_ = (GLint)i;
busyUnits_.at(i) = true;
totalActive_++;
break;
}
}
}
void ImageUnit::releaseUnit()
{
tbb::spin_mutex::scoped_lock lock(mutex_);
busyUnits_.at(number_) = false;
totalActive_--;
}
} // namespace
/**********************************************************************
* *
* cgt - CAMP Graphics Toolbox, Copyright (C) 2012-2015 *
* Chair for Computer Aided Medical Procedures *
* Technische Universitaet Muenchen, Germany. *
* <http://campar.in.tum.de/> *
* *
* forked from tgt - Tiny Graphics Toolbox, Copyright (C) 2006-2011 *
* Visualization and Computer Graphics Group, Department of *
* Computer Science, University of Muenster, Germany. *
* <http://viscg.uni-muenster.de> *
* *
* This file is part of the cgt library. This library is free *
* software; you can redistribute it and/or modify it under the terms *
* of the GNU Lesser General Public License version 2.1 as published *
* by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License in the file "LICENSE.txt" along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
**********************************************************************/
#ifndef CGT_IMAGEUNIT_H
#define CGT_IMAGEUNIT_H
#include <string>
#include <tbb/spin_mutex.h>
#include "cgt/cgt_gl.h"
#include "cgt/shadermanager.h"
namespace cgt {
/**
* OpenGL Image Unit
*/
class CGT_API ImageUnit {
public:
ImageUnit(bool keep = false);
~ImageUnit();
void releaseUnit();
// copy construction and assignment is not allowed
ImageUnit(const ImageUnit& other) = delete;
ImageUnit& operator=(const ImageUnit& other) = delete;
// move construction and assignment is possible
ImageUnit(ImageUnit&& other);
ImageUnit& operator=(ImageUnit&& rhs);
GLint getUnitNumber() const;
static void cleanup();
static unsigned short numLocalActive();
/**
* Returns true if no texture units are currently assigned.
*/
static bool unused();
protected:
void assignUnit() const;
static void init();
mutable GLint number_;
mutable bool assigned_;
static bool initialized_;
static unsigned short totalActive_;
static unsigned short maxTexUnits_;
static unsigned short numKeptUnits_;
static std::vector<bool> busyUnits_;
static tbb::spin_mutex mutex_;
};
} // namespace cgt
#endif // CGT_IMAGEUNIT_H
......@@ -32,6 +32,7 @@
#include <iostream>
#include <fstream>
#include <memory>
using std::string;
......@@ -602,9 +603,9 @@ void Shader::loadSeparate(const string& vert_filename, const string& geom_filena
const string& frag_filename, const string& customHeader, const std::string& customGlslVersion)
throw (Exception)
{
ShaderObject* frag = 0;
ShaderObject* vert = 0;
ShaderObject* geom = 0;
ShaderObject* frag = nullptr;
ShaderObject* vert = nullptr;
ShaderObject* geom = nullptr;
if (!vert_filename.empty()) {
vert = new ShaderObject(vert_filename, ShaderObject::VERTEX_SHADER);
......@@ -629,7 +630,8 @@ void Shader::loadSeparate(const string& vert_filename, const string& geom_filena
if (!vert->compileShader()) {
LERROR("Failed to compile vertex shader " << vert_filename);
LERROR("Compiler Log: \n" << vert->getCompilerLog());
LERROR("************* Compiler Log *************" << std::endl << vert->getCompilerLog());
LDEBUG("************* Vertex Shader Code *************" << std::endl << vert->getParsedSource());
delete vert;
throw Exception("Failed to compile vertex shader: " + vert_filename);
}
......@@ -658,7 +660,8 @@ void Shader::loadSeparate(const string& vert_filename, const string& geom_filena
geom->uploadSource();
if (!geom->compileShader()) {
LERROR("Failed to compile geometry shader " << geom_filename);
LERROR("Compiler Log: \n" << geom->getCompilerLog());
LERROR("************* Compiler Log *************" << std::endl << geom->getCompilerLog());
LDEBUG("************* Geometry Shader Code *************" << std::endl << geom->getParsedSource());
delete vert;
delete geom;
throw Exception("Failed to compile geometry shader: " + geom_filename);
......@@ -693,7 +696,8 @@ void Shader::loadSeparate(const string& vert_filename, const string& geom_filena
if (!frag->compileShader()) {
LERROR("Failed to compile fragment shader " << frag_filename);
LERROR("Compiler Log: \n" << frag->getCompilerLog());
LERROR("************* Compiler Log ************* \n" << frag->getCompilerLog());
LDEBUG("************* Fragment Shader Code *************" << std::endl << frag->getParsedSource());
delete vert;
delete geom;
delete frag;
......@@ -735,14 +739,18 @@ void Shader::loadSeparate(const string& vert_filename, const string& geom_filena
if (vert && vert->getCompilerLog().size() > 1) {
LDEBUG("Vertex shader compiler log for file '" << vert_filename
<< "': \n" << vert->getCompilerLog());
LDEBUG("************* Vertex Shader Code *************" << std::endl << vert->getParsedSource());
}
if (geom && geom->getCompilerLog().size() > 1) {
LDEBUG("Geometry shader compiler log for file '" << geom_filename
<< "': \n" << geom->getCompilerLog());
LDEBUG("************* Geometry Shader Code *************" << std::endl << geom->getParsedSource());
}
if (frag && frag->getCompilerLog().size() > 1) {
LDEBUG("Fragment shader compiler log for file '" << frag_filename
<< "': \n" << frag->getCompilerLog());
LDEBUG("************* Fragment Shader Code *************" << std::endl << frag->getParsedSource());
}
if (getLinkerLog().size() > 1) {
......@@ -752,6 +760,70 @@ void Shader::loadSeparate(const string& vert_filename, const string& geom_filena
}
}
void Shader::loadCompute(const string& compFilename, const string& customHeader, const string& customGlslVersion)
throw (Exception)
{
ShaderObject *comp;
if (!compFilename.empty()) {
comp = new ShaderObject(compFilename, ShaderObject::COMPUTE_SHADER);
if (!customHeader.empty()) {
comp->setHeader(customHeader);
}
if (!customGlslVersion.empty()) {
comp->setCustomGlslVersion(customGlslVersion);
}
else {
comp->setCustomGlslVersion("430");
}
try {
comp->loadSourceFromFile(compFilename);
}
catch (const Exception& e) {
LDEBUG("Failed to load compute shader " << compFilename << ": " << e.what());
delete comp;
throw Exception("Failed to load vertex shader " + compFilename + ": " + e.what());
}
comp->uploadSource();
if (!comp->compileShader()) {
LERROR("Failed to compile Compute shader " << compFilename);
LERROR("************* Compiler Log *************" << std::endl << comp->getCompilerLog());
LDEBUG("************* Compute Shader Code *************" << std::endl << comp->getParsedSource());
delete comp;
throw Exception("Failed to compile vertex shader: " + compFilename);
}
}
// Attach ShaderObjects, dtor will take care of freeing them
if (comp)
attachObject(comp);
if (!linkProgram()) {
LERROR("Failed to link shader (" << compFilename << ")");
LERROR(comp->filename_ << " Compute shader compiler log: \n" << comp->getCompilerLog());
detachObject(comp);
LERROR("************* Linker Log *************\n" << getLinkerLog());
LDEBUG("************* Compute Shader Code *************" << std::endl << comp->getParsedSource());
throw Exception("Failed to link shader (" + compFilename + ")");
}
if (comp && comp->getCompilerLog().size() > 1) {
LDEBUG("Compute shader compiler log for file '" << compFilename << "': \n" << comp->getCompilerLog());
}
if (getLinkerLog().size() > 1) {
LDEBUG("Linker log for '" << compFilename << "': \n" << getLinkerLog());
}
}
GLint Shader::getUniformLocation(const string& name) {
GLint l;
l = glGetUniformLocation(id_, name.c_str());
......@@ -1316,6 +1388,45 @@ Shader* ShaderManager::load(const std::string& vertFilename, const std::string&
return loadWithCustomGlslVersion(vertFilename, geomFilename, fragFilename, customHeader, "");
}
Shader * ShaderManager::loadCompute(const std::string& compFilename, const std::string & customHeader, const std::string & customGlslVersion) throw(Exception)
{
//LDEBUG("Loading files " << vertFilename << " and " << fragFilename);
if (!GpuCaps.areComputeShadersSupported()) {
LERROR("Compute Shaders are not supported (Requires OpenGL 4.3 capable device).");
throw Exception("Compute Shaders are not supported.");
}
// create a somewhat unique identifier for this shader triple
string identifier = compFilename;
if (isLoaded(identifier)) {
LDEBUG("Shader already loaded. Increase usage count.");
increaseUsage(identifier);
return get(identifier);
}
Shader* shdr = new Shader();
// searching in all paths for every shader
string completeFilename;
if (!compFilename.empty())
completeFilename = completePath(compFilename);
// loading and linking found shaders
try {
shdr->loadCompute(completeFilename, customHeader, customGlslVersion);
// register even when caching is disabled, needed for rebuildFromFile()
reg(shdr, identifier);
return shdr;
}
catch (const Exception& /*e*/) {
delete shdr;
throw;
}
}
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()) {
......
......@@ -71,7 +71,8 @@ public:
enum ShaderType {
VERTEX_SHADER = GL_VERTEX_SHADER,
FRAGMENT_SHADER = GL_FRAGMENT_SHADER,
GEOMETRY_SHADER = GL_GEOMETRY_SHADER_EXT
GEOMETRY_SHADER = GL_GEOMETRY_SHADER_EXT,
COMPUTE_SHADER = GL_COMPUTE_SHADER
};
// Helper for resolving line number when includes are used in shader files
......@@ -126,7 +127,9 @@ public:
source_ = source;
unparsedSource_ = source;
}
const std::string getSource() { return unparsedSource_; }
const std::string getSource() const { return unparsedSource_; }
const std::string getParsedSource() const { return source_; };
/**
* Set geometry shader input type. For this change to take effect call setDirectives() and
......@@ -433,6 +436,16 @@ protected:
const std::string& fragFilename, const std::string& customHeader = "", const std::string& customGlslVersion = "")
throw (Exception);
/**
* Load compute shader \p compFilename
*
* @param customHeader header to be put in front of the shader source
*
* @throw Exception if loading failed
*/
void loadCompute(const std::string& compFilename, const std::string& customHeader, const std::string& customGlslVersion = "")
throw (Exception);
typedef std::list<ShaderObject*> ShaderObjects;
ShaderObjects objects_;
......@@ -494,6 +507,22 @@ public:
const std::string& customHeader)
throw(Exception);
/**
* Load the given compute shader.
* Empty file names will be ignored (not loaded and linked). You have to pass the complete
* file names, inclusive file extensions (".vert", ".geom", frag").
*
* Only works if OpenGL 4.3 or higher is supported.
*
* \param compFilename Compute shader file name
* \param customHeader Custom header to add (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* loadCompute(const std::string& compFilename, const std::string& customHeader, const std::string& customGlslVersion = "")
throw(Exception);
/**
* Load given shaders from file and link them.
* Empty file names will be ignored (not loaded and linked). You have to pass the complete
......
This diff is collapsed.
......@@ -33,6 +33,8 @@
#include "cgt/cgt_gl.h"
#include "cgt/types.h"
#include "cgt/vector.h"
#include "cgt/imageunit.h"
#include "cgt/gltextureformattraits.h"
namespace cgt {
......@@ -58,6 +60,12 @@ public:
MIRRORED_REPEAT = GL_MIRRORED_REPEAT
};
enum ElementTypeClass {
SIGNED,