DirectXTex texture processing library


DirectX Logo

DirectXTex texture processing library

Copyright (c) Microsoft Corporation.

November 8, 2021

This package contains DirectXTex, a shared source library for reading and writing .DDS files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes .TGA and .HDR readers and writers since these image file formats are commonly used for texture content processing pipelines, but are not currently supported by a built-in WIC codec.

This code is designed to build with Visual Studio 2017 (15.9), Visual Studio 2019, Visual Studio 2022, or clang for Windows v11 or later. Use of the Windows 10 May 2020 Update SDK (19041) or later is required.

These components are designed to work without requiring any content from the legacy DirectX SDK. For details, see Where is the DirectX SDK?.

Directory Layout

  • DirectXTex\

    • This contains the DirectXTex library. This includes a full-featured DDS reader and writer including legacy format conversions, a TGA reader and writer, a HDR reader and writer, a WIC-based bitmap reader and writer (BMP, JPEG, PNG, TIFF, and HD Photo), and various texture processing functions. This is intended primarily for tool usage.

The majority of the header files here are intended for internal implementation of the library only (BC.h, BCDirectCompute.h, DDS.h, DirectXTexP.h, etc.). Only DirectXTex.h and DirectXTex.inl are meant as the 'public' header for the library.

  • Texconv\

    • This DirectXTex sample is an implementation of the texconv command-line texture utility from the DirectX SDK utilizing DirectXTex rather than D3DX.

      It supports the same arguments as the Texture Conversion Tool Extended (texconvex.exe) legacy DirectX SDK utility. The primary differences are the -10 and -11 arguments are not applicable and the filter names (POINT, LINEAR, CUBIC, FANT or BOX, TRIANGLE, *_DITHER, *_DITHER_DIFFUSION). This also includes support for the JPEG XR (HD Photo) bitmap format.

  • Texassemble\

    • This DirectXTex sample is a command-line utility for creating cubemaps, volume maps, or texture arrays from a set of individual input image files.
  • Texdiag\

    • This DirectXTex sample is a command-line utility for analyzing image contents, primarily for debugging purposes.
  • DDSView\

    • This DirectXTex sample is a simple Direct3D 11-based viewer for DDS files. For array textures or volume maps, the "<" and ">" keyboard keys will show different images contained in the DDS. The "1" through "0" keys can also be used to jump to a specific image index.
  • DDSTextureLoader\

    • This contains a streamlined version of the legacy DirectX SDK sample DDSWithoutD3DX11 texture loading code for a simple light-weight runtime DDS loader. There are versions for Direct3D 9, Direct3D 11, and Direct3D 12. This performs no runtime pixel data conversions. This is ideal for runtime usage, and supports the full complement of Direct3D texture resources (1D, 2D, volume maps, cubemaps, mipmap levels, texture arrays, BC formats, etc.).
  • ScreenGrab\

    • This contains texture writing modules for Direct3D 9, Direct3D 11, and Direct3D 12 primarily intended for creating screenshots. The images are written as a DDS or as an image file format using WIC.
  • WICTextureLoader\

    • This contains a Direct3D 9, Direct3D 11 and Direct3D 12 2D texture loader that uses WIC to load a bitmap (BMP, JPEG, PNG, HD Photo, or other WIC supported file container), resize if needed based on the current feature level (or by explicit parameter), format convert to a DXGI_FORMAT if required, and then create a 2D texture. Note this does not support 1D textures, volume textures, cubemaps, or texture arrays. DDSTextureLoader is recommended for fully "precooked" textures for maximum performance and image quality, but this loader can be useful for creating simple 2D texture from standard image files at runtime.

DDSTextureLoader11, ScreenGrab11, and WICTextureLoader11 are 'stand-alone' versions of the same modules provided in the DirectX Tool Kit for DX11

DDSTextureLoader12, ScreenGrab12, and WICTextureLoader12 are 'stand-alone' versions of the same modules provided in the DirectX Tool Kit for DX12.


Documentation is available on the GitHub wiki.


All content and source code for this package are subject to the terms of the MIT License.

For the latest version of DirectXTex, bug reports, etc. please visit the project site on GitHub.

Release Notes

  • Starting with the June 2020 release, this library makes use of typed enum bitmask flags per the recommendation of the C++ Standard section Bitmask types. This is consistent with Direct3D 12's use of the DEFINE_ENUM_FLAG_OPERATORS macro. This may have breaking change impacts to client code:

    • You cannot pass the 0 literal as your flags value. Instead you must make use of the appropriate default enum value: CP_FLAGS_NONE, DDS_FLAGS_NONE, WIC_FLAGS_NONE, TEX_FR_ROTATE0, TEX_FILTER_DEFAULT, TEX_FILTER_DEFAULT, TEX_FILTER_DEFAULT, CNMAP_DEFAULT, or CNMAP_DEFAULT.

    • Use the enum type instead of DWORD if building up flags values locally with bitmask operations. For example, DDS_FLAGS flags = DDS_FLAGS_NONE; if (...) flags |= DDS_FLAGS_EXPAND_LUMINANCE;

    • In cases where some of the flags overlap, you can use the | to combine the relevant types: TEX_FILTER_FLAGS filter modes combine with WIC_FLAGS, TEX_FILTER_FLAGS sRGB flags combine with TEX_PMALPHA_FLAGS or TEX_COMPRESS_FLAGS. No other bitwise operators are defined. For example, WIC_FLAGS wicFlags = WIC_FLAGS_NONE | TEX_FILTER_CUBIC;

  • Due to the underlying Windows BMP WIC codec, alpha channels are not supported for 16bpp or 32bpp BMP pixel format files. The Windows 8.x and Windows 10 version of the Windows BMP WIC codec does support 32bpp pixel formats with alpha when using the BITMAPV5HEADER file header. Note the updated WIC is available on Windows 7 SP1 with KB 2670838 installed.

  • While DXGI 1.0 and DXGI 1.1 include 5:6:5 (DXGI_FORMAT_B5G6R5_UNORM) and 5:5:5:1 (DXGI_FORMAT_B5G5R5A1_UNORM) pixel format enumerations, the DirectX 10.x and 11.0 Runtimes do not support these formats for use with Direct3D. The DirectX 11.1 runtime, DXGI 1.2, and the WDDM 1.2 driver model fully support 16bpp formats (5:6:5, 5:5:5:1, and 4:4:4:4).

  • WICTextureLoader cannot load .TGA or .HDR files unless the system has a 3rd party WIC codec installed. You must use the DirectXTex library for TGA/HDR file format support without relying on an add-on WIC codec.

  • Loading of 96bpp floating-point TIFF files results in a corrupted image prior to Windows 8. This fix is available on Windows 7 SP1 with KB 2670838 installed.

  • The UWP projects and the Win10 classic desktop project include configurations for the ARM64 platform. These require VS 2017 (15.9 update) or later to build, with the ARM64 toolset installed.

  • The CompileShaders.cmd script must have Windows-style (CRLF) line-endings. If it is changed to Linux-style (LF) line-endings, it can fail to build all the required shaders.


For questions, consider using Stack Overflow with the directxtk tag, or the DirectX Discord Server in the dx12-developers or dx9-dx11-developers channel.

For bug reports and feature requests, please use GitHub issues for this project.


This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.


This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.


The DirectXTex library is the work of Chuck Walbourn, with contributions from Matt Lee, Xin Huang, Craig Peeper, and the numerous other Microsoft engineers who developed the D3DX utility library over the years.

Thanks to Paul Penson for his help with the implementation of MemoryStreamOnBlob.

  • texdiag not recognize BC1a (bc1 with 1 bit alpha); texconv not correct work with bc3 normal map

    texdiag not recognize BC1a (bc1 with 1 bit alpha); texconv not correct work with bc3 normal map

    For texdiag BC1a = BC1 Why?! It is serious problem while batch conversion or sorting textures! Example bc1 with alpha:

    bc3 no mip gamma correct

    opened by Bxaa 18
  • pbit related quality fix for BC7 texture encoding

    pbit related quality fix for BC7 texture encoding

    When I call DirectX::D3DXEncodeBC7() with DirectX::BC_FLAGS_USE_3SUBSETS, the overall output error increases across the kodim test corpus. This is incorrect: the overall error should decrease. Other BC7 encoders don't behave in this way, so I investigated further. I modified D3DX_BC7::Refine() to call D3DXDecodeBC7() on the encoded block, computed the actual error, and compared that vs. the error computed by Refine(). They differed, which is incorrect.

    The bug is caused by D3DX_BC7::Refine() not correctly computing the block error in a way that factors in the actual coded pbits. It computes the error using the endpoints before the LSB's are slammed to the pbits, causing the encoder to choose blocks that actually increase error. This will wreck quality in pbit modes.

    The fix introduces a new helper function D3DX_BC7::FixEndpointPBits(), which Refine() calls after it computes new endpoints. It could be easily improved further for more gains (it doesn't round the component values correctly factoring in the pbits), but it's a massive improvement.

    With this fix applied the encoding quality across my test corpus increased from 44.25 to 46.02 with 3 subsets enabled, and 45.64 with 3 subsets disabled. Tested with opaque and transparent textures.

    opened by richgel999 15
  • Texconv: Add flag to control case of file extension

    Texconv: Add flag to control case of file extension


    I was wondering whether it would be possible/feasible to add a flag to texconv to control the case of the output file extension. Currently it outputs the extension in all caps (e.g. output.DDS or output.PNG, regardless of the case of the input file). It'd be great if it could match the case of the input file or otherwise be control this with a flag.

    enhancement tools 
    opened by rminderhoud 12
  • TexConv - Corrupts Alpha Channel In DXT5 Texture

    TexConv - Corrupts Alpha Channel In DXT5 Texture

    After trying multiple combinations of arguments (different mipmap levels, different resolutions, including -pmalpha and/or -sepalpha), it seems that the issue would lie more with TexConv than with anything else.

    The texture is the "DirtPath01_D.DDS" that is used by Fallout 4. Running the texture through TexConv causes the alpha to corrupt,

    Screenshot of the texture (after being resized through TexConv) itself: Screenshot of the texture used in-game: I've attached an archive containing texconv.exe, the original texture file, the resultant texture file, the texture file to be processed and a .bat file.

    The .dds format used by the texture is BC3_UNORM_2D.

    So aye, seems like TexConv doesn't like the alpha channel in that image for some reason, causing the pixels at the edge of the texture (where colour meets 100% transparency) to corrupt. The alpha channel itself, however, looks fine.

    opened by FiftyTifty 12
  • DirectXTexConvert.cpp UseWicConversion returns true for formats not supported for 'WicConversion'

    DirectXTexConvert.cpp UseWicConversion returns true for formats not supported for 'WicConversion'

    When passing a tformat or sformat of


    to the 'UseWicConversion' function in file 'DirectXTexConvert.cpp' returns 'true' and then when the 'DirectX::Convert' function tries to convert from these formats, it fails. Returning 'false' for these values in 'UseWicConversion' seems to allow the image to convert successfully to DXGI_FORMAT_B8G8R8A8_UNORM via the 'ConvertCustom()' function inside 'DirectXTex.cpp'.

    opened by BAD-AL 11
  • Dark scales of grey becomes greenish after conversion

    Dark scales of grey becomes greenish after conversion

    Hello !

    We've got an issue where converting dark images yields aberrant colors that did not exist in the input (but not obvious, since those are very dark tones) I can't exactly pinpoint whether this is a texconv issue, or an issue inherent to the BC codec which we can't do anything about ? But if it is, I don't really understand how BC could reasonably be used so widely, so something doesn't quite fit here

    The original .tif image


    The resulting BC3_UNORM output, where the dark grey/brown in some places suddenly get a greenish hue that comes from nowhere


    I've tried a range of command line options so far, but none have solved the issue Any help would be greatly appreciated !

    opened by hugoam 10
  • TexConv microsoft documentation is entirely inaccurate?

    TexConv microsoft documentation is entirely inaccurate?

    Apologies if this is some kind of user error but, the parameters listed in Microsoft TexConv documentation do not seem to be accurate. They do not match up with the github documentation and when I try the parameters from Microsoft the program does not run and instead displays the "--help" info.

    Did the parameters change?

    The microsoft documentation includes instructions for mapping channels from input to output, which I need. I need to do the following 3 operations:

    1. convert RGB channels from DDS to a 3-channel PNG/TGA, discarding the A channel.
    2. convert A channel from DDS to fill all channels in a 3-channel PNG/TGA, discarding the RGB channels.
    3. combine and convert RGB from PNG_1 and R from PNG_2 into a single 4-channel RGBA DDS.

    But I don't see any way I can do that with the parameters as specified on the github documentation.

    opened by opusGlass 10
  • Support SNORM formats

    Support SNORM formats

    Texconv will fail to load formats such as U8V8, U16V16 (R8G8_SNORM & R16G16_SNORM in D3D10 lingo).

    Looking at dds files with these formats, it appears that they're exactly the same as their unsigned counter parts (e.g. R8G8_UNORM, R16G16_UNORM) except that the 'flags' member of the DDS_PIXELFORMAT structure has the DDPF_RGB bit unset, and the undocumented bit 0x00080000 set instead.

    opened by darksylinc 10
  • Make the NuGetConfiguration explicit for Release build

    Make the NuGetConfiguration explicit for Release build

    DirectXTex NuGet package doesn't point to the correct library location in projects with configuration names other than "Debug" and "Release". The developer can provide the correct location through the use of NuGetConfiguration property. However, it's overwritten by this line in the ".targets" file:

    <PropertyGroup Label="Non_Debug" Condition="'$(Configuration.ToLower())' != 'debug'">

    Please change this to explicitly compare to "release":

    <PropertyGroup Label="Release" Condition="'$(Configuration.ToLower())' == 'release'">

    P.S. this is also applicable to DirectX tool kit NuGet packages.

    opened by Rashmatash 9
  • Fix compiler errors (Clang 5.0.0)

    Fix compiler errors (Clang 5.0.0)

    Hello, I'm trying to compile DirectXTex with Clang 5 (inside Visual Studio 2017) but I'm getting errors:

    In file included from DirectXTex\DirectXTex_Z.cpp:15: DirectXTex/DirectXTexConvert.cpp(3851,9): error : use of overloaded operator '-' is ambiguous (operand type 'const DirectX::XMVECTORF32')

    I propose this fix, but maybe a better thing to do is to fix FXMVECTOR operators ?

    opened by darwikey 9
  • Static code analysis warnings in DirectXTex

    Static code analysis warnings in DirectXTex

    The SAL annotations on some functions are either incorrect, or the code doesn't behave as advertised. Since I don't know which one it is, I'll just forward the static code analysis warnings that we are seeing when building DirectXTex:

    DirectXTexConvert.cpp(1610,14): error 6101: : Returning uninitialized memory '*pDestination'. A successful path through the function does not set the named _Out_ parameter. 
    DirectXTexConvert.cpp(3905,14): error 6101: : Returning uninitialized memory '*pDestination'. A successful path through the function does not set the named _Out_ parameter. 
    d3dx12.h(2418,62): error 6001: : Using uninitialized memory '*pParameters_1_0.DescriptorTable.pDescriptorRanges'

    This is with the release from January 9, 2021.

    opened by jakrams 8
  • D3DXLoadSurfaceFromSurface sample

    D3DXLoadSurfaceFromSurface sample

    DirectXTex has all the facilities needed to support the old 'load-surface-from-surface' behavior. A sample implementation would help those porting D3DX code as well as demonstrate how heavy-weight that function was:

            LPDIRECT3DSURFACE9        pDestSurface,
            CONST PALETTEENTRY*       pDestPalette,
            CONST RECT*               pDestRect,
            LPDIRECT3DSURFACE9        pSrcSurface,
            CONST PALETTEENTRY*       pSrcPalette,
            CONST RECT*               pSrcRect,
            DWORD                     Filter,
            D3DCOLOR                  ColorKey);
            LPDIRECT3DVOLUME9         pDestVolume,
            CONST PALETTEENTRY*       pDestPalette,
            CONST D3DBOX*             pDestBox,
            LPDIRECT3DVOLUME9         pSrcVolume,
            CONST PALETTEENTRY*       pSrcPalette,
            CONST D3DBOX*             pSrcBox,
            DWORD                     Filter,
            D3DCOLOR                  ColorKey);
    	ID3D11DeviceContext       *pContext,
            ID3D11Resource            *pSrcTexture,
            D3DX11_TEXTURE_LOAD_INFO  *pLoadInfo,
            ID3D11Resource            *pDstTexture);
    opened by walbourn 1
  • Convert angled include to quotes for cross platform clang compatability

    Convert angled include to quotes for cross platform clang compatability

    Clang will complain that these imports aren't from a system directory. 'isystem'.

    Changing them to quote includes will solve the issue and should still be compatible with the current setup.

    This will allow the library to build/run on linux/macOS.

    opened by dtzxporter 5
  • ARM64 version of texassemble, texconv, and texdiag

    ARM64 version of texassemble, texconv, and texdiag

    The VC++ projects only currently build x86/x64 versions of these tools for desktop.

    The CMakeLists.txt supports creating the ARM64 version of these tools, so this should be added to the VC++ projects.

    opened by walbourn 0
  • BC7 (no GPU) compresses (255,255,255,0) to (255,255,255,1)

    BC7 (no GPU) compresses (255,255,255,0) to (255,255,255,1)

    An image with a block of fully transparent white texels is getting compressed to white texels with an alpha value of 1 instead of 0.

    To reproduce:

    • Take a 4x4 image where each uncompressed texel is (255,255,255,0)
    • (I have attempted to attach such an image, but it's not clear to me whether the attachment process worked)
    • Enter the following command in texconv:
    • texconv.exe -f BC7_UNORM -nogpu transparentWhite.png
    • Observe that the resulting compressed texels are (255,255,255,1), and no longer fully transparent

    Note that if GPU compression is used the compressed values are the expected (255,255,255,0), and so the undesired alpha value only happens with non-GPU compression.


    opened by jpownby-es 3
  • D3D12 - Add support for memory allocators

    D3D12 - Add support for memory allocators

    CreateComittedResource is fine,

    However is good to add interface to CreateTexture, CreateTextureEx

    Particularly on d3d12 this allocator is very often used

    opened by kingofthebongo2008 3
Open source projects and samples from Microsoft
WebGL Texture plugin for Flutter

So far there is no way to render 3D objects efficiently in Flutter. Also directly accessing and programming the GPU from Dart isn't supported yet. This plugin shall close this gap.

null 99 Dec 14, 2022
GPU Texture Generator

Imogen GPU/CPU Texture Generator GPU Texture generator using dear imgui for UI. Not production ready and a bit messy but really fun to code. This is a

Cedric Guillemet 708 Dec 3, 2022
Basic framework for D3D11 init, model/texture loading, shader compilation and camera movement.

reed-framework Basic framework for D3D11 init, model/texture loading, camera movement, etc. Instructions: #include <framework.h> Link with framework.l

Nathan Reed 34 May 18, 2022
Open3D: A Modern Library for 3D Data Processing

Open3D is an open-source library that supports rapid development of software that deals with 3D data. The Open3D frontend exposes a set of carefully selected data structures and algorithms in both C++ and Python. The backend is highly optimized and is set up for parallelization. We welcome contributions from the open-source community.

Intel ISL (Intel Intelligent Systems Lab) 7.9k Dec 29, 2022
Source Codes for Injective Deformation Processing (IDP) with Incremental Potential Contact (IPC)

Source Codes for Injective Deformation Processing Reference This repository provides source code for: Yu Fang*, Minchen Li* (equal contribution), Chen

null 41 Dec 6, 2022
The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one unified and clean data structure.

Open Asset Import Library (assimp) A library to import and export various 3d-model-formats including scene-post-processing to generate missing render

Open Asset Import Library 8.6k Jan 4, 2023
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.

bgfx - Cross-platform rendering library GitHub Discussions Discord Chat What is it? Cross-platform, graphics API agnostic, "Bring Your Own Engine/Fram

Бранимир Караџић 12.6k Jan 8, 2023
Modern C++14 library for the development of real-time graphical applications

CI Community Support bs::framework is a C++ library that aims to provide a unified foundation for the development of real-time graphical applications,

null 1.7k Jan 2, 2023
A modern cross-platform low-level graphics library and rendering framework

Diligent Engine A Modern Cross-Platform Low-Level 3D Graphics Library Diligent Engine is a lightweight cross-platform graphics API abstraction library

Diligent Graphics 2.6k Dec 30, 2022
A multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input

GLFW Introduction GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan application development. It provides a simple, platf

GLFW 10k Jan 1, 2023
Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal

Low Level Graphics Library (LLGL) Documentation NOTE: This repository receives bug fixes only, but no major updates. Pull requests may still be accept

Lukas Hermanns 1.5k Jan 8, 2023
Antialiased 2D vector drawing library on top of OpenGL for UI and visualizations.

This project is not actively maintained. NanoVG NanoVG is small antialiased vector graphics rendering library for OpenGL. It has lean API modeled afte

Mikko Mononen 4.6k Jan 2, 2023
An Open-Source subdivision surface library.

OpenSubdiv OpenSubdiv is a set of open source libraries that implement high performance subdivision surface (subdiv) evaluation on massively parallel

Pixar Animation Studios 2.7k Jan 2, 2023
C++ (with python bindings) library for easily reading/writing/manipulating common animation particle formats such as PDB, BGEO, PTC. See the discussion group @

Partio - A library for particle IO and manipulation This is the initial source code release of partio a tool we used for particle reading/writing. It

Walt Disney Animation Studios 412 Dec 29, 2022
ANSI C library for NURBS, B-Splines, and Bézier curves with interfaces for C++, C#, D, Go, Java, Lua, Octave, PHP, Python, R, and Ruby.

TinySpline TinySpline is a small, yet powerful library for interpolating, transforming, and querying arbitrary NURBS, B-Splines, and Bézier curves. Th

Marcel Steinbeck 895 Dec 28, 2022
🎨 Modern 2D/3D - Importer • Exporter • Util - Library, also called (AssetIO)

Brand-new modern 3D asset importer, exporter library. This library will include common 3D utils funcs. It is written with C99 but C++ wrappers or othe

Recep Aslantas 162 Dec 21, 2022
Epoxy is a library for handling OpenGL function pointer management for you

Epoxy is a library for handling OpenGL function pointer management for you. It hides the complexity of dlopen(), dlsym(), glXGetProcAddress(), eglGetP

Eric Anholt 577 Dec 19, 2022
Freecell Solver - a C library for automatically solving Freecell and some other variants of card Solitaire

The Freecell Solver Repository Root README Freecell Solver is an open source (distributed under the MIT/Expat licence) library, written in C, for atte

Shlomi Fish 55 Dec 23, 2022