Class Helpers
Miscellaneous helpers for graphic operations.
Inherited Members
Namespace: Evergine.Common.Graphics
Assembly: Evergine.Common.dll
Syntax
public static class Helpers
  Methods
AlignUp(uint)
Align the size in bytes to 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)
Align the size in bytes to nearest multiple of alignment value specified by 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)
Align the size in bytes to nearest multiple of alignment value specified by 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)
Transform the given value to conform to an 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 sub resource 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 sub resource.  | 
      
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 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 TextureDescription.  | 
      
| 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 TextureDescription.  | 
      
| uint | mipLevel | The MipMap Level.  | 
      
Returns
| Type | Description | 
|---|---|
| uint | The mip 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 of 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 size of the array.
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 of the current 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 sub resource.
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 sub resource of the texture.  | 
      
| uint | mipLevel | The Mip Level.  | 
      
| uint | arrayLayer | The Array Layer.  | 
      
GetMipLevels(uint, uint)
Gets the mip level dimensions.
Declaration
public static uint GetMipLevels(uint width, uint height)
  Parameters
| Type | Name | Description | 
|---|---|---|
| uint | width | Texture Width.  | 
      
| uint | height | Texture Height.  | 
      
Returns
| Type | Description | 
|---|---|
| uint | Mip levels.  | 
      
GetNumRows(uint, PixelFormat)
Gets the number of rows, depending of 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 size and format.
Declaration
public static uint GetRowPitch(uint width, PixelFormat format)
  Parameters
| Type | Name | Description | 
|---|---|---|
| uint | width | The row size.  | 
      
| PixelFormat | format | The row PixelFormat.  | 
      
Returns
| Type | Description | 
|---|---|
| uint | The row pitch.  | 
      
GetSizeInBytes(PixelFormat)
Gets the size in byte 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 sub resource 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 one. False otherwise.  | 
      
IsStencilFormat(PixelFormat)
Gets a value indicating if the PixelFormat can be used as 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 stencil. False otherwise.  |