释放模式不允许使用大纹理

发布于 2024-11-01 11:06:31 字数 14910 浏览 1 评论 0原文

MS Visual Studio 2005 中是否有任何设置可以阻止 OpenGL 分配大纹理?我遇到以下行为:

情况:

我创建了两个大对象:一个纹理和一个缓冲区均约为 260 mb

在调试模式下:

两个对象的分配和使用均有效美好的。我什至可以多次销毁并重新创建具有不同但可比较大小的对象。

在释放模式下:

缓冲区已分配,但当我尝试分配纹理时,OpenGL 抛出 [1] OUT_OF_MEMORY 错误。此时大约有 1000mb 可用显存。 [2]

有谁知道一些 MSVC 设置/参数/任何可以以这种方式影响 OpenGL 的东西吗? 困惑

编辑

添加一些代码:

这是我创建缓冲区(称为updateBuffer)的地方:

glm::u32 size = glm::compMul(size) * sizeof(glm::u16);

util::odprintf("[...] creating updatebuffer\n");
util::odprintf("[...] - for texture size: %s\n", glm::string(size).c_str());
util::odprintf("[...] - new size: %.2fkb\n", size / 1024.0f);

updateBuffer.create(size, GL_STREAM_DRAW);

util::odprintf("[...] - done\n");

此时缓冲区已映射,数据已写入,缓冲区未映射并且数据传输至显卡。在下一帧的开头,我创建纹理:(

util::odprintf("[...] initialize new data texture\n");
util::odprintf("[...] - available vram (before): %.2f\n", ogl::getCurrentAvailableVidMem() / 1024.0f);
util::odprintf("[...] - old texture: %d\n", newDataTexture());  // returns opengl handle
util::odprintf("[...] - new size: %s\n", glm::string(size).c_str());

newDataTexture.create(
    GL_R16F,        // internal format
    size,       // size
    0,      // border
    GL_RED,     // data format
    updateGLType,   // data type
    0);     // copy from buffer

util::odprintf("[...] - new texture %d\n", newDataTexture());
util::odprintf("[...] - available vram (after): %.2f\n", ogl::getCurrentAvailableVidMem() / 1024.0f);

在此之前,缓冲区当然绑定到 GL_PIXEL_UNPACK_BUFFER)

发布和调试构建的输出是相同的...但在发布中 OpenGL 无法创建纹理:

[...] processing scheduled update
[...] creating updatebuffer
[...] - for texture size: ivec3(1376, 1040, 93)
[...] - new size: 259935.00kb
[...] - done
[...] update available
[...] initialize new data texture
[...] - available vram (before): 1004.09
[...] - old texture: 1
[...] - new size: ivec3(1376, 1040, 93)
Eine Ausnahme (erste Chance) bei 0x7c812afb in ....exe: Microsoft C++-Ausnahme: ogl::debug_output an Speicherposition 0x0012dc68..

根据要求编辑2

:纹理类的代码

#pragma once

#include "GLTypes.h"

#include "ParameterTraits.h"
#include "Wrapper.h"
#include "TextureUnit.h"

namespace ogl {

namespace detail {


    template <>
    struct ReferenceHandler<gl_texture>
    {   
        static 
        void onDestroy(gl_texture & handle){
            TRACE("[Texture] destroying texture %d (%p)\n", handle, &handle);
            glDeleteTextures(1,&handle.t);
            handle = 0;
        };
    };
}


template <GLenum target>
struct texture_traits {};

template <>
struct texture_traits<GL_TEXTURE_1D> {
    typedef int size_t;
};

template <>
struct texture_traits<GL_TEXTURE_2D> {
    typedef glm::ivec2 size_t;
};

template <>
struct texture_traits<GL_TEXTURE_3D> {
    typedef glm::ivec3 size_t;
};



template <GLenum target>
class Texture : public detail::Wrapper<detail::gl_texture>, public detail::TextureUnit::Bindable
{
public:
    typedef typename texture_traits<target>::size_t size_t;

public:

    /**
     * \brief default constructor
     *
     * this actually doesn't do anything useful
     */
    Texture() : Wrapper<detail::gl_texture>() {
        glGenTextures(1,&object.t);
    };

    /**
     * \brief create new texture
     *
     * this constructs a new texture
     * the new texture will have a size and
     * will be empty
     *
     * \param internalFormat    texture format
     * \param size              texture size
     * \param border            texture border
     */
    void create(
        GLint internalFormat,
        size_t size,
        GLint border);

    /**
     * \brief create new texture
     *
     * this constructs a new texture
     * the new texture will have a size and
     * will be empty
     *
     * \param internalFormat    texture format
     * \param size              texture size
     * \param border            texture border
     * \param format            data format
     * \param type              data type
     */
    void create(
        GLint internalFormat,
        size_t size,
        GLint border,
        GLenum format,
        GLenum type,
        void * data);

    /** 
     * \brief virtual deconstructor
     */
    virtual ~Texture(void){};

    /**
     * \brief copy constructor
     */
    Texture & Texture::operator = (Texture const& rhs)
    {
        if (this != &rhs) {
            detail::Wrapper<detail::gl_texture>::operator=(rhs);
        }
        return *this;
    }

    /**
     * \brief update texture data
     *
     * update texture with new data
     *
     * \param level     texture level to update
     * \param offset    offset in texture
     * \param size      size of update data
     * \param format    data format
     * \param type      data type
     * \param data      data
     */
    void update(
        GLint level,
        size_t offset,
        size_t size,
        GLenum format,
        GLenum type,
        void * data);

    /**
     * \brief convenience method that updates the whole texture
     *
     * note: uses getters to determinate size of texture -> slow
     */
    void updateAll(
        GLint level,
        GLenum format,
        GLenum type,
        void * data);

    /**
     * \brief bind texture to texture unit
     *
     * this should not be included in texture. but texture unit is no real
     * object so this is defined here
     */

    void bind(GLenum texUnit) const
    {
        glBindMultiTextureEXT(texUnit, target, object);
    }

    // --- parameter access

    // - setters

    /**
     * \brief set texture parameters
     */
    template <typename T>
    void setParameter(GLenum name, T param);

    template <>
    void setParameter(GLenum name, GLint param)
    {
        glTextureParameteriEXT(object, target, name, param);
    }
    template <>
    void setParameter(GLenum name, GLfloat param)
    {
        glTextureParameterfEXT(object, target, name, param);
    }

    template <>
    void setParameter(GLenum name, GLint * param)
    {
        glTextureParameterivEXT(object, target, name, param);
    }
    template <>
    void setParameter(GLenum name, GLfloat * param)
    {
        glTextureParameterfvEXT(object, target, name, param);
    }

    // - getters

    /**
     * \brief get texture parameters
     */
    template <typename T>
    void getParameter(GLenum name, T & value);

    template <>
    void getParameter(GLenum name, GLfloat & value)
    {
        glGetTextureParameterfvEXT(
            object, target,
            name, &value);
    }
    template <>
    void getParameter(GLenum name, GLint & value)
    {
        glGetTextureParameterivEXT(
            object, target,
            name, &value);
    }

    // - level getters

    /**
     * \brief get texture level parameters
     */
    template <typename T>
    void getLevelParameter(GLint level, GLenum name, T & value);

    template <>
    void getLevelParameter(GLint level, GLenum name, GLint & value)
    {
        glGetTextureLevelParameterivEXT(
            object, target,
            level,
            name, &value);
    }

    template <>
    void getLevelParameter(GLint level, GLenum name, GLfloat & value)
    {
        glGetTextureLevelParameterfvEXT(
            object, target,
            level,
            name, &value);
    }



    /**
     * \brief generate mipmap levels for this texture
     */
    void generateMipmap() {
        glGenerateTextureMipmapEXT(object, target);
    }
};


// --- specialization for 1d texture

template <> 
inline void Texture<GL_TEXTURE_1D>::create(
    GLint internalFormat,
    GLint size,
    GLint border )
{
    //glGenTextures(1,&object.t);

    //std::vector<GLbyte> tmp(size*4);
    glTextureImage1DEXT(
        object,     // texture
        GL_TEXTURE_1D,          // target
        0,              // level
        internalFormat, // internal format
        size,           // size
        border,         // border
        GL_RGBA,        // format
        GL_BYTE,        // type
        0);     // don't load anything
}

template <> 
inline void Texture<GL_TEXTURE_1D>::create(
        GLint internalFormat,
        size_t size,
        GLint border,
        GLenum format,
        GLenum type,
        void * data)
{
    //glGenTextures(1,&object.t);

    glTextureImage1DEXT(
        object,                 // texture
        GL_TEXTURE_1D,          // target
        0,                      // level
        internalFormat,         // internal format
        size,                   // size
        border,                 // border
        format,                 // data format
        type,                   // data type
        data);                  // data
}

template <> 
inline void Texture<GL_TEXTURE_1D>::update(
    GLint level,
    GLint offset,
    GLint size,
    GLenum format,
    GLenum type,
    void * data )
{
    glTextureSubImage1DEXT(
        object,
        GL_TEXTURE_1D,
        level,
        offset,
        size, 
        format,
        type,
        data
        );
}

template <> 
inline void Texture<GL_TEXTURE_1D>::updateAll(
    GLint level,
    GLenum format,
    GLenum type,
    void * data)
{
    GLint size;
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_1D,
        level,
        GL_TEXTURE_WIDTH,
        &size
        );

    update(level, 0, size, format, type, data);
}

// --- specialization for 2d texture

template <> 
inline void Texture<GL_TEXTURE_2D>::create(
    GLint internalFormat,
    glm::ivec2 size,
    GLint border )
{
    //glGenTextures(1,&object.t);

    //std::vector<GLbyte> tmp(glm::compMul(size)*4);
    glTextureImage2DEXT(
        object,     // texture
        GL_TEXTURE_2D,          // target
        0,              // level
        internalFormat, // internal format
        size.x, size.y, // size
        border,         // border
        GL_RGBA,        // format
        GL_BYTE,        // type
        0);     // don't load anything
}

template <> 
inline void Texture<GL_TEXTURE_2D>::create(
        GLint internalFormat,
        size_t size,
        GLint border,
        GLenum format,
        GLenum type,
        void * data)
{
    //glGenTextures(1,&object.t);

    glTextureImage2DEXT(
        object,                 // texture
        GL_TEXTURE_2D,          // target
        0,                      // level
        internalFormat,         // internal format
        size.x, size.y,         // size
        border,                 // border
        format,                 // data format
        type,                   // data type
        data);                  // data
}

template <> 
inline void Texture<GL_TEXTURE_2D>::update(
    GLint level,
    glm::ivec2 offset,
    glm::ivec2 size,
    GLenum format,
    GLenum type,
    void * data )
{
    glTextureSubImage2DEXT(
        object,
        GL_TEXTURE_2D,
        level,
        offset.x, offset.y,
        size.x, size.y,
        format,
        type,
        data
        );
}

template <> 
inline void Texture<GL_TEXTURE_2D>::updateAll(
    GLint level,
    GLenum format,
    GLenum type,
    void * data)
{
    glm::ivec2 size;
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_2D,
        level,
        GL_TEXTURE_WIDTH,
        &size.x
        );
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_2D,
        level,
        GL_TEXTURE_HEIGHT,
        &size.y
        );

    update(level, glm::ivec2(0,0), size, format, type, data);
}

// --- specialization for 3d texture

template <> 
inline void Texture<GL_TEXTURE_3D>::create(
    GLint internalFormat,
    glm::ivec3 size,
    GLint border )
{
    //glGenTextures(1,&object.t);

    //std::vector<GLbyte> tmp(glm::compMul(size)*4);
    glTextureImage3DEXT(
        object,                 // texture
        GL_TEXTURE_3D,          // target
        0,                      // level
        internalFormat,         // internal format
        size.x, size.y, size.z, // size
        border,                 // border
        GL_RGBA,                // format
        GL_BYTE,                // type
        0);             // don't load anything
}

template <> 
inline void Texture<GL_TEXTURE_3D>::create(
        GLint internalFormat,
        size_t size,
        GLint border,
        GLenum format,
        GLenum type,
        void * data)
{
    //glGenTextures(1,&object.t);

    glTextureImage3DEXT(
        object,                 // texture
        GL_TEXTURE_3D,          // target
        0,                      // level
        internalFormat,         // internal format
        size.x, size.y, size.z, // size
        border,                 // border
        format,                 // data format
        type,                   // data type
        data);                  // data
}

template <> 
inline void Texture<GL_TEXTURE_3D>::update(
    GLint level,
    glm::ivec3 offset,
    glm::ivec3 size,
    GLenum format,
    GLenum type,
    void * data ) 
{
    glTextureSubImage3DEXT(
        object,
        GL_TEXTURE_3D,
        level,
        offset.x, offset.y, offset.z,
        size.x, size.y, size.z,
        format,
        type,
        data
        );
}

template <> 
inline void Texture<GL_TEXTURE_3D>::updateAll(
    GLint level,
    GLenum format,
    GLenum type,
    void * data)
{
    glm::ivec3 size;
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_3D,
        level,
        GL_TEXTURE_WIDTH,
        &size.x
        );
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_3D,
        level,
        GL_TEXTURE_HEIGHT,
        &size.y
        );
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_3D,
        level,
        GL_TEXTURE_DEPTH,
        &size.z
        );

    update(level, glm::ivec3(0,0,0), size, format, type, data);
}

typedef Texture<GL_TEXTURE_1D> Texture1d;
typedef Texture<GL_TEXTURE_2D> Texture2d;
typedef Texture<GL_TEXTURE_3D> Texture3d;

};

如您所见,我正在使用EXT_direct_state_access。 “Wrapper”类是标准的重新计数设计。我不能透露这一点……但我可以肯定地说,它已被证明是有效的。

如果您需要了解更多信息,请继续询问...我已经没有想法了。 :(

** 解决方案 **

伙计...有人在发布版本中禁用了 /LARGEMEMORYAWARE ...感谢每个试图解决此问题的人:)

[1] 我正在使用 ARB_debug_output [2] 使用 GL_NVX_gpu_memory_info 检查

Is there any setting in MS Visual Studio 2005 that will prevent OpenGL from allocating large textures? I am experiencing the following behavior:

The situation:

I create two large objects: one texture and one buffer both about 260 mb

In Debug Mode:

Allocation and use of both objects works fine. I can even destroy and recreate the objects several times with different but comparable sizes.

In Release Mode:

The Buffer is allocated but OpenGL throws [1] an OUT_OF_MEMORY error when i try to allocate the texture. At this point there is about 1000mb video memory available. [2]

Does anyone know some MSVC settings/parameters/whatever that can affect OpenGL in this way? confused

Edit

adding some code:

This is the place i create the buffer (called updateBuffer):

glm::u32 size = glm::compMul(size) * sizeof(glm::u16);

util::odprintf("[...] creating updatebuffer\n");
util::odprintf("[...] - for texture size: %s\n", glm::string(size).c_str());
util::odprintf("[...] - new size: %.2fkb\n", size / 1024.0f);

updateBuffer.create(size, GL_STREAM_DRAW);

util::odprintf("[...] - done\n");

At this point the buffer is mapped, data is written, the buffer is unmapped and the data is streamed to the graphics card. At the beginning of the next frame I create the texture:

util::odprintf("[...] initialize new data texture\n");
util::odprintf("[...] - available vram (before): %.2f\n", ogl::getCurrentAvailableVidMem() / 1024.0f);
util::odprintf("[...] - old texture: %d\n", newDataTexture());  // returns opengl handle
util::odprintf("[...] - new size: %s\n", glm::string(size).c_str());

newDataTexture.create(
    GL_R16F,        // internal format
    size,       // size
    0,      // border
    GL_RED,     // data format
    updateGLType,   // data type
    0);     // copy from buffer

util::odprintf("[...] - new texture %d\n", newDataTexture());
util::odprintf("[...] - available vram (after): %.2f\n", ogl::getCurrentAvailableVidMem() / 1024.0f);

(the buffer is of course bound to GL_PIXEL_UNPACK_BUFFER before this)

The output is the same for release and debug build ... but in release OpenGL fails to create the texture:

[...] processing scheduled update
[...] creating updatebuffer
[...] - for texture size: ivec3(1376, 1040, 93)
[...] - new size: 259935.00kb
[...] - done
[...] update available
[...] initialize new data texture
[...] - available vram (before): 1004.09
[...] - old texture: 1
[...] - new size: ivec3(1376, 1040, 93)
Eine Ausnahme (erste Chance) bei 0x7c812afb in ....exe: Microsoft C++-Ausnahme: ogl::debug_output an Speicherposition 0x0012dc68..

Edit 2

as by request: the code for the texture class

#pragma once

#include "GLTypes.h"

#include "ParameterTraits.h"
#include "Wrapper.h"
#include "TextureUnit.h"

namespace ogl {

namespace detail {


    template <>
    struct ReferenceHandler<gl_texture>
    {   
        static 
        void onDestroy(gl_texture & handle){
            TRACE("[Texture] destroying texture %d (%p)\n", handle, &handle);
            glDeleteTextures(1,&handle.t);
            handle = 0;
        };
    };
}


template <GLenum target>
struct texture_traits {};

template <>
struct texture_traits<GL_TEXTURE_1D> {
    typedef int size_t;
};

template <>
struct texture_traits<GL_TEXTURE_2D> {
    typedef glm::ivec2 size_t;
};

template <>
struct texture_traits<GL_TEXTURE_3D> {
    typedef glm::ivec3 size_t;
};



template <GLenum target>
class Texture : public detail::Wrapper<detail::gl_texture>, public detail::TextureUnit::Bindable
{
public:
    typedef typename texture_traits<target>::size_t size_t;

public:

    /**
     * \brief default constructor
     *
     * this actually doesn't do anything useful
     */
    Texture() : Wrapper<detail::gl_texture>() {
        glGenTextures(1,&object.t);
    };

    /**
     * \brief create new texture
     *
     * this constructs a new texture
     * the new texture will have a size and
     * will be empty
     *
     * \param internalFormat    texture format
     * \param size              texture size
     * \param border            texture border
     */
    void create(
        GLint internalFormat,
        size_t size,
        GLint border);

    /**
     * \brief create new texture
     *
     * this constructs a new texture
     * the new texture will have a size and
     * will be empty
     *
     * \param internalFormat    texture format
     * \param size              texture size
     * \param border            texture border
     * \param format            data format
     * \param type              data type
     */
    void create(
        GLint internalFormat,
        size_t size,
        GLint border,
        GLenum format,
        GLenum type,
        void * data);

    /** 
     * \brief virtual deconstructor
     */
    virtual ~Texture(void){};

    /**
     * \brief copy constructor
     */
    Texture & Texture::operator = (Texture const& rhs)
    {
        if (this != &rhs) {
            detail::Wrapper<detail::gl_texture>::operator=(rhs);
        }
        return *this;
    }

    /**
     * \brief update texture data
     *
     * update texture with new data
     *
     * \param level     texture level to update
     * \param offset    offset in texture
     * \param size      size of update data
     * \param format    data format
     * \param type      data type
     * \param data      data
     */
    void update(
        GLint level,
        size_t offset,
        size_t size,
        GLenum format,
        GLenum type,
        void * data);

    /**
     * \brief convenience method that updates the whole texture
     *
     * note: uses getters to determinate size of texture -> slow
     */
    void updateAll(
        GLint level,
        GLenum format,
        GLenum type,
        void * data);

    /**
     * \brief bind texture to texture unit
     *
     * this should not be included in texture. but texture unit is no real
     * object so this is defined here
     */

    void bind(GLenum texUnit) const
    {
        glBindMultiTextureEXT(texUnit, target, object);
    }

    // --- parameter access

    // - setters

    /**
     * \brief set texture parameters
     */
    template <typename T>
    void setParameter(GLenum name, T param);

    template <>
    void setParameter(GLenum name, GLint param)
    {
        glTextureParameteriEXT(object, target, name, param);
    }
    template <>
    void setParameter(GLenum name, GLfloat param)
    {
        glTextureParameterfEXT(object, target, name, param);
    }

    template <>
    void setParameter(GLenum name, GLint * param)
    {
        glTextureParameterivEXT(object, target, name, param);
    }
    template <>
    void setParameter(GLenum name, GLfloat * param)
    {
        glTextureParameterfvEXT(object, target, name, param);
    }

    // - getters

    /**
     * \brief get texture parameters
     */
    template <typename T>
    void getParameter(GLenum name, T & value);

    template <>
    void getParameter(GLenum name, GLfloat & value)
    {
        glGetTextureParameterfvEXT(
            object, target,
            name, &value);
    }
    template <>
    void getParameter(GLenum name, GLint & value)
    {
        glGetTextureParameterivEXT(
            object, target,
            name, &value);
    }

    // - level getters

    /**
     * \brief get texture level parameters
     */
    template <typename T>
    void getLevelParameter(GLint level, GLenum name, T & value);

    template <>
    void getLevelParameter(GLint level, GLenum name, GLint & value)
    {
        glGetTextureLevelParameterivEXT(
            object, target,
            level,
            name, &value);
    }

    template <>
    void getLevelParameter(GLint level, GLenum name, GLfloat & value)
    {
        glGetTextureLevelParameterfvEXT(
            object, target,
            level,
            name, &value);
    }



    /**
     * \brief generate mipmap levels for this texture
     */
    void generateMipmap() {
        glGenerateTextureMipmapEXT(object, target);
    }
};


// --- specialization for 1d texture

template <> 
inline void Texture<GL_TEXTURE_1D>::create(
    GLint internalFormat,
    GLint size,
    GLint border )
{
    //glGenTextures(1,&object.t);

    //std::vector<GLbyte> tmp(size*4);
    glTextureImage1DEXT(
        object,     // texture
        GL_TEXTURE_1D,          // target
        0,              // level
        internalFormat, // internal format
        size,           // size
        border,         // border
        GL_RGBA,        // format
        GL_BYTE,        // type
        0);     // don't load anything
}

template <> 
inline void Texture<GL_TEXTURE_1D>::create(
        GLint internalFormat,
        size_t size,
        GLint border,
        GLenum format,
        GLenum type,
        void * data)
{
    //glGenTextures(1,&object.t);

    glTextureImage1DEXT(
        object,                 // texture
        GL_TEXTURE_1D,          // target
        0,                      // level
        internalFormat,         // internal format
        size,                   // size
        border,                 // border
        format,                 // data format
        type,                   // data type
        data);                  // data
}

template <> 
inline void Texture<GL_TEXTURE_1D>::update(
    GLint level,
    GLint offset,
    GLint size,
    GLenum format,
    GLenum type,
    void * data )
{
    glTextureSubImage1DEXT(
        object,
        GL_TEXTURE_1D,
        level,
        offset,
        size, 
        format,
        type,
        data
        );
}

template <> 
inline void Texture<GL_TEXTURE_1D>::updateAll(
    GLint level,
    GLenum format,
    GLenum type,
    void * data)
{
    GLint size;
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_1D,
        level,
        GL_TEXTURE_WIDTH,
        &size
        );

    update(level, 0, size, format, type, data);
}

// --- specialization for 2d texture

template <> 
inline void Texture<GL_TEXTURE_2D>::create(
    GLint internalFormat,
    glm::ivec2 size,
    GLint border )
{
    //glGenTextures(1,&object.t);

    //std::vector<GLbyte> tmp(glm::compMul(size)*4);
    glTextureImage2DEXT(
        object,     // texture
        GL_TEXTURE_2D,          // target
        0,              // level
        internalFormat, // internal format
        size.x, size.y, // size
        border,         // border
        GL_RGBA,        // format
        GL_BYTE,        // type
        0);     // don't load anything
}

template <> 
inline void Texture<GL_TEXTURE_2D>::create(
        GLint internalFormat,
        size_t size,
        GLint border,
        GLenum format,
        GLenum type,
        void * data)
{
    //glGenTextures(1,&object.t);

    glTextureImage2DEXT(
        object,                 // texture
        GL_TEXTURE_2D,          // target
        0,                      // level
        internalFormat,         // internal format
        size.x, size.y,         // size
        border,                 // border
        format,                 // data format
        type,                   // data type
        data);                  // data
}

template <> 
inline void Texture<GL_TEXTURE_2D>::update(
    GLint level,
    glm::ivec2 offset,
    glm::ivec2 size,
    GLenum format,
    GLenum type,
    void * data )
{
    glTextureSubImage2DEXT(
        object,
        GL_TEXTURE_2D,
        level,
        offset.x, offset.y,
        size.x, size.y,
        format,
        type,
        data
        );
}

template <> 
inline void Texture<GL_TEXTURE_2D>::updateAll(
    GLint level,
    GLenum format,
    GLenum type,
    void * data)
{
    glm::ivec2 size;
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_2D,
        level,
        GL_TEXTURE_WIDTH,
        &size.x
        );
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_2D,
        level,
        GL_TEXTURE_HEIGHT,
        &size.y
        );

    update(level, glm::ivec2(0,0), size, format, type, data);
}

// --- specialization for 3d texture

template <> 
inline void Texture<GL_TEXTURE_3D>::create(
    GLint internalFormat,
    glm::ivec3 size,
    GLint border )
{
    //glGenTextures(1,&object.t);

    //std::vector<GLbyte> tmp(glm::compMul(size)*4);
    glTextureImage3DEXT(
        object,                 // texture
        GL_TEXTURE_3D,          // target
        0,                      // level
        internalFormat,         // internal format
        size.x, size.y, size.z, // size
        border,                 // border
        GL_RGBA,                // format
        GL_BYTE,                // type
        0);             // don't load anything
}

template <> 
inline void Texture<GL_TEXTURE_3D>::create(
        GLint internalFormat,
        size_t size,
        GLint border,
        GLenum format,
        GLenum type,
        void * data)
{
    //glGenTextures(1,&object.t);

    glTextureImage3DEXT(
        object,                 // texture
        GL_TEXTURE_3D,          // target
        0,                      // level
        internalFormat,         // internal format
        size.x, size.y, size.z, // size
        border,                 // border
        format,                 // data format
        type,                   // data type
        data);                  // data
}

template <> 
inline void Texture<GL_TEXTURE_3D>::update(
    GLint level,
    glm::ivec3 offset,
    glm::ivec3 size,
    GLenum format,
    GLenum type,
    void * data ) 
{
    glTextureSubImage3DEXT(
        object,
        GL_TEXTURE_3D,
        level,
        offset.x, offset.y, offset.z,
        size.x, size.y, size.z,
        format,
        type,
        data
        );
}

template <> 
inline void Texture<GL_TEXTURE_3D>::updateAll(
    GLint level,
    GLenum format,
    GLenum type,
    void * data)
{
    glm::ivec3 size;
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_3D,
        level,
        GL_TEXTURE_WIDTH,
        &size.x
        );
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_3D,
        level,
        GL_TEXTURE_HEIGHT,
        &size.y
        );
    glGetTextureLevelParameterivEXT(
        object,
        GL_TEXTURE_3D,
        level,
        GL_TEXTURE_DEPTH,
        &size.z
        );

    update(level, glm::ivec3(0,0,0), size, format, type, data);
}

typedef Texture<GL_TEXTURE_1D> Texture1d;
typedef Texture<GL_TEXTURE_2D> Texture2d;
typedef Texture<GL_TEXTURE_3D> Texture3d;

};

As you can see i am using EXT_direct_state_access. The "Wrapper" class is a standard refcounted design. I can't disclose that one ... but i can say for sure that it is proven to work.

Please keep asking if you need to know more ... i am running out of ideas here. :(

** The solution **

man ... someone had disabled /LARGEMEMORYAWARE in the release build ... thanks to everyone who tried to warp their head around this :)

[1] I am using ARB_debug_output
[2] checked with GL_NVX_gpu_memory_info

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月隐月明月朦胧 2024-11-08 11:06:31

您没有使用 OpenGL,而是使用了一些 C++ 库,而这些库又使用了 OpenGL。我会在那里寻找你的问题。

该库是纯头文件(使用您的编译器设置从项目中的源代码重新编译),还是有二进制组件?二进制库通常不能很好地处理更改的编译器设置,例如调试和发布配置之间的差异。

You aren't using OpenGL, you are using some C++ library that in turn uses OpenGL. I would look there for your problem.

Is this library pure header files (recompiled from source in your project, using your compiler settings), or is there a binary component? Binary libraries typically don't deal well with changed compiler settings, such as the difference between Debug and Release configuration.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文