DirectXTex: Fixed bug with application of ordered dithering in non-WIC codepaths
↧
Source code checked in, #34151
↧
Source code checked in, #34173
DDSTextureLoader: Fixed computing for NV11 which requires width multiple of 4, but height can be odd
↧
↧
Commented Feature: Video format support [1027]
DirectXTex currently does not support any of the DirectX 11 video formats.
* DXGI_FORMAT_AYUV
* DXGI_FORMAT_Y410
* DXGI_FORMAT_Y416
* DXGI_FORMAT_NV12
* DXGI_FORMAT_P010
* DXGI_FORMAT_P016
* DXGI_FORMAT_420_OPAQUE
* DXGI_FORMAT_YUY2
* DXGI_FORMAT_Y210
* DXGI_FORMAT_Y216
* DXGI_FORMAT_NV11
* DXGI_FORMAT_AI44
* DXGI_FORMAT_IA44
* DXGI_FORMAT_P8
* DXGI_FORMAT_A8P8
[WIC in Windows 8.1](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280986(v=vs.85).aspx) has some limited support for them.
A minimal amount of support would include loading/saving with DDS files, and perhaps colorspace conversions.
Comments: Associated with changeset 34173: DDSTextureLoader: Fixed computing for NV11 which requires width multiple of 4, but height can be odd
* DXGI_FORMAT_AYUV
* DXGI_FORMAT_Y410
* DXGI_FORMAT_Y416
* DXGI_FORMAT_NV12
* DXGI_FORMAT_P010
* DXGI_FORMAT_P016
* DXGI_FORMAT_420_OPAQUE
* DXGI_FORMAT_YUY2
* DXGI_FORMAT_Y210
* DXGI_FORMAT_Y216
* DXGI_FORMAT_NV11
* DXGI_FORMAT_AI44
* DXGI_FORMAT_IA44
* DXGI_FORMAT_P8
* DXGI_FORMAT_A8P8
[WIC in Windows 8.1](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280986(v=vs.85).aspx) has some limited support for them.
A minimal amount of support would include loading/saving with DDS files, and perhaps colorspace conversions.
Comments: Associated with changeset 34173: DDSTextureLoader: Fixed computing for NV11 which requires width multiple of 4, but height can be odd
↧
Source code checked in, #34174
ScreenGrab: Fixed computing for NV11 which requires width multiple of 4, but height can be odd
↧
Commented Feature: Video format support [1027]
DirectXTex currently does not support any of the DirectX 11 video formats.
* DXGI_FORMAT_AYUV
* DXGI_FORMAT_Y410
* DXGI_FORMAT_Y416
* DXGI_FORMAT_NV12
* DXGI_FORMAT_P010
* DXGI_FORMAT_P016
* DXGI_FORMAT_420_OPAQUE
* DXGI_FORMAT_YUY2
* DXGI_FORMAT_Y210
* DXGI_FORMAT_Y216
* DXGI_FORMAT_NV11
* DXGI_FORMAT_AI44
* DXGI_FORMAT_IA44
* DXGI_FORMAT_P8
* DXGI_FORMAT_A8P8
[WIC in Windows 8.1](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280986(v=vs.85).aspx) has some limited support for them.
A minimal amount of support would include loading/saving with DDS files, and perhaps colorspace conversions.
Comments: Associated with changeset 34174: ScreenGrab: Fixed computing for NV11 which requires width multiple of 4, but height can be odd
* DXGI_FORMAT_AYUV
* DXGI_FORMAT_Y410
* DXGI_FORMAT_Y416
* DXGI_FORMAT_NV12
* DXGI_FORMAT_P010
* DXGI_FORMAT_P016
* DXGI_FORMAT_420_OPAQUE
* DXGI_FORMAT_YUY2
* DXGI_FORMAT_Y210
* DXGI_FORMAT_Y216
* DXGI_FORMAT_NV11
* DXGI_FORMAT_AI44
* DXGI_FORMAT_IA44
* DXGI_FORMAT_P8
* DXGI_FORMAT_A8P8
[WIC in Windows 8.1](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280986(v=vs.85).aspx) has some limited support for them.
A minimal amount of support would include loading/saving with DDS files, and perhaps colorspace conversions.
Comments: Associated with changeset 34174: ScreenGrab: Fixed computing for NV11 which requires width multiple of 4, but height can be odd
↧
↧
Source code checked in, #34175
DirectXTex: Support for Direct3D 11 video and Xbox One extended formats
- New APIs: IsPlanar, IsPalettized, IsDepthStencil, ConvertToSinglePlane
↧
Closed Feature: Video format support [1027]
DirectXTex currently does not support any of the DirectX 11 video formats.
* DXGI_FORMAT_AYUV
* DXGI_FORMAT_Y410
* DXGI_FORMAT_Y416
* DXGI_FORMAT_NV12
* DXGI_FORMAT_P010
* DXGI_FORMAT_P016
* DXGI_FORMAT_420_OPAQUE
* DXGI_FORMAT_YUY2
* DXGI_FORMAT_Y210
* DXGI_FORMAT_Y216
* DXGI_FORMAT_NV11
* DXGI_FORMAT_AI44
* DXGI_FORMAT_IA44
* DXGI_FORMAT_P8
* DXGI_FORMAT_A8P8
[WIC in Windows 8.1](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280986(v=vs.85).aspx) has some limited support for them.
A minimal amount of support would include loading/saving with DDS files, and perhaps colorspace conversions.
Comments: Resolved with changeset 34175: DirectXTex: Support for Direct3D 11 video and Xbox One extended formats
- New APIs: IsPlanar, IsPalettized, IsDepthStencil, ConvertToSinglePlane
* DXGI_FORMAT_AYUV
* DXGI_FORMAT_Y410
* DXGI_FORMAT_Y416
* DXGI_FORMAT_NV12
* DXGI_FORMAT_P010
* DXGI_FORMAT_P016
* DXGI_FORMAT_420_OPAQUE
* DXGI_FORMAT_YUY2
* DXGI_FORMAT_Y210
* DXGI_FORMAT_Y216
* DXGI_FORMAT_NV11
* DXGI_FORMAT_AI44
* DXGI_FORMAT_IA44
* DXGI_FORMAT_P8
* DXGI_FORMAT_A8P8
[WIC in Windows 8.1](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280986(v=vs.85).aspx) has some limited support for them.
A minimal amount of support would include loading/saving with DDS files, and perhaps colorspace conversions.
Comments: Resolved with changeset 34175: DirectXTex: Support for Direct3D 11 video and Xbox One extended formats
- New APIs: IsPlanar, IsPalettized, IsDepthStencil, ConvertToSinglePlane
↧
Updated Wiki: Utility Functions
These functions provide utility functionality when working with DXGI_FORMATs throughout the library.
GetWICCodec
Returns a WIC GUID for a given file container given a simple enumeration value. This function is optional and you can instead use the WIC container GUID directly instead.
IsValid
Returns false if the DXGI format is unknown.
IsCompressed
Returns true if the DXGI format is a block compressed format.
IsPacked
Returns true if the DXGI format is a 'packed' format (such as 4:2:2 video formats)
IsVideo
Returns true if the DXGI format is a DXGI 1.2 'video' format defined for Direct3D 11.1 video.
IsPlanar
Returns true if the DXGI format is a 'planar' format (such as 4:2:0 or 4:1:1 video formats).
IsPalettized
Returns true if the DXGI format is a paletted format (only legacy Direct3D 11.1 video formats are paletted).
IsDepthStencil
Returns true if the DXGI format is for use with depth/stencil resources.
IsSRGB
Returns true if the DXGI format is an sRGB format.
IsTypeless
Returns true if the DXGI format is a 'typeless' format. If partialTypeless is 'true' (the default) then formats with both typeless and typed content return true. If partialTypeless is 'false', then the mixed DXGI types (such as DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS) will return false instead.
HasAlpha
Returns true of the DXGI format includes an alpha channel. Note that BC1 formats return true because they have a 'transparency bit' trick in the encoding to handle 1-bit alpha.
BitsPerPixel
Returns the bits-per-pixel for a given DXGI format. For example, it returns 32 for DXGI_FORMAT_R10G10B10A2_UNORM.
BitsPerColor
Returns the color-depth (aka bit-depth) for a given DXGI format. For formats with a mix of different channel sizes, it returns the color-depth of the largest channel. For example, it returns 10 for DXGI_FORMAT_R10G10B10A2_UNORM.
ComputePitch
Returns both the row and slice pitch for a given width, height, and DXGI format. It supports a number of flags for overriding the default byte-alignment usually used by DDS files and Direct3D 11 resources.
ComputeScanlines
Returns the number of horizontal scanlines in an image given the DXGI format and pixel height.
MakeSRGB
Converts a DXGI format to the sRGB equivalent if any.
MakeTypeless
Converts a DXGI format to a TYPELESS equiavlent if any. This does not modify depth/stencil formats which have multiple 'typeless' mappings.
MakeTypelessUNORM
Converts a TYPELESS DXGI format to a UNORM equivalent if any.
MakeTypelessFLOAT
Converts a TYPELESS DXGI format to a FLOAT equivalent if any.
GetWICCodec
Returns a WIC GUID for a given file container given a simple enumeration value. This function is optional and you can instead use the WIC container GUID directly instead.
- WIC_CODEC_BMP Windows Bitmap (.bmp)
- WIC_CODEC_JPEG Joint Photographic Experts Group (.jpg, .jpeg)
- WIC_CODEC_PNG Portable Network Graphics (.png)
- WIC_CODEC_TIFF Tagged Image File Format (.tif, .tiff)
- WIC_CODEC_GIF Graphics Interchange Format (.gif)
- WIC_CODEC_WMP Windows Media Photo / HD Photo / JPEG XR (.hdp, .jxr, .wdp)
- WIC_CODEC_ICO Windows Icon (.ico)
IsValid
Returns false if the DXGI format is unknown.
IsCompressed
Returns true if the DXGI format is a block compressed format.
IsPacked
Returns true if the DXGI format is a 'packed' format (such as 4:2:2 video formats)
IsVideo
Returns true if the DXGI format is a DXGI 1.2 'video' format defined for Direct3D 11.1 video.
IsPlanar
Returns true if the DXGI format is a 'planar' format (such as 4:2:0 or 4:1:1 video formats).
IsPalettized
Returns true if the DXGI format is a paletted format (only legacy Direct3D 11.1 video formats are paletted).
IsDepthStencil
Returns true if the DXGI format is for use with depth/stencil resources.
IsSRGB
Returns true if the DXGI format is an sRGB format.
IsTypeless
Returns true if the DXGI format is a 'typeless' format. If partialTypeless is 'true' (the default) then formats with both typeless and typed content return true. If partialTypeless is 'false', then the mixed DXGI types (such as DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS) will return false instead.
HasAlpha
Returns true of the DXGI format includes an alpha channel. Note that BC1 formats return true because they have a 'transparency bit' trick in the encoding to handle 1-bit alpha.
BitsPerPixel
Returns the bits-per-pixel for a given DXGI format. For example, it returns 32 for DXGI_FORMAT_R10G10B10A2_UNORM.
BitsPerColor
Returns the color-depth (aka bit-depth) for a given DXGI format. For formats with a mix of different channel sizes, it returns the color-depth of the largest channel. For example, it returns 10 for DXGI_FORMAT_R10G10B10A2_UNORM.
ComputePitch
Returns both the row and slice pitch for a given width, height, and DXGI format. It supports a number of flags for overriding the default byte-alignment usually used by DDS files and Direct3D 11 resources.
- CP_FLAGS_NONE is the default
- CP_FLAGS_LEGACY_DWORD is used for some legacy Direct3D 8 era DDS files, particularly 24bpp files, that used a DWORD alignment instead of BYTE
- CP_FLAGS_24BPP used for computing pitch of Direct3D 9 era 24bpp DDS files (which cannot be indicated by a DXGI_FORMAT)
- CP_FLAGS_16BPP used for computing pitch of 16bpp DDS files (which requires DXGI 1.2 headers to define all possible combinations, so we use the flag here instead)
- CP_FLAGS_8BPP used for computing pitch of 8bpp DDS files
ComputeScanlines
Returns the number of horizontal scanlines in an image given the DXGI format and pixel height.
MakeSRGB
Converts a DXGI format to the sRGB equivalent if any.
MakeTypeless
Converts a DXGI format to a TYPELESS equiavlent if any. This does not modify depth/stencil formats which have multiple 'typeless' mappings.
MakeTypelessUNORM
Converts a TYPELESS DXGI format to a UNORM equivalent if any.
MakeTypelessFLOAT
Converts a TYPELESS DXGI format to a FLOAT equivalent if any.
↧
Updated Wiki: Texture Functions
Functions for doing texture processing based on DirectXTex data typically loaded from a WIC or TGA image file and then written to a .DDS file.
The majority of these functions cannot operate on planar or palettized formats.
FlipRotate
Flip and/or rotate image or set of images.
Resize
Resize an image or set of images.
Convert
Convert an image or set of images from one pixel format to another.
ConvertToSinglePlane
Converts a planar image or set of images to a single-plane pixel format.
GenerateMipMaps
Generates mipmaps for an image or a set of images.
GenerateMipMaps3D
Generates mipmaps for a 3D volume texture from a set of images representing the slices.
PremultiplyAlpha
This converts an image assuming the original is not using premultiplied alpha into a premultiplied alpha version of the same image.
Compress
Compresses an image or set of images to a BC format.
Decompress
Decompresses a BC format to a non-BC format image.
ComputeNormalMap
Converts a height-map to a normal-map.
CopyRectangle
Copies a rectangle from a soure image to a destination image. Does not support block compressed formats.
ComputeMSE
Computes the mean-squared error for each component based on two input images.
The majority of these functions cannot operate on planar or palettized formats.
FlipRotate
Flip and/or rotate image or set of images.
Resize
Resize an image or set of images.
Convert
Convert an image or set of images from one pixel format to another.
ConvertToSinglePlane
Converts a planar image or set of images to a single-plane pixel format.
GenerateMipMaps
Generates mipmaps for an image or a set of images.
GenerateMipMaps3D
Generates mipmaps for a 3D volume texture from a set of images representing the slices.
PremultiplyAlpha
This converts an image assuming the original is not using premultiplied alpha into a premultiplied alpha version of the same image.
Compress
Compresses an image or set of images to a BC format.
Decompress
Decompresses a BC format to a non-BC format image.
ComputeNormalMap
Converts a height-map to a normal-map.
CopyRectangle
Copies a rectangle from a soure image to a destination image. Does not support block compressed formats.
ComputeMSE
Computes the mean-squared error for each component based on two input images.
Examples
These are flexible functions for doing texture processing that can be used in many different ways. See the Texconv and Texassemble command-line utilities source code for some extensive examples of using them.Related Flags
See Filter Flags↧
↧
Updated Wiki: Convert
Convert an image or set of images from one pixel format to another.
filter: See Filter Flags
threshold: Alpha threshold used for converting to single bit alpha channels (0 to 1 range)
This function cannot operate directly on a planar format image. See ConvertToSinglePlane for a method for converting planar data to a format that is supported by this routine.
This function is implemented with both WIC and non-WIC code paths. The non-WIC paths is generally used when the standard WIC conversion behavior is unintuitive for textures or would modify the color space in unexpected ways.
HRESULT Convert( _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD filter, _In_ float threshold, _Out_ ScratchImage& image ); HRESULT Convert( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DXGI_FORMAT format, _In_ DWORD filter, _In_ float threshold, _Out_ ScratchImage& result );
Parameters
format: Target format for conversion.filter: See Filter Flags
threshold: Alpha threshold used for converting to single bit alpha channels (0 to 1 range)
Example
ScratchImage srcImage;
...
ScratchImage destImage;
hr = Convert( srcImage.GetImages(), srcImage.GetImageCount(), srcImage.GetMetadata(),
DXGI_FORMAT_R8G8B8A8_UNORM, TEX_FILTER_DEFAULT, 0.5f, destImage );
if ( FAILED(hr) )
...
Remarks
This function does not operate directly on block compressed images. See Decompress and Compress.This function cannot operate directly on a planar format image. See ConvertToSinglePlane for a method for converting planar data to a format that is supported by this routine.
This function is implemented with both WIC and non-WIC code paths. The non-WIC paths is generally used when the standard WIC conversion behavior is unintuitive for textures or would modify the color space in unexpected ways.
↧
Updated Wiki: ConvertToSinglePlane
Converts a planar image (such as 4:2:0 or 4:1:1 video format) to a non-planar format (typically 4:2:2 for video formats).
HRESULT ConvertToSinglePlane( _In_ const Image& srcImage, _Out_ ScratchImage& image ); HRESULT ConvertToSinglePlane( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _Out_ ScratchImage& image );
Remarks
The pixel format of the resulting image is determined by the format of the input. For example NV11 and NV12 are always converted to YUY2.↧
Updated Wiki: ConvertToSinglePlane
Converts a planar image (such as 4:2:0 or 4:1:1 video format) to a non-planar format (typically 4:2:2 for video formats).
http://msdn.microsoft.com/en-us/library/windows/desktop/dd206750.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578.aspx
HRESULT ConvertToSinglePlane( _In_ const Image& srcImage, _Out_ ScratchImage& image ); HRESULT ConvertToSinglePlane( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _Out_ ScratchImage& image );
Remarks
The pixel format of the resulting image is determined by the format of the input. For example NV11 and NV12 are always converted to YUY2.http://msdn.microsoft.com/en-us/library/windows/desktop/dd206750.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578.aspx
↧
Updated Wiki: ConvertToSinglePlane
Converts a planar image (such as 4:2:0 or 4:1:1 video format) to a non-planar format (typically 4:2:2 for video formats). Planar formats are not supported by other texture functions, so this routine can be used to convert planar data to a form that other functions will operate on.
http://msdn.microsoft.com/en-us/library/windows/desktop/dd206750.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578.aspx
HRESULT ConvertToSinglePlane( _In_ const Image& srcImage, _Out_ ScratchImage& image ); HRESULT ConvertToSinglePlane( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _Out_ ScratchImage& image );
Remarks
The pixel format of the resulting image is determined by the format of the input. For example NV11 and NV12 are always converted to YUY2.http://msdn.microsoft.com/en-us/library/windows/desktop/dd206750.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578.aspx
↧
↧
Updated Wiki: DDS I/O Functions
These functions perform file I/O for .DDS files. These functions support many legacy Direct3D 9 .DDS files and all Direct3D 10.x/11.x era "DX10" extension .DDS files
GetMetadataFromDDSMemory
GetMetadataFromDDSFile
Returns the TexMetadata from a .DDS file.
LoadFromDDSMemory
LoadFromDDSFile
Loads a .DDS file.
SaveToDDSMemory
SaveToDDSFile
Saves a single image or a set of images to a .DDS file.
When saving a DDS file, it can contain one or more images (mipmaps, arrays, volumes, cubemaps, etc.). Therefore, the writer needs the TexMetadata info to know how to interpret the image set.
You can also save data directly from memory without using the intermediate ScratchImage at all. This example assumes a single 2D image is being written out.
The 'DX10' header is not supported by D3DX9, older Direct3D 9 era texture tools, or the legacy DirectX SDK DXTex.exe tool. Therefore, the default behavior is to prefer to use 'legacy' pixel formats when possible.
Note that for Direct3D 11.1 video formats, only DXGI_FORMAT_YUY2 is supported by Direct3D 9. Legacy DDS files containing FourCC "UYVY" are converted to YUY2 at load-time.
http://msdn.microsoft.com/en-us/library/windows/apps/hh758319.aspx
If you are going to immediately copy it to another location via StorageFolder, then use the app's temporary folder:
http://msdn.microsoft.com/en-us/library/windows/apps/hh967755.aspx
GetMetadataFromDDSMemory
GetMetadataFromDDSFile
Returns the TexMetadata from a .DDS file.
LoadFromDDSMemory
LoadFromDDSFile
Loads a .DDS file.
SaveToDDSMemory
SaveToDDSFile
Saves a single image or a set of images to a .DDS file.
Examples
This is a simple loading example. A DDS file can potentially include any kind of Direct3D resource in any DXGI format, so the TexMetadata info is needed to understand the full content of the file.TexMetadata info; unique_ptr<ScratchImage> image ( new ScratchImage ); HRESULT hr = LoadFromDDSFile( L"TEXTURE.DDS", DDS_FLAGS_NONE, &info, *image ); if ( FAILED(hr) ) // error
When saving a DDS file, it can contain one or more images (mipmaps, arrays, volumes, cubemaps, etc.). Therefore, the writer needs the TexMetadata info to know how to interpret the image set.
const Image* img = image->GetImages(); assert( img ); size_t nimg = image->GetImageCount(); assert( nimg > 0 ); HRESULT hr = SaveToDDSFile( img, nimg, image->GetMetadata(), DDS_FLAGS_NONE, L"NEW_TEXTURE.DDS" ); if ( FAILED(hr) ) // error
You can also save data directly from memory without using the intermediate ScratchImage at all. This example assumes a single 2D image is being written out.
Image img; img.width = /*<width of pixel data>*/; img.height = /*<height of pixel data>*/; img.format = /*<any DXGI format>*/; img.rowPitch = /*<number of bytes in a scanline of the source data>*/; img.slicePitch = /*<number of bytes in the entire 2D image>*/; img.pixels = /*<pointer to pixel data>*/; HRESULT hr = SaveToDDSFile( img, DDS_FLAGS_NONE, L"NEW_TEXTURE.DDS" ); if ( FAILED(hr) ) // error
Related Flags
- DDS_FLAGS_NONE is the default
- DDS_FLAGS_LEGACY_DWORD is used for loading some legacy Direct3D 8 era 24bpp .DDS files that use the non-standard DWORD alignment instead of BYTE. There's no realiable way to determine this from the file, so this requires trial-and-error.
- DDS_FLAGS_NO_LEGACY_EXPANSION - By default the loader will expand many legacy Direct3D 9 .DDS files to supported formats. The use of this flag prevents expansions that increase the size of the pixels, and will return a failure instead.
- DDS_FLAGS_NO_R10B10G10A2_FIXUP - By default, the loader uses a work-around for a long-standing issue with the D3DX DDS file format which reverses the RGB bit-masks for 10:10:10:2 formats. If this flag is used, then the loader instead assumes such data was written 'correctly'.
- DDS_FLAGS_FORCE_RGB - By default we map many BGR formats directly to DXGI 1.1 formats. Use of this flag forces the use of DXGI 1.0 RGB formats instead for improved Direct3D 10.0/Windows Vista RTM/WDDM 1.0 driver support.
- DDS_FLAGS_NO_16BPP - By default, 5:6:5, 5:5:5:1, and 4:4:4:4 formats are returned as DXGI 1.2 formats. If this flag is used, the loader will expand these to R8G8B8A8 instead.
- DDS_FLAGS_EXPAND_LUMINANCE - By default, legacy luminance formats are mapped to the same size formats in DXGI (L8 -> R8_UNORM, L16 -> R16_UNORM, A8L8 -> R8G8_UNORM), but this requires some shader swizzling to replicate the original luminance greyscale behavior (.rrr or .rrrg)--this matches the implementation of DDSTextureLoader. Specifying this flag will instead expand these formats on load and replicate the colors to achieve the proper greyscale without any shader changes, but they will be significantly larger (8:8:8:8 or 16:16:16:16).
- DDS_FLAGS_FORCE_DX10_EXT - When saving DDS files, the writer tries to use legacy Direct3D 9 .DDS file formats if possible rather than the 'DX10' header extension for better compatiblity with older tools. Using this flag, the writer will always generate 'DX10' extension header files which are much faster to parse at load-time. These files are compatible with the legacy D3DX10 or D3DX11 library.
- DDS_FLAGS_FORCE_DX10_EXT_MISC2 - When saving DDS files, always use the 'DX10' header extension and write miscFlags2 data as needed, if even if the resulting file is not compatible with the legacy D3DX10 or D3DX11 libraries.
Remarks
Many older Direct3D 9 formats that do not directly map to DXGI formats are converted at load-time. For example, D3DFMT_R8G8B8 is always converted to DXGI_FORMAT_R8G8B8A8_UNORM since there is no 24bpp DXGI format.The 'DX10' header is not supported by D3DX9, older Direct3D 9 era texture tools, or the legacy DirectX SDK DXTex.exe tool. Therefore, the default behavior is to prefer to use 'legacy' pixel formats when possible.
Note that for Direct3D 11.1 video formats, only DXGI_FORMAT_YUY2 is supported by Direct3D 9. Legacy DDS files containing FourCC "UYVY" are converted to YUY2 at load-time.
Windows Store apps
Load
If you wish to load a texture from a file that is specified by the user from a WinRT picker, you will need to copy the file locally to a temporary location before you can use LoadFromDDSFile on it. This is because you either won't have file access rights to the user's file location, or the StorageFile is actually not a local file system path (i.e. it's a URL).create_task(openPicker->PickSingleFileAsync()).then([this](StorageFile^ file) { if (file) { auto tempFolder = Windows::Storage::ApplicationData::Current->TemporaryFolder; create_task(file->CopyAsync( tempFolder, file->Name, NameCollisionOption::GenerateUniqueName )).then([this](StorageFile^ tempFile) { if ( tempFile ) { HRESULT hr = LoadFromDDSFile( ..., tempFile->Path->Data(), ... ); DX::ThrowIfFailed(hr); } }); });
http://msdn.microsoft.com/en-us/library/windows/apps/hh758319.aspx
Save
For SaveToDDSFile to succeed, the application must have write access to the destination path. For Windows Store apps, the file access permissions are rather restricted so you'll need to make sure you use a fully qualified path to a valid write folder. A good location to use is the app data folder:auto folder = Windows::Storage::ApplicationData::Current->LocalFolder; // use folder->Path->Data() as the path base
If you are going to immediately copy it to another location via StorageFolder, then use the app's temporary folder:
auto folder = Windows::Storage::ApplicationData::Current->TemporaryFolder; // use folder->Path->Data() as the path base
http://msdn.microsoft.com/en-us/library/windows/apps/hh967755.aspx
↧
Updated Wiki: Texture Functions
Functions for doing texture processing based on DirectXTex data typically loaded from a WIC or TGA image file and then written to a .DDS file.
The majority of these functions cannot operate on planar or palettized formats. For video formats, AYUV, Y410, Y416, and YUY2, Y216, Y416 are supported and all operations are preferred in RGB colorspace.
FlipRotate
Flip and/or rotate image or set of images.
Resize
Resize an image or set of images.
Convert
Convert an image or set of images from one pixel format to another.
ConvertToSinglePlane
Converts a planar image or set of images to a single-plane pixel format.
GenerateMipMaps
Generates mipmaps for an image or a set of images.
GenerateMipMaps3D
Generates mipmaps for a 3D volume texture from a set of images representing the slices.
PremultiplyAlpha
This converts an image assuming the original is not using premultiplied alpha into a premultiplied alpha version of the same image.
Compress
Compresses an image or set of images to a BC format.
Decompress
Decompresses a BC format to a non-BC format image.
ComputeNormalMap
Converts a height-map to a normal-map.
CopyRectangle
Copies a rectangle from a soure image to a destination image. Does not support block compressed formats.
ComputeMSE
Computes the mean-squared error for each component based on two input images.
The majority of these functions cannot operate on planar or palettized formats. For video formats, AYUV, Y410, Y416, and YUY2, Y216, Y416 are supported and all operations are preferred in RGB colorspace.
FlipRotate
Flip and/or rotate image or set of images.
Resize
Resize an image or set of images.
Convert
Convert an image or set of images from one pixel format to another.
ConvertToSinglePlane
Converts a planar image or set of images to a single-plane pixel format.
GenerateMipMaps
Generates mipmaps for an image or a set of images.
GenerateMipMaps3D
Generates mipmaps for a 3D volume texture from a set of images representing the slices.
PremultiplyAlpha
This converts an image assuming the original is not using premultiplied alpha into a premultiplied alpha version of the same image.
Compress
Compresses an image or set of images to a BC format.
Decompress
Decompresses a BC format to a non-BC format image.
ComputeNormalMap
Converts a height-map to a normal-map.
CopyRectangle
Copies a rectangle from a soure image to a destination image. Does not support block compressed formats.
ComputeMSE
Computes the mean-squared error for each component based on two input images.
Examples
These are flexible functions for doing texture processing that can be used in many different ways. See the Texconv and Texassemble command-line utilities source code for some extensive examples of using them.Related Flags
See Filter Flags↧
Updated Wiki: Texture Functions
Functions for doing texture processing based on DirectXTex data typically loaded from a WIC or TGA image file and then written to a .DDS file.
The majority of these functions cannot operate on planar or palettized formats. For video formats, AYUV, Y410, Y416, and YUY2, Y216, and Y416 are supported and all operations are preferred in RGB colorspace.
FlipRotate
Flip and/or rotate image or set of images.
Resize
Resize an image or set of images.
Convert
Convert an image or set of images from one pixel format to another.
ConvertToSinglePlane
Converts a planar image or set of images to a single-plane pixel format.
GenerateMipMaps
Generates mipmaps for an image or a set of images.
GenerateMipMaps3D
Generates mipmaps for a 3D volume texture from a set of images representing the slices.
PremultiplyAlpha
This converts an image assuming the original is not using premultiplied alpha into a premultiplied alpha version of the same image.
Compress
Compresses an image or set of images to a BC format.
Decompress
Decompresses a BC format to a non-BC format image.
ComputeNormalMap
Converts a height-map to a normal-map.
CopyRectangle
Copies a rectangle from a soure image to a destination image. Does not support block compressed formats.
ComputeMSE
Computes the mean-squared error for each component based on two input images.
The majority of these functions cannot operate on planar or palettized formats. For video formats, AYUV, Y410, Y416, and YUY2, Y216, and Y416 are supported and all operations are preferred in RGB colorspace.
FlipRotate
Flip and/or rotate image or set of images.
Resize
Resize an image or set of images.
Convert
Convert an image or set of images from one pixel format to another.
ConvertToSinglePlane
Converts a planar image or set of images to a single-plane pixel format.
GenerateMipMaps
Generates mipmaps for an image or a set of images.
GenerateMipMaps3D
Generates mipmaps for a 3D volume texture from a set of images representing the slices.
PremultiplyAlpha
This converts an image assuming the original is not using premultiplied alpha into a premultiplied alpha version of the same image.
Compress
Compresses an image or set of images to a BC format.
Decompress
Decompresses a BC format to a non-BC format image.
ComputeNormalMap
Converts a height-map to a normal-map.
CopyRectangle
Copies a rectangle from a soure image to a destination image. Does not support block compressed formats.
ComputeMSE
Computes the mean-squared error for each component based on two input images.
Examples
These are flexible functions for doing texture processing that can be used in many different ways. See the Texconv and Texassemble command-line utilities source code for some extensive examples of using them.Related Flags
See Filter Flags↧
Updated Wiki: Texture Functions
Functions for doing texture processing based on DirectXTex data typically loaded from a WIC or TGA image file and then written to a .DDS file.
The majority of these functions cannot operate on planar or palettized formats. For video formats, AYUV, Y410, Y416, YUY2, Y216, and Y416 are supported and all operations are preferred in RGB colorspace.
FlipRotate
Flip and/or rotate image or set of images.
Resize
Resize an image or set of images.
Convert
Convert an image or set of images from one pixel format to another.
ConvertToSinglePlane
Converts a planar image or set of images to a single-plane pixel format.
GenerateMipMaps
Generates mipmaps for an image or a set of images.
GenerateMipMaps3D
Generates mipmaps for a 3D volume texture from a set of images representing the slices.
PremultiplyAlpha
This converts an image assuming the original is not using premultiplied alpha into a premultiplied alpha version of the same image.
Compress
Compresses an image or set of images to a BC format.
Decompress
Decompresses a BC format to a non-BC format image.
ComputeNormalMap
Converts a height-map to a normal-map.
CopyRectangle
Copies a rectangle from a soure image to a destination image. Does not support block compressed formats.
ComputeMSE
Computes the mean-squared error for each component based on two input images.
The majority of these functions cannot operate on planar or palettized formats. For video formats, AYUV, Y410, Y416, YUY2, Y216, and Y416 are supported and all operations are preferred in RGB colorspace.
FlipRotate
Flip and/or rotate image or set of images.
Resize
Resize an image or set of images.
Convert
Convert an image or set of images from one pixel format to another.
ConvertToSinglePlane
Converts a planar image or set of images to a single-plane pixel format.
GenerateMipMaps
Generates mipmaps for an image or a set of images.
GenerateMipMaps3D
Generates mipmaps for a 3D volume texture from a set of images representing the slices.
PremultiplyAlpha
This converts an image assuming the original is not using premultiplied alpha into a premultiplied alpha version of the same image.
Compress
Compresses an image or set of images to a BC format.
Decompress
Decompresses a BC format to a non-BC format image.
ComputeNormalMap
Converts a height-map to a normal-map.
CopyRectangle
Copies a rectangle from a soure image to a destination image. Does not support block compressed formats.
ComputeMSE
Computes the mean-squared error for each component based on two input images.
Examples
These are flexible functions for doing texture processing that can be used in many different ways. See the Texconv and Texassemble command-line utilities source code for some extensive examples of using them.Related Flags
See Filter Flags↧
↧
Source code checked in, #34333
DirectXTex: added alpha weight parameter for BC7 GPU compressor [breaking change]
- texconv has new '-aw' switch to take the parameter
↧
Updated Wiki: Compress
Compresses an image or set of images to a block-compressed (BC) format.
format: Format to compress to. Must be a BC compressed format (i.e. DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM_SRGB - DXGI_FORMAT_BC7_UNORM, DXGI_FORMAT_BC7_UNORM_SRGB)
Note that the DirectCompute based versions of Compress only support DXGI_FORMAT_BC6H_UF16, DXGI_FORMAT_BC6H_SF16, DXGI_FORMAT_BC7_UNORM, and DXGI_FORMAT_BC7_UNORM_SRGB
compress: Compress control flags
The sRGB color space overall is approximately equivalent to gamma 2.2. It's actually linear below a threshold, and gamma 2.4 beyond that.
http://en.wikipedia.org/wiki/SRGB
alphaRef: Threshold reference value when compressing an alpha channel for BC1 formats which support 1-bit transparency. (0 to 1 range)
alphaWeight: Used to weight the error metric's alpha computation for the BC7 GPU compressor. Use 1.0 for default, or a larger number to improve alpha accuracy potentially at the expense of the color channels.
When compressing for BC4, only the RED channel in the original image is used. When compressing for BC5, only the RED and GREEN channels are used.
The DirectXTex library functions allow arbitrary sized images to handle non-power-of-2 mipmapped BC textures. Note that Direct3D will not allow a resource to be created using BC format with the top-level size set to something other than a multiple of 4 in width and height, even though it does allow the mipchain below it to not meet that requirement. In other words, the library allows some textures to be compressed that are not actually valid on Direct3D 11.
The DirectCompute GPU-based compressor makes use of the device's immediate context.
http://msdn.microsoft.com/en-us/library/bb694531.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/hh308955.aspx
http://en.wikipedia.org/wiki/S3_Texture_Compression
http://en.wikipedia.org/wiki/3Dc
http://developer.download.nvidia.com/opengl/specs/GL_ARB_texture_compression_bptc.txt
HRESULT Compress( _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaRef, _Out_ ScratchImage& cImage ); HRESULT Compress( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaRef, _Out_ ScratchImage& cImages ); HRESULT Compress( _In_ ID3D11Device* pDevice, _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaWeight, _Out_ ScratchImage& image ); HRESULT Compress( _In_ ID3D11Device* pDevice, _In_ const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaWeight, _Out_ ScratchImage& cImages );
Parameters
device: The DirectCompute based versions of Compress require a Direct3D 11 device with Feature Level 10.0 or greater that supports DirectCompute.format: Format to compress to. Must be a BC compressed format (i.e. DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM_SRGB - DXGI_FORMAT_BC7_UNORM, DXGI_FORMAT_BC7_UNORM_SRGB)
Note that the DirectCompute based versions of Compress only support DXGI_FORMAT_BC6H_UF16, DXGI_FORMAT_BC6H_SF16, DXGI_FORMAT_BC7_UNORM, and DXGI_FORMAT_BC7_UNORM_SRGB
compress: Compress control flags
- TEX_COMPRESS_DEFAULT Default flags.
- TEX_COMPRESS_RGB_DITHER Enables dithering RGB colors for BC1-3 compression
- TEX_COMPRESS_A_DITHER Enables dithering alpha channel for BC1-3 compression
- TEX_COMPRESS_DITHER Same as TEX_COMPRESS_RGB_DITHER and TEX_COMPRESS_A_DITHER
- TEX_COMPRESS_UNIFORM By default, BC1-3 uses a perceptual weighting. By using this flag, the perceptual weighting is disabled which can be useful when using the RGB channels for other data.
- TEX_COMPRESS_PARALLEL This opts-in to multi-threaded compression if enabled.
- TEX_COMPRESS_SRGB_IN Indicates the input format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
- TEX_COMPRESS_SRGB_OUT Indicates the output format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
- TEX_COMPRESS_SRGB This is the same as setting both TEX_COMPRESS_SRGB_IN and TEX_COMPRESS_SRGB_OUT
The sRGB color space overall is approximately equivalent to gamma 2.2. It's actually linear below a threshold, and gamma 2.4 beyond that.
http://en.wikipedia.org/wiki/SRGB
alphaRef: Threshold reference value when compressing an alpha channel for BC1 formats which support 1-bit transparency. (0 to 1 range)
alphaWeight: Used to weight the error metric's alpha computation for the BC7 GPU compressor. Use 1.0 for default, or a larger number to improve alpha accuracy potentially at the expense of the color channels.
Example
ScratchImage srcImage;
...
ScratchImage bcImage;
hr = Compress( srcImage.GetImages(), srcImage.GetImageCount(), srcImage.GetMetadata(), DXGI_FORMAT_BC3_UNORM, TEX_COMPRESS_DEFAULT, 0.5f, bcImage );
if ( FAILED(hr) )
...
Remarks
By default, the BC1 - BC3 color encoding algorithms will use a perceptual weighting of the Red and Blue channels which usually gives better visual results for standard color textures. For textures that do not contain color data, you will likely want to use TEX_COMPRESS_UNIFORM to disable the perceptual weighting.When compressing for BC4, only the RED channel in the original image is used. When compressing for BC5, only the RED and GREEN channels are used.
The DirectXTex library functions allow arbitrary sized images to handle non-power-of-2 mipmapped BC textures. Note that Direct3D will not allow a resource to be created using BC format with the top-level size set to something other than a multiple of 4 in width and height, even though it does allow the mipchain below it to not meet that requirement. In other words, the library allows some textures to be compressed that are not actually valid on Direct3D 11.
Release Notes
The software based encoder for BC6H and BC7 is computationally expensive and can be quite slow. The DirectCompute based encoder which is much faster has been integrated into the DirectXTex library, but the standalone version is also available http://code.msdn.microsoft.com/BC6HBC7-DirectCompute-35e8884aThreading
The CPU-based compressor will use all cores on a system if given TEX_COMPRESS_PARALLEL for the BC6H / BC7 codec.The DirectCompute GPU-based compressor makes use of the device's immediate context.
Related Links
http://msdn.microsoft.com/en-us/library/bb204843.aspxhttp://msdn.microsoft.com/en-us/library/bb694531.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/hh308955.aspx
http://en.wikipedia.org/wiki/S3_Texture_Compression
http://en.wikipedia.org/wiki/3Dc
http://developer.download.nvidia.com/opengl/specs/GL_ARB_texture_compression_bptc.txt
↧
Updated Wiki: Compress
Compresses an image or set of images to a block-compressed (BC) format.
format: Format to compress to. Must be a BC compressed format (i.e. DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM_SRGB - DXGI_FORMAT_BC7_UNORM, DXGI_FORMAT_BC7_UNORM_SRGB)
Note that the DirectCompute based versions of Compress only support DXGI_FORMAT_BC6H_UF16, DXGI_FORMAT_BC6H_SF16, DXGI_FORMAT_BC7_UNORM, and DXGI_FORMAT_BC7_UNORM_SRGB
compress: Compress control flags
The sRGB color space overall is approximately equivalent to gamma 2.2. It's actually linear below a threshold, and gamma 2.4 beyond that.
http://en.wikipedia.org/wiki/SRGB
alphaRef: Threshold reference value when compressing an alpha channel for BC1 formats which support 1-bit transparency. (0 to 1 range)
alphaWeight: Used to weight the error metric's alpha computation for the BC7 GPU compressor. Use 1.0 for default, or a larger number to improve alpha accuracy potentially at the expense of the color channels.
When compressing for BC4, only the RED channel in the original image is used. When compressing for BC5, only the RED and GREEN channels are used.
The DirectXTex library functions allow arbitrary sized images to handle non-power-of-2 mipmapped BC textures. Note that Direct3D will not allow a resource to be created using BC format with the top-level size set to something other than a multiple of 4 in width and height, even though it does allow the mipchain below it to not meet that requirement. In other words, the library allows some textures to be compressed that are not actually valid on Direct3D 11.
The DirectCompute GPU-based compressor makes use of the device's immediate context.
http://msdn.microsoft.com/en-us/library/bb694531.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/hh308955.aspx
http://en.wikipedia.org/wiki/S3_Texture_Compression
http://en.wikipedia.org/wiki/3Dc
http://developer.download.nvidia.com/opengl/specs/GL_ARB_texture_compression_bptc.txt
HRESULT Compress( _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaRef, _Out_ ScratchImage& cImage ); HRESULT Compress( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaRef, _Out_ ScratchImage& cImages ); HRESULT Compress( _In_ ID3D11Device* pDevice, _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaWeight, _Out_ ScratchImage& image ); HRESULT Compress( _In_ ID3D11Device* pDevice, _In_ const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaWeight, _Out_ ScratchImage& cImages );
Parameters
device: The DirectCompute based versions of Compress require a Direct3D 11 device with Feature Level 10.0 or greater that supports DirectCompute.format: Format to compress to. Must be a BC compressed format (i.e. DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM_SRGB - DXGI_FORMAT_BC7_UNORM, DXGI_FORMAT_BC7_UNORM_SRGB)
Note that the DirectCompute based versions of Compress only support DXGI_FORMAT_BC6H_UF16, DXGI_FORMAT_BC6H_SF16, DXGI_FORMAT_BC7_UNORM, and DXGI_FORMAT_BC7_UNORM_SRGB
compress: Compress control flags
- TEX_COMPRESS_DEFAULT Default flags.
- TEX_COMPRESS_RGB_DITHER Enables dithering RGB colors for BC1-3 compression
- TEX_COMPRESS_A_DITHER Enables dithering alpha channel for BC1-3 compression
- TEX_COMPRESS_DITHER Same as TEX_COMPRESS_RGB_DITHER and TEX_COMPRESS_A_DITHER
- TEX_COMPRESS_UNIFORM By default, BC1-3 uses a perceptual weighting. By using this flag, the perceptual weighting is disabled which can be useful when using the RGB channels for other data.
- TEX_COMPRESS_PARALLEL This opts-in to multi-threaded compression if enabled.
- TEX_COMPRESS_SRGB_IN Indicates the input format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
- TEX_COMPRESS_SRGB_OUT Indicates the output format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
- TEX_COMPRESS_SRGB This is the same as setting both TEX_COMPRESS_SRGB_IN and TEX_COMPRESS_SRGB_OUT
The sRGB color space overall is approximately equivalent to gamma 2.2. It's actually linear below a threshold, and gamma 2.4 beyond that.
http://en.wikipedia.org/wiki/SRGB
alphaRef: Threshold reference value when compressing an alpha channel for BC1 formats which support 1-bit transparency. (0 to 1 range)
alphaWeight: Used to weight the error metric's alpha computation for the BC7 GPU compressor. Use 1.0 for default, or a larger number to improve alpha accuracy potentially at the expense of the color channels.
Example
ScratchImage srcImage;
...
ScratchImage bcImage;
hr = Compress( srcImage.GetImages(), srcImage.GetImageCount(), srcImage.GetMetadata(), DXGI_FORMAT_BC3_UNORM, TEX_COMPRESS_DEFAULT, 0.5f, bcImage );
if ( FAILED(hr) )
...
Remarks
By default, the BC1 - BC3 color encoding algorithms will use a perceptual weighting of the Red and Blue channels which usually gives better visual results for standard color textures. For textures that do not contain color data, you will likely want to use TEX_COMPRESS_UNIFORM to disable the perceptual weighting.When compressing for BC4, only the RED channel in the original image is used. When compressing for BC5, only the RED and GREEN channels are used.
The DirectXTex library functions allow arbitrary sized images to handle non-power-of-2 mipmapped BC textures. Note that Direct3D will not allow a resource to be created using BC format with the top-level size set to something other than a multiple of 4 in width and height, even though it does allow the mipchain below it to not meet that requirement. In other words, the library allows some textures to be compressed that are not actually valid on Direct3D 11.
Release Notes
The software based encoder for BC6H and BC7 is computationally expensive and can be quite slow. The DirectCompute based encoder which is much faster has been integrated into the DirectXTex library, but the standalone version is also available http://code.msdn.microsoft.com/BC6HBC7-DirectCompute-35e8884aThreading
The CPU-based compressor will use all cores on a system if given TEX_COMPRESS_PARALLEL for the BC6H / BC7 codec.The DirectCompute GPU-based compressor makes use of the device's immediate context.
Related Links
http://msdn.microsoft.com/en-us/library/bb204843.aspxhttp://msdn.microsoft.com/en-us/library/bb694531.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/hh308955.aspx
http://en.wikipedia.org/wiki/S3_Texture_Compression
http://en.wikipedia.org/wiki/3Dc
http://developer.download.nvidia.com/opengl/specs/GL_ARB_texture_compression_bptc.txt
↧