Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use Texture Views

I am reading about Texture Views in the new Red Book. On the page 322 is said:

OpenGL allows you to share a single data store between multiple textures,each with its own format and dimensions.

(via Texture Views)

Now,my questions are:

Does it mean a single texture source is being referenced by multiple instances (in this case texture views) ?

How is it different from using the same texture object,for example but with different samplers?

Also, does it mean that changing the texture pixels via texture view will change the pixels in the original texture object?(I suppose the answer is positive as the doc says it is alias to the texture store)

like image 779
Michael IV Avatar asked Jun 17 '13 16:06

Michael IV


Video Answer


1 Answers

Yes, sharing a data store means accessing the same storage from different objects. Just like sharing a pointer means being able to access the same memory from two different locations.

It's different from using sampler objects in that there is no similarities between them. Sampler objects store sampling parameters. Texture objects have parameters that are not for sampling, such as the mipmap range, swizzle mask and the like. These are not sampler state; they're texture state.

Texture objects also have a specific texture type. Different views of the same storage can have different texture types (within limits). You can have a GL_TEXTURE_2D that is a view of a single layer of a GL_TEXTURE_2D_ARRAY texture. You can take a GL_TEXTURE_2D_ARRAY of 6 or more layers and create a GL_TEXTURE_CUBE_MAP from it.

Sampler objects can't do that.

Texture objects have an internal format that defines how the storage is to be interpreted. Different views of the same storage can have different formats (within limits) Samplers don't affect the format.

Sampler objects can't do that either.

Can you use texture views to achieve the same effect as sampler objects? No. With samplers, you decouple the sampling parameters from texture objects. This allows you to use the same set of parameters for multiple different objects. And therefore, you can change one sampler object and use that with multiple textures, without having to go to each texture and modify it.

They're two different features, for two different purposes.

like image 103
Nicol Bolas Avatar answered Sep 19 '22 11:09

Nicol Bolas