Commit 445c22ba authored by Jakob Weiss's avatar Jakob Weiss
Browse files

Improvements to the CS support interface

* CSHelper ns contains methods to simplify boilerplate code
* some changes to the cgt::Texture interface
* Shader code now dumped to console when compilation fails (could still use some reworking, i.e. like line numbers)
* updated MedianFilter code
parent 2a6bc7a6
// ================================================================================================
//
// 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);
......
......@@ -29,7 +29,6 @@ SET(CGT_SOURCES
frustum.cpp
glcanvas.cpp
glcontextmanager.cpp
gltextureformattraits.cpp
gpucapabilities.cpp
gpucapabilitieswindows.cpp
imageunit.cpp
......
/**********************************************************************
* *
* 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 "gltextureformattraits.h"
namespace cgt {
//#define defFormat(INTERNAL_FORMAT, BPP, CHANNELS, PIXEL_FORMAT, PIXEL_DATA_TYPE, GLSL_FORMAT_QUALIFIER, GLSL_IMAGE_TYPE) \
//template <> \
//class GLTextureFormatTraits<INTERNAL_FORMAT> { \
// const std::string internalFormatName() { return #INTERNAL_FORMAT; }; \
// const int bpp() { return BPP; };\
// const int channels() { return CHANNELS; };\
// const GLint internalFormat() { return INTERNAL_FORMAT; };\
// const GLint pixelFormat() { return PIXEL_FORMAT; };\
// const GLint pixelDataType() { return PIXEL_DATA_TYPE; };\
// const std::string glslFormatQualifier() { return GLSL_FORMAT_QUALIFIER; };\
// const std::string glslImageType() { return GLSL_IMAGE_TYPE; };\
//};
#define defFormat(INTERNAL_FORMAT, BPP, CHANNELS, PIXEL_FORMAT, PIXEL_DATA_TYPE, GLSL_FORMAT_QUALIFIER) \
case INTERNAL_FORMAT: return GLTextureFormatTraits(INTERNAL_FORMAT, #INTERNAL_FORMAT, BPP, CHANNELS, PIXEL_FORMAT, PIXEL_DATA_TYPE, GLSL_FORMAT_QUALIFIER);
GLTextureFormatTraits GLTextureFormatTraits::get(GLint internalFormat)
{
switch(internalFormat) {
defFormat(GL_DEPTH_COMPONENT , 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT , "**UNKNOWN**");
defFormat(GL_R8 , 1, 1, GL_RED , GL_UNSIGNED_BYTE , "r8");
defFormat(GL_R8_SNORM , 1, 1, GL_RED , GL_BYTE , "r8_snorm");
defFormat(GL_R8I , 1, 1, GL_RED_INTEGER , GL_BYTE , "r8i");
defFormat(GL_R8UI , 1, 1, GL_RED_INTEGER , GL_UNSIGNED_BYTE , "r8ui");
defFormat(GL_R3_G3_B2 , 1, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**");
defFormat(GL_RGBA2 , 1, 4, GL_RGB , GL_UNSIGNED_BYTE , "**UNKNOWN**");
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_DEPTH_COMPONENT16 , 2, 1, GL_DEPTH_COMPONENT, GL_FLOAT , "**UNKNOWN**");
defFormat(GL_R16 , 2, 1, GL_RED , GL_UNSIGNED_SHORT, "r16");
defFormat(GL_R16_SNORM , 2, 1, GL_RED , GL_SHORT , "r16_snorm");
defFormat(GL_R16F , 2, 1, GL_RED , GL_FLOAT , "r16f");
defFormat(GL_R16I , 2, 1, GL_RED_INTEGER , GL_SHORT , "r16i");
defFormat(GL_R16UI , 2, 1, GL_RED_INTEGER , GL_UNSIGNED_SHORT, "r16ui");
defFormat(GL_DEPTH_STENCIL , 2, 1, GL_RG , GL_FLOAT , "**UNKNOWN**");
defFormat(GL_RG8 , 2, 2, GL_RG , GL_UNSIGNED_BYTE , "rg8");
defFormat(GL_RG8_SNORM , 2, 2, GL_RG , GL_BYTE , "rg8_snorm");
defFormat(GL_RG8I , 2, 2, GL_RG_INTEGER , GL_BYTE , "rg8i");
defFormat(GL_RG8UI , 2, 2, GL_RG_INTEGER , GL_UNSIGNED_BYTE , "rg8ui");
defFormat(GL_RGB4 , 2, 3, GL_RGB , GL_UNSIGNED_BYTE , "**UNKNOWN**");
defFormat(GL_RGB5 , 2, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**");
defFormat(GL_RGBA4 , 2, 4, GL_RGBA , GL_UNSIGNED_BYTE , "**UNKNOWN**");
defFormat(GL_RGB5_A1 , 2, 4, GL_RGBA , GL_FLOAT , "**UNKNOWN**");
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_DEPTH_COMPONENT24 , 3, 1, GL_DEPTH_COMPONENT, GL_FLOAT , "**UNKNOWN**");
defFormat(GL_RGB8 , 3, 3, GL_RGB , GL_UNSIGNED_BYTE , "**UNKNOWN**");
defFormat(GL_RGB8_SNORM , 3, 3, GL_RGB , GL_BYTE , "**UNKNOWN**");
defFormat(GL_SRGB8 , 3, 3, GL_RGB , GL_UNSIGNED_BYTE , "**UNKNOWN**");
defFormat(GL_RGB8I , 3, 3, GL_RGB_INTEGER , GL_BYTE , "**UNKNOWN**");
defFormat(GL_RGB8UI , 3, 3, GL_RGB_INTEGER , GL_UNSIGNED_BYTE , "**UNKNOWN**");
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_DEPTH_COMPONENT32 , 4, 1, GL_DEPTH_COMPONENT, GL_FLOAT , "**UNKNOWN**");
defFormat(GL_DEPTH_COMPONENT32F , 4, 1, GL_DEPTH_COMPONENT, GL_FLOAT , "**UNKNOWN**");
defFormat(GL_R32F , 4, 1, GL_RED , GL_FLOAT , "r32f");
defFormat(GL_R32I , 4, 1, GL_RED_INTEGER , GL_INT , "r32i");
defFormat(GL_R32UI , 4, 1, GL_RED_INTEGER , GL_UNSIGNED_INT , "r32ui");
defFormat(GL_RG16 , 4, 2, GL_RG , GL_UNSIGNED_SHORT, "rg16");
defFormat(GL_RG16_SNORM , 4, 2, GL_RG , GL_SHORT , "rg16_snorm");
defFormat(GL_RG16F , 4, 2, GL_RG , GL_FLOAT , "rg16f");
defFormat(GL_RG16I , 4, 2, GL_RG_INTEGER , GL_SHORT , "rg16i");
defFormat(GL_RG16UI , 4, 2, GL_RG_INTEGER , GL_UNSIGNED_SHORT, "rg16ui");
defFormat(GL_RGB10 , 4, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**");
defFormat(GL_R11F_G11F_B10F , 4, 3, GL_RGB , GL_FLOAT , "r11f_g11f_b10f");
defFormat(GL_RGB9_E5 , 4, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**");
defFormat(GL_RGBA8 , 4, 4, GL_RGBA , GL_UNSIGNED_BYTE , "rgba8");
defFormat(GL_RGBA8_SNORM , 4, 4, GL_RGBA , GL_BYTE , "rgba8_snorm");
defFormat(GL_RGB10_A2 , 4, 4, GL_RGBA , GL_FLOAT , "rgb10_a2");
defFormat(GL_RGB10_A2UI , 4, 4, GL_RGBA_INTEGER , GL_FLOAT , "rgb10_a2ui");
defFormat(GL_SRGB8_ALPHA8 , 4, 4, GL_RGBA , GL_UNSIGNED_BYTE , "**UNKNOWN**");
defFormat(GL_RGBA8I , 4, 4, GL_RGBA_INTEGER , GL_BYTE , "rgba8i");
defFormat(GL_RGBA8UI , 4, 4, GL_RGBA_INTEGER , GL_UNSIGNED_BYTE , "rgba8ui");
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_RGB12 , 5, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**");
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_RGB16 , 6, 3, GL_RGB , GL_UNSIGNED_SHORT, "glslfmptq");
defFormat(GL_RGB16_SNORM , 6, 3, GL_RGB , GL_SHORT , "**UNKNOWN**");
defFormat(GL_RGB16F , 6, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**");
defFormat(GL_RGB16I , 6, 3, GL_RGB_INTEGER , GL_SHORT , "**UNKNOWN**");
defFormat(GL_RGB16UI , 6, 3, GL_RGB_INTEGER , GL_UNSIGNED_SHORT, "**UNKNOWN**");
defFormat(GL_RGBA12 , 6, 4, GL_RGBA , GL_FLOAT , "**UNKNOWN**");
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_RG32F , 8, 2, GL_RG , GL_FLOAT , "rg32f");
defFormat(GL_RG32I , 8, 2, GL_RG_INTEGER , GL_INT , "rg32i");
defFormat(GL_RG32UI , 8, 2, GL_RG_INTEGER , GL_UNSIGNED_INT , "rg32ui");
defFormat(GL_RGBA16 , 8, 4, GL_RGBA , GL_FLOAT , "rgba16");
defFormat(GL_RGBA16_SNORM , 8, 4, GL_RGBA , GL_SHORT , "rgba16_snorm");
defFormat(GL_RGBA16F , 8, 4, GL_RGBA , GL_FLOAT , "rgba16f");
defFormat(GL_RGBA16I , 8, 4, GL_RGBA_INTEGER , GL_SHORT , "rgba16i");
defFormat(GL_RGBA16UI , 8, 4, GL_RGBA_INTEGER , GL_UNSIGNED_SHORT, "rgba16ui");
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_RGB32F , 12, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**");
defFormat(GL_RGB32I , 12, 3, GL_RGB_INTEGER , GL_INT , "**UNKNOWN**");
defFormat(GL_RGB32UI , 12, 3, GL_RGB_INTEGER , GL_UNSIGNED_INT , "**UNKNOWN**");
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_RGBA32F , 16, 4, GL_RGBA , GL_FLOAT , "rgba32f");
defFormat(GL_RGBA32I , 16, 4, GL_RGBA_INTEGER , GL_INT , "rgba32i");
defFormat(GL_RGBA32UI , 16, 4, GL_RGBA_INTEGER , GL_UNSIGNED_INT , "rgba32ui");
default: // for unknown/invalid texture format specifiers
// Log a warning here??
return GLTextureFormatTraits(internalFormat);
}
}
}; // namspace cgt
\ No newline at end of file
......@@ -34,12 +34,17 @@
namespace cgt {
/**
* Class for storing and querying texture format traits at runtime. Can be used to
* gain more insight into the texture format of a texture if only the internal format
* is known. Use the static \a get() method to query the traits for a format at
* runtime.
*/
class GLTextureFormatTraits {
public:
/// Constructor for unknown format
GLTextureFormatTraits(GLint internalFormat__)
constexpr GLTextureFormatTraits(GLint internalFormat__)
: known_{ false }
, internalFormatName_{ "Unknown" }
, bpp_{ 0 }
......@@ -51,7 +56,7 @@ public:
{};
/// Constructor for known formats
GLTextureFormatTraits(GLint internalFormat__, const char* internalFormatName__, int bpp__, int channels__, GLint pixelFormat__, GLint pixelDataType__, const char* glslFormatQualifier__)
constexpr GLTextureFormatTraits(GLint internalFormat__, const char* internalFormatName__, int bpp__, int channels__, GLint pixelFormat__, GLint pixelDataType__, const char* glslFormatQualifier__)
: internalFormatName_{ internalFormatName__ }
, known_{ true }
, bpp_{ bpp__ }
......@@ -62,59 +67,174 @@ public:
, glslFormatQualifier_{ glslFormatQualifier__ }
{};
static GLTextureFormatTraits get(GLint internalFormat);
static constexpr GLTextureFormatTraits get(GLint internalFormat);
/**
* Whether the specified GLint is a valid internal format
* Whether the specified GLint is a valid internal format. If this is
* false, all other fields will contain default (invalid) values.
*/
bool known() const { return known_; };
constexpr bool known() const { return known_; };
/**
* The name of the macro as a string
* The name of the macro as a string, empty if unknown.
*/
std::string internalFormatName() const { return internalFormatName_; } ;
constexpr const char* internalFormatName() const { return internalFormatName_; } ;
/**
* Number of bytes per pixel
* @return the number of bytes per pixel (1-16 on current hardware) or zero for unknown format
*/
int bpp() const { return bpp_; };
constexpr int bpp() const { return bpp_; };
/**
* Number of channels (1-4)
* Number of channels
* @return the number of channels (1-4) or 0 for unknown format
*/
int channels() const { return channels_; };
constexpr int channels() const { return channels_; };
/**
* GLint of the internal format
*/
GLint internalFormat() const { return internalFormat_; };
constexpr GLint internalFormat() const { return internalFormat_; };
/**
* Matching pixel format
* @return one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_RED_INTEGER, GL_RG_INTEGER, GL_RGB_INTEGER, GL_RGBA_INTEGER, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL
*/
constexpr GLint pixelFormat() const { return pixelFormat_; };
/**
* Matching pixel format (GL_RED, GL_RG, GL_RGB, GL_BGR, GL_RGBA, GL_BGRA, GL_RED_INTEGER, GL_RG_INTEGER, GL_RGB_INTEGER, GL_BGR_INTEGER, GL_RGBA_INTEGER, GL_BGRA_INTEGER, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL)
* Matching pixel data type
* @return GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, GL_FLOAT
*/
GLint pixelFormat() const { return pixelFormat_; };
constexpr GLint pixelDataType() const { return pixelDataType_; };
/**
* Matching pixel data type (GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2, and GL_UNSIGNED_INT_2_10_10_10_REV)
* Matching write format qualifier for use in glsl with image read/write operations.
* @return rgba32f, r16, r8u, ...
*/
GLint pixelDataType() const { return pixelDataType_; };
constexpr const char* glslFormatQualifier() const { return glslFormatQualifier_; };
/**
* Matching write format qualifier for use in glsl with image read/write operations. (rgba32f, r16, r8u, ...)
* Is the format is a (signed or unsigned) integer format?
*/
std::string glslFormatQualifier() const { return glslFormatQualifier_; };
constexpr bool isIntegerFormat() const {
return pixelDataType_ == GL_RED_INTEGER
|| pixelDataType_ == GL_RG_INTEGER
|| pixelDataType_ == GL_RGB_INTEGER
|| pixelDataType_ == GL_RGBA_INTEGER;
}
/**
* Is the format unsigned or not? (float formats have a sign)
*/
constexpr bool isSignedFormat() const {
return (pixelDataType_ != GL_UNSIGNED_BYTE
&& pixelDataType_ != GL_UNSIGNED_SHORT
&& pixelDataType_ != GL_UNSIGNED_INT);
}
private:
bool known_;
const std::string internalFormatName_;
const bool known_;
const char* internalFormatName_;
const int bpp_;
const int channels_;
const GLint internalFormat_;
const GLint pixelFormat_;
const GLint pixelDataType_;
const std::string glslFormatQualifier_;
const char* glslFormatQualifier_;
};
#define defFormat(INTERNAL_FORMAT, BPP, CHANNELS, PIXEL_FORMAT, PIXEL_DATA_TYPE, GLSL_FORMAT_QUALIFIER) \
(internalFormat == INTERNAL_FORMAT) ? GLTextureFormatTraits(INTERNAL_FORMAT, #INTERNAL_FORMAT, BPP, CHANNELS, PIXEL_FORMAT, PIXEL_DATA_TYPE, GLSL_FORMAT_QUALIFIER) :
constexpr GLTextureFormatTraits GLTextureFormatTraits::get(GLint internalFormat)
{
return
defFormat(GL_DEPTH_COMPONENT , 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT , "**UNKNOWN**")
defFormat(GL_R8 , 1, 1, GL_RED , GL_UNSIGNED_BYTE , "r8")
defFormat(GL_R8_SNORM , 1, 1, GL_RED , GL_BYTE , "r8_snorm")
defFormat(GL_R8I , 1, 1, GL_RED_INTEGER , GL_BYTE , "r8i")
defFormat(GL_R8UI , 1, 1, GL_RED_INTEGER , GL_UNSIGNED_BYTE , "r8ui")
defFormat(GL_R3_G3_B2 , 1, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**")
defFormat(GL_RGBA2 , 1, 4, GL_RGB , GL_UNSIGNED_BYTE , "**UNKNOWN**")
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_DEPTH_COMPONENT16 , 2, 1, GL_DEPTH_COMPONENT, GL_FLOAT , "**UNKNOWN**")
defFormat(GL_R16 , 2, 1, GL_RED , GL_UNSIGNED_SHORT, "r16")
defFormat(GL_R16_SNORM , 2, 1, GL_RED , GL_SHORT , "r16_snorm")
defFormat(GL_R16F , 2, 1, GL_RED , GL_FLOAT , "r16f")
defFormat(GL_R16I , 2, 1, GL_RED_INTEGER , GL_SHORT , "r16i")
defFormat(GL_R16UI , 2, 1, GL_RED_INTEGER , GL_UNSIGNED_SHORT, "r16ui")
defFormat(GL_DEPTH_STENCIL , 2, 1, GL_RG , GL_FLOAT , "**UNKNOWN**")
defFormat(GL_RG8 , 2, 2, GL_RG , GL_UNSIGNED_BYTE , "rg8")
defFormat(GL_RG8_SNORM , 2, 2, GL_RG , GL_BYTE , "rg8_snorm")
defFormat(GL_RG8I , 2, 2, GL_RG_INTEGER , GL_BYTE , "rg8i")
defFormat(GL_RG8UI , 2, 2, GL_RG_INTEGER , GL_UNSIGNED_BYTE , "rg8ui")
defFormat(GL_RGB4 , 2, 3, GL_RGB , GL_UNSIGNED_BYTE , "**UNKNOWN**")
defFormat(GL_RGB5 , 2, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**")
defFormat(GL_RGBA4 , 2, 4, GL_RGBA , GL_UNSIGNED_BYTE , "**UNKNOWN**")
defFormat(GL_RGB5_A1 , 2, 4, GL_RGBA , GL_FLOAT , "**UNKNOWN**")
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_DEPTH_COMPONENT24 , 3, 1, GL_DEPTH_COMPONENT, GL_FLOAT , "**UNKNOWN**")
defFormat(GL_RGB8 , 3, 3, GL_RGB , GL_UNSIGNED_BYTE , "**UNKNOWN**")
defFormat(GL_RGB8_SNORM , 3, 3, GL_RGB , GL_BYTE , "**UNKNOWN**")
defFormat(GL_SRGB8 , 3, 3, GL_RGB , GL_UNSIGNED_BYTE , "**UNKNOWN**")
defFormat(GL_RGB8I , 3, 3, GL_RGB_INTEGER , GL_BYTE , "**UNKNOWN**")
defFormat(GL_RGB8UI , 3, 3, GL_RGB_INTEGER , GL_UNSIGNED_BYTE , "**UNKNOWN**")
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_DEPTH_COMPONENT32 , 4, 1, GL_DEPTH_COMPONENT, GL_FLOAT , "**UNKNOWN**")
defFormat(GL_DEPTH_COMPONENT32F , 4, 1, GL_DEPTH_COMPONENT, GL_FLOAT , "**UNKNOWN**")
defFormat(GL_R32F , 4, 1, GL_RED , GL_FLOAT , "r32f")
defFormat(GL_R32I , 4, 1, GL_RED_INTEGER , GL_INT , "r32i")
defFormat(GL_R32UI , 4, 1, GL_RED_INTEGER , GL_UNSIGNED_INT , "r32ui")
defFormat(GL_RG16 , 4, 2, GL_RG , GL_UNSIGNED_SHORT, "rg16")
defFormat(GL_RG16_SNORM , 4, 2, GL_RG , GL_SHORT , "rg16_snorm")
defFormat(GL_RG16F , 4, 2, GL_RG , GL_FLOAT , "rg16f")
defFormat(GL_RG16I , 4, 2, GL_RG_INTEGER , GL_SHORT , "rg16i")
defFormat(GL_RG16UI , 4, 2, GL_RG_INTEGER , GL_UNSIGNED_SHORT, "rg16ui")
defFormat(GL_RGB10 , 4, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**")
defFormat(GL_R11F_G11F_B10F , 4, 3, GL_RGB , GL_FLOAT , "r11f_g11f_b10f")
defFormat(GL_RGB9_E5 , 4, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**")
defFormat(GL_RGBA8 , 4, 4, GL_RGBA , GL_UNSIGNED_BYTE , "rgba8")
defFormat(GL_RGBA8_SNORM , 4, 4, GL_RGBA , GL_BYTE , "rgba8_snorm")
defFormat(GL_RGB10_A2 , 4, 4, GL_RGBA , GL_FLOAT , "rgb10_a2")
defFormat(GL_RGB10_A2UI , 4, 4, GL_RGBA_INTEGER , GL_FLOAT , "rgb10_a2ui")
defFormat(GL_SRGB8_ALPHA8 , 4, 4, GL_RGBA , GL_UNSIGNED_BYTE , "**UNKNOWN**")
defFormat(GL_RGBA8I , 4, 4, GL_RGBA_INTEGER , GL_BYTE , "rgba8i")
defFormat(GL_RGBA8UI , 4, 4, GL_RGBA_INTEGER , GL_UNSIGNED_BYTE , "rgba8ui")
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_RGB12 , 5, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**")
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_RGB16 , 6, 3, GL_RGB , GL_UNSIGNED_SHORT, "**UNKNOWN**")
defFormat(GL_RGB16_SNORM , 6, 3, GL_RGB , GL_SHORT , "**UNKNOWN**")
defFormat(GL_RGB16F , 6, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**")
defFormat(GL_RGB16I , 6, 3, GL_RGB_INTEGER , GL_SHORT , "**UNKNOWN**")
defFormat(GL_RGB16UI , 6, 3, GL_RGB_INTEGER , GL_UNSIGNED_SHORT, "**UNKNOWN**")
defFormat(GL_RGBA12 , 6, 4, GL_RGBA , GL_FLOAT , "**UNKNOWN**")
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_RG32F , 8, 2, GL_RG , GL_FLOAT , "rg32f")
defFormat(GL_RG32I , 8, 2, GL_RG_INTEGER , GL_INT , "rg32i")
defFormat(GL_RG32UI , 8, 2, GL_RG_INTEGER , GL_UNSIGNED_INT , "rg32ui")
defFormat(GL_RGBA16 , 8, 4, GL_RGBA , GL_FLOAT , "rgba16")
defFormat(GL_RGBA16_SNORM , 8, 4, GL_RGBA , GL_SHORT , "rgba16_snorm")
defFormat(GL_RGBA16F , 8, 4, GL_RGBA , GL_FLOAT , "rgba16f")
defFormat(GL_RGBA16I , 8, 4, GL_RGBA_INTEGER , GL_SHORT , "rgba16i")
defFormat(GL_RGBA16UI , 8, 4, GL_RGBA_INTEGER , GL_UNSIGNED_SHORT, "rgba16ui")
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_RGB32F , 12, 3, GL_RGB , GL_FLOAT , "**UNKNOWN**")
defFormat(GL_RGB32I , 12, 3, GL_RGB_INTEGER , GL_INT , "**UNKNOWN**")
defFormat(GL_RGB32UI , 12, 3, GL_RGB_INTEGER , GL_UNSIGNED_INT , "**UNKNOWN**")
// , bpp, chn, pixel_format , pixel_data_type, "**UNKNOWN**");
defFormat(GL_RGBA32F , 16, 4, GL_RGBA , GL_FLOAT , "rgba32f")
defFormat(GL_RGBA32I , 16, 4, GL_RGBA_INTEGER , GL_INT , "rgba32i")
defFormat(GL_RGBA32UI , 16, 4, GL_RGBA_INTEGER , GL_UNSIGNED_INT , "rgba32ui")
// default case:
GLTextureFormatTraits(internalFormat);
}
#undef defFormat
}; // namspace cgt
\ No newline at end of file
......@@ -630,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);
}
......@@ -659,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);
......@@ -694,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;
......@@ -736,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) {
......@@ -784,7 +791,8 @@ void Shader::loadCompute(const string& compFilename, const string& customHeader,
if (!comp->compileShader()) {
LERROR("Failed to compile Compute shader " << compFilename);
LERROR("Compiler Log: \n" << comp->getCompilerLog());
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);
}
......@@ -799,7 +807,8 @@ void Shader::loadCompute(const string& compFilename, const string& customHeader,
LERROR(comp->filename_ << " Compute shader compiler log: \n" << comp->getCompilerLog());
detachObject(comp);
LERROR("Linker Log: \n" << getLinkerLog());
LERROR("************* Linker Log *************\n" << getLinkerLog());
LDEBUG("************* Compute Shader Code *************" << std::endl << comp->getParsedSource());
throw Exception("Failed to link shader (" + compFilename + ")");
}
......
......@@ -127,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
......
......@@ -33,6 +33,8 @@
// #define MEDIAN_WINDOW_Y
// #define MEDIAN_WINDOW_Z
// Size of the Median filter kernel in every dimension. All values to 1 performs results in a 3x3x3 filter window
// uniform _outputImage
// dynamically defined (i|u)image(1|2|3)D uniform to allow imageStore operation of the output
// The work group size can be overridden by dynamic defines
#ifndef WORK_GROUP_SIZE_X
......@@ -50,7 +52,6 @@
uniform sampler3D _texture;
uniform TextureParameters3D _textureParams;
layout(OUTPUT_TEXTURE_FORMAT, binding = 0) uniform image3D _outputImage;
layout(local_size_x = WORK_GROUP_SIZE_X, local_size_y = WORK_GROUP_SIZE_Y, local_size_z = WORK_GROUP_SIZE_Z) in;
#define KERNEL_X (MEDIAN_WINDOW_X*2 + 1)
......
......@@ -39,7 +39,7 @@ namespace campvis {
: AutoEvaluationPipeline(dc, getId())
, _lsp()
, _imageReader()
, _resampler(&_canvasSize)