In opengl3.3, a sampler object is added first. Remember that when we used to use OpenGL, sometimes the same texture data is required, but the filter mode is different, however, since Multiple Attribute Sets cannot share the same texture object, therefore, it is very clumsy and wasteful to create two different texture objects (of course to share multiple texture objects with the same Pixel Buffer. The newly added samplerger object makes this work easy and logical and intuitive "aesthetic"
A sampling object actually defines attributes such as filtering and addressing mode, but does not include the width and height of the texture. This is also true because the samplerger can share multiple texture objects. When these texture objects have different texture memory sizes, they will not cause ambiguity.
The procedure is as follows:
Glgensamplers (1, & samplerid); </P> <p> glsamplerparameteri (latency, latency, gl_linear); </P> <p> glsamplerparameteri (latency, latency, gl_linear ); </P> <p> // set orther sampler attributes </P> <p> glactivetexture (gl_texture0); </P> <p> glbindsampler (gl_texture0, samplerid ); </P> <p> glactivetexture (gl_texture1); </P> <p> glbindsampler (gl_texture1, samplerid); </P> <p>... </P> <p>
A single sampler can be shared by multiple texture units. When the attributes of the object change, all texture objects associated with the Texture unit lock will be affected: As shown in the code above, bind a samplerger object to two different texture units. Assume that the two texture units are bound to the texture objects tex0 and tex1 respectively, tex1 and tex2 will have the same filtering and addressing modes, and tex1 and tex2 do not need to have the same size. When multiple textures associated with the same Samper object have the same size, data type, and number of channels (although this is not actually necessary, because functions such as glteximage2d provide internalformat and format parameters to ensure that the program is correctly executed, but this should also be done out of caution and correctness ), another hidden value of this feature is that the same data source can be shared.
This feature is also introduced into cuda3.0,
Before PTX 1. *, You need to declare the texture as follows:
. Tex. u32 texid </P> <p> cuda3.0 continues to provide support for forward compatibility, but is not recommended. In section 3.0, textures are used in the unified mode and independent mode. In PTX, </P> <p>. target texmode_independent // If nessesary </P> <p>. global. texref; </P> <p>. global. samplerref sampler = {addr_mode0 = clamp, addr_mode1 = clamp, filter_mode = Linear}; </P> <p>... </P> <p> // linear filtering and clamping addressing modes are used when the texture object texref is retrieved from the texture. (Note that the texref object is bound to the texture memory, </P> <p> // sampler only sets the attribute set of the associated texture object.) </P> <p> tex.2d. v4.f32. f32 {% F0, % F1, % F2, % F3}, [texref, sampler, {% r0, % R1}]; <br/>