@Piers - I’ve also done some investigation about glTexStorage. The situation is more complicated then I thought. I was able to reproduce this performance problem in my test app. The key thing that hurts the performance is binding the texture object between glTexStorage and glTexSubImage.
This works fast:
glTexStorage2D(GL_TEXTURE_2D, numLevels, GL_RGBA8, textureWidth, textureHeight);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, texturePBO);
glTexSubImage2D(target, 0, 0, 0, textureWidth, textureHeight,GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
This is slow:
glTexStorage2D(GL_TEXTURE_2D, numLevels, GL_RGBA8, textureWidth, textureHeight);
glBindTexture(target, textureObj); // This makes it slow
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, texturePBO);
glTexSubImage2D(target, 0, 0, 0, textureWidth, textureHeight,GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
I’d like to note that there is no such slowdown when creating the texture by calling glTexImage2D(…, NULL) for each mipmap level.
I believe there are some sanity checks inside glBindTexture but due to some bug the driver does something that should not be done.
BTW. I measure the time from creating the texture up to the drawing a test triangle. This way I am sure that all the asynchronous processing is really done. When I do not rebind the texture then it takes 0.5ms. When I rebind it then it takes 7.5ms. My test hw is GTX260 @ WinXP x64. I get similar results on other computers with different NV cards. Driver 280.36.