PDA

View Full Version : Sharing texture objects between multiple contextes



Sergey Nenakhov
10-21-2011, 10:56 AM
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.

_arts_
10-22-2011, 02:29 AM
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?

Dan Bartlett
10-22-2011, 04:02 AM
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.

Sergey Nenakhov
10-22-2011, 05:06 AM
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?

_arts_
10-22-2011, 07:29 AM
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.

Dan Bartlett
10-22-2011, 08:00 AM
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

Sergey Nenakhov
10-22-2011, 08:41 AM
Thanks for a very descriptive answer!