Table of Contents

Class Texture

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

Class used for all Textures (1D, 2D, 3D, DepthStencil, RenderTargets...etc.)

[DataSerializerGlobal(typeof(ReferenceSerializer<Texture>), null, DataSerializerGenericMode.None, false, false, Profile = "Content")]
[ContentSerializer(typeof(TextureContentSerializer))]
[ContentSerializer(typeof(TextureImageSerializer))]
[DataSerializer(typeof(TextureSerializer))]
public sealed class Texture : GraphicsResource, IDisposable, IComponent, IReferencable, ICollectorHolder
Inheritance
Texture
Implements
Inherited Members
Extension Methods

Constructors

Texture()

public Texture()

Properties

ArraySize

Number of textures in the array.

public int ArraySize { get; }

Property Value

int

The size of the array.

Remarks

This field is only valid for 1D, 2D and Cube Texture.

ArraySlice

The array index of this texture view.

public int ArraySlice { get; }

Property Value

int

The array slice.

Depth

The depth of the texture.

public int Depth { get; }

Property Value

int

The depth.

Description

Common description for the original texture. See remarks.

public TextureDescription Description { get; }

Property Value

TextureDescription

Remarks

This field and the properties in TextureDessciption must be considered as readonly when accessing from this instance.

Dimension

The dimension of a texture.

public TextureDimension Dimension { get; }

Property Value

TextureDimension

Flags

Texture flags.

public TextureFlags Flags { get; }

Property Value

TextureFlags

Format

Texture format (see PixelFormat)

public PixelFormat Format { get; }

Property Value

PixelFormat

The format.

FullQualitySize

When texture streaming is activated, the size of the texture when loaded at full quality.

public Size3 FullQualitySize { get; }

Property Value

Size3

Height

The height of the texture.

public int Height { get; }

Property Value

int

The height.

IsBlockCompressed

Gets a boolean indicating whether this Texture is a using a block compress format (BC1, BC2, BC3, BC4, BC5, BC6H, BC7).

public bool IsBlockCompressed { get; }

Property Value

bool

IsDepthStencil

Gets a value indicating whether this instance is a depth stencil.

public bool IsDepthStencil { get; }

Property Value

bool

true if this instance is a depth stencil; otherwise, false.

IsDepthStencilReadOnly

Gets a value indicating whether this instance is a depth stencil readonly.

public bool IsDepthStencilReadOnly { get; }

Property Value

bool

true if this instance is a depth stencil readonly; otherwise, false.

IsMultisample

Gets a value indicating whether this instance is a multi sample texture.

public bool IsMultisample { get; }

Property Value

bool

true if this instance is multi sample texture; otherwise, false.

IsRenderTarget

Gets a value indicating whether this instance is a render target.

public bool IsRenderTarget { get; }

Property Value

bool

true if this instance is render target; otherwise, false.

IsShaderResource

Gets a value indicating whether this instance is a shader resource.

public bool IsShaderResource { get; }

Property Value

bool

true if this instance is a shader resource; otherwise, false.

IsUnorderedAccess

Gets a value indicating whether this instance is a shader resource.

public bool IsUnorderedAccess { get; }

Property Value

bool

true if this instance is a shader resource; otherwise, false.

MipLevel

The miplevel index of this texture view.

public int MipLevel { get; }

Property Value

int

The mip level.

MipLevels

The maximum number of mipmap levels in the texture.

public int MipLevels { get; }

Property Value

int

The mip levels.

MultisampleCount

Structure that specifies multisampling parameters for the texture.

public MultisampleCount MultisampleCount { get; }

Property Value

MultisampleCount

The multi sample level.

Remarks

This field is only valid for a 2D Texture.

Options

Resource options for DirectX 11 textures.

public TextureOptions Options { get; }

Property Value

TextureOptions

SharedHandle

The shared handle if created with TextureOption.Shared or TextureOption.SharedNthandle, IntPtr.Zero otherwise.

public IntPtr SharedHandle { get; }

Property Value

IntPtr

SharedNtHandleName

Gets the name of the shared Nt handle when created with TextureOption.SharedNthandle.

public string SharedNtHandleName { get; }

Property Value

string

Size

Gets the size of this texture.

public Size3 Size { get; }

Property Value

Size3

The size.

Usage

Value that identifies how the texture is to be read from and written to.

public GraphicsResourceUsage Usage { get; }

Property Value

GraphicsResourceUsage

ViewDepth

The depth of this texture view.

public int ViewDepth { get; }

Property Value

int

The view depth.

ViewDescription

Gets the view description.

public TextureViewDescription ViewDescription { get; }

Property Value

TextureViewDescription

The view description.

ViewDimension

The dimension of the texture view.

public TextureDimension ViewDimension { get; }

Property Value

TextureDimension

ViewFlags

The format of this texture view.

public TextureFlags ViewFlags { get; }

Property Value

TextureFlags

The type of the view.

ViewFormat

The format of this texture view.

public PixelFormat ViewFormat { get; }

Property Value

PixelFormat

The view format.

ViewHeight

The height of this texture view.

public int ViewHeight { get; }

Property Value

int

The height of the view.

ViewType

The format of this texture view.

public ViewType ViewType { get; }

Property Value

ViewType

The type of the view.

ViewWidth

The width of this texture view.

public int ViewWidth { get; }

Property Value

int

The width of the view.

Width

The width of the texture.

public int Width { get; }

Property Value

int

The width.

Methods

CalculateMipLevels(int, MipMapCount)

Calculates the number of miplevels for a Texture 1D.

public static int CalculateMipLevels(int width, MipMapCount mipLevels)

Parameters

width int

The width of the texture.

mipLevels MipMapCount

A MipMapCount, set to true to calculates all mipmaps, to false to calculate only 1 miplevel, or > 1 to calculate a specific amount of levels.

Returns

int

The number of miplevels.

CalculateMipLevels(int, int, MipMapCount)

Calculates the number of miplevels for a Texture 2D.

public static int CalculateMipLevels(int width, int height, MipMapCount mipLevels)

Parameters

width int

The width of the texture.

height int

The height of the texture.

mipLevels MipMapCount

A MipMapCount, set to true to calculates all mipmaps, to false to calculate only 1 miplevel, or > 1 to calculate a specific amount of levels.

Returns

int

The number of miplevels.

CalculateMipLevels(int, int, int, MipMapCount)

Calculates the number of miplevels for a Texture 2D.

public static int CalculateMipLevels(int width, int height, int depth, MipMapCount mipLevels)

Parameters

width int

The width of the texture.

height int

The height of the texture.

depth int

The depth of the texture.

mipLevels MipMapCount

A MipMapCount, set to true to calculates all mipmaps, to false to calculate only 1 miplevel, or > 1 to calculate a specific amount of levels.

Returns

int

The number of miplevels.

CalculateMipSize(int, int)

Calculates the size of a particular mip.

public static int CalculateMipSize(int size, int mipLevel)

Parameters

size int

The size.

mipLevel int

The mip level.

Returns

int

System.Int32.

CalculatePixelDataCount<TData>(int)

Calculates the number of pixel data this texture is requiring for a particular mip level.

public int CalculatePixelDataCount<TData>(int mipLevel = 0) where TData : unmanaged

Parameters

mipLevel int

The mip level.

Returns

int

The number of pixel data.

Type Parameters

TData

The type of the T pixel data.

Remarks

This method is used to allocated a texture data buffer to hold pixel datas: var textureData = new T[ texture.CalculatePixelCount<T>() ] ;.

CalculateWidth<TData>(int)

Calculates the expected width of a texture using a specified type.

public int CalculateWidth<TData>(int mipLevel = 0) where TData : unmanaged

Parameters

mipLevel int

Returns

int

The expected width

Type Parameters

TData

The type of the T pixel data.

Exceptions

ArgumentException

If the size is invalid

Clone()

Makes a copy of this texture.

public Texture Clone()

Returns

Texture

A copy of this texture.

Remarks

This method doesn't copy the content of the texture.

CountMips(int)

public static int CountMips(int width)

Parameters

width int

Returns

int

CountMips(int, int)

public static int CountMips(int width, int height)

Parameters

width int
height int

Returns

int

CountMips(int, int, int)

public static int CountMips(int width, int height, int depth)

Parameters

width int
height int
depth int

Returns

int

Destroy()

Disposes of object resources.

protected override void Destroy()

GetData(CommandList, Texture, DataPointer, int, int, bool)

Copies the content of this texture from GPU memory to a pointer on CPU memory using a specific staging resource.

public bool GetData(CommandList commandList, Texture stagingTexture, DataPointer toData, int arraySlice = 0, int mipSlice = 0, bool doNotWait = false)

Parameters

commandList CommandList

The command list.

stagingTexture Texture

The staging texture used to transfer the texture to.

toData DataPointer

The pointer to data in CPU memory.

arraySlice int

The array slice index. This value must be set to 0 for Texture 3D.

mipSlice int

The mip slice index.

doNotWait bool

if set to true this method will return immediately if the resource is still being used by the GPU for writing. Default is false

Returns

bool

true if data was correctly retrieved, false if doNotWait flag was true and the resource is still being used by the GPU for writing.

Remarks

This method is only working when called from the main thread that is accessing the main GraphicsDevice.

Exceptions

ArgumentException

When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length

GetDataAsImage(CommandList)

Gets the GPU content of this texture as an Image on the CPU.

public Image GetDataAsImage(CommandList commandList)

Parameters

commandList CommandList

Returns

Image

GetDataAsImage(CommandList, Texture)

Gets the GPU content of this texture to an Image on the CPU.

public Image GetDataAsImage(CommandList commandList, Texture stagingTexture)

Parameters

commandList CommandList

The command list.

stagingTexture Texture

The staging texture used to temporary transfer the image from the GPU to CPU.

Returns

Image

Exceptions

ArgumentException

If stagingTexture is not a staging texture.

GetData<TData>(CommandList, Texture, TData[], int, int, bool)

Copies the content of this texture from GPU memory to an array of data on CPU memory using a specific staging resource.

public bool GetData<TData>(CommandList commandList, Texture stagingTexture, TData[] toData, int arraySlice = 0, int mipSlice = 0, bool doNotWait = false) where TData : unmanaged

Parameters

commandList CommandList

The command list.

stagingTexture Texture

The staging texture used to transfer the texture to.

toData TData[]

To data.

arraySlice int

The array slice index. This value must be set to 0 for Texture 3D.

mipSlice int

The mip slice index.

doNotWait bool

if set to true this method will return immediately if the resource is still being used by the GPU for writing. Default is false

Returns

bool

true if data was correctly retrieved, false if doNotWait flag was true and the resource is still being used by the GPU for writing.

Type Parameters

TData

The type of the T data.

Remarks

This method is only working when called from the main thread that is accessing the main GraphicsDevice.

Exceptions

ArgumentException

When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length

GetData<TData>(CommandList, int, int)

Gets the content of this texture to an array of data.

public TData[] GetData<TData>(CommandList commandList, int arraySlice = 0, int mipSlice = 0) where TData : unmanaged

Parameters

commandList CommandList

The command list.

arraySlice int

The array slice index. This value must be set to 0 for Texture 3D.

mipSlice int

The mip slice index.

Returns

TData[]

The texture data.

Type Parameters

TData

The type of the T data.

Remarks

This method is only working when called from the main thread that is accessing the main GraphicsDevice. This method creates internally a stagging resource, copies to it and map it to memory. Use method with explicit staging resource for optimal performances.

GetData<TData>(CommandList, TData[], int, int, bool)

Copies the content of this texture to an array of data.

public bool GetData<TData>(CommandList commandList, TData[] toData, int arraySlice = 0, int mipSlice = 0, bool doNotWait = false) where TData : unmanaged

Parameters

commandList CommandList

The command list.

toData TData[]

The destination buffer to receive a copy of the texture datas.

arraySlice int

The array slice index. This value must be set to 0 for Texture 3D.

mipSlice int

The mip slice index.

doNotWait bool

if set to true this method will return immediately if the resource is still being used by the GPU for writing. Default is false

Returns

bool

true if data was correctly retrieved, false if doNotWait flag was true and the resource is still being used by the GPU for writing.

Type Parameters

TData

The type of the T data.

Remarks

This method is only working when called from the main thread that is accessing the main GraphicsDevice. This method creates internally a stagging resource if this texture is not already a stagging resouce, copies to it and map it to memory. Use method with explicit staging resource for optimal performances.

GetMipMapDescription(int)

Gets the mipmap description of this instance for the specified mipmap level.

public MipMapDescription GetMipMapDescription(int mipmap)

Parameters

mipmap int

The mipmap.

Returns

MipMapDescription

A description of a particular mipmap for this texture.

GetSubResourceIndex(int, int)

Gets the absolute sub-resource index from the array and mip slice.

public int GetSubResourceIndex(int arraySlice, int mipSlice)

Parameters

arraySlice int

The array slice index.

mipSlice int

The mip slice index.

Returns

int

A value equals to arraySlice * Description.MipLevels + mipSlice.

IsDepthStencilReadOnlySupported(GraphicsDevice)

public static bool IsDepthStencilReadOnlySupported(GraphicsDevice device)

Parameters

device GraphicsDevice

Returns

bool

Load(GraphicsDevice, Stream, TextureFlags, GraphicsResourceUsage, bool)

Loads a texture from a stream.

public static Texture Load(GraphicsDevice device, Stream stream, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable, bool loadAsSRGB = false)

Parameters

device GraphicsDevice

The GraphicsDevice.

stream Stream

The stream to load the texture from.

textureFlags TextureFlags

True to load the texture with unordered access enabled. Default is false.

usage GraphicsResourceUsage

Usage of the resource. Default is Immutable

loadAsSRGB bool

Indicate if the texture should be loaded as an sRGB texture. If false, the texture is load in its default format.

Returns

Texture

A texture

New(GraphicsDevice, Image, TextureFlags, GraphicsResourceUsage)

Loads a texture from a stream.

public static Texture New(GraphicsDevice device, Image image, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable)

Parameters

device GraphicsDevice

The GraphicsDevice.

image Image

The image.

textureFlags TextureFlags

True to load the texture with unordered access enabled. Default is false.

usage GraphicsResourceUsage

Usage of the resource. Default is Immutable

Returns

Texture

A texture

Exceptions

InvalidOperationException

Dimension not supported

New(GraphicsDevice, TextureDescription, params DataBox[])

Creates a new texture with the specified generic texture description.

public static Texture New(GraphicsDevice graphicsDevice, TextureDescription description, params DataBox[] boxes)

Parameters

graphicsDevice GraphicsDevice

The graphics device.

description TextureDescription

The description.

boxes DataBox[]

The data boxes.

Returns

Texture

A Texture instance, either a RenderTarget or DepthStencilBuffer or Texture, depending on Binding flags.

Exceptions

ArgumentNullException

graphicsDevice

New(GraphicsDevice, TextureDescription, TextureViewDescription, params DataBox[])

Creates a new texture with the specified generic texture description.

public static Texture New(GraphicsDevice graphicsDevice, TextureDescription description, TextureViewDescription viewDescription, params DataBox[] boxes)

Parameters

graphicsDevice GraphicsDevice

The graphics device.

description TextureDescription

The description.

viewDescription TextureViewDescription

The view description.

boxes DataBox[]

The data boxes.

Returns

Texture

A Texture instance, either a RenderTarget or DepthStencilBuffer or Texture, depending on Binding flags.

Exceptions

ArgumentNullException

graphicsDevice

New1D(GraphicsDevice, int, MipMapCount, PixelFormat, TextureFlags, int, GraphicsResourceUsage)

Creates a new 1D Texture.

public static Texture New1D(GraphicsDevice device, int width, MipMapCount mipCount, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, int arraySize = 1, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

mipCount MipMapCount

Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.

format PixelFormat

Describes the format to use.

textureFlags TextureFlags

true if the texture needs to support unordered read write.

arraySize int

Size of the texture 2D array, default to 1.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of 1D Texture class.

New1D(GraphicsDevice, int, PixelFormat, TextureFlags, int, GraphicsResourceUsage)

Creates a new 1D Texture with a single mipmap.

public static Texture New1D(GraphicsDevice device, int width, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, int arraySize = 1, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

format PixelFormat

Describes the format to use.

textureFlags TextureFlags

true if the texture needs to support unordered read write.

arraySize int

Size of the texture 2D array, default to 1.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of 1D Texture class.

New1D(GraphicsDevice, int, PixelFormat, IntPtr, TextureFlags, GraphicsResourceUsage)

Creates a new 1D Texture with a single level of mipmap.

public static Texture New1D(GraphicsDevice device, int width, PixelFormat format, IntPtr dataPtr, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable)

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

format PixelFormat

Describes the format to use.

dataPtr IntPtr

Data ptr

textureFlags TextureFlags

true if the texture needs to support unordered read write.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of 1D Texture class.

Remarks

The first dimension of mipMapTextures describes the number of array (Texture Array), second dimension is the mipmap, the third is the texture data for a particular mipmap.

New1D<T>(GraphicsDevice, int, PixelFormat, T[], TextureFlags, GraphicsResourceUsage)

Creates a new 1D Texture with a single level of mipmap.

public static Texture New1D<T>(GraphicsDevice device, int width, PixelFormat format, T[] textureData, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable) where T : unmanaged

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

format PixelFormat

Describes the format to use.

textureData T[]

Texture data. Size of must be equal to sizeof(Format) * width

textureFlags TextureFlags

true if the texture needs to support unordered read write.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of Texture class.

Type Parameters

T

Type of the initial data to upload to the texture

Remarks

The first dimension of mipMapTextures describes the number of array (Texture Array), second dimension is the mipmap, the third is the texture data for a particular mipmap.

New2D(GraphicsDevice, int, int, MipMapCount, PixelFormat, DataBox[], TextureFlags, int, GraphicsResourceUsage, MultisampleCount, TextureOptions)

Creates a new 2D Texture.

public static Texture New2D(GraphicsDevice device, int width, int height, MipMapCount mipCount, PixelFormat format, DataBox[] textureData, TextureFlags textureFlags = TextureFlags.ShaderResource, int arraySize = 1, GraphicsResourceUsage usage = GraphicsResourceUsage.Default, MultisampleCount multisampleCount = MultisampleCount.None, TextureOptions options = TextureOptions.None)

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

height int

The height.

mipCount MipMapCount

Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.

format PixelFormat

Describes the format to use.

textureData DataBox[]

Texture datas through an array of DataBox

textureFlags TextureFlags

true if the texture needs to support unordered read write.

arraySize int

Size of the texture 2D array, default to 1.

usage GraphicsResourceUsage

The usage.

multisampleCount MultisampleCount

The multisample count.

options TextureOptions

The options, e.g. sharing

Returns

Texture

A new instance of 2D Texture class.

New2D(GraphicsDevice, int, int, MipMapCount, PixelFormat, TextureFlags, int, GraphicsResourceUsage, TextureOptions)

Creates a new 2D Texture.

public static Texture New2D(GraphicsDevice device, int width, int height, MipMapCount mipCount, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, int arraySize = 1, GraphicsResourceUsage usage = GraphicsResourceUsage.Default, TextureOptions options = TextureOptions.None)

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

height int

The height.

mipCount MipMapCount

Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.

format PixelFormat

Describes the format to use.

textureFlags TextureFlags

true if the texture needs to support unordered read write.

arraySize int

Size of the texture 2D array, default to 1.

usage GraphicsResourceUsage

The usage.

options TextureOptions

Returns

Texture

A new instance of 2D Texture class.

New2D(GraphicsDevice, int, int, PixelFormat, TextureFlags, int, GraphicsResourceUsage, TextureOptions)

Creates a new 2D Texture with a single mipmap.

public static Texture New2D(GraphicsDevice device, int width, int height, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, int arraySize = 1, GraphicsResourceUsage usage = GraphicsResourceUsage.Default, TextureOptions options = TextureOptions.None)

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

height int

The height.

format PixelFormat

Describes the format to use.

textureFlags TextureFlags

true if the texture needs to support unordered read write.

arraySize int

Size of the texture 2D array, default to 1.

usage GraphicsResourceUsage

The usage.

options TextureOptions

Returns

Texture

A new instance of 2D Texture class.

New2D<T>(GraphicsDevice, int, int, PixelFormat, T[], TextureFlags, GraphicsResourceUsage, TextureOptions)

Creates a new 2D Texture with a single level of mipmap.

public static Texture New2D<T>(GraphicsDevice device, int width, int height, PixelFormat format, T[] textureData, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable, TextureOptions options = TextureOptions.None) where T : unmanaged

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

height int

The height.

format PixelFormat

Describes the format to use.

textureData T[]

The texture data for a single mipmap and a single array slice. See remarks

textureFlags TextureFlags

true if the texture needs to support unordered read write.

usage GraphicsResourceUsage

The usage.

options TextureOptions

Returns

Texture

A new instance of 2D Texture class.

Type Parameters

T

Type of the pixel data to upload to the texture.

Remarks

Each value in textureData is a pixel in the destination texture.

New3D(GraphicsDevice, int, int, int, MipMapCount, PixelFormat, DataBox[], TextureFlags, GraphicsResourceUsage)

Creates a new 3D Texture.

public static Texture New3D(GraphicsDevice device, int width, int height, int depth, MipMapCount mipCount, PixelFormat format, DataBox[] textureData, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

height int

The height.

depth int

The depth.

mipCount MipMapCount

Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.

format PixelFormat

Describes the format to use.

textureData DataBox[]
textureFlags TextureFlags

true if the texture needs to support unordered read write.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of 3D Texture class.

New3D(GraphicsDevice, int, int, int, MipMapCount, PixelFormat, TextureFlags, GraphicsResourceUsage)

Creates a new 3D Texture.

public static Texture New3D(GraphicsDevice device, int width, int height, int depth, MipMapCount mipCount, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

height int

The height.

depth int

The depth.

mipCount MipMapCount

Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.

format PixelFormat

Describes the format to use.

textureFlags TextureFlags

true if the texture needs to support unordered read write.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of 3D Texture class.

New3D(GraphicsDevice, int, int, int, PixelFormat, TextureFlags, GraphicsResourceUsage)

Creates a new 3D Texture with a single mipmap.

public static Texture New3D(GraphicsDevice device, int width, int height, int depth, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

height int

The height.

depth int

The depth.

format PixelFormat

Describes the format to use.

textureFlags TextureFlags

true if the texture needs to support unordered read write.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of 3D Texture class.

New3D<T>(GraphicsDevice, int, int, int, PixelFormat, T[], TextureFlags, GraphicsResourceUsage)

Creates a new 3D Texture with texture data for the firs map.

public static Texture New3D<T>(GraphicsDevice device, int width, int height, int depth, PixelFormat format, T[] textureData, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable) where T : unmanaged

Parameters

device GraphicsDevice

The GraphicsDevice.

width int

The width.

height int

The height.

depth int

The depth.

format PixelFormat

Describes the format to use.

textureData T[]

The texture data, width * height * depth datas

textureFlags TextureFlags

true if the texture needs to support unordered read write.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of 3D Texture class.

Type Parameters

T

Type of the data to upload to the texture

Remarks

The first dimension of mipMapTextures describes the number of is an array ot Texture3D Array

NewCube(GraphicsDevice, int, MipMapCount, PixelFormat, TextureFlags, GraphicsResourceUsage)

Creates a new Cube Texture.

public static Texture NewCube(GraphicsDevice device, int size, MipMapCount mipCount, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)

Parameters

device GraphicsDevice

The GraphicsDevice.

size int

The size (in pixels) of the top-level faces of the cube texture.

mipCount MipMapCount

Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.

format PixelFormat

Describes the format to use.

textureFlags TextureFlags

The texture flags.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of 2D Texture class.

NewCube(GraphicsDevice, int, PixelFormat, DataBox[], TextureFlags, GraphicsResourceUsage)

Creates a new Cube Texture from a initial data..

public static Texture NewCube(GraphicsDevice device, int size, PixelFormat format, DataBox[] textureData, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable)

Parameters

device GraphicsDevice

The GraphicsDevice.

size int

The size (in pixels) of the top-level faces of the cube texture.

format PixelFormat

Describes the format to use.

textureData DataBox[]

an array of 6 textures. See remarks

textureFlags TextureFlags

The texture flags.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of Cube Texture class.

Remarks

The first dimension of mipMapTextures describes the number of array (TextureCube Array), the second is the texture data for a particular cube face.

Exceptions

ArgumentException

Invalid texture datas. First dimension must be equal to 6;textureData

NewCube(GraphicsDevice, int, PixelFormat, TextureFlags, GraphicsResourceUsage)

Creates a new Cube Texture.

public static Texture NewCube(GraphicsDevice device, int size, PixelFormat format, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Default)

Parameters

device GraphicsDevice

The GraphicsDevice.

size int

The size (in pixels) of the top-level faces of the cube texture.

format PixelFormat

Describes the format to use.

textureFlags TextureFlags

The texture flags.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of 2D Texture class.

NewCube<T>(GraphicsDevice, int, PixelFormat, T[][], TextureFlags, GraphicsResourceUsage)

Creates a new Cube Texture from a initial data..

public static Texture NewCube<T>(GraphicsDevice device, int size, PixelFormat format, T[][] textureData, TextureFlags textureFlags = TextureFlags.ShaderResource, GraphicsResourceUsage usage = GraphicsResourceUsage.Immutable) where T : unmanaged

Parameters

device GraphicsDevice

The GraphicsDevice.

size int

The size (in pixels) of the top-level faces of the cube texture.

format PixelFormat

Describes the format to use.

textureData T[][]

an array of 6 textures. See remarks

textureFlags TextureFlags

The texture flags.

usage GraphicsResourceUsage

The usage.

Returns

Texture

A new instance of Cube Texture class.

Type Parameters

T

Type of a pixel data

Remarks

The first dimension of mipMapTextures describes the number of array (TextureCube Array), the second is the texture data for a particular cube face.

Exceptions

ArgumentException

Invalid texture datas. First dimension must be equal to 6;textureData

OnDestroyed()

Called when graphics device has been detected to be internally destroyed.

protected override void OnDestroyed()

OnRecreate()

Called when graphics device has been recreated.

protected override bool OnRecreate()

Returns

bool

True if item transitioned to a Active state.

Recreate(DataBox[])

public void Recreate(DataBox[] dataBoxes = null)

Parameters

dataBoxes DataBox[]

ReleaseData()

Releases the texture data.

public void ReleaseData()

Save(CommandList, Stream, ImageFileType)

Saves this texture to a stream with a specified format.

public void Save(CommandList commandList, Stream stream, ImageFileType fileType)

Parameters

commandList CommandList

The command list.

stream Stream

The stream.

fileType ImageFileType

Type of the image file.

Save(CommandList, Stream, Texture, ImageFileType)

Saves this texture to a stream with a specified format.

public void Save(CommandList commandList, Stream stream, Texture stagingTexture, ImageFileType fileType)

Parameters

commandList CommandList

The command list.

stream Stream

The stream.

stagingTexture Texture

The staging texture used to temporary transfer the image from the GPU to CPU.

fileType ImageFileType

Type of the image file.

Exceptions

ArgumentException

If stagingTexture is not a staging texture.

SetData(CommandList, DataPointer, int, int, ResourceRegion?)

Copies the content an data on CPU memory to this texture into GPU memory.

public void SetData(CommandList commandList, DataPointer fromData, int arraySlice = 0, int mipSlice = 0, ResourceRegion? region = null)

Parameters

commandList CommandList

The CommandList.

fromData DataPointer

The data to copy from.

arraySlice int

The array slice index. This value must be set to 0 for Texture 3D.

mipSlice int

The mip slice index.

region ResourceRegion?

Destination region

Remarks

See unmanaged documentation for usage and restrictions.

Exceptions

ArgumentException

When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length

SetData<TData>(CommandList, TData[], int, int, ResourceRegion?)

Copies the content an array of data on CPU memory to this texture into GPU memory using the specified GraphicsDevice (The graphics device could be deffered).

public void SetData<TData>(CommandList commandList, TData[] fromData, int arraySlice = 0, int mipSlice = 0, ResourceRegion? region = null) where TData : unmanaged

Parameters

commandList CommandList

The command list.

fromData TData[]

The data to copy from.

arraySlice int

The array slice index. This value must be set to 0 for Texture 3D.

mipSlice int

The mip slice index.

region ResourceRegion?

Destination region

Type Parameters

TData

The type of the T data.

Remarks

See unmanaged documentation for usage and restrictions.

Exceptions

ArgumentException

When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length

ToStaging()

Return an equivalent staging texture CPU read-writable from this instance.

public Texture ToStaging()

Returns

Texture

The equivalent staging texture.

ToTextureView(TextureViewDescription)

Gets a view on this texture for a particular ViewType, array index (or zIndex for Texture3D), and mipmap index.

public Texture ToTextureView(TextureViewDescription viewDescription)

Parameters

viewDescription TextureViewDescription

The view description.

Returns

Texture

A new texture object that is bouded to the requested view.