Home -> IStateContainer -> BindTextureWithCombinedSampler

Description

The BindTextureWithCombinedSampler method sets up a binding to an ITextureBuffer object, which has an associated combined ITextureSampler. Alternatively, the BindTexture and BindSampler methods allow textures and samplers to be separately bound, if this is supported by the renderer.

ImportantImportant

In order to bind textures and samplers separately, the SeparateTextureSamplers feature must be supported on the IGraphicsDevice, and activated when the CreateRenderer method is called.

WarningWarning

Separate texture samplers are supported by all underlying rendering APIs other than OpenGL. If you care about OpenGL support, you must not use separate texture samplers. The BindTextureWithCombinedSampler method is portable across all renderers, and provides the same functionality as separate texture samplers, with the restriction that each separately bound texture requires the sampler to be bound with it. ITextureSampler objects can still be shared between textures even when they are bound separately, so unless you have a case where there is a significant advantage to separately binding samplers, it is recommended to use combined image samplers.

Usage

void BindTextureWithCombinedSampler(TextureId textureId, ITextureBuffer1D* texture, ITextureSampler1D* sampler);
void BindTextureWithCombinedSampler(TextureId textureId, ITextureBuffer2D* texture, ITextureSampler2D* sampler);
void BindTextureWithCombinedSampler(TextureId textureId, ITextureBuffer3D* texture, ITextureSampler3D* sampler);
void BindTextureWithCombinedSampler(TextureId textureId, ITextureBufferCube* texture, ITextureSamplerCube* sampler);
void BindTextureWithCombinedSampler(TextureId textureId, ITextureBuffer1DArray* texture, ITextureSampler1DArray* sampler);
void BindTextureWithCombinedSampler(TextureId textureId, ITextureBuffer2DArray* texture, ITextureSampler2DArray* sampler);
void BindTextureWithCombinedSampler(TextureId textureId, ITextureBufferCubeArray* texture, ITextureSamplerCubeArray* sampler);

Argument list

textureId [TextureId]
The TextureId of the named texture object to bind
texture [ITextureBuffer*]
The ITextureBuffer to bind
sampler [ITextureSampler*]
The ITextureSampler to bind

Shader-side code

In HLSL, define a SamplerState and a Texture with the same name, with the sampler suffixed with _CombinedSampler. Eg:


Texture2D objectTexture;
SamplerState objectTexture_CombinedSampler;
      

In GLSL, define a single variable with the desired name Eg:


uniform sampler2D objectTexture;

In SPIRV, use OpName to annotate the pointer to the OpTypeSampledImage with a name.

Several tools from Khronos force the use of "textureName" and "_textureName_sampler" naming convention for splitting up combined samplers, without allowing customisation. These are also supported for convenience.

See also