Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save BoyBaykiller/ba1a6926f2b196d2b53af1b45f4d7234 to your computer and use it in GitHub Desktop.
OpenGL: Creating & Deleting many Bindless Textures without glfwSwapBuffers causes access violation in driver

Running the following code throws an exception (when creating the 1536th texture) from inside the driver: Exception thrown at 0x00007FFC07BFDB20 (atio6axx.dll) in MyProgram.exe: 0xC0000005: Access violation reading location 0x0000000000000008.

I am simply creating a texture making it bindless and deleting it again. If the texture is not made bindless it runs fine. Also putting glfwSwapBuffers always makes it run fine.

for (int i = 0; i < 1600; i++) {
    uint32_t test;
    glCreateTextures(GL_TEXTURE_2D, 1, &test);

    glTextureStorage2D(test, 1, GL_R8, 1920, 1080);
    glTextureParameteri(test, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTextureParameteri(test, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    // Not making it bindless makes it run fine
    GLuint64 handle = glGetTextureHandleARB(test);
    glMakeTextureHandleResidentARB(handle);
    glMakeTextureHandleNonResidentARB(handle);

    if (handle == 0) {
        printf("err\n"); // never hit
    }
    glDeleteTextures(1, &test);

    // Swapping buffers makes it run fine
    //glfwSwapBuffers(window);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment