Class GPUTexture
The GPU texture resource object. This class is able to create 2D/3D textures, volume textures and render targets.
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public sealed class GPUTexture : GPUResource
Constructors
GPUTexture()
Properties
ArraySize
Gets number of textures in the array.
Declaration
[Unmanaged]
public int ArraySize { get; }
Property Value
System.Int32
|
Depth
Gets texture depth (in texels).
Declaration
[Unmanaged]
public int Depth { get; }
Property Value
System.Int32
|
Description
Gets texture description structure.
Declaration
[Unmanaged]
public GPUTextureDescription Description { get; }
Property Value
GPUTextureDescription
|
Dimensions
Gets texture dimensions.
Declaration
[Unmanaged]
public TextureDimensions Dimensions { get; }
Property Value
TextureDimensions
|
Flags
Gets flags of the texture.
Declaration
[Unmanaged]
public GPUTextureFlags Flags { get; }
Property Value
GPUTextureFlags
|
Format
Gets texture data format.
Declaration
[Unmanaged]
public PixelFormat Format { get; }
Property Value
PixelFormat
|
HasResidentMip
Gets a value indicating whether this texture has any resided mip (data already uploaded to the GPU).
Declaration
[Unmanaged]
public bool HasResidentMip { get; }
Property Value
System.Boolean
|
Height
Gets texture height (in texels).
Declaration
[Unmanaged]
public int Height { get; }
Property Value
System.Int32
|
HighestResidentMipIndex
Gets the index of the highest resident mip map (may be equal to MipLevels if no mip has been uploaded). Note: mip=0 is the highest (top quality).
Declaration
[Unmanaged]
public int HighestResidentMipIndex { get; }
Property Value
System.Int32
|
IsAllocated
Gets a value indicating whether this texture has been allocated.
Declaration
[Unmanaged]
public bool IsAllocated { get; }
Property Value
System.Boolean
|
IsPowerOfTwo
Returns true if texture has size that is power of two.
Declaration
[Unmanaged]
public bool IsPowerOfTwo { get; }
Property Value
System.Boolean
|
MipLevels
Gets number of mipmap levels in the texture.
Declaration
[Unmanaged]
public int MipLevels { get; }
Property Value
System.Int32
|
MultiSampleLevel
Gets multi-sampling parameters for the texture.
Declaration
[Unmanaged]
public MSAALevel MultiSampleLevel { get; }
Property Value
MSAALevel
|
NativePtr
Gets the native pointer to the underlying resource. It's a low-level platform-specific handle.
Declaration
[Unmanaged]
public IntPtr NativePtr { get; }
Property Value
System.IntPtr
|
ResidentMipLevels
Gets or sets the number of resident mipmap levels in the texture (already uploaded to the GPU).
Declaration
[Unmanaged]
public int ResidentMipLevels { get; set; }
Property Value
System.Int32
|
Size
Gets the texture total size in pixels.
Declaration
[Unmanaged]
public Float2 Size { get; }
Property Value
Float2
|
Size3
Gets the texture total size in pixels (with depth).
Declaration
[Unmanaged]
public Float3 Size3 { get; }
Property Value
Float3
|
Width
Gets texture width (in texels).
Declaration
[Unmanaged]
public int Width { get; }
Property Value
System.Int32
|
Methods
DownloadData()
Downloads the texture data to be accessible from CPU. For frequent access, use staging textures, otherwise current thread will be stalled to wait for the GPU frame to copy data into staging buffer.
Declaration
[Unmanaged]
public TextureData DownloadData()
Returns
TextureData
Downloaded texture data container, or nul if failed. |
DownloadData(TextureData)
Downloads the texture data to be accessible from CPU. For frequent access, use staging textures, otherwise current thread will be stalled to wait for the GPU frame to copy data into staging buffer.
Declaration
[Unmanaged]
public bool DownloadData(TextureData result)
Parameters
TextureData
result
The destination texture data container. |
Returns
System.Boolean
True if cannot download data, otherwise false. |
GetMipSize(Int32, out Int32, out Int32)
Gets the texture mip map dimensions.
Declaration
[Unmanaged]
public void GetMipSize(int mipLevelIndex, out int mipWidth, out int mipHeight)
Parameters
System.Int32
mipLevelIndex
Mip level index (zero-based where 0 is top texture surface). |
System.Int32
mipWidth
The calculated mip level width (in pixels). |
System.Int32
mipHeight
The calculated mip level height (in pixels). |
GetMipSize(Int32, out Int32, out Int32, out Int32)
Gets the texture mip map dimensions.
Declaration
[Unmanaged]
public void GetMipSize(int mipLevelIndex, out int mipWidth, out int mipHeight, out int mipDepth)
Parameters
System.Int32
mipLevelIndex
Mip level index (zero-based where 0 is top texture surface). |
System.Int32
mipWidth
The calculated mip level width (in pixels). |
System.Int32
mipHeight
The calculated mip level height (in pixels). |
System.Int32
mipDepth
The calculated mip level depth (in pixels). |
Init(ref GPUTextureDescription)
Initializes a texture resource (allocates the GPU memory and performs the resource setup).
Declaration
[Unmanaged]
public bool Init(ref GPUTextureDescription desc)
Parameters
GPUTextureDescription
desc
The texture description. |
Returns
System.Boolean
True if cannot create texture, otherwise false. |
Resize(Int32, Int32, PixelFormat)
Resizes the texture. It must be created first.
Declaration
[Unmanaged]
public bool Resize(int width, int height, PixelFormat format)
Parameters
System.Int32
width
The width. |
System.Int32
height
The height. |
PixelFormat
format
The new texture format. Use Unknown to remain texture format unchanged. |
Returns
System.Boolean
True if fails, otherwise false. |
Resize(Int32, Int32, Int32, PixelFormat)
Resizes the texture. It must be created first.
Declaration
[Unmanaged]
public bool Resize(int width, int height, int depth, PixelFormat format)
Parameters
System.Int32
width
The width. |
System.Int32
height
The height. |
System.Int32
depth
The depth. |
PixelFormat
format
The new texture format. Use Unknown to remain texture format unchanged. |
Returns
System.Boolean
True if fails, otherwise false. |
View()
Gets the view to the first surface (only for 2D textures).
Declaration
[Unmanaged]
public GPUTextureView View()
Returns
GPUTextureView
The view to the main texture surface. |
View(Int32)
Gets the view to the surface at index in an array.
Declaration
[Unmanaged]
public GPUTextureView View(int arrayOrDepthIndex)
Parameters
System.Int32
arrayOrDepthIndex
The index of the surface in an array (or depth slice index). |
Returns
GPUTextureView
The view to the surface at index in an array. |
Remarks
To use per depth/array slice view you need to specify the PerSliceViews when creating the resource.
View(Int32, Int32)
Gets the view to the mip map surface at index in an array.
Declaration
[Unmanaged]
public GPUTextureView View(int arrayOrDepthIndex, int mipMapIndex)
Parameters
System.Int32
arrayOrDepthIndex
The index of the surface in an array (or depth slice index). |
System.Int32
mipMapIndex
Index of the mip level. |
Returns
GPUTextureView
The view to the surface at index in an array. |
Remarks
To use per mip map view you need to specify the PerMipViews when creating the resource.
ViewArray()
Gets the view to the array of surfaces
Declaration
[Unmanaged]
public GPUTextureView ViewArray()
Returns
GPUTextureView
The view to the array of surfaces. |
Remarks
To use array texture view you need to create render target as an array.
ViewReadOnlyDepth()
Gets the view to the texture as read-only depth/stencil buffer. Valid only if graphics device supports it and the texture uses depth/stencil.
Declaration
[Unmanaged]
public GPUTextureView ViewReadOnlyDepth()
Returns
GPUTextureView
The view to the depth-stencil resource descriptor as read-only depth. |
ViewVolume()
Gets the view to the volume texture (3D).
Declaration
[Unmanaged]
public GPUTextureView ViewVolume()
Returns
GPUTextureView
The view to the volume texture. |
Remarks
To use volume texture view you need to create render target as a volume resource (3D texture with Depth > 1).