Class Helpers
Miscellaneous helper methods for graphic operations.
Namespace: Evergine.Common.Graphics
Assembly: Evergine.Common.dll
Syntax
public static class Helpers
Methods
AlignUp(uint)
Aligns the size in bytes to the nearest multiple of 256.
Declaration
public static uint AlignUp(uint sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
uint | sizeInBytes | The size in bytes. |
Returns
Type | Description |
---|---|
uint | The aligned size. |
AlignUp(uint, uint)
Aligns the size in bytes to the nearest multiple of the alignment value specified by the parameter.
Declaration
public static uint AlignUp(uint alignment, uint sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
uint | alignment | The alignment size. |
uint | sizeInBytes | The size in bytes. |
Returns
Type | Description |
---|---|
uint | The aligned size. |
AlignUp(uint, ulong)
Aligns the size in bytes to the nearest multiple of the alignment value specified by the parameter.
Declaration
public static ulong AlignUp(uint alignment, ulong sizeInBytes)
Parameters
Type | Name | Description |
---|---|---|
uint | alignment | The alignment size. |
ulong | sizeInBytes | The size in bytes. |
Returns
Type | Description |
---|---|
ulong | The aligned size. |
ApplyAddressMode(ref float, TextureAddressMode)
Transforms the given value to conform to a specified TextureAddressMode.
Declaration
public static void ApplyAddressMode(ref float value, TextureAddressMode addressMode)
Parameters
Type | Name | Description |
---|---|---|
float | value | The value to transform. |
TextureAddressMode | addressMode | The address mode. |
CalculateSubResource(TextureDescription, uint, uint)
Calculates the subresource index.
Declaration
public static uint CalculateSubResource(TextureDescription description, uint mipLevel, uint arrayLayer)
Parameters
Type | Name | Description |
---|---|---|
TextureDescription | description | The texture description. |
uint | mipLevel | The mipmap level. |
uint | arrayLayer | The array layer index. |
Returns
Type | Description |
---|---|
uint | The ID of the subresource. |
CheckArrayCapacity<T>(ref T[], int)
Ensures the size of the array.
Declaration
public static void CheckArrayCapacity<T>(ref T[] array, int size)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array. |
int | size | The required size. |
Type Parameters
Name | Description |
---|---|
T | The type of the array items. |
ComputeLayerOffset(TextureDescription, uint)
Computes the layer offset.
Declaration
public static uint ComputeLayerOffset(TextureDescription description, uint arrayLayer)
Parameters
Type | Name | Description |
---|---|---|
TextureDescription | description | The texture description. |
uint | arrayLayer | The array layer. |
Returns
Type | Description |
---|---|
uint | The layer offset. |
ComputeMipOffset(TextureDescription, uint)
Computes the MipMap offset.
Declaration
public static uint ComputeMipOffset(TextureDescription description, uint mipLevel)
Parameters
Type | Name | Description |
---|---|---|
TextureDescription | description | The texture description. |
uint | mipLevel | The mipmap level. |
Returns
Type | Description |
---|---|
uint | The MipMap offset. |
ComputeSubResourceOffset(TextureDescription, uint)
Calculates the subresource offset of a texture.
Declaration
public static ulong ComputeSubResourceOffset(TextureDescription description, uint subResource)
Parameters
Type | Name | Description |
---|---|---|
TextureDescription | description | The texture description. |
uint | subResource | The subresource index. |
Returns
Type | Description |
---|---|
ulong | The subresource offset. |
ComputeTextureSize(TextureDescription)
Computes the texture size in bytes from a texture description.
Declaration
public static uint ComputeTextureSize(TextureDescription description)
Parameters
Type | Name | Description |
---|---|---|
TextureDescription | description | The texture description. |
Returns
Type | Description |
---|---|
uint | The size in bytes of the texture. |
EnsureArraySize<T>(ref T[], int)
Ensures the array size.
Declaration
public static void EnsureArraySize<T>(ref T[] array, int size)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array. |
int | size | The size. |
Type Parameters
Name | Description |
---|---|
T | The type of the array items. |
GetBlockSizeInBytes(PixelFormat)
Gets the size in bytes of a block.
Declaration
public static uint GetBlockSizeInBytes(PixelFormat format)
Parameters
Type | Name | Description |
---|---|---|
PixelFormat | format | The pixel format. |
Returns
Type | Description |
---|---|
uint | The size in bytes. |
GetDimension(uint, uint)
Gets the dimension size of a specified mip level.
Declaration
public static uint GetDimension(uint largestLevelDimension, uint mipLevel)
Parameters
Type | Name | Description |
---|---|---|
uint | largestLevelDimension | The largest level dimension. |
uint | mipLevel | The mip level. |
Returns
Type | Description |
---|---|
uint | The dimension size of the specified mip level. |
GetMipDimensions(TextureDescription, uint, out uint, out uint, out uint)
Gets the mip level dimensions.
Declaration
public static void GetMipDimensions(TextureDescription description, uint mipLevel, out uint width, out uint height, out uint depth)
Parameters
Type | Name | Description |
---|---|---|
TextureDescription | description | The texture description. |
uint | mipLevel | The texture mip level. |
uint | width | The texture width. |
uint | height | The texture height. |
uint | depth | The texture depth. |
GetMipLevelAndArrayLayer(TextureDescription, uint, out uint, out uint)
Gets the mip level and the array layer of a texture subresource.
Declaration
public static void GetMipLevelAndArrayLayer(TextureDescription description, uint subResource, out uint mipLevel, out uint arrayLayer)
Parameters
Type | Name | Description |
---|---|---|
TextureDescription | description | The texture description. |
uint | subResource | The subresource of the texture. |
uint | mipLevel | The mip level. |
uint | arrayLayer | The array layer. |
GetNumRows(uint, PixelFormat)
Gets the number of rows, depending on the height and the pixel format.
Declaration
public static uint GetNumRows(uint height, PixelFormat format)
Parameters
Type | Name | Description |
---|---|---|
uint | height | The height. |
PixelFormat | format | The pixel format. |
Returns
Type | Description |
---|---|
uint | The number of rows. |
GetRegionSize(uint, uint, uint, PixelFormat)
Gets the block size in bytes of a texture.
Declaration
public static uint GetRegionSize(uint width, uint height, uint depth, PixelFormat format)
Parameters
Type | Name | Description |
---|---|---|
uint | width | The texture width. |
uint | height | The texture height. |
uint | depth | The texture depth. |
PixelFormat | format | The texture pixel format. |
Returns
Type | Description |
---|---|
uint | The size in bytes of the block region. |
GetRowPitch(uint, PixelFormat)
Gets the size of a row with a specified width and format.
Declaration
public static uint GetRowPitch(uint width, PixelFormat format)
Parameters
Type | Name | Description |
---|---|---|
uint | width | The width of the row. |
PixelFormat | format | The PixelFormat of the row. |
Returns
Type | Description |
---|---|
uint | The pitch of the row. |
GetSizeInBytes(PixelFormat)
Gets the size in bytes of a PixelFormat.
Declaration
public static uint GetSizeInBytes(PixelFormat format)
Parameters
Type | Name | Description |
---|---|---|
PixelFormat | format | The PixelFormat. |
Returns
Type | Description |
---|---|
uint | The size in bytes of the format. |
GetSlicePitch(uint, uint, PixelFormat)
Gets the slice pitch.
Declaration
public static uint GetSlicePitch(uint rowPitch, uint height, PixelFormat format)
Parameters
Type | Name | Description |
---|---|---|
uint | rowPitch | The row pitch. |
uint | height | The height. |
PixelFormat | format | The pixel format. |
Returns
Type | Description |
---|---|
uint | The slice pitch. |
GetSubResourceInfo(TextureDescription, uint)
Gets the subresource info of a texture.
Declaration
public static SubResourceInfo GetSubResourceInfo(TextureDescription description, uint subResource)
Parameters
Type | Name | Description |
---|---|---|
TextureDescription | description | The texture info. |
uint | subResource | The subresource ID. |
Returns
Type | Description |
---|---|
SubResourceInfo | The subresource info. |
IsCompressedFormat(PixelFormat)
Returns a value indicating if the PixelFormat is a compressed one.
Declaration
public static bool IsCompressedFormat(PixelFormat format)
Parameters
Type | Name | Description |
---|---|---|
PixelFormat | format | The pixel format. |
Returns
Type | Description |
---|---|
bool | True if the pixel format represents a compressed format. False otherwise. |
IsStencilFormat(PixelFormat)
Gets a value indicating whether the PixelFormat can be used as a stencil pixel format.
Declaration
public static bool IsStencilFormat(PixelFormat format)
Parameters
Type | Name | Description |
---|---|---|
PixelFormat | format | The pixel format. |
Returns
Type | Description |
---|---|
bool | True if the format can be used as a stencil; false otherwise. |