Skip to content

XboxDDSTextureLoader

Chuck Walbourn edited this page Jun 29, 2016 · 11 revisions

This is a version of DDSTextureLoader for use by Xbox One XDK developers. This loads pre-tiled texture resources for use with the CreatePlacedResourceX API available to Xbox One exclusive app developers.

These pre-tiled resources are stored in a variant of the .DDS file format marked with the "XBOX" FourCC pixel format. To generate these .DDS files, see the xtexconv sample on the Microsoft Game Developer Network site (access required).

To load traditional or FourCC "DX10" variant DDS files, use DDSTextureLoader

Header

#include <XboxDDSTextureLoader.h>

Functions

These are in the Xbox namespace rather than DirectX

CreateDDSTextureFromMemory, CreateDDSTextureFromFile

These are equivalent to the same functions in DDSTextureLoader.

HRESULT CreateDDSTextureFromMemory(
    ID3D12Device* d3dDevice,
    const uint8_t* ddsData,
    size_t ddsDataSize,
    ID3D12Resource** texture,
    void** grfxMemory,
    DDS_ALPHA_MODE* alphaMode = nullptr, 
    bool forceSRGB = false,
    bool* isCubeMap = nullptr);

HRESULT CreateDDSTextureFromFile( 
    ID3D12Device* d3dDevice,
    const wchar_t* szFileName,
    ID3D12Resource** texture,
    void** grfxMemory,
    DDS_ALPHA_MODE* alphaMode = nullptr,
    bool forceSRGB = false,
    bool* isCubeMap = nullptr);

Parameters

The grfxMemory is returned as a pointer to the video memory which the caller is responsible for releasing with FreeDDSTextureMemory

Remark

Auto-gen mipmaps are not supported with these functions.

Be sure to flush the GPU caches before using textures created with these functions

ID3D12CommandList::FlushPipelineX(D3D12XBOX_FLUSH_IDLE, 0, 0);

You may wish to consider more fine-grained flushes if creating textures at run-time. See the documentation for FlushPipelineX on GDNP.

DDS File Format

This function expects the DDS file to contain a pixel format with FourCC "XBOX" which signifies a specific variant of the file.

DWORD dwMagic
DDS_HEADER header
DDS_HEADER_XBOX
{
    DXGI_FORMAT dxgiFormat;
    uint32_t    resourceDimension;
    uint32_t    miscFlag; // see DDS_RESOURCE_MISC_FLAG
    uint32_t    arraySize;
    uint32_t    miscFlags2; // see DDS_MISC_FLAGS2
    uint32_t    tileMode; // see XG_TILE_MODE
    uint32_t    baseAlignment;
    uint32_t    dataSize;
    uint32_t    xdkVer; // matching _XDK_VER
} headerXbox
// Remainder of file is a tiled texture binary layout suitable
// for use with CreatePlacedResource API

Other DDS loaders and viewers will fail to recognize this pixel format, and other DDS creation tools do not support creating it. See the xtexconv sample for more information on creating this variant form of DDS files.

DDS on MSDN

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Xbox One
  • Xbox Series X|S

Architecture

  • x86
  • x64
  • ARM64

For Development

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

Related Projects

DirectX Tool Kit for DirectX 11

DirectXMesh

DirectXTex

DirectXMath

Tools

Test Suite

Model Viewer

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally