0

I have a texture, whose texture wrapping needs to change based on the view.

I am using bindless textures, therefore I made it resident.

I understand I cant call glTexParameter/glTextureParameter if the handles are resident, but this does not work either:

makeNonResident()
glTextureParameter(....) -> invalid_operation
makeResident()

What am I missing? Strangely enough, I am not even rendering yet, this is just after creating the texture and making it resident..

psquare
  • 79
  • 5

1 Answers1

3

Once you call glGetTextureHandleARB to retrieve a handle from a texture, that texture becomes immutable. Not immutable storage, but is completely immutable.

You cannot change any of its parameters. Ever again. There is no undo.

The reason for this is that the handle stores all of the texture's parameters into it internally. So changing those parameters would not affect the handle's copy of them, and allowing such changes to affect every handle that a texture references would cause an undue burden on performance and synchronization.

What you really want is to use glGetTextureSamplerHandleARB to get a new handle from a texture/sampler pair. So you can create a sampler with whatever sampling parameters you want, then get a new handle for it and the original texture. The sampler's parameters will override those from the texture, and you'll get a new handle out of it that encodes both the texture and sampler's parameters.

Now, you don't want to keep creating handle after handle for these sorts of things. So you should plan out exactly which texture/sampler pairs you need, and create them up-front.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • Thanks. That works. I just made 2 different samplers before hand and I use one or the other in tandem with glGetTextureSamplerHandleARB – psquare Mar 19 '17 at 15:56