Update DirectXTex to mar2024
This commit is contained in:
@@ -36,7 +36,7 @@ namespace
|
|||||||
return static_cast<DXGI_FORMAT>(format);
|
return static_cast<DXGI_FORMAT>(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Compress(const DirectX::Image* srcImages, size_t nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, DWORD compress, float threshold, DirectX::ScratchImage& cImages)
|
HRESULT Compress(const DirectX::Image* srcImages, size_t nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, DirectX::TEX_COMPRESS_FLAGS compress, float threshold, DirectX::ScratchImage& cImages)
|
||||||
{
|
{
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
if ((format == DXGI_FORMAT_BC7_UNORM || format == DXGI_FORMAT_BC7_UNORM_SRGB || format == DXGI_FORMAT_BC6H_UF16 || format == DXGI_FORMAT_BC6H_SF16) &&
|
if ((format == DXGI_FORMAT_BC7_UNORM || format == DXGI_FORMAT_BC7_UNORM_SRGB || format == DXGI_FORMAT_BC6H_UF16 || format == DXGI_FORMAT_BC6H_SF16) &&
|
||||||
@@ -60,12 +60,12 @@ namespace
|
|||||||
size_t _nimages;
|
size_t _nimages;
|
||||||
const DirectX::TexMetadata& _metadata;
|
const DirectX::TexMetadata& _metadata;
|
||||||
DXGI_FORMAT _format;
|
DXGI_FORMAT _format;
|
||||||
DWORD _compress;
|
DirectX::TEX_COMPRESS_FLAGS _compress;
|
||||||
DirectX::ScratchImage& _cImages;
|
DirectX::ScratchImage& _cImages;
|
||||||
public:
|
public:
|
||||||
HRESULT CompressResult = E_FAIL;
|
HRESULT CompressResult = E_FAIL;
|
||||||
|
|
||||||
GPUCompressTask(ConditionVariable& signal, const DirectX::Image* srcImages, size_t nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, DWORD compress, DirectX::ScratchImage& cImages)
|
GPUCompressTask(ConditionVariable& signal, const DirectX::Image* srcImages, size_t nimages, const DirectX::TexMetadata& metadata, DXGI_FORMAT format, DirectX::TEX_COMPRESS_FLAGS compress, DirectX::ScratchImage& cImages)
|
||||||
: GPUTask(Type::Custom)
|
: GPUTask(Type::Custom)
|
||||||
, _signal(&signal)
|
, _signal(&signal)
|
||||||
, _srcImages(srcImages)
|
, _srcImages(srcImages)
|
||||||
@@ -688,7 +688,7 @@ bool TextureTool::ImportTextureDirectXTex(ImageType type, const StringView& path
|
|||||||
if (!keepAsIs && options.FlipY)
|
if (!keepAsIs && options.FlipY)
|
||||||
{
|
{
|
||||||
auto& tmpImg = GET_TMP_IMG();
|
auto& tmpImg = GET_TMP_IMG();
|
||||||
DWORD flags = DirectX::TEX_FR_FLIP_VERTICAL;
|
DirectX::TEX_FR_FLAGS flags = DirectX::TEX_FR_FLIP_VERTICAL;
|
||||||
result = FlipRotate(currentImage->GetImages(), currentImage->GetImageCount(), currentImage->GetMetadata(), flags, tmpImg);
|
result = FlipRotate(currentImage->GetImages(), currentImage->GetImageCount(), currentImage->GetMetadata(), flags, tmpImg);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
@@ -698,7 +698,7 @@ bool TextureTool::ImportTextureDirectXTex(ImageType type, const StringView& path
|
|||||||
SET_CURRENT_IMG(tmpImg);
|
SET_CURRENT_IMG(tmpImg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if it invert green channel
|
// Check if invert green channel
|
||||||
if (!keepAsIs && options.InvertGreenChannel)
|
if (!keepAsIs && options.InvertGreenChannel)
|
||||||
{
|
{
|
||||||
auto& timage = GET_TMP_IMG();
|
auto& timage = GET_TMP_IMG();
|
||||||
|
|||||||
BIN
Source/Platforms/Windows/Binaries/ThirdParty/x64/DirectXTex.lib
(Stored with Git LFS)
vendored
BIN
Source/Platforms/Windows/Binaries/ThirdParty/x64/DirectXTex.lib
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
Source/Platforms/Windows/Binaries/ThirdParty/x64/DirectXTex.pdb
(Stored with Git LFS)
vendored
BIN
Source/Platforms/Windows/Binaries/ThirdParty/x64/DirectXTex.pdb
(Stored with Git LFS)
vendored
Binary file not shown.
631
Source/ThirdParty/DirectXTex/DirectXTex.h
vendored
631
Source/ThirdParty/DirectXTex/DirectXTex.h
vendored
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// DirectX Texture Library
|
// DirectX Texture Library
|
||||||
//
|
//
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
//
|
//
|
||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
@@ -11,28 +11,43 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
#include <algorithm>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if !defined(__d3d11_h__) && !defined(__d3d11_x_h__) && !defined(__d3d12_h__) && !defined(__d3d12_x_h__)
|
#ifdef _WIN32
|
||||||
#if defined(_XBOX_ONE) && defined(_TITLE)
|
#if !defined(__d3d11_h__) && !defined(__d3d11_x_h__) && !defined(__d3d12_h__) && !defined(__d3d12_x_h__) && !defined(__XBOX_D3D12_X__)
|
||||||
|
#ifdef _GAMING_XBOX_SCARLETT
|
||||||
|
#include <d3d12_xs.h>
|
||||||
|
#elif defined(_GAMING_XBOX)
|
||||||
|
#include <d3d12_x.h>
|
||||||
|
#elif defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include <d3d11_x.h>
|
#include <d3d11_x.h>
|
||||||
#else
|
#else
|
||||||
#include <d3d11_1.h>
|
#include <d3d11_1.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#else // !WIN32
|
||||||
|
#include <directx/dxgiformat.h>
|
||||||
|
#include <wsl/winadapter.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <DirectXMath.h>
|
#include <DirectXMath.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__)
|
||||||
|
#include <ocidl.h>
|
||||||
|
#else
|
||||||
#include <OCIdl.h>
|
#include <OCIdl.h>
|
||||||
|
#endif
|
||||||
#define DIRECTX_TEX_VERSION 162
|
|
||||||
|
|
||||||
struct IWICImagingFactory;
|
struct IWICImagingFactory;
|
||||||
struct IWICMetadataQueryReader;
|
struct IWICMetadataQueryReader;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DIRECTX_TEX_VERSION 203
|
||||||
|
|
||||||
|
|
||||||
namespace DirectX
|
namespace DirectX
|
||||||
@@ -40,46 +55,82 @@ namespace DirectX
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// DXGI Format Utilities
|
// DXGI Format Utilities
|
||||||
bool __cdecl IsValid(_In_ DXGI_FORMAT fmt);
|
constexpr bool __cdecl IsValid(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
bool __cdecl IsCompressed(_In_ DXGI_FORMAT fmt);
|
bool __cdecl IsCompressed(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
bool __cdecl IsPacked(_In_ DXGI_FORMAT fmt);
|
bool __cdecl IsPacked(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
bool __cdecl IsVideo(_In_ DXGI_FORMAT fmt);
|
bool __cdecl IsVideo(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
bool __cdecl IsPlanar(_In_ DXGI_FORMAT fmt);
|
bool __cdecl IsPlanar(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
bool __cdecl IsPalettized(_In_ DXGI_FORMAT fmt);
|
bool __cdecl IsPalettized(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
bool __cdecl IsDepthStencil(_In_ DXGI_FORMAT fmt);
|
bool __cdecl IsDepthStencil(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
bool __cdecl IsSRGB(_In_ DXGI_FORMAT fmt);
|
bool __cdecl IsSRGB(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
bool __cdecl IsTypeless(_In_ DXGI_FORMAT fmt, _In_ bool partialTypeless = true);
|
bool __cdecl IsBGR(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
|
bool __cdecl IsTypeless(_In_ DXGI_FORMAT fmt, _In_ bool partialTypeless = true) noexcept;
|
||||||
|
|
||||||
bool __cdecl HasAlpha(_In_ DXGI_FORMAT fmt);
|
bool __cdecl HasAlpha(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
|
|
||||||
size_t __cdecl BitsPerPixel(_In_ DXGI_FORMAT fmt);
|
size_t __cdecl BitsPerPixel(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
|
|
||||||
size_t __cdecl BitsPerColor(_In_ DXGI_FORMAT fmt);
|
size_t __cdecl BitsPerColor(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
|
|
||||||
enum CP_FLAGS
|
enum FORMAT_TYPE
|
||||||
{
|
{
|
||||||
CP_FLAGS_NONE = 0x0, // Normal operation
|
FORMAT_TYPE_TYPELESS,
|
||||||
CP_FLAGS_LEGACY_DWORD = 0x1, // Assume pitch is DWORD aligned instead of BYTE aligned
|
FORMAT_TYPE_FLOAT,
|
||||||
CP_FLAGS_PARAGRAPH = 0x2, // Assume pitch is 16-byte aligned instead of BYTE aligned
|
FORMAT_TYPE_UNORM,
|
||||||
CP_FLAGS_YMM = 0x4, // Assume pitch is 32-byte aligned instead of BYTE aligned
|
FORMAT_TYPE_SNORM,
|
||||||
CP_FLAGS_ZMM = 0x8, // Assume pitch is 64-byte aligned instead of BYTE aligned
|
FORMAT_TYPE_UINT,
|
||||||
CP_FLAGS_PAGE4K = 0x200, // Assume pitch is 4096-byte aligned instead of BYTE aligned
|
FORMAT_TYPE_SINT,
|
||||||
CP_FLAGS_BAD_DXTN_TAILS = 0x1000, // BC formats with malformed mipchain blocks smaller than 4x4
|
};
|
||||||
CP_FLAGS_24BPP = 0x10000, // Override with a legacy 24 bits-per-pixel format size
|
|
||||||
CP_FLAGS_16BPP = 0x20000, // Override with a legacy 16 bits-per-pixel format size
|
FORMAT_TYPE __cdecl FormatDataType(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
CP_FLAGS_8BPP = 0x40000, // Override with a legacy 8 bits-per-pixel format size
|
|
||||||
|
enum CP_FLAGS : unsigned long
|
||||||
|
{
|
||||||
|
CP_FLAGS_NONE = 0x0,
|
||||||
|
// Normal operation
|
||||||
|
|
||||||
|
CP_FLAGS_LEGACY_DWORD = 0x1,
|
||||||
|
// Assume pitch is DWORD aligned instead of BYTE aligned
|
||||||
|
|
||||||
|
CP_FLAGS_PARAGRAPH = 0x2,
|
||||||
|
// Assume pitch is 16-byte aligned instead of BYTE aligned
|
||||||
|
|
||||||
|
CP_FLAGS_YMM = 0x4,
|
||||||
|
// Assume pitch is 32-byte aligned instead of BYTE aligned
|
||||||
|
|
||||||
|
CP_FLAGS_ZMM = 0x8,
|
||||||
|
// Assume pitch is 64-byte aligned instead of BYTE aligned
|
||||||
|
|
||||||
|
CP_FLAGS_PAGE4K = 0x200,
|
||||||
|
// Assume pitch is 4096-byte aligned instead of BYTE aligned
|
||||||
|
|
||||||
|
CP_FLAGS_BAD_DXTN_TAILS = 0x1000,
|
||||||
|
// BC formats with malformed mipchain blocks smaller than 4x4
|
||||||
|
|
||||||
|
CP_FLAGS_24BPP = 0x10000,
|
||||||
|
// Override with a legacy 24 bits-per-pixel format size
|
||||||
|
|
||||||
|
CP_FLAGS_16BPP = 0x20000,
|
||||||
|
// Override with a legacy 16 bits-per-pixel format size
|
||||||
|
|
||||||
|
CP_FLAGS_8BPP = 0x40000,
|
||||||
|
// Override with a legacy 8 bits-per-pixel format size
|
||||||
|
|
||||||
|
CP_FLAGS_LIMIT_4GB = 0x10000000,
|
||||||
|
// Don't allow pixel allocations in excess of 4GB (always true for 32-bit)
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT __cdecl ComputePitch(
|
HRESULT __cdecl ComputePitch(
|
||||||
_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height,
|
_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height,
|
||||||
_Out_ size_t& rowPitch, _Out_ size_t& slicePitch, _In_ DWORD flags = CP_FLAGS_NONE);
|
_Out_ size_t& rowPitch, _Out_ size_t& slicePitch, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept;
|
||||||
|
|
||||||
size_t __cdecl ComputeScanlines(_In_ DXGI_FORMAT fmt, _In_ size_t height);
|
size_t __cdecl ComputeScanlines(_In_ DXGI_FORMAT fmt, _In_ size_t height) noexcept;
|
||||||
|
|
||||||
DXGI_FORMAT __cdecl MakeSRGB(_In_ DXGI_FORMAT fmt);
|
DXGI_FORMAT __cdecl MakeSRGB(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
DXGI_FORMAT __cdecl MakeTypeless(_In_ DXGI_FORMAT fmt);
|
DXGI_FORMAT __cdecl MakeLinear(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
DXGI_FORMAT __cdecl MakeTypelessUNORM(_In_ DXGI_FORMAT fmt);
|
DXGI_FORMAT __cdecl MakeTypeless(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
DXGI_FORMAT __cdecl MakeTypelessFLOAT(_In_ DXGI_FORMAT fmt);
|
DXGI_FORMAT __cdecl MakeTypelessUNORM(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
|
DXGI_FORMAT __cdecl MakeTypelessFLOAT(_In_ DXGI_FORMAT fmt) noexcept;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Texture metadata
|
// Texture metadata
|
||||||
@@ -91,13 +142,13 @@ namespace DirectX
|
|||||||
TEX_DIMENSION_TEXTURE3D = 4,
|
TEX_DIMENSION_TEXTURE3D = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TEX_MISC_FLAG
|
enum TEX_MISC_FLAG : unsigned long
|
||||||
// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
|
// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
|
||||||
{
|
{
|
||||||
TEX_MISC_TEXTURECUBE = 0x4L,
|
TEX_MISC_TEXTURECUBE = 0x4L,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TEX_MISC_FLAG2
|
enum TEX_MISC_FLAG2 : unsigned long
|
||||||
{
|
{
|
||||||
TEX_MISC2_ALPHA_MODE_MASK = 0x7L,
|
TEX_MISC2_ALPHA_MODE_MASK = 0x7L,
|
||||||
};
|
};
|
||||||
@@ -124,22 +175,40 @@ namespace DirectX
|
|||||||
DXGI_FORMAT format;
|
DXGI_FORMAT format;
|
||||||
TEX_DIMENSION dimension;
|
TEX_DIMENSION dimension;
|
||||||
|
|
||||||
size_t __cdecl ComputeIndex(_In_ size_t mip, _In_ size_t item, _In_ size_t slice) const;
|
size_t __cdecl ComputeIndex(size_t mip, size_t item, size_t slice) const noexcept;
|
||||||
// Returns size_t(-1) to indicate an out-of-range error
|
// Returns size_t(-1) to indicate an out-of-range error
|
||||||
|
|
||||||
bool __cdecl IsCubemap() const { return (miscFlags & TEX_MISC_TEXTURECUBE) != 0; }
|
bool __cdecl IsCubemap() const noexcept { return (miscFlags & TEX_MISC_TEXTURECUBE) != 0; }
|
||||||
// Helper for miscFlags
|
// Helper for miscFlags
|
||||||
|
|
||||||
bool __cdecl IsPMAlpha() const { return ((miscFlags2 & TEX_MISC2_ALPHA_MODE_MASK) == TEX_ALPHA_MODE_PREMULTIPLIED) != 0; }
|
bool __cdecl IsPMAlpha() const noexcept { return ((miscFlags2 & TEX_MISC2_ALPHA_MODE_MASK) == TEX_ALPHA_MODE_PREMULTIPLIED) != 0; }
|
||||||
void __cdecl SetAlphaMode(TEX_ALPHA_MODE mode) { miscFlags2 = (miscFlags2 & ~static_cast<uint32_t>(TEX_MISC2_ALPHA_MODE_MASK)) | static_cast<uint32_t>(mode); }
|
void __cdecl SetAlphaMode(TEX_ALPHA_MODE mode) noexcept { miscFlags2 = (miscFlags2 & ~static_cast<uint32_t>(TEX_MISC2_ALPHA_MODE_MASK)) | static_cast<uint32_t>(mode); }
|
||||||
TEX_ALPHA_MODE __cdecl GetAlphaMode() const { return static_cast<TEX_ALPHA_MODE>(miscFlags2 & TEX_MISC2_ALPHA_MODE_MASK); }
|
TEX_ALPHA_MODE __cdecl GetAlphaMode() const noexcept { return static_cast<TEX_ALPHA_MODE>(miscFlags2 & TEX_MISC2_ALPHA_MODE_MASK); }
|
||||||
// Helpers for miscFlags2
|
// Helpers for miscFlags2
|
||||||
|
|
||||||
bool __cdecl IsVolumemap() const { return (dimension == TEX_DIMENSION_TEXTURE3D); }
|
bool __cdecl IsVolumemap() const noexcept { return (dimension == TEX_DIMENSION_TEXTURE3D); }
|
||||||
// Helper for dimension
|
// Helper for dimension
|
||||||
|
|
||||||
|
uint32_t __cdecl CalculateSubresource(size_t mip, size_t item) const noexcept;
|
||||||
|
uint32_t __cdecl CalculateSubresource(size_t mip, size_t item, size_t plane) const noexcept;
|
||||||
|
// Returns size_t(-1) to indicate an out-of-range error
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DDS_FLAGS
|
struct DDSMetaData
|
||||||
|
{
|
||||||
|
uint32_t size; // DDPIXELFORMAT.dwSize
|
||||||
|
uint32_t flags; // DDPIXELFORMAT.dwFlags
|
||||||
|
uint32_t fourCC; // DDPIXELFORMAT.dwFourCC
|
||||||
|
uint32_t RGBBitCount; // DDPIXELFORMAT.dwRGBBitCount/dwYUVBitCount/dwAlphaBitDepth/dwLuminanceBitCount/dwBumpBitCount
|
||||||
|
uint32_t RBitMask; // DDPIXELFORMAT.dwRBitMask/dwYBitMask/dwLuminanceBitMask/dwBumpDuBitMask
|
||||||
|
uint32_t GBitMask; // DDPIXELFORMAT.dwGBitMask/dwUBitMask/dwBumpDvBitMask
|
||||||
|
uint32_t BBitMask; // DDPIXELFORMAT.dwBBitMask/dwVBitMask/dwBumpLuminanceBitMask
|
||||||
|
uint32_t ABitMask; // DDPIXELFORMAT.dwRGBAlphaBitMask/dwYUVAlphaBitMask/dwLuminanceAlphaBitMask
|
||||||
|
|
||||||
|
bool __cdecl IsDX10() const noexcept { return (fourCC == 0x30315844); }
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DDS_FLAGS : unsigned long
|
||||||
{
|
{
|
||||||
DDS_FLAGS_NONE = 0x0,
|
DDS_FLAGS_NONE = 0x0,
|
||||||
|
|
||||||
@@ -164,14 +233,49 @@ namespace DirectX
|
|||||||
DDS_FLAGS_BAD_DXTN_TAILS = 0x40,
|
DDS_FLAGS_BAD_DXTN_TAILS = 0x40,
|
||||||
// Some older DXTn DDS files incorrectly handle mipchain tails for blocks smaller than 4x4
|
// Some older DXTn DDS files incorrectly handle mipchain tails for blocks smaller than 4x4
|
||||||
|
|
||||||
|
DDS_FLAGS_PERMISSIVE = 0x80,
|
||||||
|
// Allow some file variants due to common bugs in the header written by various leagcy DDS writers
|
||||||
|
|
||||||
DDS_FLAGS_FORCE_DX10_EXT = 0x10000,
|
DDS_FLAGS_FORCE_DX10_EXT = 0x10000,
|
||||||
// Always use the 'DX10' header extension for DDS writer (i.e. don't try to write DX9 compatible DDS files)
|
// Always use the 'DX10' header extension for DDS writer (i.e. don't try to write DX9 compatible DDS files)
|
||||||
|
|
||||||
DDS_FLAGS_FORCE_DX10_EXT_MISC2 = 0x20000,
|
DDS_FLAGS_FORCE_DX10_EXT_MISC2 = 0x20000,
|
||||||
// DDS_FLAGS_FORCE_DX10_EXT including miscFlags2 information (result may not be compatible with D3DX10 or D3DX11)
|
// DDS_FLAGS_FORCE_DX10_EXT including miscFlags2 information (result may not be compatible with D3DX10 or D3DX11)
|
||||||
|
|
||||||
|
DDS_FLAGS_FORCE_DX9_LEGACY = 0x40000,
|
||||||
|
// Force use of legacy header for DDS writer (will fail if unable to write as such)
|
||||||
|
|
||||||
|
DDS_FLAGS_FORCE_DXT5_RXGB = 0x80000,
|
||||||
|
// Force use of 'RXGB' instead of 'DXT5' for DDS write of BC3_UNORM data
|
||||||
|
|
||||||
|
DDS_FLAGS_ALLOW_LARGE_FILES = 0x1000000,
|
||||||
|
// Enables the loader to read large dimension .dds files (i.e. greater than known hardware requirements)
|
||||||
};
|
};
|
||||||
|
|
||||||
enum WIC_FLAGS
|
enum TGA_FLAGS : unsigned long
|
||||||
|
{
|
||||||
|
TGA_FLAGS_NONE = 0x0,
|
||||||
|
|
||||||
|
TGA_FLAGS_BGR = 0x1,
|
||||||
|
// 24bpp files are returned as BGRX; 32bpp files are returned as BGRA
|
||||||
|
|
||||||
|
TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA = 0x2,
|
||||||
|
// If the loaded image has an all zero alpha channel, normally we assume it should be opaque. This flag leaves it alone.
|
||||||
|
|
||||||
|
TGA_FLAGS_IGNORE_SRGB = 0x10,
|
||||||
|
// Ignores sRGB TGA 2.0 metadata if present in the file
|
||||||
|
|
||||||
|
TGA_FLAGS_FORCE_SRGB = 0x20,
|
||||||
|
// Writes sRGB metadata into the file reguardless of format (TGA 2.0 only)
|
||||||
|
|
||||||
|
TGA_FLAGS_FORCE_LINEAR = 0x40,
|
||||||
|
// Writes linear gamma metadata into the file reguardless of format (TGA 2.0 only)
|
||||||
|
|
||||||
|
TGA_FLAGS_DEFAULT_SRGB = 0x80,
|
||||||
|
// If no colorspace is specified in TGA 2.0 metadata, assume sRGB
|
||||||
|
};
|
||||||
|
|
||||||
|
enum WIC_FLAGS : unsigned long
|
||||||
{
|
{
|
||||||
WIC_FLAGS_NONE = 0x0,
|
WIC_FLAGS_NONE = 0x0,
|
||||||
|
|
||||||
@@ -199,6 +303,9 @@ namespace DirectX
|
|||||||
WIC_FLAGS_FORCE_LINEAR = 0x80,
|
WIC_FLAGS_FORCE_LINEAR = 0x80,
|
||||||
// Writes linear gamma metadata into the file reguardless of format
|
// Writes linear gamma metadata into the file reguardless of format
|
||||||
|
|
||||||
|
WIC_FLAGS_DEFAULT_SRGB = 0x100,
|
||||||
|
// If no colorspace is specified, assume sRGB
|
||||||
|
|
||||||
WIC_FLAGS_DITHER = 0x10000,
|
WIC_FLAGS_DITHER = 0x10000,
|
||||||
// Use ordered 4x4 dithering for any required conversions
|
// Use ordered 4x4 dithering for any required conversions
|
||||||
|
|
||||||
@@ -214,38 +321,61 @@ namespace DirectX
|
|||||||
|
|
||||||
HRESULT __cdecl GetMetadataFromDDSMemory(
|
HRESULT __cdecl GetMetadataFromDDSMemory(
|
||||||
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
_In_ DWORD flags,
|
_In_ DDS_FLAGS flags,
|
||||||
_Out_ TexMetadata& metadata);
|
_Out_ TexMetadata& metadata) noexcept;
|
||||||
HRESULT __cdecl GetMetadataFromDDSFile(
|
HRESULT __cdecl GetMetadataFromDDSFile(
|
||||||
_In_z_ const wchar_t* szFile,
|
_In_z_ const wchar_t* szFile,
|
||||||
_In_ DWORD flags,
|
_In_ DDS_FLAGS flags,
|
||||||
_Out_ TexMetadata& metadata);
|
_Out_ TexMetadata& metadata) noexcept;
|
||||||
|
|
||||||
|
HRESULT __cdecl GetMetadataFromDDSMemoryEx(
|
||||||
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
|
_In_ DDS_FLAGS flags,
|
||||||
|
_Out_ TexMetadata& metadata,
|
||||||
|
_Out_opt_ DDSMetaData* ddPixelFormat) noexcept;
|
||||||
|
HRESULT __cdecl GetMetadataFromDDSFileEx(
|
||||||
|
_In_z_ const wchar_t* szFile,
|
||||||
|
_In_ DDS_FLAGS flags,
|
||||||
|
_Out_ TexMetadata& metadata,
|
||||||
|
_Out_opt_ DDSMetaData* ddPixelFormat) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl GetMetadataFromHDRMemory(
|
HRESULT __cdecl GetMetadataFromHDRMemory(
|
||||||
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
_Out_ TexMetadata& metadata);
|
_Out_ TexMetadata& metadata) noexcept;
|
||||||
HRESULT __cdecl GetMetadataFromHDRFile(
|
HRESULT __cdecl GetMetadataFromHDRFile(
|
||||||
_In_z_ const wchar_t* szFile,
|
_In_z_ const wchar_t* szFile,
|
||||||
_Out_ TexMetadata& metadata);
|
_Out_ TexMetadata& metadata) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl GetMetadataFromTGAMemory(
|
HRESULT __cdecl GetMetadataFromTGAMemory(
|
||||||
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
_Out_ TexMetadata& metadata);
|
_In_ TGA_FLAGS flags,
|
||||||
|
_Out_ TexMetadata& metadata) noexcept;
|
||||||
HRESULT __cdecl GetMetadataFromTGAFile(
|
HRESULT __cdecl GetMetadataFromTGAFile(
|
||||||
_In_z_ const wchar_t* szFile,
|
_In_z_ const wchar_t* szFile,
|
||||||
_Out_ TexMetadata& metadata);
|
_In_ TGA_FLAGS flags,
|
||||||
|
_Out_ TexMetadata& metadata) noexcept;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
HRESULT __cdecl GetMetadataFromWICMemory(
|
HRESULT __cdecl GetMetadataFromWICMemory(
|
||||||
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
_In_ DWORD flags,
|
_In_ WIC_FLAGS flags,
|
||||||
_Out_ TexMetadata& metadata,
|
_Out_ TexMetadata& metadata,
|
||||||
_In_opt_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
|
_In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
|
||||||
|
|
||||||
HRESULT __cdecl GetMetadataFromWICFile(
|
HRESULT __cdecl GetMetadataFromWICFile(
|
||||||
_In_z_ const wchar_t* szFile,
|
_In_z_ const wchar_t* szFile,
|
||||||
_In_ DWORD flags,
|
_In_ WIC_FLAGS flags,
|
||||||
_Out_ TexMetadata& metadata,
|
_Out_ TexMetadata& metadata,
|
||||||
_In_opt_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
|
_In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Compatability helpers
|
||||||
|
HRESULT __cdecl GetMetadataFromTGAMemory(
|
||||||
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
|
_Out_ TexMetadata& metadata) noexcept;
|
||||||
|
HRESULT __cdecl GetMetadataFromTGAFile(
|
||||||
|
_In_z_ const wchar_t* szFile,
|
||||||
|
_Out_ TexMetadata& metadata) noexcept;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Bitmap image container
|
// Bitmap image container
|
||||||
@@ -273,32 +403,32 @@ namespace DirectX
|
|||||||
ScratchImage(const ScratchImage&) = delete;
|
ScratchImage(const ScratchImage&) = delete;
|
||||||
ScratchImage& operator=(const ScratchImage&) = delete;
|
ScratchImage& operator=(const ScratchImage&) = delete;
|
||||||
|
|
||||||
HRESULT __cdecl Initialize(_In_ const TexMetadata& mdata, _In_ DWORD flags = CP_FLAGS_NONE);
|
HRESULT __cdecl Initialize(_In_ const TexMetadata& mdata, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl Initialize1D(_In_ DXGI_FORMAT fmt, _In_ size_t length, _In_ size_t arraySize, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE);
|
HRESULT __cdecl Initialize1D(_In_ DXGI_FORMAT fmt, _In_ size_t length, _In_ size_t arraySize, _In_ size_t mipLevels, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept;
|
||||||
HRESULT __cdecl Initialize2D(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t arraySize, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE);
|
HRESULT __cdecl Initialize2D(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t arraySize, _In_ size_t mipLevels, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept;
|
||||||
HRESULT __cdecl Initialize3D(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t depth, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE);
|
HRESULT __cdecl Initialize3D(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t depth, _In_ size_t mipLevels, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept;
|
||||||
HRESULT __cdecl InitializeCube(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t nCubes, _In_ size_t mipLevels, _In_ DWORD flags = CP_FLAGS_NONE);
|
HRESULT __cdecl InitializeCube(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t nCubes, _In_ size_t mipLevels, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl InitializeFromImage(_In_ const Image& srcImage, _In_ bool allow1D = false, _In_ DWORD flags = CP_FLAGS_NONE);
|
HRESULT __cdecl InitializeFromImage(_In_ const Image& srcImage, _In_ bool allow1D = false, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept;
|
||||||
HRESULT __cdecl InitializeArrayFromImages(_In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ bool allow1D = false, _In_ DWORD flags = CP_FLAGS_NONE);
|
HRESULT __cdecl InitializeArrayFromImages(_In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ bool allow1D = false, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept;
|
||||||
HRESULT __cdecl InitializeCubeFromImages(_In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ DWORD flags = CP_FLAGS_NONE);
|
HRESULT __cdecl InitializeCubeFromImages(_In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept;
|
||||||
HRESULT __cdecl Initialize3DFromImages(_In_reads_(depth) const Image* images, _In_ size_t depth, _In_ DWORD flags = CP_FLAGS_NONE);
|
HRESULT __cdecl Initialize3DFromImages(_In_reads_(depth) const Image* images, _In_ size_t depth, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept;
|
||||||
|
|
||||||
void __cdecl Release();
|
void __cdecl Release() noexcept;
|
||||||
|
|
||||||
bool __cdecl OverrideFormat(_In_ DXGI_FORMAT f);
|
bool __cdecl OverrideFormat(_In_ DXGI_FORMAT f) noexcept;
|
||||||
|
|
||||||
const TexMetadata& __cdecl GetMetadata() const { return m_metadata; }
|
const TexMetadata& __cdecl GetMetadata() const noexcept { return m_metadata; }
|
||||||
const Image* __cdecl GetImage(_In_ size_t mip, _In_ size_t item, _In_ size_t slice) const;
|
const Image* __cdecl GetImage(_In_ size_t mip, _In_ size_t item, _In_ size_t slice) const noexcept;
|
||||||
|
|
||||||
const Image* __cdecl GetImages() const { return m_image; }
|
const Image* __cdecl GetImages() const noexcept { return m_image; }
|
||||||
size_t __cdecl GetImageCount() const { return m_nimages; }
|
size_t __cdecl GetImageCount() const noexcept { return m_nimages; }
|
||||||
|
|
||||||
uint8_t* __cdecl GetPixels() const { return m_memory; }
|
uint8_t* __cdecl GetPixels() const noexcept { return m_memory; }
|
||||||
size_t __cdecl GetPixelsSize() const { return m_size; }
|
size_t __cdecl GetPixelsSize() const noexcept { return m_size; }
|
||||||
|
|
||||||
bool __cdecl IsAlphaAllOpaque() const;
|
bool __cdecl IsAlphaAllOpaque() const noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t m_nimages;
|
size_t m_nimages;
|
||||||
@@ -322,14 +452,18 @@ namespace DirectX
|
|||||||
Blob(const Blob&) = delete;
|
Blob(const Blob&) = delete;
|
||||||
Blob& operator=(const Blob&) = delete;
|
Blob& operator=(const Blob&) = delete;
|
||||||
|
|
||||||
HRESULT __cdecl Initialize(_In_ size_t size);
|
HRESULT __cdecl Initialize(_In_ size_t size) noexcept;
|
||||||
|
|
||||||
void __cdecl Release();
|
void __cdecl Release() noexcept;
|
||||||
|
|
||||||
void *__cdecl GetBufferPointer() const { return m_buffer; }
|
void *__cdecl GetBufferPointer() const noexcept { return m_buffer; }
|
||||||
size_t __cdecl GetBufferSize() const { return m_size; }
|
size_t __cdecl GetBufferSize() const noexcept { return m_size; }
|
||||||
|
|
||||||
HRESULT __cdecl Trim(size_t size);
|
HRESULT __cdecl Resize(size_t size) noexcept;
|
||||||
|
// Reallocate for a new size
|
||||||
|
|
||||||
|
HRESULT __cdecl Trim(size_t size) noexcept;
|
||||||
|
// Shorten size without reallocation
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void* m_buffer;
|
void* m_buffer;
|
||||||
@@ -342,84 +476,116 @@ namespace DirectX
|
|||||||
// DDS operations
|
// DDS operations
|
||||||
HRESULT __cdecl LoadFromDDSMemory(
|
HRESULT __cdecl LoadFromDDSMemory(
|
||||||
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
_In_ DWORD flags,
|
_In_ DDS_FLAGS flags,
|
||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image);
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
|
||||||
HRESULT __cdecl LoadFromDDSFile(
|
HRESULT __cdecl LoadFromDDSFile(
|
||||||
_In_z_ const wchar_t* szFile,
|
_In_z_ const wchar_t* szFile,
|
||||||
_In_ DWORD flags,
|
_In_ DDS_FLAGS flags,
|
||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image);
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
|
||||||
|
|
||||||
|
HRESULT __cdecl LoadFromDDSMemoryEx(
|
||||||
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
|
_In_ DDS_FLAGS flags,
|
||||||
|
_Out_opt_ TexMetadata* metadata,
|
||||||
|
_Out_opt_ DDSMetaData* ddPixelFormat,
|
||||||
|
_Out_ ScratchImage& image) noexcept;
|
||||||
|
HRESULT __cdecl LoadFromDDSFileEx(
|
||||||
|
_In_z_ const wchar_t* szFile,
|
||||||
|
_In_ DDS_FLAGS flags,
|
||||||
|
_Out_opt_ TexMetadata* metadata,
|
||||||
|
_Out_opt_ DDSMetaData* ddPixelFormat,
|
||||||
|
_Out_ ScratchImage& image) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl SaveToDDSMemory(
|
HRESULT __cdecl SaveToDDSMemory(
|
||||||
_In_ const Image& image,
|
_In_ const Image& image,
|
||||||
_In_ DWORD flags,
|
_In_ DDS_FLAGS flags,
|
||||||
_Out_ Blob& blob);
|
_Out_ Blob& blob) noexcept;
|
||||||
HRESULT __cdecl SaveToDDSMemory(
|
HRESULT __cdecl SaveToDDSMemory(
|
||||||
_In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ DWORD flags,
|
_In_ DDS_FLAGS flags,
|
||||||
_Out_ Blob& blob);
|
_Out_ Blob& blob) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl SaveToDDSFile(_In_ const Image& image, _In_ DWORD flags, _In_z_ const wchar_t* szFile);
|
HRESULT __cdecl SaveToDDSFile(_In_ const Image& image, _In_ DDS_FLAGS flags, _In_z_ const wchar_t* szFile) noexcept;
|
||||||
HRESULT __cdecl SaveToDDSFile(
|
HRESULT __cdecl SaveToDDSFile(
|
||||||
_In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ DWORD flags, _In_z_ const wchar_t* szFile);
|
_In_ DDS_FLAGS flags, _In_z_ const wchar_t* szFile) noexcept;
|
||||||
|
|
||||||
// HDR operations
|
// HDR operations
|
||||||
HRESULT __cdecl LoadFromHDRMemory(
|
HRESULT __cdecl LoadFromHDRMemory(
|
||||||
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image);
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
|
||||||
HRESULT __cdecl LoadFromHDRFile(
|
HRESULT __cdecl LoadFromHDRFile(
|
||||||
_In_z_ const wchar_t* szFile,
|
_In_z_ const wchar_t* szFile,
|
||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image);
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl SaveToHDRMemory(_In_ const Image& image, _Out_ Blob& blob);
|
HRESULT __cdecl SaveToHDRMemory(_In_ const Image& image, _Out_ Blob& blob) noexcept;
|
||||||
HRESULT __cdecl SaveToHDRFile(_In_ const Image& image, _In_z_ const wchar_t* szFile);
|
HRESULT __cdecl SaveToHDRFile(_In_ const Image& image, _In_z_ const wchar_t* szFile) noexcept;
|
||||||
|
|
||||||
// TGA operations
|
// TGA operations
|
||||||
HRESULT __cdecl LoadFromTGAMemory(
|
HRESULT __cdecl LoadFromTGAMemory(
|
||||||
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image);
|
_In_ TGA_FLAGS flags,
|
||||||
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
|
||||||
HRESULT __cdecl LoadFromTGAFile(
|
HRESULT __cdecl LoadFromTGAFile(
|
||||||
_In_z_ const wchar_t* szFile,
|
_In_z_ const wchar_t* szFile,
|
||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image);
|
_In_ TGA_FLAGS flags,
|
||||||
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl SaveToTGAMemory(_In_ const Image& image, _Out_ Blob& blob, _In_opt_ const TexMetadata* metadata = nullptr);
|
HRESULT __cdecl SaveToTGAMemory(_In_ const Image& image,
|
||||||
HRESULT __cdecl SaveToTGAFile(_In_ const Image& image, _In_z_ const wchar_t* szFile, _In_opt_ const TexMetadata* metadata = nullptr);
|
_In_ TGA_FLAGS flags,
|
||||||
|
_Out_ Blob& blob, _In_opt_ const TexMetadata* metadata = nullptr) noexcept;
|
||||||
|
HRESULT __cdecl SaveToTGAFile(_In_ const Image& image,
|
||||||
|
_In_ TGA_FLAGS flags,
|
||||||
|
_In_z_ const wchar_t* szFile, _In_opt_ const TexMetadata* metadata = nullptr) noexcept;
|
||||||
|
|
||||||
// WIC operations
|
// WIC operations
|
||||||
|
#ifdef _WIN32
|
||||||
HRESULT __cdecl LoadFromWICMemory(
|
HRESULT __cdecl LoadFromWICMemory(
|
||||||
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
_In_ DWORD flags,
|
_In_ WIC_FLAGS flags,
|
||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image,
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image,
|
||||||
_In_opt_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
|
_In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
|
||||||
HRESULT __cdecl LoadFromWICFile(
|
HRESULT __cdecl LoadFromWICFile(
|
||||||
_In_z_ const wchar_t* szFile, _In_ DWORD flags,
|
_In_z_ const wchar_t* szFile, _In_ WIC_FLAGS flags,
|
||||||
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image,
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image,
|
||||||
_In_opt_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
|
_In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
|
||||||
|
|
||||||
HRESULT __cdecl SaveToWICMemory(
|
HRESULT __cdecl SaveToWICMemory(
|
||||||
_In_ const Image& image, _In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
_In_ const Image& image, _In_ WIC_FLAGS flags, _In_ REFGUID guidContainerFormat,
|
||||||
_Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr,
|
_Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr,
|
||||||
_In_opt_ std::function<void __cdecl(IPropertyBag2*)> setCustomProps = nullptr);
|
_In_ std::function<void __cdecl(IPropertyBag2*)> setCustomProps = nullptr);
|
||||||
HRESULT __cdecl SaveToWICMemory(
|
HRESULT __cdecl SaveToWICMemory(
|
||||||
_In_count_(nimages) const Image* images, _In_ size_t nimages,
|
_In_count_(nimages) const Image* images, _In_ size_t nimages,
|
||||||
_In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
_In_ WIC_FLAGS flags, _In_ REFGUID guidContainerFormat,
|
||||||
_Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr,
|
_Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr,
|
||||||
_In_opt_ std::function<void __cdecl(IPropertyBag2*)> setCustomProps = nullptr);
|
_In_ std::function<void __cdecl(IPropertyBag2*)> setCustomProps = nullptr);
|
||||||
|
|
||||||
HRESULT __cdecl SaveToWICFile(
|
HRESULT __cdecl SaveToWICFile(
|
||||||
_In_ const Image& image, _In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
_In_ const Image& image, _In_ WIC_FLAGS flags, _In_ REFGUID guidContainerFormat,
|
||||||
_In_z_ const wchar_t* szFile, _In_opt_ const GUID* targetFormat = nullptr,
|
_In_z_ const wchar_t* szFile, _In_opt_ const GUID* targetFormat = nullptr,
|
||||||
_In_opt_ std::function<void __cdecl(IPropertyBag2*)> setCustomProps = nullptr);
|
_In_ std::function<void __cdecl(IPropertyBag2*)> setCustomProps = nullptr);
|
||||||
HRESULT __cdecl SaveToWICFile(
|
HRESULT __cdecl SaveToWICFile(
|
||||||
_In_count_(nimages) const Image* images, _In_ size_t nimages,
|
_In_count_(nimages) const Image* images, _In_ size_t nimages,
|
||||||
_In_ DWORD flags, _In_ REFGUID guidContainerFormat,
|
_In_ WIC_FLAGS flags, _In_ REFGUID guidContainerFormat,
|
||||||
_In_z_ const wchar_t* szFile, _In_opt_ const GUID* targetFormat = nullptr,
|
_In_z_ const wchar_t* szFile, _In_opt_ const GUID* targetFormat = nullptr,
|
||||||
_In_opt_ std::function<void __cdecl(IPropertyBag2*)> setCustomProps = nullptr);
|
_In_ std::function<void __cdecl(IPropertyBag2*)> setCustomProps = nullptr);
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
|
// Compatability helpers
|
||||||
|
HRESULT __cdecl LoadFromTGAMemory(
|
||||||
|
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
|
||||||
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
|
||||||
|
HRESULT __cdecl LoadFromTGAFile(
|
||||||
|
_In_z_ const wchar_t* szFile,
|
||||||
|
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
|
||||||
|
|
||||||
|
HRESULT __cdecl SaveToTGAMemory(_In_ const Image& image, _Out_ Blob& blob, _In_opt_ const TexMetadata* metadata = nullptr) noexcept;
|
||||||
|
HRESULT __cdecl SaveToTGAFile(_In_ const Image& image, _In_z_ const wchar_t* szFile, _In_opt_ const TexMetadata* metadata = nullptr) noexcept;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Texture conversion, resizing, mipmap generation, and block compression
|
// Texture conversion, resizing, mipmap generation, and block compression
|
||||||
|
|
||||||
enum TEX_FR_FLAGS
|
enum TEX_FR_FLAGS : unsigned long
|
||||||
{
|
{
|
||||||
TEX_FR_ROTATE0 = 0x0,
|
TEX_FR_ROTATE0 = 0x0,
|
||||||
TEX_FR_ROTATE90 = 0x1,
|
TEX_FR_ROTATE90 = 0x1,
|
||||||
@@ -429,13 +595,15 @@ namespace DirectX
|
|||||||
TEX_FR_FLIP_VERTICAL = 0x10,
|
TEX_FR_FLIP_VERTICAL = 0x10,
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT __cdecl FlipRotate(_In_ const Image& srcImage, _In_ DWORD flags, _Out_ ScratchImage& image);
|
#ifdef _WIN32
|
||||||
|
HRESULT __cdecl FlipRotate(_In_ const Image& srcImage, _In_ TEX_FR_FLAGS flags, _Out_ ScratchImage& image) noexcept;
|
||||||
HRESULT __cdecl FlipRotate(
|
HRESULT __cdecl FlipRotate(
|
||||||
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ DWORD flags, _Out_ ScratchImage& result);
|
_In_ TEX_FR_FLAGS flags, _Out_ ScratchImage& result) noexcept;
|
||||||
// Flip and/or rotate image
|
// Flip and/or rotate image
|
||||||
|
#endif
|
||||||
|
|
||||||
enum TEX_FILTER_FLAGS
|
enum TEX_FILTER_FLAGS : unsigned long
|
||||||
{
|
{
|
||||||
TEX_FILTER_DEFAULT = 0,
|
TEX_FILTER_DEFAULT = 0,
|
||||||
|
|
||||||
@@ -458,8 +626,9 @@ namespace DirectX
|
|||||||
TEX_FILTER_RGB_COPY_RED = 0x1000,
|
TEX_FILTER_RGB_COPY_RED = 0x1000,
|
||||||
TEX_FILTER_RGB_COPY_GREEN = 0x2000,
|
TEX_FILTER_RGB_COPY_GREEN = 0x2000,
|
||||||
TEX_FILTER_RGB_COPY_BLUE = 0x4000,
|
TEX_FILTER_RGB_COPY_BLUE = 0x4000,
|
||||||
// When converting RGB to R, defaults to using grayscale. These flags indicate copying a specific channel instead
|
TEX_FILTER_RGB_COPY_ALPHA = 0x8000,
|
||||||
// When converting RGB to RG, defaults to copying RED | GREEN. These flags control which channels are selected instead.
|
// When converting RGB(A) to R, defaults to using grayscale. These flags indicate copying a specific channel instead
|
||||||
|
// When converting RGB(A) to RG, defaults to copying RED | GREEN. These flags control which channels are selected instead.
|
||||||
|
|
||||||
TEX_FILTER_DITHER = 0x10000,
|
TEX_FILTER_DITHER = 0x10000,
|
||||||
// Use ordered 4x4 dithering for any required conversions
|
// Use ordered 4x4 dithering for any required conversions
|
||||||
@@ -488,57 +657,76 @@ namespace DirectX
|
|||||||
// Forces use of the WIC path even when logic would have picked a non-WIC path when both are an option
|
// Forces use of the WIC path even when logic would have picked a non-WIC path when both are an option
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr unsigned long TEX_FILTER_DITHER_MASK = 0xF0000;
|
||||||
|
constexpr unsigned long TEX_FILTER_MODE_MASK = 0xF00000;
|
||||||
|
constexpr unsigned long TEX_FILTER_SRGB_MASK = 0xF000000;
|
||||||
|
|
||||||
HRESULT __cdecl Resize(
|
HRESULT __cdecl Resize(
|
||||||
_In_ const Image& srcImage, _In_ size_t width, _In_ size_t height,
|
_In_ const Image& srcImage, _In_ size_t width, _In_ size_t height,
|
||||||
_In_ DWORD filter,
|
_In_ TEX_FILTER_FLAGS filter,
|
||||||
_Out_ ScratchImage& image);
|
_Out_ ScratchImage& image) noexcept;
|
||||||
HRESULT __cdecl Resize(
|
HRESULT __cdecl Resize(
|
||||||
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ size_t width, _In_ size_t height, _In_ DWORD filter, _Out_ ScratchImage& result);
|
_In_ size_t width, _In_ size_t height, _In_ TEX_FILTER_FLAGS filter, _Out_ ScratchImage& result) noexcept;
|
||||||
// Resize the image to width x height. Defaults to Fant filtering.
|
// Resize the image to width x height. Defaults to Fant filtering.
|
||||||
// Note for a complex resize, the result will always have mipLevels == 1
|
// Note for a complex resize, the result will always have mipLevels == 1
|
||||||
|
|
||||||
const float TEX_THRESHOLD_DEFAULT = 0.5f;
|
constexpr float TEX_THRESHOLD_DEFAULT = 0.5f;
|
||||||
// Default value for alpha threshold used when converting to 1-bit alpha
|
// Default value for alpha threshold used when converting to 1-bit alpha
|
||||||
|
|
||||||
|
struct ConvertOptions
|
||||||
|
{
|
||||||
|
TEX_FILTER_FLAGS filter;
|
||||||
|
float threshold;
|
||||||
|
};
|
||||||
|
|
||||||
HRESULT __cdecl Convert(
|
HRESULT __cdecl Convert(
|
||||||
_In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD filter, _In_ float threshold,
|
_In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ TEX_FILTER_FLAGS filter, _In_ float threshold,
|
||||||
_Out_ ScratchImage& image);
|
_Out_ ScratchImage& image) noexcept;
|
||||||
HRESULT __cdecl Convert(
|
HRESULT __cdecl Convert(
|
||||||
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_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);
|
_In_ DXGI_FORMAT format, _In_ TEX_FILTER_FLAGS filter, _In_ float threshold, _Out_ ScratchImage& result) noexcept;
|
||||||
|
|
||||||
|
HRESULT __cdecl ConvertEx(
|
||||||
|
_In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ const ConvertOptions& options,
|
||||||
|
_Out_ ScratchImage& image,
|
||||||
|
_In_ std::function<bool __cdecl(size_t, size_t)> statusCallBack = nullptr);
|
||||||
|
HRESULT __cdecl ConvertEx(
|
||||||
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
|
_In_ DXGI_FORMAT format, _In_ const ConvertOptions& options, _Out_ ScratchImage& result,
|
||||||
|
_In_ std::function<bool __cdecl(size_t, size_t)> statusCallBack = nullptr);
|
||||||
// Convert the image to a new format
|
// Convert the image to a new format
|
||||||
|
|
||||||
HRESULT __cdecl ConvertToSinglePlane(_In_ const Image& srcImage, _Out_ ScratchImage& image);
|
HRESULT __cdecl ConvertToSinglePlane(_In_ const Image& srcImage, _Out_ ScratchImage& image) noexcept;
|
||||||
HRESULT __cdecl ConvertToSinglePlane(
|
HRESULT __cdecl ConvertToSinglePlane(
|
||||||
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_Out_ ScratchImage& image);
|
_Out_ ScratchImage& image) noexcept;
|
||||||
// Converts the image from a planar format to an equivalent non-planar format
|
// Converts the image from a planar format to an equivalent non-planar format
|
||||||
|
|
||||||
HRESULT __cdecl GenerateMipMaps(
|
HRESULT __cdecl GenerateMipMaps(
|
||||||
_In_ const Image& baseImage, _In_ DWORD filter, _In_ size_t levels,
|
_In_ const Image& baseImage, _In_ TEX_FILTER_FLAGS filter, _In_ size_t levels,
|
||||||
_Inout_ ScratchImage& mipChain, _In_ bool allow1D = false);
|
_Inout_ ScratchImage& mipChain, _In_ bool allow1D = false) noexcept;
|
||||||
HRESULT __cdecl GenerateMipMaps(
|
HRESULT __cdecl GenerateMipMaps(
|
||||||
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ DWORD filter, _In_ size_t levels, _Inout_ ScratchImage& mipChain);
|
_In_ TEX_FILTER_FLAGS filter, _In_ size_t levels, _Inout_ ScratchImage& mipChain);
|
||||||
// levels of '0' indicates a full mipchain, otherwise is generates that number of total levels (including the source base image)
|
// levels of '0' indicates a full mipchain, otherwise is generates that number of total levels (including the source base image)
|
||||||
// Defaults to Fant filtering which is equivalent to a box filter
|
// Defaults to Fant filtering which is equivalent to a box filter
|
||||||
|
|
||||||
HRESULT __cdecl GenerateMipMaps3D(
|
HRESULT __cdecl GenerateMipMaps3D(
|
||||||
_In_reads_(depth) const Image* baseImages, _In_ size_t depth, _In_ DWORD filter, _In_ size_t levels,
|
_In_reads_(depth) const Image* baseImages, _In_ size_t depth, _In_ TEX_FILTER_FLAGS filter, _In_ size_t levels,
|
||||||
_Out_ ScratchImage& mipChain);
|
_Out_ ScratchImage& mipChain) noexcept;
|
||||||
HRESULT __cdecl GenerateMipMaps3D(
|
HRESULT __cdecl GenerateMipMaps3D(
|
||||||
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ DWORD filter, _In_ size_t levels, _Out_ ScratchImage& mipChain);
|
_In_ TEX_FILTER_FLAGS filter, _In_ size_t levels, _Out_ ScratchImage& mipChain);
|
||||||
// levels of '0' indicates a full mipchain, otherwise is generates that number of total levels (including the source base image)
|
// levels of '0' indicates a full mipchain, otherwise is generates that number of total levels (including the source base image)
|
||||||
// Defaults to Fant filtering which is equivalent to a box filter
|
// Defaults to Fant filtering which is equivalent to a box filter
|
||||||
|
|
||||||
HRESULT __cdecl ScaleMipMapsAlphaForCoverage(
|
HRESULT __cdecl ScaleMipMapsAlphaForCoverage(
|
||||||
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ size_t item,
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ size_t item,
|
||||||
_In_ float alphaReference, _Inout_ ScratchImage& mipChain);
|
_In_ float alphaReference, _Inout_ ScratchImage& mipChain) noexcept;
|
||||||
|
|
||||||
|
|
||||||
enum TEX_PMALPHA_FLAGS
|
enum TEX_PMALPHA_FLAGS : unsigned long
|
||||||
{
|
{
|
||||||
TEX_PMALPHA_DEFAULT = 0,
|
TEX_PMALPHA_DEFAULT = 0,
|
||||||
|
|
||||||
@@ -555,13 +743,13 @@ namespace DirectX
|
|||||||
// if the output format type is IsSRGB(), then SRGB_OUT is on by default
|
// if the output format type is IsSRGB(), then SRGB_OUT is on by default
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT __cdecl PremultiplyAlpha(_In_ const Image& srcImage, _In_ DWORD flags, _Out_ ScratchImage& image);
|
HRESULT __cdecl PremultiplyAlpha(_In_ const Image& srcImage, _In_ TEX_PMALPHA_FLAGS flags, _Out_ ScratchImage& image) noexcept;
|
||||||
HRESULT __cdecl PremultiplyAlpha(
|
HRESULT __cdecl PremultiplyAlpha(
|
||||||
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ DWORD flags, _Out_ ScratchImage& result);
|
_In_ TEX_PMALPHA_FLAGS flags, _Out_ ScratchImage& result) noexcept;
|
||||||
// Converts to/from a premultiplied alpha version of the texture
|
// Converts to/from a premultiplied alpha version of the texture
|
||||||
|
|
||||||
enum TEX_COMPRESS_FLAGS
|
enum TEX_COMPRESS_FLAGS : unsigned long
|
||||||
{
|
{
|
||||||
TEX_COMPRESS_DEFAULT = 0,
|
TEX_COMPRESS_DEFAULT = 0,
|
||||||
|
|
||||||
@@ -593,33 +781,61 @@ namespace DirectX
|
|||||||
// Compress is free to use multithreading to improve performance (by default it does not use multithreading)
|
// Compress is free to use multithreading to improve performance (by default it does not use multithreading)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr float TEX_ALPHA_WEIGHT_DEFAULT = 1.0f;
|
||||||
|
// Default value for alpha weight used for GPU BC7 compression
|
||||||
|
|
||||||
|
struct CompressOptions
|
||||||
|
{
|
||||||
|
TEX_COMPRESS_FLAGS flags;
|
||||||
|
float threshold;
|
||||||
|
float alphaWeight;
|
||||||
|
};
|
||||||
|
|
||||||
HRESULT __cdecl Compress(
|
HRESULT __cdecl Compress(
|
||||||
_In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float threshold,
|
_In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ TEX_COMPRESS_FLAGS compress, _In_ float threshold,
|
||||||
_Out_ ScratchImage& cImage);
|
_Out_ ScratchImage& cImage) noexcept;
|
||||||
HRESULT __cdecl Compress(
|
HRESULT __cdecl Compress(
|
||||||
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float threshold, _Out_ ScratchImage& cImages);
|
_In_ DXGI_FORMAT format, _In_ TEX_COMPRESS_FLAGS compress, _In_ float threshold, _Out_ ScratchImage& cImages) noexcept;
|
||||||
// Note that threshold is only used by BC1. TEX_THRESHOLD_DEFAULT is a typical value to use
|
// Note that threshold is only used by BC1. TEX_THRESHOLD_DEFAULT is a typical value to use
|
||||||
|
|
||||||
|
HRESULT __cdecl CompressEx(
|
||||||
|
_In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ const CompressOptions& options,
|
||||||
|
_Out_ ScratchImage& cImage,
|
||||||
|
_In_ std::function<bool __cdecl(size_t, size_t)> statusCallBack = nullptr);
|
||||||
|
HRESULT __cdecl CompressEx(
|
||||||
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
|
_In_ DXGI_FORMAT format, _In_ const CompressOptions& options, _Out_ ScratchImage& cImages,
|
||||||
|
_In_ std::function<bool __cdecl(size_t, size_t)> statusCallBack = nullptr);
|
||||||
|
|
||||||
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
|
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
|
||||||
HRESULT __cdecl Compress(
|
HRESULT __cdecl Compress(
|
||||||
_In_ ID3D11Device* pDevice, _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD compress,
|
_In_ ID3D11Device* pDevice, _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ TEX_COMPRESS_FLAGS compress,
|
||||||
_In_ float alphaWeight, _Out_ ScratchImage& image);
|
_In_ float alphaWeight, _Out_ ScratchImage& image) noexcept;
|
||||||
HRESULT __cdecl Compress(
|
HRESULT __cdecl Compress(
|
||||||
_In_ ID3D11Device* pDevice, _In_ const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_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);
|
_In_ DXGI_FORMAT format, _In_ TEX_COMPRESS_FLAGS compress, _In_ float alphaWeight, _Out_ ScratchImage& cImages) noexcept;
|
||||||
// DirectCompute-based compression (alphaWeight is only used by BC7. 1.0 is the typical value to use)
|
// DirectCompute-based compression (alphaWeight is only used by BC7. 1.0 is the typical value to use)
|
||||||
|
|
||||||
|
HRESULT __cdecl CompressEx(
|
||||||
|
_In_ ID3D11Device* pDevice, _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ const CompressOptions& options,
|
||||||
|
_Out_ ScratchImage& image,
|
||||||
|
_In_ std::function<bool __cdecl(size_t, size_t)> statusCallBack = nullptr);
|
||||||
|
HRESULT __cdecl CompressEx(
|
||||||
|
_In_ ID3D11Device* pDevice, _In_ const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
|
_In_ DXGI_FORMAT format, _In_ const CompressOptions& options, _Out_ ScratchImage& cImages,
|
||||||
|
_In_ std::function<bool __cdecl(size_t, size_t)> statusCallBack = nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HRESULT __cdecl Decompress(_In_ const Image& cImage, _In_ DXGI_FORMAT format, _Out_ ScratchImage& image);
|
HRESULT __cdecl Decompress(_In_ const Image& cImage, _In_ DXGI_FORMAT format, _Out_ ScratchImage& image) noexcept;
|
||||||
HRESULT __cdecl Decompress(
|
HRESULT __cdecl Decompress(
|
||||||
_In_reads_(nimages) const Image* cImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* cImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ DXGI_FORMAT format, _Out_ ScratchImage& images);
|
_In_ DXGI_FORMAT format, _Out_ ScratchImage& images) noexcept;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Normal map operations
|
// Normal map operations
|
||||||
|
|
||||||
enum CNMAP_FLAGS
|
enum CNMAP_FLAGS : unsigned long
|
||||||
{
|
{
|
||||||
CNMAP_DEFAULT = 0,
|
CNMAP_DEFAULT = 0,
|
||||||
|
|
||||||
@@ -644,11 +860,11 @@ namespace DirectX
|
|||||||
};
|
};
|
||||||
|
|
||||||
HRESULT __cdecl ComputeNormalMap(
|
HRESULT __cdecl ComputeNormalMap(
|
||||||
_In_ const Image& srcImage, _In_ DWORD flags, _In_ float amplitude,
|
_In_ const Image& srcImage, _In_ CNMAP_FLAGS flags, _In_ float amplitude,
|
||||||
_In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMap);
|
_In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMap) noexcept;
|
||||||
HRESULT __cdecl ComputeNormalMap(
|
HRESULT __cdecl ComputeNormalMap(
|
||||||
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
_In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
_In_ DWORD flags, _In_ float amplitude, _In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMaps);
|
_In_ CNMAP_FLAGS flags, _In_ float amplitude, _In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMaps) noexcept;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Misc image operations
|
// Misc image operations
|
||||||
@@ -661,14 +877,14 @@ namespace DirectX
|
|||||||
size_t h;
|
size_t h;
|
||||||
|
|
||||||
Rect() = default;
|
Rect() = default;
|
||||||
Rect(size_t _x, size_t _y, size_t _w, size_t _h) : x(_x), y(_y), w(_w), h(_h) {}
|
Rect(size_t _x, size_t _y, size_t _w, size_t _h) noexcept : x(_x), y(_y), w(_w), h(_h) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT __cdecl CopyRectangle(
|
HRESULT __cdecl CopyRectangle(
|
||||||
_In_ const Image& srcImage, _In_ const Rect& srcRect, _In_ const Image& dstImage,
|
_In_ const Image& srcImage, _In_ const Rect& srcRect, _In_ const Image& dstImage,
|
||||||
_In_ DWORD filter, _In_ size_t xOffset, _In_ size_t yOffset);
|
_In_ TEX_FILTER_FLAGS filter, _In_ size_t xOffset, _In_ size_t yOffset) noexcept;
|
||||||
|
|
||||||
enum CMSE_FLAGS
|
enum CMSE_FLAGS : unsigned long
|
||||||
{
|
{
|
||||||
CMSE_DEFAULT = 0,
|
CMSE_DEFAULT = 0,
|
||||||
|
|
||||||
@@ -687,7 +903,7 @@ namespace DirectX
|
|||||||
// Indicates that image should be scaled and biased before comparison (i.e. UNORM -> SNORM)
|
// Indicates that image should be scaled and biased before comparison (i.e. UNORM -> SNORM)
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT __cdecl ComputeMSE(_In_ const Image& image1, _In_ const Image& image2, _Out_ float& mse, _Out_writes_opt_(4) float* mseV, _In_ DWORD flags = 0);
|
HRESULT __cdecl ComputeMSE(_In_ const Image& image1, _In_ const Image& image2, _Out_ float& mse, _Out_writes_opt_(4) float* mseV, _In_ CMSE_FLAGS flags = CMSE_DEFAULT) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl EvaluateImage(
|
HRESULT __cdecl EvaluateImage(
|
||||||
_In_ const Image& image,
|
_In_ const Image& image,
|
||||||
@@ -709,7 +925,7 @@ namespace DirectX
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// WIC utility code
|
// WIC utility code
|
||||||
|
#ifdef _WIN32
|
||||||
enum WICCodecs
|
enum WICCodecs
|
||||||
{
|
{
|
||||||
WIC_CODEC_BMP = 1, // Windows Bitmap (.bmp)
|
WIC_CODEC_BMP = 1, // Windows Bitmap (.bmp)
|
||||||
@@ -719,52 +935,69 @@ namespace DirectX
|
|||||||
WIC_CODEC_GIF, // Graphics Interchange Format (.gif)
|
WIC_CODEC_GIF, // Graphics Interchange Format (.gif)
|
||||||
WIC_CODEC_WMP, // Windows Media Photo / HD Photo / JPEG XR (.hdp, .jxr, .wdp)
|
WIC_CODEC_WMP, // Windows Media Photo / HD Photo / JPEG XR (.hdp, .jxr, .wdp)
|
||||||
WIC_CODEC_ICO, // Windows Icon (.ico)
|
WIC_CODEC_ICO, // Windows Icon (.ico)
|
||||||
|
WIC_CODEC_HEIF, // High Efficiency Image File (.heif, .heic)
|
||||||
};
|
};
|
||||||
|
|
||||||
REFGUID __cdecl GetWICCodec(_In_ WICCodecs codec);
|
REFGUID __cdecl GetWICCodec(_In_ WICCodecs codec) noexcept;
|
||||||
|
|
||||||
IWICImagingFactory* __cdecl GetWICFactory(bool& iswic2);
|
IWICImagingFactory* __cdecl GetWICFactory(bool& iswic2) noexcept;
|
||||||
void __cdecl SetWICFactory(_In_opt_ IWICImagingFactory* pWIC);
|
void __cdecl SetWICFactory(_In_opt_ IWICImagingFactory* pWIC) noexcept;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
|
||||||
// Direct3D 11 functions
|
|
||||||
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
|
|
||||||
bool __cdecl IsSupportedTexture(_In_ ID3D11Device* pDevice, _In_ const TexMetadata& metadata);
|
|
||||||
|
|
||||||
HRESULT __cdecl CreateTexture(
|
|
||||||
_In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
|
||||||
_Outptr_ ID3D11Resource** ppResource);
|
|
||||||
|
|
||||||
HRESULT __cdecl CreateShaderResourceView(
|
|
||||||
_In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
|
||||||
_Outptr_ ID3D11ShaderResourceView** ppSRV);
|
|
||||||
|
|
||||||
HRESULT __cdecl CreateTextureEx(
|
|
||||||
_In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
|
||||||
_In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ bool forceSRGB,
|
|
||||||
_Outptr_ ID3D11Resource** ppResource);
|
|
||||||
|
|
||||||
HRESULT __cdecl CreateShaderResourceViewEx(
|
|
||||||
_In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
|
||||||
_In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ bool forceSRGB,
|
|
||||||
_Outptr_ ID3D11ShaderResourceView** ppSRV);
|
|
||||||
|
|
||||||
HRESULT __cdecl CaptureTexture(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource* pSource, _Out_ ScratchImage& result);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
|
// DDS helper functions
|
||||||
|
HRESULT __cdecl EncodeDDSHeader(
|
||||||
|
_In_ const TexMetadata& metadata, DDS_FLAGS flags,
|
||||||
|
_Out_writes_bytes_to_opt_(maxsize, required) void* pDestination, _In_ size_t maxsize,
|
||||||
|
_Out_ size_t& required) noexcept;
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------
|
||||||
|
// Direct3D interop
|
||||||
|
|
||||||
|
enum CREATETEX_FLAGS : uint32_t
|
||||||
|
{
|
||||||
|
CREATETEX_DEFAULT = 0,
|
||||||
|
CREATETEX_FORCE_SRGB = 0x1,
|
||||||
|
CREATETEX_IGNORE_SRGB = 0x2,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Direct3D 11 functions
|
||||||
|
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
|
||||||
|
bool __cdecl IsSupportedTexture(_In_ ID3D11Device* pDevice, _In_ const TexMetadata& metadata) noexcept;
|
||||||
|
|
||||||
|
HRESULT __cdecl CreateTexture(
|
||||||
|
_In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
|
_Outptr_ ID3D11Resource** ppResource) noexcept;
|
||||||
|
|
||||||
|
HRESULT __cdecl CreateShaderResourceView(
|
||||||
|
_In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
|
_Outptr_ ID3D11ShaderResourceView** ppSRV) noexcept;
|
||||||
|
|
||||||
|
HRESULT __cdecl CreateTextureEx(
|
||||||
|
_In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
|
_In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ CREATETEX_FLAGS flags,
|
||||||
|
_Outptr_ ID3D11Resource** ppResource) noexcept;
|
||||||
|
|
||||||
|
HRESULT __cdecl CreateShaderResourceViewEx(
|
||||||
|
_In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||||
|
_In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ CREATETEX_FLAGS flags,
|
||||||
|
_Outptr_ ID3D11ShaderResourceView** ppSRV) noexcept;
|
||||||
|
|
||||||
|
HRESULT __cdecl CaptureTexture(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource* pSource, _Out_ ScratchImage& result) noexcept;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Direct3D 12 functions
|
// Direct3D 12 functions
|
||||||
#if defined(__d3d12_h__) || defined(__d3d12_x_h__)
|
#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||||
bool __cdecl IsSupportedTexture(_In_ ID3D12Device* pDevice, _In_ const TexMetadata& metadata);
|
bool __cdecl IsSupportedTexture(_In_ ID3D12Device* pDevice, _In_ const TexMetadata& metadata) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl CreateTexture(
|
HRESULT __cdecl CreateTexture(
|
||||||
_In_ ID3D12Device* pDevice, _In_ const TexMetadata& metadata,
|
_In_ ID3D12Device* pDevice, _In_ const TexMetadata& metadata,
|
||||||
_Outptr_ ID3D12Resource** ppResource);
|
_Outptr_ ID3D12Resource** ppResource) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl CreateTextureEx(
|
HRESULT __cdecl CreateTextureEx(
|
||||||
_In_ ID3D12Device* pDevice, _In_ const TexMetadata& metadata,
|
_In_ ID3D12Device* pDevice, _In_ const TexMetadata& metadata,
|
||||||
_In_ D3D12_RESOURCE_FLAGS resFlags, _In_ bool forceSRGB,
|
_In_ D3D12_RESOURCE_FLAGS resFlags, _In_ CREATETEX_FLAGS flags,
|
||||||
_Outptr_ ID3D12Resource** ppResource);
|
_Outptr_ ID3D12Resource** ppResource) noexcept;
|
||||||
|
|
||||||
HRESULT __cdecl PrepareUpload(
|
HRESULT __cdecl PrepareUpload(
|
||||||
_In_ ID3D12Device* pDevice,
|
_In_ ID3D12Device* pDevice,
|
||||||
@@ -775,9 +1008,29 @@ namespace DirectX
|
|||||||
_In_ ID3D12CommandQueue* pCommandQueue, _In_ ID3D12Resource* pSource, _In_ bool isCubeMap,
|
_In_ ID3D12CommandQueue* pCommandQueue, _In_ ID3D12Resource* pSource, _In_ bool isCubeMap,
|
||||||
_Out_ ScratchImage& result,
|
_Out_ ScratchImage& result,
|
||||||
_In_ D3D12_RESOURCE_STATES beforeState = D3D12_RESOURCE_STATE_RENDER_TARGET,
|
_In_ D3D12_RESOURCE_STATES beforeState = D3D12_RESOURCE_STATE_RENDER_TARGET,
|
||||||
_In_ D3D12_RESOURCE_STATES afterState = D3D12_RESOURCE_STATE_RENDER_TARGET);
|
_In_ D3D12_RESOURCE_STATES afterState = D3D12_RESOURCE_STATE_RENDER_TARGET) noexcept;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
|
||||||
|
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4619 4616 4061)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "DirectXTex.inl"
|
#include "DirectXTex.inl"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
84
Source/ThirdParty/DirectXTex/DirectXTex.inl
vendored
84
Source/ThirdParty/DirectXTex/DirectXTex.inl
vendored
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// DirectX Texture Library
|
// DirectX Texture Library
|
||||||
//
|
//
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
//
|
//
|
||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
@@ -11,18 +11,46 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
//=====================================================================================
|
||||||
|
// Bitmask flags enumerator operators
|
||||||
|
//=====================================================================================
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(CP_FLAGS);
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(DDS_FLAGS);
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(TGA_FLAGS);
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(WIC_FLAGS);
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(TEX_FR_FLAGS);
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(TEX_FILTER_FLAGS);
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(TEX_PMALPHA_FLAGS);
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(TEX_COMPRESS_FLAGS);
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(CNMAP_FLAGS);
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(CMSE_FLAGS);
|
||||||
|
DEFINE_ENUM_FLAG_OPERATORS(CREATETEX_FLAGS);
|
||||||
|
|
||||||
|
// WIC_FILTER modes match TEX_FILTER modes
|
||||||
|
constexpr WIC_FLAGS operator|(WIC_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<WIC_FLAGS>(static_cast<unsigned long>(a) | static_cast<unsigned long>(b & TEX_FILTER_MODE_MASK)); }
|
||||||
|
constexpr WIC_FLAGS operator|(TEX_FILTER_FLAGS a, WIC_FLAGS b) { return static_cast<WIC_FLAGS>(static_cast<unsigned long>(a & TEX_FILTER_MODE_MASK) | static_cast<unsigned long>(b)); }
|
||||||
|
|
||||||
|
// TEX_PMALPHA_SRGB match TEX_FILTER_SRGB
|
||||||
|
constexpr TEX_PMALPHA_FLAGS operator|(TEX_PMALPHA_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<TEX_PMALPHA_FLAGS>(static_cast<unsigned long>(a) | static_cast<unsigned long>(b & TEX_FILTER_SRGB_MASK)); }
|
||||||
|
constexpr TEX_PMALPHA_FLAGS operator|(TEX_FILTER_FLAGS a, TEX_PMALPHA_FLAGS b) { return static_cast<TEX_PMALPHA_FLAGS>(static_cast<unsigned long>(a & TEX_FILTER_SRGB_MASK) | static_cast<unsigned long>(b)); }
|
||||||
|
|
||||||
|
// TEX_COMPRESS_SRGB match TEX_FILTER_SRGB
|
||||||
|
constexpr TEX_COMPRESS_FLAGS operator|(TEX_COMPRESS_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<TEX_COMPRESS_FLAGS>(static_cast<unsigned long>(a) | static_cast<unsigned long>(b & TEX_FILTER_SRGB_MASK)); }
|
||||||
|
constexpr TEX_COMPRESS_FLAGS operator|(TEX_FILTER_FLAGS a, TEX_COMPRESS_FLAGS b) { return static_cast<TEX_COMPRESS_FLAGS>(static_cast<unsigned long>(a & TEX_FILTER_SRGB_MASK) | static_cast<unsigned long>(b)); }
|
||||||
|
|
||||||
|
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
// DXGI Format Utilities
|
// DXGI Format Utilities
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
|
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
inline bool __cdecl IsValid(DXGI_FORMAT fmt)
|
constexpr bool __cdecl IsValid(DXGI_FORMAT fmt) noexcept
|
||||||
{
|
{
|
||||||
return (static_cast<size_t>(fmt) >= 1 && static_cast<size_t>(fmt) <= 190);
|
return (static_cast<size_t>(fmt) >= 1 && static_cast<size_t>(fmt) <= 191);
|
||||||
}
|
}
|
||||||
|
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
inline bool __cdecl IsCompressed(DXGI_FORMAT fmt)
|
inline bool __cdecl IsCompressed(DXGI_FORMAT fmt) noexcept
|
||||||
{
|
{
|
||||||
switch (fmt)
|
switch (fmt)
|
||||||
{
|
{
|
||||||
@@ -55,7 +83,7 @@ inline bool __cdecl IsCompressed(DXGI_FORMAT fmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
inline bool __cdecl IsPalettized(DXGI_FORMAT fmt)
|
inline bool __cdecl IsPalettized(DXGI_FORMAT fmt) noexcept
|
||||||
{
|
{
|
||||||
switch (fmt)
|
switch (fmt)
|
||||||
{
|
{
|
||||||
@@ -71,7 +99,7 @@ inline bool __cdecl IsPalettized(DXGI_FORMAT fmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
inline bool __cdecl IsSRGB(DXGI_FORMAT fmt)
|
inline bool __cdecl IsSRGB(DXGI_FORMAT fmt) noexcept
|
||||||
{
|
{
|
||||||
switch (fmt)
|
switch (fmt)
|
||||||
{
|
{
|
||||||
@@ -94,7 +122,7 @@ inline bool __cdecl IsSRGB(DXGI_FORMAT fmt)
|
|||||||
// Image I/O
|
// Image I/O
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
inline HRESULT __cdecl SaveToDDSMemory(const Image& image, DWORD flags, Blob& blob)
|
inline HRESULT __cdecl SaveToDDSMemory(const Image& image, DDS_FLAGS flags, Blob& blob) noexcept
|
||||||
{
|
{
|
||||||
TexMetadata mdata = {};
|
TexMetadata mdata = {};
|
||||||
mdata.width = image.width;
|
mdata.width = image.width;
|
||||||
@@ -109,7 +137,7 @@ inline HRESULT __cdecl SaveToDDSMemory(const Image& image, DWORD flags, Blob& bl
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Use_decl_annotations_
|
_Use_decl_annotations_
|
||||||
inline HRESULT __cdecl SaveToDDSFile(const Image& image, DWORD flags, const wchar_t* szFile)
|
inline HRESULT __cdecl SaveToDDSFile(const Image& image, DDS_FLAGS flags, const wchar_t* szFile) noexcept
|
||||||
{
|
{
|
||||||
TexMetadata mdata = {};
|
TexMetadata mdata = {};
|
||||||
mdata.width = image.width;
|
mdata.width = image.width;
|
||||||
@@ -122,3 +150,43 @@ inline HRESULT __cdecl SaveToDDSFile(const Image& image, DWORD flags, const wcha
|
|||||||
|
|
||||||
return SaveToDDSFile(&image, 1, mdata, flags, szFile);
|
return SaveToDDSFile(&image, 1, mdata, flags, szFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================================
|
||||||
|
// Compatability helpers
|
||||||
|
//=====================================================================================
|
||||||
|
_Use_decl_annotations_
|
||||||
|
inline HRESULT __cdecl GetMetadataFromTGAMemory(const void* pSource, size_t size, TexMetadata& metadata) noexcept
|
||||||
|
{
|
||||||
|
return GetMetadataFromTGAMemory(pSource, size, TGA_FLAGS_NONE, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Use_decl_annotations_
|
||||||
|
inline HRESULT __cdecl GetMetadataFromTGAFile(const wchar_t* szFile, TexMetadata& metadata) noexcept
|
||||||
|
{
|
||||||
|
return GetMetadataFromTGAFile(szFile, TGA_FLAGS_NONE, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Use_decl_annotations_
|
||||||
|
inline HRESULT __cdecl LoadFromTGAMemory(const void* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept
|
||||||
|
{
|
||||||
|
return LoadFromTGAMemory(pSource, size, TGA_FLAGS_NONE, metadata, image);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Use_decl_annotations_
|
||||||
|
inline HRESULT __cdecl LoadFromTGAFile(const wchar_t* szFile, TexMetadata* metadata, ScratchImage& image) noexcept
|
||||||
|
{
|
||||||
|
return LoadFromTGAFile(szFile, TGA_FLAGS_NONE, metadata, image);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Use_decl_annotations_
|
||||||
|
inline HRESULT __cdecl SaveToTGAMemory(const Image& image, Blob& blob, const TexMetadata* metadata) noexcept
|
||||||
|
{
|
||||||
|
return SaveToTGAMemory(image, TGA_FLAGS_NONE, blob, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
_Use_decl_annotations_
|
||||||
|
inline HRESULT __cdecl SaveToTGAFile(const Image& image, const wchar_t* szFile, const TexMetadata* metadata) noexcept
|
||||||
|
{
|
||||||
|
return SaveToTGAFile(image, TGA_FLAGS_NONE, szFile, metadata);
|
||||||
|
}
|
||||||
|
|||||||
34
Source/ThirdParty/DirectXTex/LICENSE
vendored
34
Source/ThirdParty/DirectXTex/LICENSE
vendored
@@ -1,21 +1,21 @@
|
|||||||
The MIT License (MIT)
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2011-2019 Microsoft Corp
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
software and associated documentation files (the "Software"), to deal in the Software
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
without restriction, including without limitation the rights to use, copy, modify,
|
in the Software without restriction, including without limitation the rights
|
||||||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
permit persons to whom the Software is furnished to do so, subject to the following
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies
|
The above copyright notice and this permission notice shall be included in all
|
||||||
or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
||||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
|
||||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace Flax.Deps.Dependencies
|
|||||||
|
|
||||||
// Get the source
|
// Get the source
|
||||||
CloneGitRepo(root, "https://github.com/Microsoft/DirectXTex.git");
|
CloneGitRepo(root, "https://github.com/Microsoft/DirectXTex.git");
|
||||||
GitCheckout(root, "master", "9a417f506c43e087b84c017260ad673abd6c64e1");
|
GitCheckout(root, "main", "5cfd711dc5d64cde1e8b27670036535df5c3f922");
|
||||||
|
|
||||||
foreach (var platform in options.Platforms)
|
foreach (var platform in options.Platforms)
|
||||||
{
|
{
|
||||||
@@ -52,60 +52,39 @@ namespace Flax.Deps.Dependencies
|
|||||||
{
|
{
|
||||||
case TargetPlatform.Windows:
|
case TargetPlatform.Windows:
|
||||||
{
|
{
|
||||||
var solutionPath = Path.Combine(root, "DirectXTex_Desktop_2015.sln");
|
var solutionPath = Path.Combine(root, "DirectXTex_Desktop_2022.sln");
|
||||||
var binFolder = Path.Combine(root, "DirectXTex", "Bin", "Desktop_2015");
|
var binFolder = Path.Combine(root, "DirectXTex", "Bin", "Desktop_2022");
|
||||||
Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, "x64");
|
Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, "x64");
|
||||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
||||||
foreach (var file in outputFileNames)
|
foreach (var file in outputFileNames)
|
||||||
{
|
|
||||||
Utilities.FileCopy(Path.Combine(binFolder, "x64", configuration, file), Path.Combine(depsFolder, file));
|
Utilities.FileCopy(Path.Combine(binFolder, "x64", configuration, file), Path.Combine(depsFolder, file));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TargetPlatform.UWP:
|
case TargetPlatform.UWP:
|
||||||
{
|
{
|
||||||
var solutionPath = Path.Combine(root, "DirectXTex_Windows10_2017.sln");
|
var solutionPath = Path.Combine(root, "DirectXTex_Windows10_2019.sln");
|
||||||
var binFolder = Path.Combine(root, "DirectXTex", "Bin", "Windows10_2017");
|
var binFolder = Path.Combine(root, "DirectXTex", "Bin", "Windows10_2019");
|
||||||
Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, "x64");
|
Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, "x64");
|
||||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
||||||
foreach (var file in outputFileNames)
|
foreach (var file in outputFileNames)
|
||||||
{
|
|
||||||
Utilities.FileCopy(Path.Combine(binFolder, "x64", configuration, file), Path.Combine(depsFolder, file));
|
Utilities.FileCopy(Path.Combine(binFolder, "x64", configuration, file), Path.Combine(depsFolder, file));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TargetPlatform.XboxOne:
|
case TargetPlatform.XboxOne:
|
||||||
{
|
|
||||||
var solutionPath = Path.Combine(root, "DirectXTex_GXDK_2017.sln");
|
|
||||||
File.Copy(Path.Combine(GetBinariesFolder(options, platform), "DirectXTex_GXDK_2017.sln"), solutionPath, true);
|
|
||||||
var projectFileContents = File.ReadAllText(Path.Combine(GetBinariesFolder(options, platform), "DirectXTex_GXDK_2017.vcxproj"));
|
|
||||||
projectFileContents = projectFileContents.Replace("___VS_TOOLSET___", "v142");
|
|
||||||
var projectPath = Path.Combine(root, "DirectXTex", "DirectXTex_GXDK_2017.vcxproj");
|
|
||||||
File.WriteAllText(projectPath, projectFileContents);
|
|
||||||
var binFolder = Path.Combine(root, "DirectXTex", "Bin", "GXDK_2017");
|
|
||||||
Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, "Gaming.Xbox.XboxOne.x64");
|
|
||||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
|
||||||
foreach (var file in outputFileNames)
|
|
||||||
{
|
|
||||||
Utilities.FileCopy(Path.Combine(binFolder, "Gaming.Xbox.XboxOne.x64", configuration, file), Path.Combine(depsFolder, file));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TargetPlatform.XboxScarlett:
|
case TargetPlatform.XboxScarlett:
|
||||||
{
|
{
|
||||||
var solutionPath = Path.Combine(root, "DirectXTex_GXDK_2017.sln");
|
var solutionPath = Path.Combine(root, "DirectXTex_GXDK_2019.sln");
|
||||||
File.Copy(Path.Combine(GetBinariesFolder(options, platform), "DirectXTex_GXDK_2017.sln"), solutionPath, true);
|
File.Copy(Path.Combine(GetBinariesFolder(options, platform), "DirectXTex_GXDK_2019.sln"), solutionPath, true);
|
||||||
var projectFileContents = File.ReadAllText(Path.Combine(GetBinariesFolder(options, platform), "DirectXTex_GXDK_2017.vcxproj"));
|
var projectFileContents = File.ReadAllText(Path.Combine(GetBinariesFolder(options, platform), "DirectXTex_GXDK_2019.vcxproj"));
|
||||||
projectFileContents = projectFileContents.Replace("___VS_TOOLSET___", "v142");
|
projectFileContents = projectFileContents.Replace("___VS_TOOLSET___", "v142");
|
||||||
var projectPath = Path.Combine(root, "DirectXTex", "DirectXTex_GXDK_2017.vcxproj");
|
var projectPath = Path.Combine(root, "DirectXTex", "DirectXTex_GXDK_2019.vcxproj");
|
||||||
File.WriteAllText(projectPath, projectFileContents);
|
File.WriteAllText(projectPath, projectFileContents);
|
||||||
var binFolder = Path.Combine(root, "DirectXTex", "Bin", "GXDK_2017");
|
var binFolder = Path.Combine(root, "DirectXTex", "Bin", "GXDK_2019");
|
||||||
Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, "Gaming.Xbox.Scarlett.x64");
|
var xboxName = platform == TargetPlatform.XboxOne ? "Gaming.Xbox.XboxOne.x64" : "Gaming.Xbox.Scarlett.x64";
|
||||||
|
Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, xboxName);
|
||||||
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64);
|
||||||
foreach (var file in outputFileNames)
|
foreach (var file in outputFileNames)
|
||||||
{
|
Utilities.FileCopy(Path.Combine(binFolder, xboxName, configuration, file), Path.Combine(depsFolder, file));
|
||||||
Utilities.FileCopy(Path.Combine(binFolder, "Gaming.Xbox.Scarlett.x64", configuration, file), Path.Combine(depsFolder, file));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user