1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-09-18 22:59:54 +00:00
4 TexMetadata
Chuck Walbourn edited this page 2024-02-28 13:03:03 -08:00
DirectXTex

The TexMetadata structure describes a (potentially complex) image surface.

struct TexMetadata
{
    size_t          width;
    size_t          height;
    size_t          depth;
    size_t          arraySize;
    size_t          mipLevels;
    uint32_t        miscFlags;
    uint32_t        miscFlags2;
    DXGI_FORMAT     format;
    TEX_DIMENSION   dimension;
}

Fields

  • height should be 1 for 1D textures.

  • depth should be 1 for 1D and 2D textures.

  • arraySize should be 1 for non-array resources. For cubemaps it should be 6. For cubemap arrays it should be a multiple of 6 (i.e. numCubes = arraySize / 6).

  • mipLevels should be 1 for non-mipmapped images.

  • dimension can be 1D, 2D, or 3D. D3D1x_RESOURCE_DIMENSION_BUFFER is not a valid value.

Methods

  • ComputeIndex: Returns the image index given the parameters for miplevel (0-based), array item (0-based), and volume slice (0-based). Returns size_t(-1) to indicate an out-of-range error.

  • CalculateSubresource: Returns the proper Direct3D subresource from array index, mip level, and/or plane index.

  • IsCubemap: Returns true if the image is defined as cubemap or cubemap array as indicated by miscFlags.

  • IsPMAlpha: Returns true if the image data is premultipled alpha content (rather than straight alpha) as indicated by miscFlags2.

  • SetAlphaMode: Encodes the alpha mode into the miscFlags2 field.

  • GetAlphaMode: Returns the alpha mode encoded into the miscFlags2 field.

  • IsVolumemap: Returns true if the image data is a volume map (i.e. 3D texture) as indicated by dimension.

Remarks

The alpha modes are TEX_ALPHA_MODE_UNKNOWN, TEX_ALPHA_MODE_STRAIGHT, TEX_ALPHA_MODE_PREMULTIPLIED, TEX_ALPHA_MODE_OPAQUE, and TEX_ALPHA_MODE_CUSTOM. They match DDS_ALPHA_MODE.

Remarks

  • TEX_DIMENSION_TEXTURE1D, TEX_DIMENSION_TEXTURE2D, and TEX_DIMENSION_TEXTURE3D are aliases for D3D10_RESOURCE_DIMEMSION, D3D11_RESOURCE_DIMENSION, and D3D12_RESOURCE_DIMENSION values.

  • TEX_MISC_TEXTURECUBE is an alias for the same D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG.

  • TEX_MISC2_ALPHA_MODE_MASK is a mask for miscFlags2 to obtain the TEX_ALPHA_MODE.