Skip to content

TexMetadata

Chuck Walbourn edited this page Jul 13, 2020 · 4 revisions

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.

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.

  • 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 and D3D11_RESOURCE_DIMENSION.

  • 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.

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Windows 7 Service Pack 1
  • Xbox One
  • Xbox Series X|S
  • Windows Subsystem for Linux

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • GCC 10.5, 11.4, 12.3
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectXTex Rust bindings

DirectX Tool Kit for DirectX 11

DirectX Tool Kit for DirectX 12

DirectXMesh

DirectXMath

Tools

Test Suite

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally