Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ NVidia驱动程序320.86纹理缓冲错误导致崩溃_C++_Opengl - Fatal编程技术网

C++ NVidia驱动程序320.86纹理缓冲错误导致崩溃

C++ NVidia驱动程序320.86纹理缓冲错误导致崩溃,c++,opengl,C++,Opengl,在最大缓冲区大小为2^27 texel之前,以下代码很快崩溃 我去掉了每一行无用的代码,使它更容易阅读 const int MAX_LAYER_DEPTH = 5; #include "vapp.h" #include "vmath.h" #include <stdio.h> BEGIN_APP_DECLARATION(OITDemo) // Override functions from base class virtual void Initialize(c

在最大缓冲区大小为2^27 texel之前,以下代码很快崩溃

我去掉了每一行无用的代码,使它更容易阅读

const int MAX_LAYER_DEPTH = 5;

#include "vapp.h"

#include "vmath.h"

#include <stdio.h>

BEGIN_APP_DECLARATION(OITDemo)
    // Override functions from base class
   virtual void Initialize(const char * title);
    virtual void Display(bool auto_redraw);
    virtual void Finalize(void);
    virtual void Reshape(int width, int height);

    GLuint  linked_list_buffer;
    GLuint  linked_list_texture;
    GLint current_width;
    GLint current_height;
END_APP_DECLARATION()

DEFINE_APP(OITDemo, "Order Independent Transparency")

void OITDemo::Initialize(const char * title)
{
    base::Initialize(title);
    glGenBuffers(1, &linked_list_buffer);
    glGenTextures(1, &linked_list_texture);
    Reshape(100,100);
    return;
}

void OITDemo::Display(bool auto_redraw)
{

    glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
    glBindImageTexture(1, linked_list_texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32UI);
    glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);

    base::Display();

    return;
}

void OITDemo::Reshape(int width, int height)
{
    current_width = width;
    current_height = height;

    glBindImageTexture(1, 0, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32UI);
    static GLuint texBufferSize = 2047;
    ++texBufferSize;
    printf("%d : texBufferSize\n",texBufferSize);
    glBindBuffer(GL_TEXTURE_BUFFER, linked_list_buffer);
    glBufferData(GL_TEXTURE_BUFFER, texBufferSize * texBufferSize * MAX_LAYER_DEPTH * sizeof(vmath::vec4), NULL, GL_DYNAMIC_DRAW);
    glBindBuffer(GL_TEXTURE_BUFFER, 0);

    // Bind it to a texture (for use as a TBO)
    glBindTexture(GL_TEXTURE_BUFFER, linked_list_texture);
    glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32UI, linked_list_buffer);
    glBindTexture(GL_TEXTURE_BUFFER, 0);

    glViewport(0, 0, current_width, current_height);
    return;
}

void OITDemo::Finalize(void)
{
    glDeleteTextures(1, &linked_list_texture);
    glDeleteBuffers(1, &linked_list_buffer);
}
驱动程序很可能无法处理碎片 它在2169445 2083 x 2083 x 5和23587920元素的重新分配之间崩溃。图形卡返回的最大缓冲区大小texel数为2^27 134百万texel

如果我们在应用程序开始时分配一个大的缓冲区,并且从不更改它,那么效果会更好。 但是,如果我们在应用程序的生命周期中尝试重新分配它,则会失败得很惨

最初,代码绑定图像纹理,然后使用着色器跟踪,该着色器将图像纹理与imageStore一起使用,但我发现我不需要任何着色器来使驱动程序崩溃


预测/预防驾驶员撞车的任何线索?

是您的平台32位还是64位。我同意这可能是地址空间碎片问题。如果您在32位系统上工作,我们可以排除进程地址空间碎片是原因。//我还建议您在代码中省略glBindImageTexture调用;它很容易在粗心的读者中引起混乱,我一直在为它挠头,直到我理解它为什么会出现,但这并不能解释问题。事实上,glBindImageTexture导致了问题。原始代码绑定了一个着色器,该着色器使用图像来存储累积的片段,但我发现即使没有着色器,也可能导致驱动程序崩溃。如果我不绑定图像纹理,我猜驱动程序会对其进行优化。我使用的是64位Windows7,安装了24千兆内存。我的图形车有1G。无论如何,我想我们都同意这可能是一个空间碎片问题。你知道预防/预测这种情况的方法吗?谢谢你的回答。如果你想通知其他人你已经回复了他们的评论,你必须在评论的开头添加@[用户名]。我想你可能想知道。前@datenwolf@datenwolf我知道,我是告诉OP:P的