struct _Texture<T, Shape, int isArray, int isMS, int sampleCount, int access, int isShadow, int isCombined, int format>

Conditionally conforms to: __IDynamicResourceCastable<__DynamicResourceKind.General>

Internal Feature

The feature described in this page is marked as an internal implementation detail, and is not intended for use by end-users. Users are advised to avoid using this declaration directly, as it may be removed or changed in future releases.

Description

A parameterized type that represents all flavors of texture types supported by the Slang language. Please note that this type is not intended to be used directly in user code, and not all combinations of the generic arguments are valid. Instead, use the specific texture types such as Texture1D, Texture2DArray and Sampler2D etc. This documentation is provided for reference purposes only.

Generic Parameters

T: ITexelElement

The element type of the texture. Must be a scalar or vector type.

Shape: __ITextureShape

The shape of the texture. Must be one of __Shape1D, __Shape2D, __Shape3D, __ShapeCube or __ShapeBuffer.

isArray : int

Indicates whether the texture is an array texture.

isMS : int

Indicates whether the texture is a multisampled texture.

sampleCount : int

The number of samples of a multisampled texture.

access : int

The access mode of the texture. 0 for read-only, 1 for read-write, 2 for write-only, 3 for rasterizer-ordered, 4 for feedback.

isShadow : int

Indicates whether the texture is a depth texture (isCombined==0) or a shadow texture (isCombined==1).

isCombined : int

Indicates whether the texture is a combined texture-sampler.

format : int

The storage format of the texture. Users should specify the format using an [format(”…”)] attribute instead.

Fields

descriptorAccess : DescriptorAccess = access

kind : DescriptorKind =…

Methods

Conditional Conformances

Conformance to __IDynamicResourceCastable<__DynamicResourceKind.General>

_Texture<T, Shape, int isArray, int isMS, int sampleCount, int access, int isShadow, int isCombined, int format> additionally conforms to __IDynamicResourceCastable<__DynamicResourceKind.General> when the following conditions are met:

Remarks

HLSL texture types are implemented as typealiases to the builtin _Texture type. Users are advised to use the HLSL-specific texture types instead of _Texture directly.

For read-write textures, Slang will automatically infer format from T. To explicitly specify texel storage formats for read-write textures, use the [format(“formatString”)] attribute on the texture parameter declaration. Allowed formatString values are:

id

Format string

Meaning

1

”rgba32f”

4 channel 32-bit floating point texture

2

”rgba16f”

4 channel 16-bit floating point texture

3

”rg32f”

2 channel 32-bit floating point texture

4

”rg16f”

2 channel 16-bit floating point texture

5

”r11f_g11f_b10f”

3 channel 11/11/10-bit floating point texture

6

”r32f”

1 channel 32-bit floating point texture

7

”r16f”

1 channel 16-bit floating point texture

8

”rgba16”

4 channel 16-bit normalized unsigned integer texture

9

”rgb10_a2”

4 channel 10/10/10/2-bit normalized unsigned integer texture

10

”rgba8”

4 channel 8-bit normalized unsigned integer texture

11

”rg16”

2 channel 16-bit normalized unsigned integer texture

12

”rg8”

2 channel 8-bit normalized unsigned integer texture

13

”r16”

1 channel 16-bit normalized unsigned integer texture

14

”r8”

1 channel 8-bit normalized unsigned integer texture

15

”rgba16_snorm”

4 channel 16-bit normalized signed integer texture

16

”rgba8_snorm”

4 channel 8-bit normalized signed integer texture

17

”rg16_snorm”

2 channel 16-bit normalized signed integer texture

18

”rg8_snorm”

2 channel 8-bit normalized signed integer texture

19

”r16_snorm”

1 channel 16-bit normalized signed integer texture

20

”r8_snorm”

1 channel 8-bit normalized signed integer texture

21

”rgba32i”

4 channel 32-bit signed integer texture

22

”rgba16i”

4 channel 16-bit signed integer texture

23

”rgba8i”

4 channel 8-bit signed integer texture

24

”rg32i”

2 channel 32-bit signed integer texture

25

”rg16i”

2 channel 16-bit signed integer texture

26

”rg8i”

2 channel 8-bit signed integer texture

27

”r32i”

1 channel 32-bit signed integer texture

28

”r16i”

1 channel 16-bit signed integer texture

29

”r8i”

1 channel 8-bit signed integer texture

30

”rgba32ui”

4 channel 32-bit unsigned integer texture

31

”rgba16ui”

4 channel 16-bit unsigned integer texture

32

”rgb10_a2ui”

4 channel 10/10/10/2-bit unsigned integer texture

33

”rgba8ui”

4 channel 8-bit unsigned integer texture

34

”rg32ui”

2 channel 32-bit unsigned integer texture

35

”rg16ui”

2 channel 16-bit unsigned integer texture

36

”rg8ui”

2 channel 8-bit unsigned integer texture

37

”r32ui”

1 channel 32-bit unsigned integer texture

38

”r16ui”

1 channel 16-bit unsigned integer texture

39

”r8ui”

1 channel 8-bit unsigned integer texture

40

”r64ui”

1 channel 64-bit unsigned integer texture

41

”r64i”

1 channel 64-bit signed integer texture

When targeting Vulkan, a combined-texture-sampler type (isCombined==1) translates to a OpTypeSampledImage type in SPIR-V. For other targets, the combined-texture-sampler type is translated to a pair of a Texture and SamplerState.

The defined texture types and their backend support:

Type

Cuda

GLSL core version / extension

HLSL

Metal/macOS

SPIR-V

WGSL

DepthTexture1D

110

SM 4.0

-

-

DepthTexture1DArray

130 / EXT_texture_array

SM 4.0

-

-

DepthTexture2D

110

SM 4.0

1.0

1.0

DepthTexture2DArray

130 / EXT_texture_array

SM 4.0

1.0

1.0

DepthTexture2DMS

-

SM 4.0

1.0

1.0

DepthTexture2DMSArray

-

SM 4.0

2.0

-

DepthTexture3D

-

-

-

-

DepthTextureCube

110

SM 4.0

1.0

1.0

DepthTextureCubeArray

400 / ARB_texture_cube_map_array

SM 4.0

1.0

1.0

FeedbackTexture2D

-

SM 6.5

-

-

FeedbackTexture2DArray

-

SM 6.5

-

-

RWTexture1D

420 / ARB_shader_image_load_store

SM 5.0

1.0

1.0

RWTexture1DArray

420 / ARB_shader_image_load_store

SM 5.0

1.0

-

RWTexture2D

420 / ARB_shader_image_load_store

SM 5.0

1.0

1.0

RWTexture2DArray

420 / ARB_shader_image_load_store

SM 5.0

1.0

1.0

RWTexture2DMS

420 / ARB_shader_image_load_store

SM 6.7

-

-

RWTexture2DMSArray

420 / ARB_shader_image_load_store

SM 6.7

-

-

RWTexture3D

420 / ARB_shader_image_load_store

SM 5.0

1.0

1.0

RasterizerOrderedTexture1D

none / ARB_fragment_shader_interlock

SM 5.1

2.0

-

RasterizerOrderedTexture1DArray

none / ARB_fragment_shader_interlock

SM 5.1

2.0

-

RasterizerOrderedTexture2D

none / ARB_fragment_shader_interlock

SM 5.1

2.0

-

RasterizerOrderedTexture2DArray

none / ARB_fragment_shader_interlock

SM 5.1

2.0

-

RasterizerOrderedTexture3D

none / ARB_fragment_shader_interlock

SM 5.1

2.0

-

Texture1D

110

SM 4.0

1.0

1.0

Texture1DArray

130 / EXT_texture_array

SM 4.0

1.0

-

Texture2D

110

SM 4.0

1.0

1.0

Texture2DArray

130 / EXT_texture_array

SM 4.0

1.0

1.0

Texture2DMS

150(*)

SM 4.0

1.0

1.0

Texture2DMSArray

150(*)

SM 4.0

2.0

-

Texture3D

110

SM 4.0

1.0

1.0

TextureCube

110

SM 4.0

1.0

1.0

TextureCubeArray

400 / ARB_texture_cube_map_array

SM 4.0

1.0

1.0

WTexture1D

420 / ARB_shader_image_load_store

-

1.0

1.0

WTexture1DArray

420 / ARB_shader_image_load_store

-

1.0

-

WTexture2D

420 / ARB_shader_image_load_store

-

1.0

1.0

WTexture2DArray

420 / ARB_shader_image_load_store

-

1.0

1.0

WTexture3D

420 / ARB_shader_image_load_store

-

1.0

1.0

(*) Usable only via combined texture-sampler types.

The combined texture-sampler types and their backend support:

See also

Texture1D, Texture2D, Texture3D, TextureCube, Texture1DArray, Texture2DArray, TextureCubeArray, Sampler1D, Sampler2D, Sampler3D, SamplerCube, Sampler1DArray, Sampler2DArray, SamplerCubeArray, Texture2DMS, Texture2DMSArray, RWTexture1D, RWTexture2D, RWTexture3D, RWTexture1DArray, RWTexture2DArray, RWTexture2DMS, RWTexture2DMSArray, Buffer, RWBuffer, FeedbackTexture2D, FeedbackTexture2DArray.