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

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

# Conflicts:
#	ext/cgt/texture.cpp
parents 1e8bb380 609563e6
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -98,7 +98,7 @@ namespace campvis {
                // converting from GL representation
                // converting from GL representation
                GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* toReturn = nullptr;
                GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* toReturn = nullptr;
                GLJobProc.enqueueJobBlocking([&]() {
                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.");
                        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);
                    WeaklyTypedPointer wtp = tester->getWeaklyTypedPointerConvert(TypeTraits<BASETYPE, NUMCHANNELS>::glDataType);
+3 −3
Original line number Original line Diff line number Diff line
@@ -201,15 +201,15 @@ namespace campvis {
    }
    }


    const WeaklyTypedPointer ImageRepresentationGL::getWeaklyTypedPointerCopy() const {
    const WeaklyTypedPointer ImageRepresentationGL::getWeaklyTypedPointerCopy() const {
        GLint format = cgt::Texture::calcMatchingFormat(_texture->getInternalFormat());
        GLint format = cgt::Texture::calcMatchingPixelFormat(_texture->getInternalFormat());
        GLenum dataType = cgt::Texture::calcMatchingDataType(_texture->getInternalFormat());
        GLenum dataType = cgt::Texture::calcMatchingPixelDataType(_texture->getInternalFormat());
        GLubyte* data = _texture->downloadTextureToBuffer(format, dataType);
        GLubyte* data = _texture->downloadTextureToBuffer(format, dataType);


        return WeaklyTypedPointer(WeaklyTypedPointer::baseType(dataType), _texture->getNumChannels(), data);
        return WeaklyTypedPointer(WeaklyTypedPointer::baseType(dataType), _texture->getNumChannels(), data);
    }
    }


    const WeaklyTypedPointer ImageRepresentationGL::getWeaklyTypedPointerConvert(GLenum dataType) const {
    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);
        GLubyte* data = _texture->downloadTextureToBuffer(format, dataType);


        return WeaklyTypedPointer(WeaklyTypedPointer::baseType(dataType), _texture->getNumChannels(), data);
        return WeaklyTypedPointer(WeaklyTypedPointer::baseType(dataType), _texture->getNumChannels(), data);
+50 −0
Original line number Original line Diff line number Diff line
// ================================================================================================
// 
// 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

core/tools/cshelper.h

0 → 100644
+56 −0
Original line number Original line Diff line number Diff line
// ================================================================================================
// 
// 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__
+1 −1
Original line number Original line Diff line number Diff line
@@ -176,7 +176,7 @@ namespace campvis {
        }
        }


        // read back stuff
        // read back stuff
        GLenum readBackFormat = cgt::Texture::calcMatchingFormat(outputTex->getInternalFormat());
        GLenum readBackFormat = cgt::Texture::calcMatchingPixelFormat(outputTex->getInternalFormat());
        size_t channels = outputTex->getNumChannels();
        size_t channels = outputTex->getNumChannels();
        toReturn.resize(channels);
        toReturn.resize(channels);
        glReadBuffer(GL_COLOR_ATTACHMENT0);
        glReadBuffer(GL_COLOR_ATTACHMENT0);
Loading