directxtex-usage
Skill2.2k starsChanged 4 months agoMITView on GitHub
Guide for integrating and using the DirectXTex texture processing library in new projects. Use this skill when asked about adding DirectXTex to a project, loading/saving textures, format conversion, mipmap generation, block compression, or Direct3D resource creation.
Trending
Quiet since August.about the whole repository
Who's talking about microsoft/DirectXTex
- woelper/oculante“DDS BC7, cubemaps, volume maps, or texture arrays”GitHub · Mar 6, 2023 · 3 reactions
- aleko2144/KoTR_Modern_Patch“D2GI: Taking screenshots leaks a lot of resources”GitHub · Jan 4, 2026 · 1 reactions
- FlaxEngine/FlaxEngine“Add options to reconstruct z channel for textures.”GitHub · Oct 4, 2024 · 1 reactions
- RimSort/RimSort“Implement texture compression/conversion utilities”GitHub · Feb 21, 2023 · 1 reactions
- vrm-c/vrm-specification“テクスチャ圧縮の検討について”GitHub · Dec 4, 2019 · 1 reactions
The biggest 5 of 30 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 30
Talked about on GitHub (30 times).
On GitHub · 30
- Mar 6, 2023DDS BC7, cubemaps, volume maps, or texture arrays — woelper/oculante3 reactions · 7 comments
- Jan 4, 2026D2GI: Taking screenshots leaks a lot of resources — aleko2144/KoTR_Modern_Patch1 reaction · 10 comments
- Oct 4, 2024Add options to reconstruct z channel for textures. — FlaxEngine/FlaxEngine1 reaction
- Feb 21, 2023Implement texture compression/conversion utilities — RimSort/RimSort1 reaction · 3 comments
- Dec 4, 2019テクスチャ圧縮の検討について — vrm-c/vrm-specification1 reaction · 6 comments
25 more on GitHub
- Aug 30, 2016Resized .dds Texture (BCn format) With Alpha Shows Corrupted Edges — GameTechDev/Intel-Texture-Works-Plugin1 reaction
- Aug 5, 2026Bump deps/DirectXTex from `f06dd7e` to `cd6e576` — Joelrau/x64-zt0 reactions
- Apr 28, 2025FL_IMAGE_PACKER — Facta-Leopard/FL_IMAGE_PACKER0 reactions
- Nov 19, 2024Bump deps/DirectXTex from `e102d0b` to `d095bec` — Antiwoll/mwr0 reactions
- Jun 7, 2024Reading and decoding image files with DirectXTex — dejan-xd/Game_Engine_MBRS0 reactions
- Apr 28, 2023Bump directxtex_desktop_win10 from 2021.1.10.2 to 2023.1.31.1 in /Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingMiniEngineSample — sarvex/DirectxGraphicsSamples0 reactions
- Apr 28, 2023Bump directxtex_desktop_win10 from 2019.2.7.1 to 2023.1.31.1 in /MiniEngine/ModelConverter — sarvex/DirectxGraphicsSamples0 reactions
- Apr 28, 2023Bump directxtex_uwp from 2018.8.5.1 to 2023.1.31.1 in /glTF-Toolkit.UWP — sarvex/glTF-Toolkit0 reactions
- Apr 28, 2023Bump directxtex_desktop_win10 from 2021.1.10.2 to 2023.1.31.1 in /MiniEngine/ModelViewer — sarvex/DirectxGraphicsSamples0 reactions
- Feb 17, 2023Bump deps/DirectXTex from `679538e` to `0f77045` — alicealys/h2-zonetool0 reactions
- Feb 1, 2023Bump directxtex_desktop_win10 from 2021.1.10.2 to 2023.1.31.1 in /MiniEngine/ModelViewer — NOUIY/DirectX-Graphics-Samples0 reactions
- Feb 1, 2023Bump directxtex_desktop_win10 from 2019.8.23.1 to 2023.1.31.1 in /Engine — DznEggs4Keira/Engine5020 reactions
- Feb 1, 2023Bump directxtex_desktop_win10 from 2021.1.10.2 to 2023.1.31.1 in /MiniEngine/ModelViewer — bl1mp/DirectX-Graphics-Samples0 reactions
- Feb 1, 2023Bump directxtex_desktop_win10 from 2019.2.7.1 to 2023.1.31.1 in /MiniEngine/ModelConverter — NOUIY/DirectX-Graphics-Samples0 reactions
- Feb 1, 2023Bump directxtex_desktop_win10 from 2019.2.7.1 to 2023.1.31.1 in /MiniEngine/ModelConverter — bl1mp/DirectX-Graphics-Samples0 reactions
- Feb 1, 2023Bump directxtex_desktop_win10 from 2019.8.23.1 to 2023.1.31.1 in /EpionNodeShaderTool — 13treize/EpionNodeEditorProject0 reactions
- Feb 1, 2023Bump directxtex_desktop_win10 from 2019.8.23.1 to 2023.1.31.1 in /NodeDataLib — 13treize/EpionNodeEditorProject0 reactions
- Feb 1, 2023Bump directxtex_desktop_win10 from 2019.8.23.1 to 2023.1.31.1 in /AliceGames/AliceLibrary — kaosu7201/AliceGames0 reactions
- Feb 1, 2023Bump directxtex_desktop_win10 from 2020.9.30.1 to 2023.1.31.1 — 13treize/Epion-Graphics0 reactions
- Feb 1, 2023Bump directxtex_desktop_win10 from 2018.11.20.1 to 2023.1.31.1 in /ElixirEngine — nitvic793/dx12-engine-elixir0 reactions
- Feb 1, 2023Bump directxtex_uwp from 2022.12.18.1 to 2023.1.31.1 in /UnitTests — 13thsymphony/HDRImageViewer0 reactions
- Feb 1, 2023Bump directxtex_uwp from 2022.12.18.1 to 2023.1.31.1 in /DXRenderer — 13thsymphony/HDRImageViewer0 reactions
- Oct 14, 2021[PROPOSAL] Add bindings for DirectXTex — terrafx/terrafx.interop.windows0 reactions
- Oct 16, 2020[REQ] Allow importing of BC7 .dds textures — monkeyman192/NMSDK0 reactions
- Apr 12, 2019Roundtrip Texture Files — kk49/deca0 reactions · 5 comments
In this repository4 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- Release ProcessSkill
- texture-assemblerSkill
- texture-converterSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 68
Use directxtex_desktop_win10 for Win32 desktop applications or directxtex_uwp for UWP apps.
- Very specific: line 72
Add the appropriate .vcxproj from the DirectXTex/ folder to your solution and add a project reference.
- Very specific: line 120
All processing functions return HRESULT.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
DirectXTex Usage Guide
This skill provides guidance for integrating the DirectXTex texture processing library into a C++ project.
When to Use
Invoke this skill when:
- Adding DirectXTex as a dependency to a new or existing project.
- Writing code that processes texture data (resizing, format conversion, mipmap generation, DirectX Block Compression, etc.).
- Needing to understand the typical DirectXTex processing pipeline.
Overview
DirectXTex is a texture processing library for Direct3D 11 and Direct3D 12 applications. It provides support for reading and writing DDS files, and performing various texture content processing operations including resizing, format conversion, mipmap generation, block compression, and normal map creation.
- Repository: https://github.com/microsoft/DirectXTex
- Documentation: https://github.com/microsoft/DirectXTex/wiki
- NuGet Packages:
directxtex_desktop_win10,directxtex_uwp - vcpkg Port:
directxtex
Integration Methods
vcpkg manifest-mode (Recommended)
In your vcpkg.json file, add the following:
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"directxtex"
]
}vcpkg (classic)
vcpkg install directxtexFeatures: dx12 (DirectX 12 API support), openexr (OpenEXR support), tools (command-line tools). Triplets: x64-windows, x64-linux, arm64-windows, etc.
For DLL usage (x64-windows default triplet), define DIRECTX_TEX_IMPORT in your consuming project. For static library usage, use -static-md triplet variants.
CMakeLists.txt:
find_package(directxtex CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectXTex)NuGet
Use directxtex_desktop_win10 for Win32 desktop applications or directxtex_uwp for UWP apps.
Project Reference
Add the appropriate .vcxproj from the DirectXTex/ folder to your solution and add a project reference. Add the DirectXTex directory to your Additional Include Directories.
Header Include
#include <d3d12.h> // or <d3d11_1.h> — include BEFORE DirectXTex.h
#include <DirectXTex.h>
using namespace DirectX;For auxiliary features, include additional headers:
#include <DirectXTexEXR.h> // OpenEXR support
#include <DirectXTexJPEG.h> // libjpeg support (non-WIC)
#include <DirectXTexPNG.h> // libpng support (non-WIC)
#include <DirectXTexXbox.h> // Xbox tiling extensionsDirectXTexJPEG, DirectXTexPNG are typically only used on Linux.
Key Concepts
ScratchImage
ScratchImage is the primary image container. It owns pixel memory and provides access to individual mip levels, array slices, and volume depth slices.
ScratchImage image;
HRESULT hr = LoadFromDDSFile(L"texture.dds", DDS_FLAGS_NONE, nullptr, image);
if (FAILED(hr))
// handle error
const TexMetadata& metadata = image.GetMetadata();
const Image* img = image.GetImage(0, 0, 0); // mip 0, item 0, slice 0TexMetadata
Describes the texture dimensions, format, mip levels, array size, and type (1D, 2D, 3D, cubemap).
Blob
A memory buffer used for serialized output (e.g., saving to memory rather than files).
Error Handling
All processing functions return HRESULT. Check with FAILED() / SUCCEEDED() macros.
Common Workflows
Loading Textures
// From DDS file
ScratchImage image;
HRESULT hr = LoadFromDDSFile(L"texture.dds", DDS_FLAGS_NONE, nullptr, image);
// From WIC file (PNG, BMP, JPEG, TIFF, etc.) — Windows only
ScratchImage image;
HRESULT hr = LoadFromWICFile(L"texture.png", WIC_FLAGS_NONE, nullptr, image);
// From TGA file
ScratchImage image;
HRESULT hr = LoadFromTGAFile(L"texture.tga", TGA_FLAGS_NONE, nullptr, image);
// From HDR file
ScratchImage image;
HRESULT hr = LoadFromHDRFile(L"texture.hdr", nullptr, image);
// From memory
ScratchImage image;
HRESULT hr = LoadFromDDSMemory(pData, dataSize, DDS_FLAGS_NONE, nullptr, image);Saving Textures
// Save to DDS file
const Image* img = image.GetImages();
size_t nimages = image.GetImageCount();
const TexMetadata& metadata = image.GetMetadata();
HRESULT hr = SaveToDDSFile(img, nimages, metadata, DDS_FLAGS_NONE, L"output.dds");
// Save single image to WIC file (PNG) — Windows only
hr = SaveToWICFile(*image.GetImage(0, 0, 0), WIC_FLAGS_NONE,
GetWICCodec(WIC_CODEC_PNG), L"output.png");
// Save to memory blob
Blob blob;
hr = SaveToDDSMemory(img, nimages, metadata, DDS_FLAGS_NONE, blob);Format Conversion
ScratchImage converted;
HRESULT hr = Convert(image.GetImages(), image.GetImageCount(), image.GetMetadata(),
DXGI_FORMAT_R8G8B8A8_UNORM, TEX_FILTER_DEFAULT, TEX_THRESHOLD_DEFAULT, converted);Resizing
ScratchImage resized;
HRESULT hr = Resize(image.GetImages(), image.GetImageCount(), image.GetMetadata(),
1024, 1024, TEX_FILTER_DEFAULT, resized);Mipmap Generation
ScratchImage mipChain;
HRESULT hr = GenerateMipMaps(image.GetImages(), image.GetImageCount(), image.GetMetadata(),
TEX_FILTER_DEFAULT, 0, mipChain);
// 0 levels = generate full mip chainBlock Compression
ScratchImage compressed;
HRESULT hr = Compress(image.GetImages(), image.GetImageCount(), image.GetMetadata(),
DXGI_FORMAT_BC7_UNORM, TEX_COMPRESS_DEFAULT, TEX_THRESHOLD_DEFAULT, compressed);
// GPU-accelerated BC6H/BC7 compression (Direct3D 11)
ScratchImage compressed;
HRESULT hr = Compress(pDevice, image.GetImages(), image.GetImageCount(), image.GetMetadata(),
DXGI_FORMAT_BC7_UNORM, TEX_COMPRESS_DEFAULT, TEX_ALPHA_WEIGHT_DEFAULT, compressed);Decompression
ScratchImage decompressed;
HRESULT hr = Decompress(image.GetImages(), image.GetImageCount(), image.GetMetadata(),
DXGI_FORMAT_R8G8B8A8_UNORM, decompressed);Normal Map Generation
ScratchImage normalMap;
HRESULT hr = ComputeNormalMap(*image.GetImage(0, 0, 0),
CNMAP_CHANNEL_LUMINANCE, 2.0f,
DXGI_FORMAT_R8G8B8A8_UNORM, normalMap);Premultiplied Alpha
ScratchImage pmAlpha;
HRESULT hr = PremultiplyAlpha(image.GetImages(), image.GetImageCount(), image.GetMetadata(),
TEX_PMALPHA_DEFAULT, pmAlpha);Creating Direct3D 11 Resources
#include <d3d11.h>
#include <DirectXTex.h>
// Create texture resource
ID3D11Resource* pTexture = nullptr;
HRESULT hr = CreateTexture(pDevice, image.GetImages(), image.GetImageCount(),
image.GetMetadata(), &pTexture);
// Create shader resource view directly
ID3D11ShaderResourceView* pSRV = nullptr;
hr = CreateShaderResourceView(pDevice, image.GetImages(), image.GetImageCount(),
image.GetMetadata(), &pSRV);Creating Direct3D 12 Resources
#include <d3d12.h>
#include <DirectXTex.h>
// Create committed resource
ID3D12Resource* pTexture = nullptr;
HRESULT hr = CreateTexture(pDevice, image.GetMetadata(), &pTexture);
// Prepare upload data for CopyTextureRegion
std::vector<D3D12_SUBRESOURCE_DATA> subresources;
hr = PrepareUpload(pDevice, image.GetImages(), image.GetImageCount(),
image.GetMetadata(), subresources);Typical Texture Pipeline
A common offline texture processing pipeline:
// 1. Load source image
ScratchImage source;
HRESULT hr = LoadFromWICFile(L"diffuse.png", WIC_FLAGS_NONE, nullptr, source);
if (FAILED(hr)) return hr;
// 2. Resize if needed
ScratchImage resized;
if (source.GetMetadata().width != 1024 || source.GetMetadata().height != 1024)
{
hr = Resize(*source.GetImage(0, 0, 0), 1024, 1024, TEX_FILTER_DEFAULT, resized);
if (FAILED(hr)) return hr;
}
else
{
resized = std::move(source);
}
// 3. Generate mipmaps
ScratchImage mipChain;
hr = GenerateMipMaps(*resized.GetImage(0, 0, 0), TEX_FILTER_DEFAULT, 0, mipChain);
if (FAILED(hr)) return hr;
// 4. Compress to BC7
ScratchImage compressed;
hr = Compress(mipChain.GetImages(), mipChain.GetImageCount(), mipChain.GetMetadata(),
DXGI_FORMAT_BC7_UNORM, TEX_COMPRESS_DEFAULT, TEX_THRESHOLD_DEFAULT, compressed);
if (FAILED(hr)) return hr;
// 5. Save as DDS
hr = SaveToDDSFile(compressed.GetImages(), compressed.GetImageCount(),
compressed.GetMetadata(), DDS_FLAGS_NONE, L"diffuse.dds");Format Utilities
DirectXTex provides utility functions for querying DXGI format properties:
bool compressed = IsCompressed(DXGI_FORMAT_BC7_UNORM); // true
size_t bpp = BitsPerPixel(DXGI_FORMAT_R8G8B8A8_UNORM); // 32
bool srgb = IsSRGB(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); // true
DXGI_FORMAT srgbFmt = MakeSRGB(DXGI_FORMAT_R8G8B8A8_UNORM); // _SRGB variant
DXGI_FORMAT linearFmt = MakeLinear(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); // non-SRGB
size_t rowPitch, slicePitch;
ComputePitch(DXGI_FORMAT_R8G8B8A8_UNORM, 256, 256, rowPitch, slicePitch);Platform Support
| Platform | DDS | HDR | TGA | WIC | Direct3D 11 | Direct3D 12 |
| Windows desktop | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| UWP | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Xbox (GDK) | ✓ | ✓ | ✓ | — | ✓ | ✓ |
| Linux | ✓ | ✓ | ✓ | — | — | — |
Command-Line Tools
DirectXTex includes three CLI tools for texture processing:
- texconv — Convert images to DDS with compression, mipmaps, and resizing
- texassemble — Create cubemaps, texture arrays, and volume maps from individual images
- texdiag — Inspect and validate DDS files
Example texconv usage:
texconv -f BC7_UNORM -m 0 -y diffuse.pngFurther Reading
- Getting Started
- DirectXTex Wiki
- API Reference
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

