Sharing texture objects between multiple contextes

Hi,

I wonder if texture parameters are per-texture-per-context or just per-texture. The latter case makes it hard to use the same texture with a different context in another thread for instance.

Thanks.

Texture parameters are part of a texture object state. So sharing textures threw contexts also share texture parameters.

You can read this: http://www.opengl.org/resources/faq/technical/texture.htm

mainly this paragraph: 21.070 How do texture objects work?

Objects that are shared are shared entirely, including all properties unless otherwise stated.

Objects with properties that are per-context state instead of per-object are quite rare, the only example I can think of are program subroutine uniform variables. I’m not sure why they decided these should be per-context whilst other program state is okay being per-object though.

Ok, that basically means I can’t use the same texture rendering from multiple threads on different contextes in case I need to change the texture parameters in one of the threads ? Or am I missing something?

Another question - is this possible to create another texture object using the same memory space?

You generally change texture environments, not texture parameters. If you set mipmapping for example, it is rare that you’ll need to use the same image but without mipmap or change the repeat/clamp value.

But if you really need to do so then you will need to use another texture object (this will duplicate the image memory on the graphic card and give you another texture object name, ie different id), or change the parameter, depending on your needs.

The following parameters can be replaced by binding a sampler object to the texture unit:
TEXTURE_BORDER_COLOR, TEXTURE_MIN_FILTER, TEXTURE_MAG_FILTER, TEXTURE_WRAP_S, TEXTURE_WRAP_T, TEXTURE_WRAP_R, TEXTURE_MIN_LOD, TEXTURE_MAX_LOD, TEXTURE_LOD_BIAS, TEXTURE_COMPARE_MODE, TEXTURE_COMPARE_FUNC

If you bind a different sampler on each context, you may get what you are after.

The others parameters that aren’t replaced by a sampler object are:
TEXTURE_SWIZZLE_R, TEXTURE_SWIZZLE_G, TEXTURE_SWIZZLE_B, TEXTURE_SWIZZLE_A, TEXTURE_BASE_LEVEL, TEXTURE_MAX_LEVEL

Thanks for a very descriptive answer!