Skip to content

Instantly share code, notes, and snippets.

@BoyBaykiller
Last active March 9, 2025 05:22
Show Gist options
  • Select an option

  • Save BoyBaykiller/aaa4673f4ea424edffa7d2d7ece55d88 to your computer and use it in GitHub Desktop.

Select an option

Save BoyBaykiller/aaa4673f4ea424edffa7d2d7ece55d88 to your computer and use it in GitHub Desktop.
OpenGL Bug: Very simple shader sampling a texture and using Bindless Textures causes crash

Running this very simple shader causes a freeze for a few seconds and ultimately some kind of driver reset. This bug does not happen on latest public driver (24.3.1)!

Here is the shader code to reproduce it:

#version 460 core
#extension GL_ARB_bindless_texture : require

layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;

layout(binding = 0) restrict writeonly uniform image2D ImgResult;
layout(binding = 0) uniform sampler2D SamplerVolumetric;

void main()
{
    // GL_ARB_bindless_texture must be used and texture must be sampled in order to crash
    sampler2D somethingBindless;
    vec4 color = texture(SamplerVolumetric, vec2(0.0));

    imageStore(ImgResult, ivec2(0), color);
}

And the accompanying host code:

uint32_t computeShaderProgram;
{
    uint32_t computeShader = glCreateShader(GL_COMPUTE_SHADER);
    glShaderSource(computeShader, 1, &computeShaderSrcCode, 0);
    glCompileShader(computeShader);

    computeShaderProgram = glCreateProgram();
    glAttachShader(computeShaderProgram, computeShader);
    glLinkProgram(computeShaderProgram);
}

uint32_t texture;
glCreateTextures(GL_TEXTURE_2D, 1, &texture);
glTextureStorage2D(texture, 1, GL_RGBA8, 512, 512);
glTextureParameteri(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTextureParameteri(texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR);


while (!glfwWindowShouldClose(window))
{
    glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA8);
    glBindTextureUnit(0, texture);

    glUseProgram(computeShaderProgram);
    glDispatchCompute(1, 1, 1);

    glfwSwapBuffers(window);
    glfwPollEvents();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment