1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-21 12:00:06 +00:00

Use fixed width integers for underlying enum types (#538)

This commit is contained in:
Chuck Walbourn 2024-10-24 11:44:33 -07:00 committed by GitHub
parent cea630ac4c
commit 6e7801e324
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 112 additions and 106 deletions

View File

@ -41,6 +41,9 @@
#include <d3d11_1.h>
#endif
#include <cstdint>
#include <utility>
#define DIRECTX_TEX_XBOX_VERSION 150
namespace Xbox
@ -95,13 +98,13 @@ namespace Xbox
// Image I/O
HRESULT __cdecl GetMetadataFromDDSMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox);
HRESULT __cdecl GetMetadataFromDDSFile(
_In_z_ const wchar_t* szFile, _Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox);
HRESULT __cdecl GetMetadataFromDDSMemoryEx(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat);
HRESULT __cdecl GetMetadataFromDDSFileEx(
@ -109,14 +112,14 @@ namespace Xbox
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat);
HRESULT __cdecl LoadFromDDSMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_opt_ DirectX::TexMetadata* metadata, _Out_ XboxImage& image);
HRESULT __cdecl LoadFromDDSFile(
_In_z_ const wchar_t* szFile,
_Out_opt_ DirectX::TexMetadata* metadata, _Out_ XboxImage& image);
HRESULT __cdecl LoadFromDDSMemoryEx(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_opt_ DirectX::TexMetadata* metadata,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat,
_Out_ XboxImage& image);
@ -173,6 +176,6 @@ namespace Xbox
// DDS helper functions
HRESULT __cdecl EncodeDDSHeader(
const XboxImage& xbox,
_Out_writes_bytes_(maxsize) void* pDestination, _In_ size_t maxsize) noexcept;
_Out_writes_bytes_(maxsize) uint8_t* pDestination, _In_ size_t maxsize) noexcept;
} // namespace

View File

@ -27,7 +27,7 @@ namespace
// Decodes DDS header using XBOX extended header (variant of DX10 header)
//-------------------------------------------------------------------------------------
HRESULT DecodeDDSHeader(
_In_reads_bytes_(size) const void* pSource,
_In_reads_bytes_(size) const uint8_t* pSource,
size_t size,
DirectX::TexMetadata& metadata,
_Out_opt_ DDSMetaData* ddPixelFormat,
@ -229,7 +229,7 @@ namespace
_Use_decl_annotations_
HRESULT Xbox::EncodeDDSHeader(
const XboxImage& xbox,
void* pDestination,
uint8_t* pDestination,
size_t maxsize) noexcept
{
if (!pDestination)
@ -383,7 +383,7 @@ HRESULT Xbox::EncodeDDSHeader(
_Use_decl_annotations_
HRESULT Xbox::GetMetadataFromDDSMemory(
const void* pSource,
const uint8_t* pSource,
size_t size,
TexMetadata& metadata,
bool& isXbox)
@ -393,7 +393,7 @@ HRESULT Xbox::GetMetadataFromDDSMemory(
_Use_decl_annotations_
HRESULT Xbox::GetMetadataFromDDSMemoryEx(
const void* pSource,
const uint8_t* pSource,
size_t size,
TexMetadata& metadata,
bool& isXbox,
@ -498,7 +498,7 @@ HRESULT Xbox::GetMetadataFromDDSFileEx(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT Xbox::LoadFromDDSMemory(
const void* pSource,
const uint8_t* pSource,
size_t size,
TexMetadata* metadata,
XboxImage& xbox)
@ -508,7 +508,7 @@ HRESULT Xbox::LoadFromDDSMemory(
_Use_decl_annotations_
HRESULT Xbox::LoadFromDDSMemoryEx(
const void* pSource,
const uint8_t* pSource,
size_t size,
TexMetadata* metadata,
DDSMetaData* ddPixelFormat,
@ -694,7 +694,7 @@ HRESULT Xbox::SaveToDDSMemory(const XboxImage& xbox, Blob& blob)
return hr;
// Copy header
auto pDestination = reinterpret_cast<uint8_t*>(blob.GetBufferPointer());
auto pDestination = blob.GetBufferPointer();
assert(pDestination);
hr = EncodeDDSHeader(xbox, pDestination, DDS_XBOX_HEADER_SIZE);

View File

@ -53,7 +53,7 @@ namespace DirectX
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif
DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS);
DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS)
#ifdef __clang__
#pragma clang diagnostic pop

View File

@ -70,7 +70,7 @@ namespace DirectX
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif
DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS);
DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS)
#ifdef __clang__
#pragma clang diagnostic pop

View File

@ -86,7 +86,7 @@ namespace DirectX
FORMAT_TYPE __cdecl FormatDataType(_In_ DXGI_FORMAT fmt) noexcept;
enum CP_FLAGS : unsigned long
enum CP_FLAGS : uint32_t
{
CP_FLAGS_NONE = 0x0,
// Normal operation
@ -144,13 +144,13 @@ namespace DirectX
TEX_DIMENSION_TEXTURE3D = 4,
};
enum TEX_MISC_FLAG : unsigned long
enum TEX_MISC_FLAG : uint32_t
// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
{
TEX_MISC_TEXTURECUBE = 0x4L,
};
enum TEX_MISC_FLAG2 : unsigned long
enum TEX_MISC_FLAG2 : uint32_t
{
TEX_MISC2_ALPHA_MODE_MASK = 0x7L,
};
@ -210,7 +210,7 @@ namespace DirectX
bool __cdecl IsDX10() const noexcept { return (fourCC == 0x30315844); }
};
enum DDS_FLAGS : unsigned long
enum DDS_FLAGS : uint32_t
{
DDS_FLAGS_NONE = 0x0,
@ -257,7 +257,7 @@ namespace DirectX
// Enables the loader to read large dimension .dds files (i.e. greater than known hardware requirements)
};
enum TGA_FLAGS : unsigned long
enum TGA_FLAGS : uint32_t
{
TGA_FLAGS_NONE = 0x0,
@ -280,7 +280,7 @@ namespace DirectX
// If no colorspace is specified in TGA 2.0 metadata, assume sRGB
};
enum WIC_FLAGS : unsigned long
enum WIC_FLAGS : uint32_t
{
WIC_FLAGS_NONE = 0x0,
@ -325,7 +325,7 @@ namespace DirectX
};
HRESULT __cdecl GetMetadataFromDDSMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ DDS_FLAGS flags,
_Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromDDSFile(
@ -334,7 +334,7 @@ namespace DirectX
_Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromDDSMemoryEx(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ DDS_FLAGS flags,
_Out_ TexMetadata& metadata,
_Out_opt_ DDSMetaData* ddPixelFormat) noexcept;
@ -345,14 +345,14 @@ namespace DirectX
_Out_opt_ DDSMetaData* ddPixelFormat) noexcept;
HRESULT __cdecl GetMetadataFromHDRMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromHDRFile(
_In_z_ const wchar_t* szFile,
_Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromTGAMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ TGA_FLAGS flags,
_Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromTGAFile(
@ -362,7 +362,7 @@ namespace DirectX
#ifdef _WIN32
HRESULT __cdecl GetMetadataFromWICMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ WIC_FLAGS flags,
_Out_ TexMetadata& metadata,
_In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
@ -376,7 +376,7 @@ namespace DirectX
// Compatability helpers
HRESULT __cdecl GetMetadataFromTGAMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromTGAFile(
_In_z_ const wchar_t* szFile,
@ -461,7 +461,10 @@ namespace DirectX
void __cdecl Release() noexcept;
void *__cdecl GetBufferPointer() const noexcept { return m_buffer; }
uint8_t* __cdecl GetBufferPointer() const noexcept { return m_buffer; }
const uint8_t* __cdecl GetConstBufferPointer() const noexcept { return m_buffer; }
size_t __cdecl GetBufferSize() const noexcept { return m_size; }
HRESULT __cdecl Resize(size_t size) noexcept;
@ -471,7 +474,7 @@ namespace DirectX
// Shorten size without reallocation
private:
void* m_buffer;
uint8_t* m_buffer;
size_t m_size;
};
@ -480,7 +483,7 @@ namespace DirectX
// DDS operations
HRESULT __cdecl LoadFromDDSMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ DDS_FLAGS flags,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
HRESULT __cdecl LoadFromDDSFile(
@ -489,7 +492,7 @@ namespace DirectX
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
HRESULT __cdecl LoadFromDDSMemoryEx(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ DDS_FLAGS flags,
_Out_opt_ TexMetadata* metadata,
_Out_opt_ DDSMetaData* ddPixelFormat,
@ -517,7 +520,7 @@ namespace DirectX
// HDR operations
HRESULT __cdecl LoadFromHDRMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
HRESULT __cdecl LoadFromHDRFile(
_In_z_ const wchar_t* szFile,
@ -528,7 +531,7 @@ namespace DirectX
// TGA operations
HRESULT __cdecl LoadFromTGAMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ TGA_FLAGS flags,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
HRESULT __cdecl LoadFromTGAFile(
@ -546,7 +549,7 @@ namespace DirectX
// WIC operations
#ifdef _WIN32
HRESULT __cdecl LoadFromWICMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ WIC_FLAGS flags,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image,
_In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
@ -578,7 +581,7 @@ namespace DirectX
// Compatability helpers
HRESULT __cdecl LoadFromTGAMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size,
_In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
HRESULT __cdecl LoadFromTGAFile(
_In_z_ const wchar_t* szFile,
@ -590,7 +593,7 @@ namespace DirectX
//---------------------------------------------------------------------------------
// Texture conversion, resizing, mipmap generation, and block compression
enum TEX_FR_FLAGS : unsigned long
enum TEX_FR_FLAGS : uint32_t
{
TEX_FR_ROTATE0 = 0x0,
TEX_FR_ROTATE90 = 0x1,
@ -608,7 +611,7 @@ namespace DirectX
// Flip and/or rotate image
#endif
enum TEX_FILTER_FLAGS : unsigned long
enum TEX_FILTER_FLAGS : uint32_t
{
TEX_FILTER_DEFAULT = 0,
@ -662,9 +665,9 @@ namespace DirectX
// 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;
constexpr uint32_t TEX_FILTER_DITHER_MASK = 0xF0000;
constexpr uint32_t TEX_FILTER_MODE_MASK = 0xF00000;
constexpr uint32_t TEX_FILTER_SRGB_MASK = 0xF000000;
HRESULT __cdecl Resize(
_In_ const Image& srcImage, _In_ size_t width, _In_ size_t height,
@ -731,7 +734,7 @@ namespace DirectX
_In_ float alphaReference, _Inout_ ScratchImage& mipChain) noexcept;
enum TEX_PMALPHA_FLAGS : unsigned long
enum TEX_PMALPHA_FLAGS : uint32_t
{
TEX_PMALPHA_DEFAULT = 0,
@ -754,7 +757,7 @@ namespace DirectX
_In_ TEX_PMALPHA_FLAGS flags, _Out_ ScratchImage& result) noexcept;
// Converts to/from a premultiplied alpha version of the texture
enum TEX_COMPRESS_FLAGS : unsigned long
enum TEX_COMPRESS_FLAGS : uint32_t
{
TEX_COMPRESS_DEFAULT = 0,
@ -840,7 +843,7 @@ namespace DirectX
//---------------------------------------------------------------------------------
// Normal map operations
enum CNMAP_FLAGS : unsigned long
enum CNMAP_FLAGS : uint32_t
{
CNMAP_DEFAULT = 0,
@ -889,7 +892,7 @@ namespace DirectX
_In_ const Image& srcImage, _In_ const Rect& srcRect, _In_ const Image& dstImage,
_In_ TEX_FILTER_FLAGS filter, _In_ size_t xOffset, _In_ size_t yOffset) noexcept;
enum CMSE_FLAGS : unsigned long
enum CMSE_FLAGS : uint32_t
{
CMSE_DEFAULT = 0,
@ -953,7 +956,7 @@ namespace DirectX
// 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_writes_bytes_to_opt_(maxsize, required) uint8_t* pDestination, _In_ size_t maxsize,
_Out_ size_t& required) noexcept;
//---------------------------------------------------------------------------------

View File

@ -14,29 +14,29 @@
//=====================================================================================
// 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);
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)); }
constexpr WIC_FLAGS operator|(WIC_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<WIC_FLAGS>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b & TEX_FILTER_MODE_MASK)); }
constexpr WIC_FLAGS operator|(TEX_FILTER_FLAGS a, WIC_FLAGS b) { return static_cast<WIC_FLAGS>(static_cast<uint32_t>(a & TEX_FILTER_MODE_MASK) | static_cast<uint32_t>(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)); }
constexpr TEX_PMALPHA_FLAGS operator|(TEX_PMALPHA_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<TEX_PMALPHA_FLAGS>(static_cast<uint32_t>(a) | static_cast<uint32_t>(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<uint32_t>(a & TEX_FILTER_SRGB_MASK) | static_cast<uint32_t>(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)); }
constexpr TEX_COMPRESS_FLAGS operator|(TEX_COMPRESS_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<TEX_COMPRESS_FLAGS>(static_cast<uint32_t>(a) | static_cast<uint32_t>(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<uint32_t>(a & TEX_FILTER_SRGB_MASK) | static_cast<uint32_t>(b)); }
//=====================================================================================
@ -156,7 +156,7 @@ inline HRESULT __cdecl SaveToDDSFile(const Image& image, DDS_FLAGS flags, const
// Compatability helpers
//=====================================================================================
_Use_decl_annotations_
inline HRESULT __cdecl GetMetadataFromTGAMemory(const void* pSource, size_t size, TexMetadata& metadata) noexcept
inline HRESULT __cdecl GetMetadataFromTGAMemory(const uint8_t* pSource, size_t size, TexMetadata& metadata) noexcept
{
return GetMetadataFromTGAMemory(pSource, size, TGA_FLAGS_NONE, metadata);
}
@ -168,7 +168,7 @@ inline HRESULT __cdecl GetMetadataFromTGAFile(const wchar_t* szFile, TexMetadata
}
_Use_decl_annotations_
inline HRESULT __cdecl LoadFromTGAMemory(const void* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept
inline HRESULT __cdecl LoadFromTGAMemory(const uint8_t* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept
{
return LoadFromTGAMemory(pSource, size, TGA_FLAGS_NONE, metadata, image);
}

View File

@ -675,7 +675,7 @@ _Use_decl_annotations_
HRESULT DirectX::EncodeDDSHeader(
const TexMetadata& metadata,
DDS_FLAGS flags,
void* pDestination,
uint8_t* pDestination,
size_t maxsize,
size_t& required) noexcept
{
@ -851,7 +851,7 @@ HRESULT DirectX::EncodeDDSHeader(
if (maxsize < required)
return E_NOT_SUFFICIENT_BUFFER;
*static_cast<uint32_t*>(pDestination) = DDS_MAGIC;
*reinterpret_cast<uint32_t*>(pDestination) = DDS_MAGIC;
auto header = reinterpret_cast<DDS_HEADER*>(static_cast<uint8_t*>(pDestination) + sizeof(uint32_t));
assert(header);
@ -1835,7 +1835,7 @@ namespace
_Use_decl_annotations_
HRESULT DirectX::GetMetadataFromDDSMemory(
const void* pSource,
const uint8_t* pSource,
size_t size,
DDS_FLAGS flags,
TexMetadata& metadata) noexcept
@ -1845,7 +1845,7 @@ HRESULT DirectX::GetMetadataFromDDSMemory(
_Use_decl_annotations_
HRESULT DirectX::GetMetadataFromDDSMemoryEx(
const void* pSource,
const uint8_t* pSource,
size_t size,
DDS_FLAGS flags,
TexMetadata& metadata,
@ -1957,7 +1957,7 @@ HRESULT DirectX::GetMetadataFromDDSFileEx(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::LoadFromDDSMemory(
const void* pSource,
const uint8_t* pSource,
size_t size,
DDS_FLAGS flags,
TexMetadata* metadata,
@ -1968,7 +1968,7 @@ HRESULT DirectX::LoadFromDDSMemory(
_Use_decl_annotations_
HRESULT DirectX::LoadFromDDSMemoryEx(
const void* pSource,
const uint8_t* pSource,
size_t size,
DDS_FLAGS flags,
TexMetadata* metadata,
@ -2355,7 +2355,7 @@ HRESULT DirectX::SaveToDDSMemory(
if (FAILED(hr))
return hr;
auto pDestination = static_cast<uint8_t*>(blob.GetBufferPointer());
auto pDestination = blob.GetBufferPointer();
assert(pDestination);
hr = EncodeDDSHeader(metadata, flags, pDestination, blob.GetBufferSize(), required);

View File

@ -94,7 +94,7 @@ namespace
// Decodes HDR header
//-------------------------------------------------------------------------------------
HRESULT DecodeHDRHeader(
_In_reads_bytes_(size) const void* pSource,
_In_reads_bytes_(size) const uint8_t* pSource,
size_t size,
_Out_ TexMetadata& metadata,
size_t& offset,
@ -121,7 +121,7 @@ namespace
// Process first part of header
bool formatFound = false;
auto info = static_cast<const char*>(pSource);
auto info = reinterpret_cast<const char*>(pSource);
while (size > 0)
{
if (*info == '\n')
@ -310,7 +310,7 @@ namespace
return E_FAIL;
}
offset = size_t(info - static_cast<const char*>(pSource));
offset = size_t(info - reinterpret_cast<const char*>(pSource));
metadata.width = width;
metadata.height = height;
@ -600,7 +600,7 @@ namespace
// Obtain metadata from HDR file in memory/on disk
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::GetMetadataFromHDRMemory(const void* pSource, size_t size, TexMetadata& metadata) noexcept
HRESULT DirectX::GetMetadataFromHDRMemory(const uint8_t* pSource, size_t size, TexMetadata& metadata) noexcept
{
if (!pSource || size == 0)
return E_INVALIDARG;
@ -696,7 +696,7 @@ HRESULT DirectX::GetMetadataFromHDRFile(const wchar_t* szFile, TexMetadata& meta
// Load a HDR file in memory
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::LoadFromHDRMemory(const void* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept
HRESULT DirectX::LoadFromHDRMemory(const uint8_t* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept
{
if (!pSource || size == 0)
return E_INVALIDARG;
@ -1045,7 +1045,7 @@ HRESULT DirectX::SaveToHDRMemory(const Image& image, Blob& blob) noexcept
return hr;
// Copy header
auto dPtr = static_cast<uint8_t*>(blob.GetBufferPointer());
auto dPtr = blob.GetBufferPointer();
assert(dPtr != nullptr);
memcpy(dPtr, header, headerLen);
dPtr += headerLen;
@ -1097,7 +1097,7 @@ HRESULT DirectX::SaveToHDRMemory(const Image& image, Blob& blob) noexcept
}
#endif
hr = blob.Trim(size_t(dPtr - static_cast<uint8_t*>(blob.GetBufferPointer())));
hr = blob.Trim(size_t(dPtr - blob.GetConstBufferPointer()));
if (FAILED(hr))
{
blob.Release();
@ -1184,7 +1184,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
#ifdef _WIN32
auto const bytesToWrite = static_cast<const DWORD>(blob.GetBufferSize());
DWORD bytesWritten;
if (!WriteFile(hFile.get(), blob.GetBufferPointer(), bytesToWrite, &bytesWritten, nullptr))
if (!WriteFile(hFile.get(), blob.GetConstBufferPointer(), bytesToWrite, &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
}
@ -1194,7 +1194,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
return E_FAIL;
}
#else
outFile.write(reinterpret_cast<char*>(blob.GetBufferPointer()),
outFile.write(reinterpret_cast<const char*>(blob.GetConstBufferPointer()),
static_cast<std::streamsize>(blob.GetBufferSize()));
if (!outFile)

View File

@ -2955,7 +2955,7 @@ HRESULT DirectX::GenerateMipMaps(
mdata.mipLevels = levels;
mdata.format = baseImage.format;
unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK);
uint32_t filter_select = (filter & TEX_FILTER_MODE_MASK);
if (!filter_select)
{
// Default filter choice
@ -3170,7 +3170,7 @@ HRESULT DirectX::GenerateMipMaps(
TexMetadata mdata2 = metadata;
mdata2.mipLevels = levels;
unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK);
uint32_t filter_select = (filter & TEX_FILTER_MODE_MASK);
if (!filter_select)
{
// Default filter choice
@ -3300,7 +3300,7 @@ HRESULT DirectX::GenerateMipMaps3D(
HRESULT hr = E_UNEXPECTED;
unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK);
uint32_t filter_select = (filter & TEX_FILTER_MODE_MASK);
if (!filter_select)
{
// Default filter choice
@ -3419,7 +3419,7 @@ HRESULT DirectX::GenerateMipMaps3D(
static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK");
unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK);
uint32_t filter_select = (filter & TEX_FILTER_MODE_MASK);
if (!filter_select)
{
// Default filter choice

View File

@ -811,7 +811,7 @@ namespace
static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MASK");
unsigned long filter_select = filter & TEX_FILTER_MODE_MASK;
uint32_t filter_select = filter & TEX_FILTER_MODE_MASK;
if (!filter_select)
{
// Default filter choice

View File

@ -139,7 +139,7 @@ namespace
// Decodes TGA header
//-------------------------------------------------------------------------------------
HRESULT DecodeTGAHeader(
_In_reads_bytes_(size) const void* pSource,
_In_reads_bytes_(size) const uint8_t* pSource,
size_t size,
TGA_FLAGS flags,
_Out_ TexMetadata& metadata,
@ -156,7 +156,7 @@ namespace
return HRESULT_E_INVALID_DATA;
}
auto pHeader = static_cast<const TGA_HEADER*>(pSource);
auto pHeader = reinterpret_cast<const TGA_HEADER*>(pSource);
if (pHeader->bDescriptor & (TGA_FLAGS_INTERLEAVED_2WAY | TGA_FLAGS_INTERLEAVED_4WAY))
{
@ -1447,7 +1447,7 @@ namespace
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::GetMetadataFromTGAMemory(
const void* pSource,
const uint8_t* pSource,
size_t size,
TGA_FLAGS flags,
TexMetadata& metadata) noexcept
@ -1641,7 +1641,7 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags,
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::LoadFromTGAMemory(
const void* pSource,
const uint8_t* pSource,
size_t size,
TGA_FLAGS flags,
TexMetadata* metadata,
@ -2279,7 +2279,7 @@ HRESULT DirectX::SaveToTGAMemory(
return hr;
// Copy header
auto destPtr = static_cast<uint8_t*>(blob.GetBufferPointer());
auto destPtr = blob.GetBufferPointer();
assert(destPtr != nullptr);
uint8_t* dPtr = destPtr;
@ -2396,7 +2396,7 @@ HRESULT DirectX::SaveToTGAFile(
#ifdef _WIN32
const DWORD bytesToWrite = static_cast<DWORD>(blob.GetBufferSize());
DWORD bytesWritten;
if (!WriteFile(hFile.get(), blob.GetBufferPointer(), bytesToWrite, &bytesWritten, nullptr))
if (!WriteFile(hFile.get(), blob.GetConstBufferPointer(), bytesToWrite, &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
}
@ -2406,7 +2406,7 @@ HRESULT DirectX::SaveToTGAFile(
return E_FAIL;
}
#else
outFile.write(reinterpret_cast<char*>(blob.GetBufferPointer()),
outFile.write(reinterpret_cast<const char*>(blob.GetConstBufferPointer()),
static_cast<std::streamsize>(blob.GetBufferSize()));
if (!outFile)

View File

@ -1688,7 +1688,7 @@ HRESULT Blob::Initialize(size_t size) noexcept
Release();
m_buffer = _aligned_malloc(size, 16);
m_buffer = reinterpret_cast<uint8_t*>(_aligned_malloc(size, 16));
if (!m_buffer)
{
Release();
@ -1724,7 +1724,7 @@ HRESULT Blob::Resize(size_t size) noexcept
if (!m_buffer || !m_size)
return E_UNEXPECTED;
void *tbuffer = _aligned_malloc(size, 16);
auto tbuffer = reinterpret_cast<uint8_t*>(_aligned_malloc(size, 16));
if (!tbuffer)
return E_OUTOFMEMORY;

View File

@ -208,7 +208,7 @@ namespace
m_streamEOF(0),
mRefCount(1)
{
assert(mBlob.GetBufferPointer() && mBlob.GetBufferSize() > 0);
assert(mBlob.GetConstBufferPointer() && mBlob.GetBufferSize() > 0);
}
public:
@ -254,7 +254,7 @@ namespace
HRESULT STDMETHODCALLTYPE Read(void* pv, ULONG cb, ULONG* pcbRead) override
{
size_t maxRead = m_streamEOF - m_streamPosition;
auto ptr = static_cast<const uint8_t*>(mBlob.GetBufferPointer());
auto ptr = mBlob.GetBufferPointer();
if (cb > maxRead)
{
const uint64_t pos = uint64_t(m_streamPosition) + uint64_t(maxRead);
@ -324,7 +324,7 @@ namespace
if (pos > UINT32_MAX)
return HRESULT_E_ARITHMETIC_OVERFLOW;
auto ptr = static_cast<uint8_t*>(mBlob.GetBufferPointer());
auto ptr = mBlob.GetBufferPointer();
memcpy(&ptr[m_streamPosition], pv, cb);
m_streamPosition = static_cast<size_t>(pos);
@ -347,7 +347,7 @@ namespace
if (blobSize >= size.LowPart)
{
auto ptr = static_cast<uint8_t*>(mBlob.GetBufferPointer());
auto ptr = mBlob.GetBufferPointer();
if (m_streamEOF < size.LowPart)
{
memset(&ptr[m_streamEOF], 0, size.LowPart - m_streamEOF);
@ -367,7 +367,7 @@ namespace
if (FAILED(hr))
return hr;
auto ptr = static_cast<uint8_t*>(mBlob.GetBufferPointer());
auto ptr = mBlob.GetBufferPointer();
if (m_streamEOF < size.LowPart)
{
memset(&ptr[m_streamEOF], 0, size.LowPart - m_streamEOF);
@ -1221,7 +1221,7 @@ namespace
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::GetMetadataFromWICMemory(
const void* pSource,
const uint8_t* pSource,
size_t size,
WIC_FLAGS flags,
TexMetadata& metadata,
@ -1244,7 +1244,7 @@ HRESULT DirectX::GetMetadataFromWICMemory(
if (FAILED(hr))
return hr;
hr = stream->InitializeFromMemory(static_cast<BYTE*>(const_cast<void*>(pSource)),
hr = stream->InitializeFromMemory(static_cast<BYTE*>(const_cast<uint8_t*>(pSource)),
static_cast<UINT>(size));
if (FAILED(hr))
return hr;
@ -1312,7 +1312,7 @@ HRESULT DirectX::GetMetadataFromWICFile(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::LoadFromWICMemory(
const void* pSource,
const uint8_t* pSource,
size_t size,
WIC_FLAGS flags,
TexMetadata* metadata,
@ -1338,7 +1338,7 @@ HRESULT DirectX::LoadFromWICMemory(
if (FAILED(hr))
return hr;
hr = stream->InitializeFromMemory(static_cast<uint8_t*>(const_cast<void*>(pSource)), static_cast<DWORD>(size));
hr = stream->InitializeFromMemory(static_cast<uint8_t*>(const_cast<uint8_t*>(pSource)), static_cast<DWORD>(size));
if (FAILED(hr))
return hr;

View File

@ -51,7 +51,7 @@ namespace DirectX
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif
DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS);
DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS)
#ifdef __clang__
#pragma clang diagnostic pop

View File

@ -65,7 +65,7 @@ namespace DirectX
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif
DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS);
DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS)
#ifdef __clang__
#pragma clang diagnostic pop

View File

@ -47,7 +47,7 @@ namespace DirectX
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif
DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS);
DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS)
#ifdef __clang__
#pragma clang diagnostic pop