Bindless Texture can't update by glTexImage2D?

After i use glGetTextureHandleARB get TextureHandle, glTexImage2D can’t update by nTexID .

eg:
glBindTexture(GL_TEXTURE_2D, nTexID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_pTextureData);
//this glTexImage2D can update new m_pTextureData to nTexID

glBindTexture(GL_TEXTURE_2D, nTexID);
m_SystemTexHandle[i]=glGetTextureHandleARB(nTexID);
glMakeTextureHandleResidentARB(m_SystemTexHandle[i]);

glBindTexture(GL_TEXTURE_2D, nTexID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_pTextureData);
//this glTexImage2D can’t update m_pTextureData to nTexID point texture,what can i do?

After a texture handle is generated the texture is immutable.
That means you can’t reallocate its storage or change its state, but you can still update its content.

I think this error applies to you:

The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
CompressedTexImage*, TexBuffer*, TexParameter*, as well as other functions
defined in terms of these, if the texture object to be modified is
referenced by one or more texture or image handles.

You want to use glTexSubImage2D or glTextureSubImage2D.
I also suggest immutable storage + DSA as better texture APIs in general.

2 Likes

Thank you for your answer.
what is DSA?
It can be used by OpenGL?
Can you provide relevant document introductions.

There are lots of resources on it online. Here is one: GitHub - fendevel/Guide-to-Modern-OpenGL-Functions: A guide to using modern OpenGL functions.