简体   繁体   中英

Same sampler, multiple texture units, OpenGL

With OpenGL (core profile, 4.4), is it "legal" to bind the same sampler object to 2 different texture units at the same time?

My test shows it works, but I don't know if my driver is being forgiving or if it's a feature.

Yes, this is perfectly acceptable as discussed below.

OpenGL 4.4 Core Profile Specification - 8.2 Sampler Objects - pp. 164-165

8.2 Sampler Objects

When a sampler object is bound to a texture unit, its state supersedes that of the texture object bound to that texture unit. If the sampler name zero is bound to a texture unit, the currently bound texture's sampler state becomes active. A single sampler object may be bound to multiple texture units simultaneously.

A sampler object binding is effected with the command:

void glBindSampler (GLuint unit, GLuint sampler);

with unit set to the zero-based index of the texture unit to which to bind the sampler and sampler set to the name of a sampler object returned from a previous call to glGenSamplers .

If the bind is successful no change is made to the state of the bound sampler object, and any previous binding to unit is broken.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM