1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-09-18 22:59:54 +00:00

.edtiorconfig driven reformat of source (#271)

This commit is contained in:
Chuck Walbourn 2022-04-04 15:03:02 -07:00 committed by GitHub
parent 091835fa86
commit b1001d15b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 5645 additions and 5531 deletions

View File

@ -1,9 +1,74 @@
root = true
[*.{cpp,h,inl,fx,hlsl}]
[*.{fx,fxh,hlsl,hlsli}]
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = crlf
charset = latin1
cpp_space_before_function_open_parenthesis = remove
cpp_space_around_binary_operator = ignore
cpp_space_pointer_reference_alignment = ignore
[*.{cpp,h,hpp,inl}]
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = crlf
charset = latin1
cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = false
cpp_indent_case_contents = true
cpp_indent_case_labels = false
cpp_indent_case_contents_when_block = true
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_preprocessor = one_left
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = true
cpp_indent_preserve_comments = true
cpp_new_line_before_open_brace_namespace = new_line
cpp_new_line_before_open_brace_type = new_line
cpp_new_line_before_open_brace_function = new_line
cpp_new_line_before_open_brace_block = new_line
cpp_new_line_before_open_brace_lambda = new_line
cpp_new_line_scope_braces_on_separate_lines = true
cpp_new_line_close_brace_same_line_empty_type = true
cpp_new_line_close_brace_same_line_empty_function = true
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
cpp_new_line_before_while_in_do_while = true
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = false
cpp_space_between_empty_parameter_list_parentheses = false
cpp_space_after_keywords_in_control_flow_statements = true
cpp_space_within_control_flow_statement_parentheses = false
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = false
cpp_space_after_cast_close_parenthesis = false
cpp_space_within_expression_parentheses = false
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = true
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = false
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = true
cpp_space_before_constructor_colon = true
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = false
cpp_space_remove_around_unary_operator = false
cpp_space_around_binary_operator = ignore
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = ignore
cpp_space_around_ternary_operator = insert
cpp_wrap_preserve_blocks = one_liners

View File

@ -43,7 +43,7 @@ using namespace DirectX;
// Macros
//--------------------------------------------------------------------------------------
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
#endif /* defined(MAKEFOURCC) */
@ -136,7 +136,7 @@ namespace
inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char (&name)[TNameLength]) noexcept
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength]) noexcept
{
#if defined(_DEBUG) || defined(PROFILE)
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
@ -229,13 +229,13 @@ namespace
*bitSize = 0;
// open the file
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
ScopedHandle hFile(safe_handle(CreateFile2(fileName,
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
nullptr)));
#else
#else
ScopedHandle hFile(safe_handle(CreateFileW(fileName,
GENERIC_READ,
FILE_SHARE_READ,
@ -243,7 +243,7 @@ namespace
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr)));
#endif
#endif
if (!hFile)
{
@ -611,13 +611,13 @@ namespace
numBytes = rowBytes * height;
}
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!");
if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX)
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
#else
#else
static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!");
#endif
#endif
if (outNumBytes)
{
@ -637,7 +637,7 @@ namespace
//--------------------------------------------------------------------------------------
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
DXGI_FORMAT GetDXGIFormat(const DDS_PIXELFORMAT& ddpf) noexcept
{
@ -904,10 +904,10 @@ namespace
return DXGI_FORMAT_UNKNOWN;
}
#undef ISBITMASK
#undef ISBITMASK
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) noexcept
{
switch (format)
@ -1682,7 +1682,7 @@ namespace
_In_opt_ ID3D11Resource** texture,
_In_opt_ ID3D11ShaderResourceView** textureView) noexcept
{
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
if (texture || textureView)
{
CHAR strFileA[MAX_PATH];
@ -1724,11 +1724,11 @@ namespace
}
}
}
#else
#else
UNREFERENCED_PARAMETER(fileName);
UNREFERENCED_PARAMETER(texture);
UNREFERENCED_PARAMETER(textureView);
#endif
#endif
}
} // anonymous namespace

View File

@ -59,7 +59,7 @@ using namespace DirectX;
// Macros
//--------------------------------------------------------------------------------------
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
#endif /* defined(MAKEFOURCC) */
@ -274,7 +274,7 @@ namespace
*bitSize = 0;
#ifdef WIN32
#ifdef WIN32
// open the file
ScopedHandle hFile(safe_handle(CreateFile2(fileName,
GENERIC_READ,
@ -334,7 +334,7 @@ namespace
size_t len = fileInfo.EndOfFile.LowPart;
#else // !WIN32
#else // !WIN32
std::ifstream inFile(std::filesystem::path(fileName), std::ios::in | std::ios::binary | std::ios::ate);
if (!inFile)
return E_FAIL;
@ -368,7 +368,7 @@ namespace
inFile.close();
size_t len = fileLen;
#endif
#endif
// DDS files always start with the same magic number ("DDS ")
auto const dwMagicNumber = *reinterpret_cast<const uint32_t*>(ddsData.get());
@ -690,13 +690,13 @@ namespace
numBytes = rowBytes * height;
}
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!");
if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX)
return HRESULT_E_ARITHMETIC_OVERFLOW;
#else
#else
static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!");
#endif
#endif
if (outNumBytes)
{
@ -716,7 +716,7 @@ namespace
//--------------------------------------------------------------------------------------
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
DXGI_FORMAT GetDXGIFormat(const DDS_PIXELFORMAT& ddpf) noexcept
{
@ -983,10 +983,10 @@ namespace
return DXGI_FORMAT_UNKNOWN;
}
#undef ISBITMASK
#undef ISBITMASK
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) noexcept
{
switch (format)
@ -1503,15 +1503,15 @@ namespace
}
//--------------------------------------------------------------------------------------
DDS_ALPHA_MODE GetAlphaMode( _In_ const DDS_HEADER* header ) noexcept
DDS_ALPHA_MODE GetAlphaMode(_In_ const DDS_HEADER* header) noexcept
{
if ( header->ddspf.flags & DDS_FOURCC )
if (header->ddspf.flags & DDS_FOURCC)
{
if ( MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC )
if (MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC)
{
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>(reinterpret_cast<const uint8_t*>(header) + sizeof(DDS_HEADER));
auto const mode = static_cast<DDS_ALPHA_MODE>( d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK );
switch( mode )
auto const mode = static_cast<DDS_ALPHA_MODE>(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK);
switch (mode)
{
case DDS_ALPHA_MODE_STRAIGHT:
case DDS_ALPHA_MODE_PREMULTIPLIED:
@ -1524,8 +1524,8 @@ namespace
break;
}
}
else if ( ( MAKEFOURCC( 'D', 'X', 'T', '2' ) == header->ddspf.fourCC )
|| ( MAKEFOURCC( 'D', 'X', 'T', '4' ) == header->ddspf.fourCC ) )
else if ((MAKEFOURCC('D', 'X', 'T', '2') == header->ddspf.fourCC)
|| (MAKEFOURCC('D', 'X', 'T', '4') == header->ddspf.fourCC))
{
return DDS_ALPHA_MODE_PREMULTIPLIED;
}
@ -1539,7 +1539,7 @@ namespace
_In_z_ const wchar_t* fileName,
_In_ ID3D12Resource** texture) noexcept
{
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
if (texture && *texture)
{
const wchar_t* pstrName = wcsrchr(fileName, '\\');
@ -1554,10 +1554,10 @@ namespace
(*texture)->SetName(pstrName);
}
#else
#else
UNREFERENCED_PARAMETER(fileName);
UNREFERENCED_PARAMETER(texture);
#endif
#endif
}
} // anonymous namespace

View File

@ -47,7 +47,7 @@ using Microsoft::WRL::ComPtr;
// Macros
//--------------------------------------------------------------------------------------
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
#endif /* defined(MAKEFOURCC) */
@ -199,13 +199,13 @@ namespace
*bitSize = 0;
// open the file
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
ScopedHandle hFile(safe_handle(CreateFile2(fileName,
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
nullptr)));
#else
#else
ScopedHandle hFile(safe_handle(CreateFileW(fileName,
GENERIC_READ,
FILE_SHARE_READ,
@ -213,7 +213,7 @@ namespace
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr)));
#endif
#endif
if (!hFile)
{
@ -338,9 +338,9 @@ namespace
case D3DFMT_INDEX32:
case D3DFMT_G16R16F:
case D3DFMT_R32F:
#if !defined(D3D_DISABLE_9EX)
#if !defined(D3D_DISABLE_9EX)
case D3DFMT_D32_LOCKABLE:
#endif
#endif
return 32;
case D3DFMT_R8G8B8:
@ -383,9 +383,9 @@ namespace
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/directxvideoaccelerationdxvavideosubtypes.asp
case MAKEFOURCC('A', 'I', '4', '4'):
case MAKEFOURCC('I', 'A', '4', '4'):
#if !defined(D3D_DISABLE_9EX)
#if !defined(D3D_DISABLE_9EX)
case D3DFMT_S8_LOCKABLE:
#endif
#endif
return 8;
case D3DFMT_DXT1:
@ -394,10 +394,10 @@ namespace
case MAKEFOURCC('Y', 'V', '1', '2'):
return 12;
#if !defined(D3D_DISABLE_9EX)
#if !defined(D3D_DISABLE_9EX)
case D3DFMT_A1:
return 1;
#endif
#endif
default:
return 0;
@ -483,13 +483,13 @@ namespace
numBytes = rowBytes * height;
}
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!");
if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX)
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
#else
#else
static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!");
#endif
#endif
if (outNumBytes)
{
@ -509,7 +509,7 @@ namespace
//--------------------------------------------------------------------------------------
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
D3DFORMAT GetD3D9Format(const DDS_PIXELFORMAT& ddpf) noexcept
{
@ -766,10 +766,10 @@ namespace
return D3DFMT_UNKNOWN;
}
#undef ISBITMASK
#undef ISBITMASK
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
HRESULT CreateTextureFromDDS(
_In_ LPDIRECT3DDEVICE9 device,
_In_ const DDS_HEADER* header,

View File

@ -84,9 +84,9 @@ namespace
for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++)
{
#ifdef COLOR_WEIGHTS
#ifdef COLOR_WEIGHTS
if (pPoints[iPoint].a > 0.0f)
#endif // COLOR_WEIGHTS
#endif // COLOR_WEIGHTS
{
if (pPoints[iPoint].r < X.r)
X.r = pPoints[iPoint].r;
@ -144,7 +144,7 @@ namespace
float f;
#ifdef COLOR_WEIGHTS
#ifdef COLOR_WEIGHTS
f = Pt.r + Pt.g + Pt.b;
fDir[0] += pPoints[iPoint].a * f * f;
@ -156,7 +156,7 @@ namespace
f = Pt.r - Pt.g - Pt.b;
fDir[3] += pPoints[iPoint].a * f * f;
#else
#else
f = Pt.r + Pt.g + Pt.b;
fDir[0] += f * f;
@ -168,7 +168,7 @@ namespace
f = Pt.r - Pt.g - Pt.b;
fDir[3] += f * f;
#endif // COLOR_WEIGHTS
#endif // COLOR_WEIGHTS
}
float fDirMax = fDir[0];
@ -264,13 +264,13 @@ namespace
Diff.b = pSteps[iStep].b - pPoints[iPoint].b;
Diff.a = 0.0f;
#ifdef COLOR_WEIGHTS
#ifdef COLOR_WEIGHTS
const float fC = pC[iStep] * pPoints[iPoint].a * (1.0f / 8.0f);
const float fD = pD[iStep] * pPoints[iPoint].a * (1.0f / 8.0f);
#else
#else
const float fC = pC[iStep] * (1.0f / 8.0f);
const float fD = pD[iStep] * (1.0f / 8.0f);
#endif // COLOR_WEIGHTS
#endif // COLOR_WEIGHTS
d2X += fC * pC[iStep];
dX.r += fC * Diff.r;
@ -434,11 +434,11 @@ namespace
Color[i].g = static_cast<float>(static_cast<int32_t>(Clr.g * 63.0f + 0.5f)) * (1.0f / 63.0f);
Color[i].b = static_cast<float>(static_cast<int32_t>(Clr.b * 31.0f + 0.5f)) * (1.0f / 31.0f);
#ifdef COLOR_WEIGHTS
#ifdef COLOR_WEIGHTS
Color[i].a = pColor[i].a;
#else
#else
Color[i].a = 1.0f;
#endif // COLOR_WEIGHTS
#endif // COLOR_WEIGHTS
if (flags & BC_FLAGS_DITHER_RGB)
{
@ -688,7 +688,7 @@ namespace
#ifdef COLOR_WEIGHTS
void EncodeSolidBC1(_Out_ D3DX_BC1 *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor)
{
#ifdef COLOR_AVG_0WEIGHTS
#ifdef COLOR_AVG_0WEIGHTS
// Compute avg color
HDRColorA Color;
Color.r = pColor[0].r;
@ -707,9 +707,9 @@ namespace
Color.b *= 1.0f / 16.0f;
const uint16_t wColor = Encode565(&Color);
#else
#else
const uint16_t wColor = 0x0000;
#endif // COLOR_AVG_0WEIGHTS
#endif // COLOR_AVG_0WEIGHTS
// Encode solid block
pBC->rgb[0] = wColor;
@ -814,7 +814,7 @@ void DirectX::D3DXDecodeBC2(XMVECTOR *pColor, const uint8_t *pBC) noexcept
for (size_t i = 0; i < 8; ++i, dw >>= 4)
{
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
pColor[i] = XMVectorSetW(pColor[i], static_cast<float>(dw & 0xf) * (1.0f / 15.0f));
}

View File

@ -27,27 +27,37 @@ namespace DirectX
// Constants
//-------------------------------------------------------------------------------------
enum BC_FLAGS : uint32_t
{
enum BC_FLAGS : uint32_t
{
BC_FLAGS_NONE = 0x0,
BC_FLAGS_DITHER_RGB = 0x10000, // Enables dithering for RGB colors for BC1-3
BC_FLAGS_DITHER_A = 0x20000, // Enables dithering for Alpha channel for BC1-3
BC_FLAGS_UNIFORM = 0x40000, // By default, uses perceptual weighting for BC1-3; this flag makes it a uniform weighting
BC_FLAGS_USE_3SUBSETS = 0x80000, // By default, BC7 skips mode 0 & 2; this flag adds those modes back
BC_FLAGS_FORCE_BC7_MODE6 = 0x100000, // BC7 should only use mode 6; skip other modes
};
//-------------------------------------------------------------------------------------
// Structures
//-------------------------------------------------------------------------------------
class LDRColorA;
BC_FLAGS_DITHER_RGB = 0x10000,
// Enables dithering for RGB colors for BC1-3
class HDRColorA
{
public:
BC_FLAGS_DITHER_A = 0x20000,
// Enables dithering for Alpha channel for BC1-3
BC_FLAGS_UNIFORM = 0x40000,
// By default, uses perceptual weighting for BC1-3; this flag makes it a uniform weighting
BC_FLAGS_USE_3SUBSETS = 0x80000,
// By default, BC7 skips mode 0 & 2; this flag adds those modes back
BC_FLAGS_FORCE_BC7_MODE6 = 0x100000,
// BC7 should only use mode 6; skip other modes
};
//-------------------------------------------------------------------------------------
// Structures
//-------------------------------------------------------------------------------------
class LDRColorA;
class HDRColorA
{
public:
float r, g, b, a;
public:
public:
HDRColorA() = default;
HDRColorA(float _r, float _g, float _b, float _a) noexcept : r(_r), g(_g), b(_b), a(_a) {}
HDRColorA(const HDRColorA& c) noexcept : r(c.r), g(c.g), b(c.b), a(c.a) {}
@ -129,39 +139,39 @@ public:
HDRColorA(const LDRColorA& c) noexcept;
HDRColorA& operator = (const LDRColorA& c) noexcept;
LDRColorA ToLDRColorA() const noexcept;
};
};
inline HDRColorA* HDRColorALerp(_Out_ HDRColorA *pOut, _In_ const HDRColorA *pC1, _In_ const HDRColorA *pC2, _In_ float s) noexcept
{
inline HDRColorA* HDRColorALerp(_Out_ HDRColorA *pOut, _In_ const HDRColorA *pC1, _In_ const HDRColorA *pC2, _In_ float s) noexcept
{
pOut->r = pC1->r + s * (pC2->r - pC1->r);
pOut->g = pC1->g + s * (pC2->g - pC1->g);
pOut->b = pC1->b + s * (pC2->b - pC1->b);
pOut->a = pC1->a + s * (pC2->a - pC1->a);
return pOut;
}
}
#pragma pack(push,1)
// BC1/DXT1 compression (4 bits per texel)
struct D3DX_BC1
{
struct D3DX_BC1
{
uint16_t rgb[2]; // 565 colors
uint32_t bitmap; // 2bpp rgb bitmap
};
};
// BC2/DXT2/3 compression (8 bits per texel)
struct D3DX_BC2
{
// BC2/DXT2/3 compression (8 bits per texel)
struct D3DX_BC2
{
uint32_t bitmap[2]; // 4bpp alpha bitmap
D3DX_BC1 bc1; // BC1 rgb data
};
};
// BC3/DXT4/5 compression (8 bits per texel)
struct D3DX_BC3
{
// BC3/DXT4/5 compression (8 bits per texel)
struct D3DX_BC3
{
uint8_t alpha[2]; // alpha values
uint8_t bitmap[6]; // 3bpp alpha bitmap
D3DX_BC1 bc1; // BC1 rgb data
};
};
#pragma pack(pop)
//-------------------------------------------------------------------------------------
@ -169,8 +179,8 @@ struct D3DX_BC3
//-------------------------------------------------------------------------------------
#pragma warning(push)
#pragma warning(disable : 4127)
template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPoints, uint32_t cSteps) noexcept
{
template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPoints, uint32_t cSteps) noexcept
{
static const float pC6[] = { 5.0f / 5.0f, 4.0f / 5.0f, 3.0f / 5.0f, 2.0f / 5.0f, 1.0f / 5.0f, 0.0f / 5.0f };
static const float pD6[] = { 0.0f / 5.0f, 1.0f / 5.0f, 2.0f / 5.0f, 3.0f / 5.0f, 4.0f / 5.0f, 5.0f / 5.0f };
static const float pC8[] = { 7.0f / 7.0f, 6.0f / 7.0f, 5.0f / 7.0f, 4.0f / 7.0f, 3.0f / 7.0f, 2.0f / 7.0f, 1.0f / 7.0f, 0.0f / 7.0f };
@ -293,38 +303,38 @@ template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPo
*pX = (fX < MIN_VALUE) ? MIN_VALUE : (fX > MAX_VALUE) ? MAX_VALUE : fX;
*pY = (fY < MIN_VALUE) ? MIN_VALUE : (fY > MAX_VALUE) ? MAX_VALUE : fY;
}
}
#pragma warning(pop)
//-------------------------------------------------------------------------------------
// Functions
//-------------------------------------------------------------------------------------
typedef void (*BC_DECODE)(XMVECTOR *pColor, const uint8_t *pBC);
typedef void (*BC_ENCODE)(uint8_t *pDXT, const XMVECTOR *pColor, uint32_t flags);
typedef void (*BC_DECODE)(XMVECTOR *pColor, const uint8_t *pBC);
typedef void (*BC_ENCODE)(uint8_t *pDXT, const XMVECTOR *pColor, uint32_t flags);
void D3DXDecodeBC1(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC2(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC3(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC4U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC4S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC5U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC5S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC6HU(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC6HS(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC7(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC1(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC2(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC3(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC4U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC4S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept;
void D3DXDecodeBC5U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC5S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC6HU(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC6HS(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXDecodeBC7(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept;
void D3DXEncodeBC1(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float threshold, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC1(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float threshold, _In_ uint32_t flags) noexcept;
// BC1 requires one additional parameter, so it doesn't match signature of BC_ENCODE above
void D3DXEncodeBC2(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC3(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC4U(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC4S(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC5U(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC5S(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC6HU(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC6HS(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC7(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC2(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC3(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC4U(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC4S(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC5U(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC5S(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC6HU(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC6HS(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
void D3DXEncodeBC7(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept;
} // namespace

View File

@ -395,7 +395,7 @@ void DirectX::D3DXDecodeBC4U(XMVECTOR *pColor, const uint8_t *pBC) noexcept
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
pColor[i] = XMVectorSet(pBC4->R(i), 0, 0, 1.0f);
}
}
@ -410,7 +410,7 @@ void DirectX::D3DXDecodeBC4S(XMVECTOR *pColor, const uint8_t *pBC) noexcept
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
pColor[i] = XMVectorSet(pBC4->R(i), 0, 0, 1.0f);
}
}
@ -472,7 +472,7 @@ void DirectX::D3DXDecodeBC5U(XMVECTOR *pColor, const uint8_t *pBC) noexcept
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
pColor[i] = XMVectorSet(pBCR->R(i), pBCG->R(i), 0, 1.0f);
}
}
@ -488,7 +488,7 @@ void DirectX::D3DXDecodeBC5S(XMVECTOR *pColor, const uint8_t *pBC) noexcept
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22103, "writing blocks in two halves confuses tool")
pColor[i] = XMVectorSet(pBCR->R(i), pBCG->R(i), 0, 1.0f);
}
}

View File

@ -660,8 +660,8 @@ namespace
void Encode(_In_ bool bSigned, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn) noexcept;
private:
#pragma warning(push)
#pragma warning(disable : 4480)
#pragma warning(push)
#pragma warning(disable : 4480)
enum EField : uint8_t
{
NA, // N/A
@ -680,7 +680,7 @@ namespace
BY,
BZ,
};
#pragma warning(pop)
#pragma warning(pop)
struct ModeDescriptor
{
@ -697,8 +697,8 @@ namespace
LDRColorA RGBAPrec[BC6H_MAX_REGIONS][2];
};
#pragma warning(push)
#pragma warning(disable : 4512)
#pragma warning(push)
#pragma warning(disable : 4512)
struct EncodeParams
{
float fBestErr;
@ -718,7 +718,7 @@ namespace
}
}
};
#pragma warning(pop)
#pragma warning(pop)
static int Quantize(_In_ int iValue, _In_ int prec, _In_ bool bSigned) noexcept;
static int Unquantize(_In_ int comp, _In_ uint8_t uBitsPerComp, _In_ bool bSigned) noexcept;
@ -777,8 +777,8 @@ namespace
LDRColorA RGBAPrecWithP;
};
#pragma warning(push)
#pragma warning(disable : 4512)
#pragma warning(push)
#pragma warning(disable : 4512)
struct EncodeParams
{
uint8_t uMode;
@ -788,7 +788,7 @@ namespace
EncodeParams(const HDRColorA* const aOriginal) noexcept : uMode(0), aEndPts{}, aLDRPixels{}, aHDRPixels(aOriginal) {}
};
#pragma warning(pop)
#pragma warning(pop)
static uint8_t Quantize(_In_ uint8_t comp, _In_ uint8_t uPrec) noexcept
{
@ -1035,20 +1035,20 @@ const D3DX_BC6H::ModeDescriptor D3DX_BC6H::ms_aDesc[14][82] =
// Mode, Partitions, Transformed, IndexPrec, RGBAPrec
const D3DX_BC6H::ModeInfo D3DX_BC6H::ms_aInfo[] =
{
{0x00, 1, true, 3, { { LDRColorA(10,10,10,0), LDRColorA( 5, 5, 5,0) }, { LDRColorA(5,5,5,0), LDRColorA(5,5,5,0) } } }, // Mode 1
{0x01, 1, true, 3, { { LDRColorA( 7, 7, 7,0), LDRColorA( 6, 6, 6,0) }, { LDRColorA(6,6,6,0), LDRColorA(6,6,6,0) } } }, // Mode 2
{0x02, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA( 5, 4, 4,0) }, { LDRColorA(5,4,4,0), LDRColorA(5,4,4,0) } } }, // Mode 3
{0x06, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA( 4, 5, 4,0) }, { LDRColorA(4,5,4,0), LDRColorA(4,5,4,0) } } }, // Mode 4
{0x0a, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA( 4, 4, 5,0) }, { LDRColorA(4,4,5,0), LDRColorA(4,4,5,0) } } }, // Mode 5
{0x0e, 1, true, 3, { { LDRColorA( 9, 9, 9,0), LDRColorA( 5, 5, 5,0) }, { LDRColorA(5,5,5,0), LDRColorA(5,5,5,0) } } }, // Mode 6
{0x12, 1, true, 3, { { LDRColorA( 8, 8, 8,0), LDRColorA( 6, 5, 5,0) }, { LDRColorA(6,5,5,0), LDRColorA(6,5,5,0) } } }, // Mode 7
{0x16, 1, true, 3, { { LDRColorA( 8, 8, 8,0), LDRColorA( 5, 6, 5,0) }, { LDRColorA(5,6,5,0), LDRColorA(5,6,5,0) } } }, // Mode 8
{0x1a, 1, true, 3, { { LDRColorA( 8, 8, 8,0), LDRColorA( 5, 5, 6,0) }, { LDRColorA(5,5,6,0), LDRColorA(5,5,6,0) } } }, // Mode 9
{0x1e, 1, false, 3, { { LDRColorA( 6, 6, 6,0), LDRColorA( 6, 6, 6,0) }, { LDRColorA(6,6,6,0), LDRColorA(6,6,6,0) } } }, // Mode 10
{0x00, 1, true, 3, { { LDRColorA(10,10,10,0), LDRColorA(5, 5, 5,0) }, { LDRColorA(5,5,5,0), LDRColorA(5,5,5,0) } } }, // Mode 1
{0x01, 1, true, 3, { { LDRColorA(7, 7, 7,0), LDRColorA(6, 6, 6,0) }, { LDRColorA(6,6,6,0), LDRColorA(6,6,6,0) } } }, // Mode 2
{0x02, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA(5, 4, 4,0) }, { LDRColorA(5,4,4,0), LDRColorA(5,4,4,0) } } }, // Mode 3
{0x06, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA(4, 5, 4,0) }, { LDRColorA(4,5,4,0), LDRColorA(4,5,4,0) } } }, // Mode 4
{0x0a, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA(4, 4, 5,0) }, { LDRColorA(4,4,5,0), LDRColorA(4,4,5,0) } } }, // Mode 5
{0x0e, 1, true, 3, { { LDRColorA(9, 9, 9,0), LDRColorA(5, 5, 5,0) }, { LDRColorA(5,5,5,0), LDRColorA(5,5,5,0) } } }, // Mode 6
{0x12, 1, true, 3, { { LDRColorA(8, 8, 8,0), LDRColorA(6, 5, 5,0) }, { LDRColorA(6,5,5,0), LDRColorA(6,5,5,0) } } }, // Mode 7
{0x16, 1, true, 3, { { LDRColorA(8, 8, 8,0), LDRColorA(5, 6, 5,0) }, { LDRColorA(5,6,5,0), LDRColorA(5,6,5,0) } } }, // Mode 8
{0x1a, 1, true, 3, { { LDRColorA(8, 8, 8,0), LDRColorA(5, 5, 6,0) }, { LDRColorA(5,5,6,0), LDRColorA(5,5,6,0) } } }, // Mode 9
{0x1e, 1, false, 3, { { LDRColorA(6, 6, 6,0), LDRColorA(6, 6, 6,0) }, { LDRColorA(6,6,6,0), LDRColorA(6,6,6,0) } } }, // Mode 10
{0x03, 0, false, 4, { { LDRColorA(10,10,10,0), LDRColorA(10,10,10,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 11
{0x07, 0, true, 4, { { LDRColorA(11,11,11,0), LDRColorA( 9, 9, 9,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 12
{0x0b, 0, true, 4, { { LDRColorA(12,12,12,0), LDRColorA( 8, 8, 8,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 13
{0x0f, 0, true, 4, { { LDRColorA(16,16,16,0), LDRColorA( 4, 4, 4,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 14
{0x07, 0, true, 4, { { LDRColorA(11,11,11,0), LDRColorA(9, 9, 9,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 12
{0x0b, 0, true, 4, { { LDRColorA(12,12,12,0), LDRColorA(8, 8, 8,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 13
{0x0f, 0, true, 4, { { LDRColorA(16,16,16,0), LDRColorA(4, 4, 4,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 14
};
const int D3DX_BC6H::ms_aModeToInfo[] =
@ -1628,13 +1628,13 @@ namespace
{
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{
#ifdef _DEBUG
#ifdef _DEBUG
// Use Magenta in debug as a highly-visible error color
pOut[i] = HDRColorA(1.0f, 0.0f, 1.0f, 1.0f);
#else
#else
// In production use, default to black
pOut[i] = HDRColorA(0.0f, 0.0f, 0.0f, 1.0f);
#endif
#endif
}
}
}
@ -1695,9 +1695,9 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const noexcept
case BZ: aEndPts[1].B.b |= 1 << uint32_t(desc[uCurBit].m_uBit); break;
default:
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC6H: Invalid header bits encountered during decoding\n");
#endif
#endif
FillWithErrorColors(pOut);
return;
}
@ -1739,9 +1739,9 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const noexcept
const size_t uNumBits = IsFixUpOffset(info.uPartitions, uShape, i) ? info.uIndexPrec - 1u : info.uIndexPrec;
if (uStartBit + uNumBits > 128)
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC6H: Invalid block encountered during decoding\n");
#endif
#endif
FillWithErrorColors(pOut);
return;
}
@ -1749,9 +1749,9 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const noexcept
if (uIndex >= ((info.uPartitions > 0) ? 8 : 16))
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC6H: Invalid index encountered during decoding\n");
#endif
#endif
FillWithErrorColors(pOut);
return;
}
@ -1784,7 +1784,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const noexcept
}
else
{
#ifdef _DEBUG
#ifdef _DEBUG
const char* warnstr = "BC6H: Invalid mode encountered during decoding\n";
switch (uMode)
{
@ -1794,7 +1794,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const noexcept
case 0x1F: warnstr = "BC6H: Reserved mode 11111 encountered during decoding\n"; break;
}
OutputDebugStringA(warnstr);
#endif
#endif
// Per the BC6H format spec, we must return opaque black
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{
@ -2003,7 +2003,7 @@ void D3DX_BC6H::GeneratePaletteQuantized(const EncodeParams* pEP, const INTEndPn
assert(false);
for (size_t i = 0; i < uNumIndices; ++i)
{
#pragma prefast(suppress:22102 22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22102 22103, "writing blocks in two halves confuses tool")
aPalette[i] = INTColor(0, 0, 0);
}
return;
@ -2409,7 +2409,7 @@ void D3DX_BC6H::GeneratePaletteUnquantized(const EncodeParams* pEP, size_t uRegi
assert(false);
for (size_t i = 0; i < uNumIndices; ++i)
{
#pragma prefast(suppress:22102 22103, "writing blocks in two halves confuses tool")
#pragma prefast(suppress:22102 22103, "writing blocks in two halves confuses tool")
aPalette[i] = INTColor(0, 0, 0);
}
return;
@ -2558,9 +2558,9 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept
{
if (uStartBit + RGBAPrec.r > 128)
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC7: Invalid block encountered during decoding\n");
#endif
#endif
FillWithErrorColors(pOut);
return;
}
@ -2573,9 +2573,9 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept
{
if (uStartBit + RGBAPrec.g > 128)
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC7: Invalid block encountered during decoding\n");
#endif
#endif
FillWithErrorColors(pOut);
return;
}
@ -2588,9 +2588,9 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept
{
if (uStartBit + RGBAPrec.b > 128)
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC7: Invalid block encountered during decoding\n");
#endif
#endif
FillWithErrorColors(pOut);
return;
}
@ -2603,9 +2603,9 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept
{
if (uStartBit + RGBAPrec.a > 128)
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC7: Invalid block encountered during decoding\n");
#endif
#endif
FillWithErrorColors(pOut);
return;
}
@ -2620,9 +2620,9 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept
{
if (uStartBit > 127)
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC7: Invalid block encountered during decoding\n");
#endif
#endif
FillWithErrorColors(pOut);
return;
}
@ -2658,9 +2658,9 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept
const size_t uNumBits = IsFixUpOffset(ms_aInfo[uMode].uPartitions, uShape, i) ? uIndexPrec - 1u : uIndexPrec;
if (uStartBit + uNumBits > 128)
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC7: Invalid block encountered during decoding\n");
#endif
#endif
FillWithErrorColors(pOut);
return;
}
@ -2675,9 +2675,9 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept
const size_t uNumBits = i ? uIndexPrec2 : uIndexPrec2 - 1u;
if (uStartBit + uNumBits > 128)
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC7: Invalid block encountered during decoding\n");
#endif
#endif
FillWithErrorColors(pOut);
return;
}
@ -2717,9 +2717,9 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept
}
else
{
#ifdef _DEBUG
#ifdef _DEBUG
OutputDebugStringA("BC7: Reserved mode 8 encountered during decoding\n");
#endif
#endif
// Per the BC7 format spec, we must return transparent black
memset(pOut, 0, sizeof(HDRColorA) * NUM_PIXELS_PER_BLOCK);
}
@ -3201,7 +3201,7 @@ void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotatio
for (i = 0; i < uPBits; i++)
{
SetBits(uStartBit, 1, aPVote[i] > (aCount[i] >> 1) ? 1u : 0u);
SetBits(uStartBit, 1, (aPVote[i] >(aCount[i] >> 1)) ? 1u : 0u);
}
}
else

View File

@ -20,13 +20,13 @@ using Microsoft::WRL::ComPtr;
namespace
{
#include "BC7Encode_EncodeBlockCS.inc"
#include "BC7Encode_TryMode02CS.inc"
#include "BC7Encode_TryMode137CS.inc"
#include "BC7Encode_TryMode456CS.inc"
#include "BC6HEncode_EncodeBlockCS.inc"
#include "BC6HEncode_TryModeG10CS.inc"
#include "BC6HEncode_TryModeLE10CS.inc"
#include "BC7Encode_EncodeBlockCS.inc"
#include "BC7Encode_TryMode02CS.inc"
#include "BC7Encode_TryMode137CS.inc"
#include "BC7Encode_TryMode456CS.inc"
#include "BC6HEncode_EncodeBlockCS.inc"
#include "BC6HEncode_TryModeG10CS.inc"
#include "BC6HEncode_TryModeLE10CS.inc"
struct BufferBC6HBC7
{

View File

@ -25,10 +25,10 @@ namespace DirectX
#pragma pack(push,1)
constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS "
constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS "
struct DDS_PIXELFORMAT
{
struct DDS_PIXELFORMAT
{
uint32_t size;
uint32_t flags;
uint32_t fourCC;
@ -37,7 +37,7 @@ struct DDS_PIXELFORMAT
uint32_t GBitMask;
uint32_t BBitMask;
uint32_t ABitMask;
};
};
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
#define DDS_RGB 0x00000040 // DDPF_RGB
@ -52,7 +52,7 @@ struct DDS_PIXELFORMAT
// DDS_BUMPLUMINANCE 0x00040000
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
(static_cast<uint32_t>(static_cast<uint8_t>(ch0)) \
| (static_cast<uint32_t>(static_cast<uint8_t>(ch1)) << 8) \
| (static_cast<uint32_t>(static_cast<uint8_t>(ch2)) << 16) \
@ -60,131 +60,131 @@ struct DDS_PIXELFORMAT
#endif /* MAKEFOURCC */
#ifndef DDSGLOBALCONST
#if defined(__GNUC__) && !defined(__MINGW32__)
#define DDSGLOBALCONST extern const __attribute__((weak))
#else
#define DDSGLOBALCONST extern const __declspec(selectany)
#endif
#if defined(__GNUC__) && !defined(__MINGW32__)
#define DDSGLOBALCONST extern const __attribute__((weak))
#else
#define DDSGLOBALCONST extern const __declspec(selectany)
#endif
#endif /* DDSGLOBALCONST */
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT1 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT1 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT2 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT2 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT3 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT3 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT4 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT4 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT5 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT5 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_UNORM =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_UNORM =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_SNORM =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_SNORM =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_UNORM =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_UNORM =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_SNORM =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_SNORM =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8_B8G8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8_B8G8 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G8R8_G8B8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G8R8_G8B8 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_YUY2 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_YUY2 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_UYVY =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_UYVY =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8R8G8B8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8R8G8B8 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8B8G8R8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8B8G8R8 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8B8G8R8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8B8G8R8 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G16R16 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G16R16 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R5G6B5 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R5G6B5 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X1R5G5B5 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X1R5G5B5 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x7c00, 0x03e0, 0x001f, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X4R4G4B4 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X4R4G4B4 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0f00, 0x00f0, 0x000f, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8B8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8B8 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0xff0000, 0x00ff00, 0x0000ff, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R3G3B2 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R3G3B2 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00e0, 0x001c, 0x0003, 0xff00 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R3G3B2 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R3G3B2 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xe0, 0x1c, 0x03, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4L4 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4L4 =
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x0f, 0, 0, 0xf0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8 =
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16 =
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8 =
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0, 0, 0xff00 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_ALT =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_ALT =
{ sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x00ff, 0, 0, 0xff00 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8_NVTT1 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8_NVTT1 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xff, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16_NVTT1 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16_NVTT1 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xffff, 0, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_NVTT1 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_NVTT1 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00ff, 0, 0, 0xff00 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8 =
{ sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0, 0, 0, 0xff };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V8U8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V8U8 =
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_Q8W8V8U8 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_Q8W8V8U8 =
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V16U16 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V16U16 =
{ sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 };
// D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2R10G10B10 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2R10G10B10 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000 };
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2B10G10R10 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2B10G10R10 =
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000 };
// We do not support the following legacy Direct3D 9 formats:
@ -193,7 +193,7 @@ DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2B10G10R10 =
// DDSPF_X8L8V8U8 = { sizeof(DDS_PIXELFORMAT), DDS_BUMPLUMINANCE, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 };
// This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat)
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DX10 =
DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DX10 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 };
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
@ -225,38 +225,38 @@ DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DX10 =
#define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME
// Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION
enum DDS_RESOURCE_DIMENSION : uint32_t
{
enum DDS_RESOURCE_DIMENSION : uint32_t
{
DDS_DIMENSION_TEXTURE1D = 2,
DDS_DIMENSION_TEXTURE2D = 3,
DDS_DIMENSION_TEXTURE3D = 4,
};
};
// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
enum DDS_RESOURCE_MISC_FLAG : uint32_t
{
// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
enum DDS_RESOURCE_MISC_FLAG : uint32_t
{
DDS_RESOURCE_MISC_TEXTURECUBE = 0x4L,
};
};
enum DDS_MISC_FLAGS2 : uint32_t
{
enum DDS_MISC_FLAGS2 : uint32_t
{
DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L,
};
};
#ifndef DDS_ALPHA_MODE_DEFINED
#define DDS_ALPHA_MODE_DEFINED
enum DDS_ALPHA_MODE : uint32_t
{
enum DDS_ALPHA_MODE : uint32_t
{
DDS_ALPHA_MODE_UNKNOWN = 0,
DDS_ALPHA_MODE_STRAIGHT = 1,
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
DDS_ALPHA_MODE_OPAQUE = 3,
DDS_ALPHA_MODE_CUSTOM = 4,
};
};
#endif
struct DDS_HEADER
{
struct DDS_HEADER
{
uint32_t size;
uint32_t flags;
uint32_t height;
@ -271,20 +271,20 @@ struct DDS_HEADER
uint32_t caps3;
uint32_t caps4;
uint32_t reserved2;
};
};
struct DDS_HEADER_DXT10
{
struct DDS_HEADER_DXT10
{
DXGI_FORMAT dxgiFormat;
uint32_t resourceDimension;
uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG
uint32_t arraySize;
uint32_t miscFlags2; // see DDS_MISC_FLAGS2
};
};
#pragma pack(pop)
static_assert( sizeof(DDS_HEADER) == 124, "DDS Header size mismatch" );
static_assert( sizeof(DDS_HEADER_DXT10) == 20, "DDS DX10 Extended Header size mismatch");
static_assert(sizeof(DDS_HEADER) == 124, "DDS Header size mismatch");
static_assert(sizeof(DDS_HEADER_DXT10) == 20, "DDS DX10 Extended Header size mismatch");
} // namespace

View File

@ -85,16 +85,35 @@ namespace DirectX
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_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
};
HRESULT __cdecl ComputePitch(

View File

@ -158,7 +158,7 @@ namespace
{
for (size_t s = pw; s < 4; ++s)
{
#pragma prefast(suppress: 26000, "PREFAST false positive")
#pragma prefast(suppress: 26000, "PREFAST false positive")
temp[(t << 2) | s] = temp[(t << 2) | uSrc[s]];
}
}
@ -170,7 +170,7 @@ namespace
{
for (size_t s = 0; s < 4; ++s)
{
#pragma prefast(suppress: 26000, "PREFAST false positive")
#pragma prefast(suppress: 26000, "PREFAST false positive")
temp[(t << 2) | s] = temp[(uSrc[t] << 2) | s];
}
}
@ -239,7 +239,7 @@ namespace
bool fail = false;
#pragma omp parallel for
#pragma omp parallel for
for (int nb = 0; nb < static_cast<int>(nBlocks); ++nb)
{
const int nbWidth = std::max<int>(1, int((image.width + 3) / 4));
@ -615,11 +615,11 @@ HRESULT DirectX::Compress(
// Compress single image
if (compress & TEX_COMPRESS_PARALLEL)
{
#ifndef _OPENMP
#ifndef _OPENMP
return E_NOTIMPL;
#else
#else
hr = CompressBC_Parallel(srcImage, *img, GetBCFlags(compress), GetSRGBFlags(compress), threshold);
#endif // _OPENMP
#endif // _OPENMP
}
else
{
@ -687,9 +687,9 @@ HRESULT DirectX::Compress(
if ((compress & TEX_COMPRESS_PARALLEL))
{
#ifndef _OPENMP
#ifndef _OPENMP
return E_NOTIMPL;
#else
#else
if (compress & TEX_COMPRESS_PARALLEL)
{
hr = CompressBC_Parallel(src, dest[index], GetBCFlags(compress), GetSRGBFlags(compress), threshold);
@ -699,7 +699,7 @@ HRESULT DirectX::Compress(
return hr;
}
}
#endif // _OPENMP
#endif // _OPENMP
}
else
{

View File

@ -69,7 +69,8 @@ namespace
{
Exponent--;
Mantissa <<= 1;
} while ((Mantissa & 0x80) == 0);
}
while ((Mantissa & 0x80) == 0);
Mantissa &= 0x7F;
}
@ -135,7 +136,8 @@ namespace
{
Exponent--;
Mantissa <<= 1;
} while ((Mantissa & 0x40) == 0);
}
while ((Mantissa & 0x40) == 0);
Mantissa &= 0x3F;
}
@ -3263,13 +3265,13 @@ void DirectX::Internal::ConvertScanline(
break;
}
#if (__cplusplus >= 201703L)
#if (__cplusplus >= 201703L)
[[fallthrough]];
#elif defined(__clang__)
#elif defined(__clang__)
[[clang::fallthrough]];
#elif defined(_MSC_VER)
#elif defined(_MSC_VER)
__fallthrough;
#endif
#endif
case TEX_FILTER_RGB_COPY_RED:
{
@ -3553,13 +3555,13 @@ void DirectX::Internal::ConvertScanline(
break;
}
#if (__cplusplus >= 201703L)
#if (__cplusplus >= 201703L)
[[fallthrough]];
#elif defined(__clang__)
#elif defined(__clang__)
[[clang::fallthrough]];
#elif defined(_MSC_VER)
#elif defined(_MSC_VER)
__fallthrough;
#endif
#endif
case TEX_FILTER_RGB_COPY_RED:
{
@ -3652,13 +3654,13 @@ void DirectX::Internal::ConvertScanline(
break;
}
#if (__cplusplus >= 201703L)
#if (__cplusplus >= 201703L)
[[fallthrough]];
#elif defined(__clang__)
#elif defined(__clang__)
[[clang::fallthrough]];
#elif defined(_MSC_VER)
#elif defined(_MSC_VER)
__fallthrough;
#endif
#endif
case TEX_FILTER_RGB_COPY_RED:
// Leave data unchanged and the store will handle this...
@ -3670,7 +3672,7 @@ void DirectX::Internal::ConvertScanline(
// RGB format -> RG format
switch (static_cast<int>(flags & (TEX_FILTER_RGB_COPY_RED | TEX_FILTER_RGB_COPY_GREEN | TEX_FILTER_RGB_COPY_BLUE)))
{
case static_cast<int>(TEX_FILTER_RGB_COPY_RED) | static_cast<int>(TEX_FILTER_RGB_COPY_BLUE):
case (static_cast<int>(TEX_FILTER_RGB_COPY_RED) | static_cast<int>(TEX_FILTER_RGB_COPY_BLUE)):
{
XMVECTOR* ptr = pBuffer;
for (size_t i = 0; i < count; ++i)
@ -3682,7 +3684,7 @@ void DirectX::Internal::ConvertScanline(
}
break;
case static_cast<int>(TEX_FILTER_RGB_COPY_GREEN) | static_cast<int>(TEX_FILTER_RGB_COPY_BLUE):
case (static_cast<int>(TEX_FILTER_RGB_COPY_GREEN) | static_cast<int>(TEX_FILTER_RGB_COPY_BLUE)):
{
XMVECTOR* ptr = pBuffer;
for (size_t i = 0; i < count; ++i)
@ -3694,7 +3696,7 @@ void DirectX::Internal::ConvertScanline(
}
break;
case static_cast<int>(TEX_FILTER_RGB_COPY_RED) | static_cast<int>(TEX_FILTER_RGB_COPY_GREEN):
case (static_cast<int>(TEX_FILTER_RGB_COPY_RED) | static_cast<int>(TEX_FILTER_RGB_COPY_GREEN)):
default:
// Leave data unchanged and the store will handle this...
break;
@ -4392,14 +4394,14 @@ namespace
_Out_ WICPixelFormatGUID& pfGUID,
_Out_ WICPixelFormatGUID& targetGUID) noexcept
{
#ifndef WIN32
#ifndef WIN32
UNREFERENCED_PARAMETER(filter);
UNREFERENCED_PARAMETER(sformat);
UNREFERENCED_PARAMETER(tformat);
UNREFERENCED_PARAMETER(pfGUID);
UNREFERENCED_PARAMETER(targetGUID);
return false;
#else
#else
memset(&pfGUID, 0, sizeof(GUID));
memset(&targetGUID, 0, sizeof(GUID));
@ -4434,7 +4436,7 @@ namespace
}
// Check for special cases
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
if (sformat == DXGI_FORMAT_R16G16B16A16_FLOAT
|| sformat == DXGI_FORMAT_R16_FLOAT
|| tformat == DXGI_FORMAT_R16G16B16A16_FLOAT
@ -4443,7 +4445,7 @@ namespace
// Use non-WIC code paths as these conversions are not supported by Xbox version of WIC
return false;
}
#endif
#endif
switch (sformat)
{
@ -4541,7 +4543,7 @@ namespace
}
return true;
#endif // WIN32
#endif // WIN32
}
//-------------------------------------------------------------------------------------
@ -4555,7 +4557,7 @@ namespace
_In_ float threshold,
_In_ const Image& destImage)
{
#ifndef WIN32
#ifndef WIN32
UNREFERENCED_PARAMETER(srcImage);
UNREFERENCED_PARAMETER(pfGUID);
UNREFERENCED_PARAMETER(targetGUID);
@ -4563,7 +4565,7 @@ namespace
UNREFERENCED_PARAMETER(threshold);
UNREFERENCED_PARAMETER(destImage);
return E_NOTIMPL;
#else
#else
assert(srcImage.width == destImage.width);
assert(srcImage.height == destImage.height);
@ -4609,7 +4611,7 @@ namespace
return hr;
return S_OK;
#endif // WIN32
#endif // WIN32
}
//-------------------------------------------------------------------------------------
@ -4773,6 +4775,10 @@ namespace
}\
}
#ifdef __clang__
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#endif
HRESULT ConvertToSinglePlane_(_In_ const Image& srcImage, _In_ const Image& destImage) noexcept
{
assert(srcImage.width == destImage.width);
@ -4787,17 +4793,17 @@ namespace
{
case DXGI_FORMAT_NV12:
assert(destImage.format == DXGI_FORMAT_YUY2);
CONVERT_420_TO_422(uint8_t, XMUBYTEN4)
CONVERT_420_TO_422(uint8_t, XMUBYTEN4);
return S_OK;
case DXGI_FORMAT_P010:
assert(destImage.format == DXGI_FORMAT_Y210);
CONVERT_420_TO_422(uint16_t, XMUSHORTN4)
CONVERT_420_TO_422(uint16_t, XMUSHORTN4);
return S_OK;
case DXGI_FORMAT_P016:
assert(destImage.format == DXGI_FORMAT_Y216);
CONVERT_420_TO_422(uint16_t, XMUSHORTN4)
CONVERT_420_TO_422(uint16_t, XMUSHORTN4);
return S_OK;
case DXGI_FORMAT_NV11:

View File

@ -39,7 +39,7 @@ namespace
if (!pContext || !pSource || !result.GetPixels())
return E_POINTER;
#if defined(_XBOX_ONE) && defined(_TITLE)
#if defined(_XBOX_ONE) && defined(_TITLE)
ComPtr<ID3D11Device> d3dDevice;
pContext->GetDevice(d3dDevice.GetAddressOf());
@ -64,7 +64,7 @@ namespace
}
}
#endif
#endif
if (metadata.IsVolumemap())
{

View File

@ -304,11 +304,11 @@ namespace
// Block until the copy is complete
while (fence->GetCompletedValue() < 1)
{
#ifdef WIN32
#ifdef WIN32
SwitchToThread();
#else
#else
std::this_thread::yield();
#endif
#endif
}
return S_OK;

View File

@ -1824,18 +1824,18 @@ HRESULT DirectX::LoadFromDDSFile(
if (!(convFlags & CONV_FLAGS_DX10))
{
#ifdef WIN32
#ifdef WIN32
// Must reset file position since we read more than the standard header above
const LARGE_INTEGER filePos = { { sizeof(uint32_t) + sizeof(DDS_HEADER), 0 } };
if (!SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN))
{
return HRESULT_FROM_WIN32(GetLastError());
}
#else
#else
inFile.seekg(sizeof(uint32_t) + sizeof(DDS_HEADER), std::ios::beg);
if (!inFile)
return E_FAIL;
#endif
#endif
offset = sizeof(uint32_t) + sizeof(DDS_HEADER);
}
@ -1849,7 +1849,7 @@ HRESULT DirectX::LoadFromDDSFile(
return E_OUTOFMEMORY;
}
#ifdef WIN32
#ifdef WIN32
if (!ReadFile(hFile.get(), pal8.get(), 256 * sizeof(uint32_t), &bytesRead, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
@ -1859,11 +1859,11 @@ HRESULT DirectX::LoadFromDDSFile(
{
return E_FAIL;
}
#else
#else
inFile.read(reinterpret_cast<char*>(pal8.get()), 256 * sizeof(uint32_t));
if (!inFile)
return E_FAIL;
#endif
#endif
offset += (256 * sizeof(uint32_t));
}
@ -1885,7 +1885,7 @@ HRESULT DirectX::LoadFromDDSFile(
return E_OUTOFMEMORY;
}
#ifdef WIN32
#ifdef WIN32
if (!ReadFile(hFile.get(), temp.get(), static_cast<DWORD>(remaining), &bytesRead, nullptr))
{
image.Release();
@ -1897,14 +1897,14 @@ HRESULT DirectX::LoadFromDDSFile(
image.Release();
return E_FAIL;
}
#else
#else
inFile.read(reinterpret_cast<char*>(temp.get()), remaining);
if (!inFile)
{
image.Release();
return E_FAIL;
}
#endif
#endif
CP_FLAGS cflags = CP_FLAGS_NONE;
if (flags & DDS_FLAGS_LEGACY_DWORD)
@ -1943,20 +1943,20 @@ HRESULT DirectX::LoadFromDDSFile(
return HRESULT_E_ARITHMETIC_OVERFLOW;
}
#ifdef WIN32
#ifdef WIN32
if (!ReadFile(hFile.get(), image.GetPixels(), static_cast<DWORD>(image.GetPixelsSize()), &bytesRead, nullptr))
{
image.Release();
return HRESULT_FROM_WIN32(GetLastError());
}
#else
#else
inFile.read(reinterpret_cast<char*>(image.GetPixels()), image.GetPixelsSize());
if (!inFile)
{
image.Release();
return E_FAIL;
}
#endif
#endif
if (convFlags & (CONV_FLAGS_SWIZZLE | CONV_FLAGS_NOALPHA))
{
@ -2285,7 +2285,7 @@ HRESULT DirectX::SaveToDDSFile(
if ((images[index].slicePitch == ddsSlicePitch) && (ddsSlicePitch <= UINT32_MAX))
{
#ifdef WIN32
#ifdef WIN32
if (!WriteFile(hFile.get(), images[index].pixels, static_cast<DWORD>(ddsSlicePitch), &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
@ -2295,11 +2295,11 @@ HRESULT DirectX::SaveToDDSFile(
{
return E_FAIL;
}
#else
#else
outFile.write(reinterpret_cast<char*>(images[index].pixels), static_cast<std::streamsize>(ddsSlicePitch));
if (!outFile)
return E_FAIL;
#endif
#endif
}
else
{
@ -2318,7 +2318,7 @@ HRESULT DirectX::SaveToDDSFile(
const size_t lines = ComputeScanlines(metadata.format, images[index].height);
for (size_t j = 0; j < lines; ++j)
{
#ifdef WIN32
#ifdef WIN32
if (!WriteFile(hFile.get(), sPtr, static_cast<DWORD>(ddsRowPitch), &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
@ -2328,11 +2328,11 @@ HRESULT DirectX::SaveToDDSFile(
{
return E_FAIL;
}
#else
#else
outFile.write(reinterpret_cast<const char*>(sPtr), static_cast<std::streamsize>(ddsRowPitch));
if (!outFile)
return E_FAIL;
#endif
#endif
sPtr += rowPitch;
}
@ -2370,7 +2370,7 @@ HRESULT DirectX::SaveToDDSFile(
if ((images[index].slicePitch == ddsSlicePitch) && (ddsSlicePitch <= UINT32_MAX))
{
#ifdef WIN32
#ifdef WIN32
if (!WriteFile(hFile.get(), images[index].pixels, static_cast<DWORD>(ddsSlicePitch), &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
@ -2380,11 +2380,11 @@ HRESULT DirectX::SaveToDDSFile(
{
return E_FAIL;
}
#else
#else
outFile.write(reinterpret_cast<char*>(images[index].pixels), static_cast<std::streamsize>(ddsSlicePitch));
if (!outFile)
return E_FAIL;
#endif
#endif
}
else
{
@ -2403,7 +2403,7 @@ HRESULT DirectX::SaveToDDSFile(
const size_t lines = ComputeScanlines(metadata.format, images[index].height);
for (size_t j = 0; j < lines; ++j)
{
#ifdef WIN32
#ifdef WIN32
if (!WriteFile(hFile.get(), sPtr, static_cast<DWORD>(ddsRowPitch), &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
@ -2413,11 +2413,11 @@ HRESULT DirectX::SaveToDDSFile(
{
return E_FAIL;
}
#else
#else
outFile.write(reinterpret_cast<const char*>(sPtr), static_cast<std::streamsize>(ddsRowPitch));
if (!outFile)
return E_FAIL;
#endif
#endif
sPtr += rowPitch;
}
}

View File

@ -79,7 +79,7 @@ namespace
#ifndef WIN32
template<size_t sizeOfBuffer>
inline int sprintf_s(char (&buffer)[sizeOfBuffer], const char* format, ...)
inline int sprintf_s(char(&buffer)[sizeOfBuffer], const char* format, ...)
{
// This is adapter code. It is not a full implementation of sprintf_s!
va_list ap;
@ -400,7 +400,7 @@ namespace
return 0;
}
#ifdef WRITE_OLD_COLORS
#ifdef WRITE_OLD_COLORS
size_t encSize = 0;
const uint8_t* scanPtr = rgbe;
@ -502,7 +502,7 @@ namespace
}
return encSize;
#else
#else
enc[0] = 2;
enc[1] = 2;
enc[2] = uint8_t(width >> 8);
@ -569,7 +569,7 @@ namespace
}
return encSize;
#endif
#endif
}
}
@ -748,7 +748,7 @@ HRESULT DirectX::LoadFromHDRMemory(const void* pSource, size_t size, TexMetadata
for (int channel = 0; channel < 4; ++channel)
{
auto pixelLoc = scanLine + channel;
for(size_t pixelCount = 0; pixelCount < mdata.width;)
for (size_t pixelCount = 0; pixelCount < mdata.width;)
{
if (pixelLen < 2)
{
@ -1163,7 +1163,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
return hr;
// Write blob
#ifdef WIN32
#ifdef WIN32
auto const bytesToWrite = static_cast<const DWORD>(blob.GetBufferSize());
DWORD bytesWritten;
if (!WriteFile(hFile.get(), blob.GetBufferPointer(), bytesToWrite, &bytesWritten, nullptr))
@ -1175,13 +1175,13 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
{
return E_FAIL;
}
#else
#else
outFile.write(reinterpret_cast<char*>(blob.GetBufferPointer()),
static_cast<std::streamsize>(blob.GetBufferSize()));
if (!outFile)
return E_FAIL;
#endif
#endif
}
else
{
@ -1196,7 +1196,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
char header[256] = {};
sprintf_s(header, g_Header, image.height, image.width);
#ifdef WIN32
#ifdef WIN32
auto const headerLen = static_cast<DWORD>(strlen(header));
DWORD bytesWritten;
@ -1207,13 +1207,13 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
if (bytesWritten != headerLen)
return E_FAIL;
#else
#else
outFile.write(reinterpret_cast<char*>(header), static_cast<std::streamsize>(strlen(header)));
if (!outFile)
return E_FAIL;
#endif
#endif
#ifdef DISABLE_COMPRESS
#ifdef DISABLE_COMPRESS
// Uncompressed write
auto sPtr = reinterpret_cast<const uint8_t*>(image.pixels);
for (size_t scan = 0; scan < image.height; ++scan)
@ -1236,7 +1236,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
#endif
}
#else
#else
auto enc = temp.get() + rowPitch;
const uint8_t* sPtr = image.pixels;
@ -1258,7 +1258,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
if (encSize > UINT32_MAX)
return HRESULT_E_ARITHMETIC_OVERFLOW;
#ifdef WIN32
#ifdef WIN32
if (!WriteFile(hFile.get(), enc, static_cast<DWORD>(encSize), &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
@ -1266,15 +1266,15 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
if (bytesWritten != encSize)
return E_FAIL;
#else
#else
outFile.write(reinterpret_cast<char*>(enc), static_cast<std::streamsize>(encSize));
if (!outFile)
return E_FAIL;
#endif
#endif
}
else
{
#ifdef WIN32
#ifdef WIN32
if (!WriteFile(hFile.get(), rgbe, static_cast<DWORD>(rowPitch), &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
@ -1282,14 +1282,14 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
if (bytesWritten != rowPitch)
return E_FAIL;
#else
#else
outFile.write(reinterpret_cast<char*>(rgbe), static_cast<std::streamsize>(rowPitch));
if (!outFile)
return E_FAIL;
#endif
#endif
}
}
#endif
#endif
}
#ifdef WIN32

View File

@ -23,7 +23,7 @@ namespace
return std::aligned_alloc(alignment, size);
}
#define _aligned_free free
#define _aligned_free free
}
#endif
@ -801,7 +801,7 @@ bool ScratchImage::IsAlphaAllOpaque() const noexcept
for (size_t index = 0; index < m_nimages; ++index)
{
#pragma warning( suppress : 6011 )
#pragma warning( suppress : 6011 )
const Image& img = m_image[index];
const uint8_t *pPixels = img.pixels;

View File

@ -454,16 +454,16 @@ HRESULT DirectX::Internal::ResizeSeparateColorAndAlpha(
}
else
{
#if(_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if(_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
if (iswic2)
{
colorBytesInPixel = colorBytesPerPixel = 12;
colorPixelFormat = GUID_WICPixelFormat96bppRGBFloat;
}
else
#else
#else
UNREFERENCED_PARAMETER(iswic2);
#endif
#endif
{
colorBytesInPixel = 12;
colorBytesPerPixel = 16;
@ -593,7 +593,7 @@ HRESULT DirectX::Internal::ResizeSeparateColorAndAlpha(
}
else
{
#pragma warning( suppress : 26014 6386 ) // No overflow possible here
#pragma warning( suppress : 26014 6386 ) // No overflow possible here
memcpy_s(colorWithAlphaData + colorWithAlphaIndex, colorWithAlphaBytesPerPixel, colorData + colorIndex, colorBytesInPixel);
}
}
@ -642,14 +642,14 @@ namespace
return false;
}
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
if (format == DXGI_FORMAT_R16G16B16A16_FLOAT
|| format == DXGI_FORMAT_R16_FLOAT)
{
// Use non-WIC code paths as these conversions are not supported by Xbox version of WIC
return false;
}
#endif
#endif
static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK");
@ -921,9 +921,9 @@ namespace
// Resize base image to each target mip level
for (size_t level = 1; level < levels; ++level)
{
#ifdef _DEBUG
#ifdef _DEBUG
memset(row, 0xCD, sizeof(XMVECTOR)*width);
#endif
#endif
// 2D point filter
const Image* src = mipChain.GetImage(level - 1, item, 0);
@ -1129,10 +1129,10 @@ namespace
const size_t nheight = (height > 1) ? (height >> 1) : 1;
CreateLinearFilter(height, nheight, (filter & TEX_FILTER_WRAP_V) != 0, lfY);
#ifdef _DEBUG
#ifdef _DEBUG
memset(row0, 0xCD, sizeof(XMVECTOR)*width);
memset(row1, 0xDD, sizeof(XMVECTOR)*width);
#endif
#endif
size_t u0 = size_t(-1);
size_t u1 = size_t(-1);
@ -1190,6 +1190,10 @@ namespace
}
//--- 2D Cubic Filter ---
#ifdef __clang__
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#endif
HRESULT Generate2DMipsCubicFilter(size_t levels, TEX_FILTER_FLAGS filter, const ScratchImage& mipChain, size_t item) noexcept
{
using namespace DirectX::Filters;
@ -1244,12 +1248,12 @@ namespace
const size_t nheight = (height > 1) ? (height >> 1) : 1;
CreateCubicFilter(height, nheight, (filter & TEX_FILTER_WRAP_V) != 0, (filter & TEX_FILTER_MIRROR_V) != 0, cfY);
#ifdef _DEBUG
#ifdef _DEBUG
memset(row0, 0xCD, sizeof(XMVECTOR)*width);
memset(row1, 0xDD, sizeof(XMVECTOR)*width);
memset(row2, 0xED, sizeof(XMVECTOR)*width);
memset(row3, 0xFD, sizeof(XMVECTOR)*width);
#endif
#endif
size_t u0 = size_t(-1);
size_t u1 = size_t(-1);
@ -1353,12 +1357,12 @@ namespace
XMVECTOR C0, C1, C2, C3;
CUBIC_INTERPOLATE(C0, toX.x, row0[toX.u0], row0[toX.u1], row0[toX.u2], row0[toX.u3])
CUBIC_INTERPOLATE(C1, toX.x, row1[toX.u0], row1[toX.u1], row1[toX.u2], row1[toX.u3])
CUBIC_INTERPOLATE(C2, toX.x, row2[toX.u0], row2[toX.u1], row2[toX.u2], row2[toX.u3])
CUBIC_INTERPOLATE(C3, toX.x, row3[toX.u0], row3[toX.u1], row3[toX.u2], row3[toX.u3])
CUBIC_INTERPOLATE(C0, toX.x, row0[toX.u0], row0[toX.u1], row0[toX.u2], row0[toX.u3]);
CUBIC_INTERPOLATE(C1, toX.x, row1[toX.u0], row1[toX.u1], row1[toX.u2], row1[toX.u3]);
CUBIC_INTERPOLATE(C2, toX.x, row2[toX.u0], row2[toX.u1], row2[toX.u2], row2[toX.u3]);
CUBIC_INTERPOLATE(C3, toX.x, row3[toX.u0], row3[toX.u1], row3[toX.u2], row3[toX.u3]);
CUBIC_INTERPOLATE(target[x], toY.x, C0, C1, C2, C3)
CUBIC_INTERPOLATE(target[x], toY.x, C0, C1, C2, C3);
}
if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter))
@ -1433,9 +1437,9 @@ namespace
if (FAILED(hr))
return hr;
#ifdef _DEBUG
#ifdef _DEBUG
memset(row, 0xCD, sizeof(XMVECTOR)*width);
#endif
#endif
auto xFromEnd = reinterpret_cast<const FilterFrom*>(reinterpret_cast<const uint8_t*>(tfX.get()) + tfX->sizeInBytes);
auto yFromEnd = reinterpret_cast<const FilterFrom*>(reinterpret_cast<const uint8_t*>(tfY.get()) + tfY->sizeInBytes);
@ -1673,9 +1677,9 @@ namespace
// Resize base image to each target mip level
for (size_t level = 1; level < levels; ++level)
{
#ifdef _DEBUG
#ifdef _DEBUG
memset(row, 0xCD, sizeof(XMVECTOR)*width);
#endif
#endif
if (depth > 1)
{
@ -2012,12 +2016,12 @@ namespace
const size_t nheight = (height > 1) ? (height >> 1) : 1;
CreateLinearFilter(height, nheight, (filter & TEX_FILTER_WRAP_V) != 0, lfY);
#ifdef _DEBUG
#ifdef _DEBUG
memset(urow0, 0xCD, sizeof(XMVECTOR)*width);
memset(urow1, 0xDD, sizeof(XMVECTOR)*width);
memset(vrow0, 0xED, sizeof(XMVECTOR)*width);
memset(vrow1, 0xFD, sizeof(XMVECTOR)*width);
#endif
#endif
if (depth > 1)
{
@ -2216,7 +2220,7 @@ namespace
const size_t nheight = (height > 1) ? (height >> 1) : 1;
CreateCubicFilter(height, nheight, (filter & TEX_FILTER_WRAP_V) != 0, (filter & TEX_FILTER_MIRROR_V) != 0, cfY);
#ifdef _DEBUG
#ifdef _DEBUG
for (size_t j = 0; j < 4; ++j)
{
memset(urow[j], 0xCD, sizeof(XMVECTOR)*width);
@ -2224,7 +2228,7 @@ namespace
memset(srow[j], 0xED, sizeof(XMVECTOR)*width);
memset(trow[j], 0xFD, sizeof(XMVECTOR)*width);
}
#endif
#endif
if (depth > 1)
{
@ -2384,15 +2388,15 @@ namespace
for (size_t j = 0; j < 4; ++j)
{
XMVECTOR C0, C1, C2, C3;
CUBIC_INTERPOLATE(C0, toX.x, urow[j][toX.u0], urow[j][toX.u1], urow[j][toX.u2], urow[j][toX.u3])
CUBIC_INTERPOLATE(C1, toX.x, vrow[j][toX.u0], vrow[j][toX.u1], vrow[j][toX.u2], vrow[j][toX.u3])
CUBIC_INTERPOLATE(C2, toX.x, srow[j][toX.u0], srow[j][toX.u1], srow[j][toX.u2], srow[j][toX.u3])
CUBIC_INTERPOLATE(C3, toX.x, trow[j][toX.u0], trow[j][toX.u1], trow[j][toX.u2], trow[j][toX.u3])
CUBIC_INTERPOLATE(C0, toX.x, urow[j][toX.u0], urow[j][toX.u1], urow[j][toX.u2], urow[j][toX.u3]);
CUBIC_INTERPOLATE(C1, toX.x, vrow[j][toX.u0], vrow[j][toX.u1], vrow[j][toX.u2], vrow[j][toX.u3]);
CUBIC_INTERPOLATE(C2, toX.x, srow[j][toX.u0], srow[j][toX.u1], srow[j][toX.u2], srow[j][toX.u3]);
CUBIC_INTERPOLATE(C3, toX.x, trow[j][toX.u0], trow[j][toX.u1], trow[j][toX.u2], trow[j][toX.u3]);
CUBIC_INTERPOLATE(D[j], toY.x, C0, C1, C2, C3)
CUBIC_INTERPOLATE(D[j], toY.x, C0, C1, C2, C3);
}
CUBIC_INTERPOLATE(target[x], toZ.x, D[0], D[1], D[2], D[3])
CUBIC_INTERPOLATE(target[x], toZ.x, D[0], D[1], D[2], D[3]);
}
if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter))
@ -2516,12 +2520,12 @@ namespace
auto const& toX = cfX[x];
XMVECTOR C0, C1, C2, C3;
CUBIC_INTERPOLATE(C0, toX.x, urow[0][toX.u0], urow[0][toX.u1], urow[0][toX.u2], urow[0][toX.u3])
CUBIC_INTERPOLATE(C1, toX.x, vrow[0][toX.u0], vrow[0][toX.u1], vrow[0][toX.u2], vrow[0][toX.u3])
CUBIC_INTERPOLATE(C2, toX.x, srow[0][toX.u0], srow[0][toX.u1], srow[0][toX.u2], srow[0][toX.u3])
CUBIC_INTERPOLATE(C3, toX.x, trow[0][toX.u0], trow[0][toX.u1], trow[0][toX.u2], trow[0][toX.u3])
CUBIC_INTERPOLATE(C0, toX.x, urow[0][toX.u0], urow[0][toX.u1], urow[0][toX.u2], urow[0][toX.u3]);
CUBIC_INTERPOLATE(C1, toX.x, vrow[0][toX.u0], vrow[0][toX.u1], vrow[0][toX.u2], vrow[0][toX.u3]);
CUBIC_INTERPOLATE(C2, toX.x, srow[0][toX.u0], srow[0][toX.u1], srow[0][toX.u2], srow[0][toX.u3]);
CUBIC_INTERPOLATE(C3, toX.x, trow[0][toX.u0], trow[0][toX.u1], trow[0][toX.u2], trow[0][toX.u3]);
CUBIC_INTERPOLATE(target[x], toY.x, C0, C1, C2, C3)
CUBIC_INTERPOLATE(target[x], toY.x, C0, C1, C2, C3);
}
if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter))
@ -2592,9 +2596,9 @@ namespace
if (FAILED(hr))
return hr;
#ifdef _DEBUG
#ifdef _DEBUG
memset(row, 0xCD, sizeof(XMVECTOR)*width);
#endif
#endif
auto xFromEnd = reinterpret_cast<const FilterFrom*>(reinterpret_cast<const uint8_t*>(tfX.get()) + tfX->sizeInBytes);
auto yFromEnd = reinterpret_cast<const FilterFrom*>(reinterpret_cast<const uint8_t*>(tfY.get()) + tfY->sizeInBytes);
@ -2903,7 +2907,7 @@ HRESULT DirectX::GenerateMipMaps(
}
}
else
#endif // WIN32
#endif // WIN32
{
//--- Use custom filters to generate mipmaps ----------------------------------
TexMetadata mdata = {};
@ -3131,7 +3135,7 @@ HRESULT DirectX::GenerateMipMaps(
}
}
else
#endif // WIN32
#endif // WIN32
{
//--- Use custom filters to generate mipmaps ----------------------------------
TexMetadata mdata2 = metadata;

View File

@ -246,9 +246,9 @@ namespace
if (!LoadScanline(sScanline, width, pSrc, spitch, srcImage.format))
return E_FAIL;
#ifdef _DEBUG
#ifdef _DEBUG
memset(dScanline, 0xCD, sizeof(XMVECTOR)*width);
#endif
#endif
pixelFunc(dScanline, sScanline, width, h);

View File

@ -210,7 +210,7 @@ namespace DirectX
{
//-----------------------------------------------------------------------------
// WIC helper functions
#ifdef WIN32
#ifdef WIN32
DXGI_FORMAT __cdecl WICToDXGI(_In_ const GUID& guid) noexcept;
bool __cdecl DXGIToWIC(_In_ DXGI_FORMAT format, _Out_ GUID& guid, _In_ bool ignoreRGBvsBGR = false) noexcept;
@ -295,7 +295,7 @@ namespace DirectX
return WICBitmapInterpolationModeFant;
}
}
#endif // WIN32
#endif // WIN32
//---------------------------------------------------------------------------------
// Image helper functions
@ -314,8 +314,12 @@ namespace DirectX
enum TEXP_SCANLINE_FLAGS : uint32_t
{
TEXP_SCANLINE_NONE = 0,
TEXP_SCANLINE_SETALPHA = 0x1, // Set alpha channel to known opaque value
TEXP_SCANLINE_LEGACY = 0x2, // Enables specific legacy format conversion cases
TEXP_SCANLINE_SETALPHA = 0x1,
// Set alpha channel to known opaque value
TEXP_SCANLINE_LEGACY = 0x2,
// Enables specific legacy format conversion cases
};
enum CONVERT_FLAGS : uint32_t
@ -413,13 +417,13 @@ namespace DirectX
bool __cdecl CalculateMipLevels3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth,
_Inout_ size_t& mipLevels) noexcept;
#ifdef WIN32
#ifdef WIN32
HRESULT __cdecl ResizeSeparateColorAndAlpha(_In_ IWICImagingFactory* pWIC,
_In_ bool iswic2,
_In_ IWICBitmap* original,
_In_ size_t newWidth, _In_ size_t newHeight, _In_ TEX_FILTER_FLAGS filter,
_Inout_ const Image* img) noexcept;
#endif
#endif
} // namespace Internal
} // namespace DirectX

View File

@ -189,14 +189,14 @@ namespace
return false;
}
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
if (format == DXGI_FORMAT_R16G16B16A16_FLOAT
|| format == DXGI_FORMAT_R16_FLOAT)
{
// Use non-WIC code paths as these conversions are not supported by Xbox version of WIC
return false;
}
#endif
#endif
static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MASK");
@ -258,9 +258,9 @@ namespace
XMVECTOR* row = target + destImage.width;
#ifdef _DEBUG
#ifdef _DEBUG
memset(row, 0xCD, sizeof(XMVECTOR)*srcImage.width);
#endif
#endif
const uint8_t* pSrc = srcImage.pixels;
uint8_t* pDest = destImage.pixels;
@ -321,10 +321,10 @@ namespace
XMVECTOR* urow0 = target + destImage.width;
XMVECTOR* urow1 = urow0 + srcImage.width;
#ifdef _DEBUG
#ifdef _DEBUG
memset(urow0, 0xCD, sizeof(XMVECTOR)*srcImage.width);
memset(urow1, 0xDD, sizeof(XMVECTOR)*srcImage.width);
#endif
#endif
const XMVECTOR* urow2 = urow0 + 1;
const XMVECTOR* urow3 = urow1 + 1;
@ -391,10 +391,10 @@ namespace
XMVECTOR* row0 = target + destImage.width;
XMVECTOR* row1 = row0 + srcImage.width;
#ifdef _DEBUG
#ifdef _DEBUG
memset(row0, 0xCD, sizeof(XMVECTOR)*srcImage.width);
memset(row1, 0xDD, sizeof(XMVECTOR)*srcImage.width);
#endif
#endif
const uint8_t* pSrc = srcImage.pixels;
uint8_t* pDest = destImage.pixels;
@ -451,6 +451,10 @@ namespace
//--- Cubic Filter ---
#ifdef __clang__
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#endif
HRESULT ResizeCubicFilter(const Image& srcImage, TEX_FILTER_FLAGS filter, const Image& destImage) noexcept
{
using namespace DirectX::Filters;
@ -480,12 +484,12 @@ namespace
XMVECTOR* row2 = row0 + srcImage.width * 2;
XMVECTOR* row3 = row0 + srcImage.width * 3;
#ifdef _DEBUG
#ifdef _DEBUG
memset(row0, 0xCD, sizeof(XMVECTOR)*srcImage.width);
memset(row1, 0xDD, sizeof(XMVECTOR)*srcImage.width);
memset(row2, 0xED, sizeof(XMVECTOR)*srcImage.width);
memset(row3, 0xFD, sizeof(XMVECTOR)*srcImage.width);
#endif
#endif
const uint8_t* pSrc = srcImage.pixels;
uint8_t* pDest = destImage.pixels;
@ -594,12 +598,12 @@ namespace
XMVECTOR C0, C1, C2, C3;
CUBIC_INTERPOLATE(C0, toX.x, row0[toX.u0], row0[toX.u1], row0[toX.u2], row0[toX.u3])
CUBIC_INTERPOLATE(C1, toX.x, row1[toX.u0], row1[toX.u1], row1[toX.u2], row1[toX.u3])
CUBIC_INTERPOLATE(C2, toX.x, row2[toX.u0], row2[toX.u1], row2[toX.u2], row2[toX.u3])
CUBIC_INTERPOLATE(C3, toX.x, row3[toX.u0], row3[toX.u1], row3[toX.u2], row3[toX.u3])
CUBIC_INTERPOLATE(C0, toX.x, row0[toX.u0], row0[toX.u1], row0[toX.u2], row0[toX.u3]);
CUBIC_INTERPOLATE(C1, toX.x, row1[toX.u0], row1[toX.u1], row1[toX.u2], row1[toX.u3]);
CUBIC_INTERPOLATE(C2, toX.x, row2[toX.u0], row2[toX.u1], row2[toX.u2], row2[toX.u3]);
CUBIC_INTERPOLATE(C3, toX.x, row3[toX.u0], row3[toX.u1], row3[toX.u2], row3[toX.u3]);
CUBIC_INTERPOLATE(target[x], toY.x, C0, C1, C2, C3)
CUBIC_INTERPOLATE(target[x], toY.x, C0, C1, C2, C3);
}
if (!StoreScanlineLinear(pDest, destImage.rowPitch, destImage.format, target, destImage.width, filter))
@ -642,9 +646,9 @@ namespace
XMVECTOR* row = scanline.get();
#ifdef _DEBUG
#ifdef _DEBUG
memset(row, 0xCD, sizeof(XMVECTOR)*srcImage.width);
#endif
#endif
auto xFromEnd = reinterpret_cast<const FilterFrom*>(reinterpret_cast<const uint8_t*>(tfX.get()) + tfX->sizeInBytes);
auto yFromEnd = reinterpret_cast<const FilterFrom*>(reinterpret_cast<const uint8_t*>(tfY.get()) + tfY->sizeInBytes);
@ -908,7 +912,7 @@ HRESULT DirectX::Resize(
}
}
else
#endif
#endif
{
// Case 3: not using WIC resizing
hr = PerformResizeUsingCustomFilters(srcImage, filter, *rimage);
@ -1007,7 +1011,7 @@ HRESULT DirectX::Resize(
return E_FAIL;
}
#ifdef WIN32
#ifdef WIN32
if (usewic)
{
if (wicpf)
@ -1022,7 +1026,7 @@ HRESULT DirectX::Resize(
}
}
else
#endif
#endif
{
// Case 3: not using WIC resizing
hr = PerformResizeUsingCustomFilters(*srcimg, filter, *destimg);
@ -1068,7 +1072,7 @@ HRESULT DirectX::Resize(
return E_FAIL;
}
#ifdef WIN32
#ifdef WIN32
if (usewic)
{
if (wicpf)
@ -1083,7 +1087,7 @@ HRESULT DirectX::Resize(
}
}
else
#endif
#endif
{
// Case 3: not using WIC resizing
hr = PerformResizeUsingCustomFilters(*srcimg, filter, *destimg);

View File

@ -1224,14 +1224,14 @@ namespace
time_t now = {};
time(&now);
#ifdef WIN32
#ifdef WIN32
tm info;
auto pinfo = &info;
if (!gmtime_s(pinfo, &now))
#else
#else
const tm* pinfo = gmtime(&now);
if (pinfo)
#endif
#endif
{
ext->wStampMonth = static_cast<uint16_t>(pinfo->tm_mon + 1);
ext->wStampDay = static_cast<uint16_t>(pinfo->tm_mday);
@ -1424,7 +1424,7 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags,
{
TGA_FOOTER footer = {};
#ifdef WIN32
#ifdef WIN32
if (SetFilePointer(hFile.get(), -static_cast<int>(sizeof(TGA_FOOTER)), nullptr, FILE_END) != INVALID_SET_FILE_POINTER)
{
if (!ReadFile(hFile.get(), &footer, sizeof(TGA_FOOTER), &bytesRead, nullptr))
@ -1437,7 +1437,7 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags,
return E_FAIL;
}
}
#else
#else
inFile.seekg(-static_cast<int>(sizeof(TGA_FOOTER)), std::ios::end);
if (inFile)
{
@ -1445,14 +1445,14 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags,
if (!inFile)
return E_FAIL;
}
#endif
#endif
if (memcmp(footer.Signature, g_Signature, sizeof(g_Signature)) == 0)
{
if (footer.dwExtensionOffset != 0
&& ((footer.dwExtensionOffset + sizeof(TGA_EXTENSION)) <= len))
{
#ifdef WIN32
#ifdef WIN32
const LARGE_INTEGER filePos = { { static_cast<DWORD>(footer.dwExtensionOffset), 0 } };
if (SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN))
{
@ -1463,7 +1463,7 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags,
metadata.SetAlphaMode(GetAlphaModeFromExtension(ext));
}
}
#else // !WIN32
#else // !WIN32
inFile.seekg(static_cast<std::streampos>(footer.dwExtensionOffset), std::ios::beg);
if (inFile)
{
@ -1474,7 +1474,7 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags,
metadata.SetAlphaMode(GetAlphaModeFromExtension(ext));
}
}
#endif
#endif
}
}
}
@ -1676,18 +1676,18 @@ HRESULT DirectX::LoadFromTGAFile(
if (offset > sizeof(TGA_HEADER))
{
#ifdef WIN32
#ifdef WIN32
// Skip past the id string
const LARGE_INTEGER filePos = { { static_cast<DWORD>(offset), 0 } };
if (!SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN))
{
return HRESULT_FROM_WIN32(GetLastError());
}
#else
#else
inFile.seekg(offset, std::ios::beg);
if (!inFile)
return E_FAIL;
#endif
#endif
}
hr = image.Initialize2D(mdata.format, mdata.width, mdata.height, 1, 1);
@ -1713,7 +1713,7 @@ HRESULT DirectX::LoadFromTGAFile(
return HRESULT_E_ARITHMETIC_OVERFLOW;
}
#ifdef WIN32
#ifdef WIN32
if (!ReadFile(hFile.get(), image.GetPixels(), static_cast<DWORD>(image.GetPixelsSize()), &bytesRead, nullptr))
{
image.Release();
@ -1725,14 +1725,14 @@ HRESULT DirectX::LoadFromTGAFile(
image.Release();
return E_FAIL;
}
#else
#else
inFile.read(reinterpret_cast<char*>(image.GetPixels()), image.GetPixelsSize());
if (!inFile)
{
image.Release();
return E_FAIL;
}
#endif
#endif
switch (mdata.format)
{
@ -1932,7 +1932,7 @@ HRESULT DirectX::LoadFromTGAFile(
return E_OUTOFMEMORY;
}
#ifdef WIN32
#ifdef WIN32
if (!ReadFile(hFile.get(), temp.get(), static_cast<DWORD>(remaining), &bytesRead, nullptr))
{
image.Release();
@ -1944,14 +1944,14 @@ HRESULT DirectX::LoadFromTGAFile(
image.Release();
return E_FAIL;
}
#else
#else
inFile.read(reinterpret_cast<char*>(temp.get()), remaining);
if (!inFile)
{
image.Release();
return E_FAIL;
}
#endif
#endif
if (convFlags & CONV_FLAGS_RLE)
{
@ -1978,7 +1978,7 @@ HRESULT DirectX::LoadFromTGAFile(
{
TGA_FOOTER footer = {};
#ifdef WIN32
#ifdef WIN32
if (SetFilePointer(hFile.get(), -static_cast<int>(sizeof(TGA_FOOTER)), nullptr, FILE_END) != INVALID_SET_FILE_POINTER)
{
if (!ReadFile(hFile.get(), &footer, sizeof(TGA_FOOTER), &bytesRead, nullptr))
@ -1993,7 +1993,7 @@ HRESULT DirectX::LoadFromTGAFile(
return E_FAIL;
}
}
#else // !WIN32
#else // !WIN32
inFile.seekg(-static_cast<int>(sizeof(TGA_FOOTER)), std::ios::end);
if (inFile)
{
@ -2004,14 +2004,14 @@ HRESULT DirectX::LoadFromTGAFile(
return E_FAIL;
}
}
#endif
#endif
if (memcmp(footer.Signature, g_Signature, sizeof(g_Signature)) == 0)
{
if (footer.dwExtensionOffset != 0
&& ((footer.dwExtensionOffset + sizeof(TGA_EXTENSION)) <= len))
{
#ifdef WIN32
#ifdef WIN32
const LARGE_INTEGER filePos = { { static_cast<DWORD>(footer.dwExtensionOffset), 0 } };
if (SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN))
{
@ -2021,7 +2021,7 @@ HRESULT DirectX::LoadFromTGAFile(
ext = &extData;
}
}
#else // !WIN32
#else // !WIN32
inFile.seekg(static_cast<std::streampos>(footer.dwExtensionOffset), std::ios::beg);
if (inFile)
{
@ -2031,7 +2031,7 @@ HRESULT DirectX::LoadFromTGAFile(
ext = &extData;
}
}
#endif
#endif
}
}
}
@ -2211,7 +2211,7 @@ HRESULT DirectX::SaveToTGAFile(
return hr;
// Write blob
#ifdef WIN32
#ifdef WIN32
const DWORD bytesToWrite = static_cast<DWORD>(blob.GetBufferSize());
DWORD bytesWritten;
if (!WriteFile(hFile.get(), blob.GetBufferPointer(), bytesToWrite, &bytesWritten, nullptr))
@ -2223,13 +2223,13 @@ HRESULT DirectX::SaveToTGAFile(
{
return E_FAIL;
}
#else
#else
outFile.write(reinterpret_cast<char*>(blob.GetBufferPointer()),
static_cast<std::streamsize>(blob.GetBufferSize()));
if (!outFile)
return E_FAIL;
#endif
#endif
}
else
{
@ -2239,7 +2239,7 @@ HRESULT DirectX::SaveToTGAFile(
return E_OUTOFMEMORY;
// Write header
#ifdef WIN32
#ifdef WIN32
DWORD bytesWritten;
if (!WriteFile(hFile.get(), &tga_header, sizeof(TGA_HEADER), &bytesWritten, nullptr))
{
@ -2248,11 +2248,11 @@ HRESULT DirectX::SaveToTGAFile(
if (bytesWritten != sizeof(TGA_HEADER))
return E_FAIL;
#else
#else
outFile.write(reinterpret_cast<char*>(&tga_header), sizeof(TGA_HEADER));
if (!outFile)
return E_FAIL;
#endif
#endif
if (rowPitch > UINT32_MAX)
return HRESULT_E_ARITHMETIC_OVERFLOW;
@ -2278,7 +2278,7 @@ HRESULT DirectX::SaveToTGAFile(
pPixels += image.rowPitch;
#ifdef WIN32
#ifdef WIN32
if (!WriteFile(hFile.get(), temp.get(), static_cast<DWORD>(rowPitch), &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
@ -2286,11 +2286,11 @@ HRESULT DirectX::SaveToTGAFile(
if (bytesWritten != rowPitch)
return E_FAIL;
#else
#else
outFile.write(reinterpret_cast<char*>(temp.get()), rowPitch);
if (!outFile)
return E_FAIL;
#endif
#endif
}
uint32_t extOffset = 0;
@ -2300,7 +2300,7 @@ HRESULT DirectX::SaveToTGAFile(
TGA_EXTENSION ext = {};
SetExtension(&ext, flags, *metadata);
#ifdef WIN32
#ifdef WIN32
extOffset = SetFilePointer(hFile.get(), 0, nullptr, FILE_CURRENT);
if (extOffset == INVALID_SET_FILE_POINTER)
{
@ -2314,7 +2314,7 @@ HRESULT DirectX::SaveToTGAFile(
if (bytesWritten != sizeof(TGA_EXTENSION))
return E_FAIL;
#else
#else
extOffset = static_cast<uint32_t>(outFile.tellp());
if (!outFile)
return E_FAIL;
@ -2322,7 +2322,7 @@ HRESULT DirectX::SaveToTGAFile(
outFile.write(reinterpret_cast<char*>(&ext), sizeof(TGA_EXTENSION));
if (!outFile)
return E_FAIL;
#endif
#endif
}
// Write TGA 2.0 footer
@ -2330,7 +2330,7 @@ HRESULT DirectX::SaveToTGAFile(
footer.dwExtensionOffset = extOffset;
memcpy(footer.Signature, g_Signature, sizeof(g_Signature));
#ifdef WIN32
#ifdef WIN32
if (!WriteFile(hFile.get(), &footer, sizeof(TGA_FOOTER), &bytesWritten, nullptr))
{
return HRESULT_FROM_WIN32(GetLastError());
@ -2338,11 +2338,11 @@ HRESULT DirectX::SaveToTGAFile(
if (bytesWritten != sizeof(footer))
return E_FAIL;
#else
#else
outFile.write(reinterpret_cast<char*>(&footer), sizeof(TGA_FOOTER));
if (!outFile)
return E_FAIL;
#endif
#endif
}
#ifdef WIN32

View File

@ -122,7 +122,7 @@ namespace
return std::aligned_alloc(alignment, size);
}
#define _aligned_free free
#define _aligned_free free
#endif
}
@ -317,14 +317,14 @@ void DirectX::SetWICFactory(_In_opt_ IWICImagingFactory* pWIC) noexcept
bool iswic2 = false;
if (pWIC)
{
#if(_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if(_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
ComPtr<IWICImagingFactory2> wic2;
HRESULT hr = pWIC->QueryInterface(IID_PPV_ARGS(wic2.GetAddressOf()));
if (SUCCEEDED(hr))
{
iswic2 = true;
}
#endif
#endif
pWIC->AddRef();
}

View File

@ -106,7 +106,7 @@ namespace
{
if (memcmp(&GUID_WICPixelFormat96bppRGBFixedPoint, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0)
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
if (iswic2)
{
if (pConvert)
@ -114,9 +114,9 @@ namespace
format = DXGI_FORMAT_R32G32B32_FLOAT;
}
else
#else
#else
UNREFERENCED_PARAMETER(iswic2);
#endif
#endif
{
if (pConvert)
memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat128bppRGBAFloat, sizeof(GUID));
@ -600,7 +600,7 @@ namespace
sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0;
}
}
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
else if (memcmp(&containerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID)) == 0)
{
if (SUCCEEDED(metareader->GetMetadataByName(L"/app1/ifd/exif/{ushort=40961}", &value)) && value.vt == VT_UI2)
@ -623,7 +623,7 @@ namespace
sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0;
}
}
#else
#else
else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2)
{
sRGB = (value.uiVal == 1);
@ -632,7 +632,7 @@ namespace
{
sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0;
}
#endif
#endif
std::ignore = PropVariantClear(&value);
@ -913,7 +913,7 @@ namespace
std::ignore = metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent");
}
}
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
else if (memcmp(&containerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID)) == 0)
{
// Set Software name
@ -940,7 +940,7 @@ namespace
std::ignore = metawriter->SetMetadataByName(L"/ifd/exif/{ushort=40961}", &value);
}
}
#else
#else
else
{
// Set Software name
@ -954,7 +954,7 @@ namespace
std::ignore = metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value);
}
}
#endif
#endif
}
else if (hr == WINCODEC_ERR_UNSUPPORTEDOPERATION)
{

View File

@ -18,7 +18,7 @@
#define MAX_INT asint(0x7FFFFFFF)
#define MIN_INT asint(0x80000000)
cbuffer cbCS : register( b0 )
cbuffer cbCS : register(b0)
{
uint g_tex_width;
uint g_num_block_x;
@ -73,14 +73,14 @@ static const uint candidateFixUpIndex1D[32] =
};
//0, 9, 18, 27, 37, 46, 55, 64
static const uint aStep1[64] = {0,0,0,0,0,1,1,1,
static const uint aStep1[64] = { 0,0,0,0,0,1,1,1,
1,1,1,1,1,1,2,2,
2,2,2,2,2,2,2,3,
3,3,3,3,3,3,3,3,
3,4,4,4,4,4,4,4,
4,4,5,5,5,5,5,5,
5,5,5,6,6,6,6,6,
6,6,6,6,7,7,7,7};
6,6,6,6,7,7,7,7 };
//0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64
static const uint aStep2[64] = { 0, 0, 0, 1, 1, 1, 1, 2,
@ -90,7 +90,7 @@ static const uint aStep2[64] = { 0, 0, 0, 1, 1, 1, 1, 2,
7, 8, 8, 8, 8, 9, 9, 9,
9,10,10,10,10,10,11,11,
11,11,12,12,12,12,13,13,
13,13,14,14,14,14,15,15};
13,13,14,14,14,14,15,15 };
static const float3 RGB2LUM = float3(0.2126f, 0.7152f, 0.0722f);
@ -101,23 +101,23 @@ static const float3 RGB2LUM = float3(0.2126f, 0.7152f, 0.0722f);
//Forward declaration
uint3 float2half( float3 pixel_f );
int3 start_quantize( uint3 pixel_h );
void quantize( inout int2x3 endPoint, uint prec );
void finish_quantize_0( inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed );
void finish_quantize_1( inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed );
void finish_quantize( out bool bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed );
uint3 float2half(float3 pixel_f);
int3 start_quantize(uint3 pixel_h);
void quantize(inout int2x3 endPoint, uint prec);
void finish_quantize_0(inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed);
void finish_quantize_1(inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed);
void finish_quantize(out bool bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed);
void start_unquantize( inout int2x3 endPoint[2], uint4 prec, bool transformed );
void start_unquantize( inout int2x3 endPoint, uint4 prec, bool transformed );
void unquantize( inout int2x3 color, uint prec );
uint3 finish_unquantize( int3 color );
void generate_palette_unquantized8( out uint3 palette, int3 low, int3 high, int i );
void generate_palette_unquantized16( out uint3 palette, int3 low, int3 high, int i );
float3 half2float(uint3 color_h );
void start_unquantize(inout int2x3 endPoint[2], uint4 prec, bool transformed);
void start_unquantize(inout int2x3 endPoint, uint4 prec, bool transformed);
void unquantize(inout int2x3 color, uint prec);
uint3 finish_unquantize(int3 color);
void generate_palette_unquantized8(out uint3 palette, int3 low, int3 high, int i);
void generate_palette_unquantized16(out uint3 palette, int3 low, int3 high, int i);
float3 half2float(uint3 color_h);
void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint partition_index );
void block_package( inout uint4 block, int2x3 endPoint, uint mode_type );
void block_package(inout uint4 block, int2x3 endPoint[2], uint mode_type, uint partition_index);
void block_package(inout uint4 block, int2x3 endPoint, uint mode_type);
void swap(inout int3 lhs, inout int3 rhs)
{
@ -126,10 +126,10 @@ void swap(inout int3 lhs, inout int3 rhs)
rhs = tmp;
}
Texture2D<float4> g_Input : register( t0 );
StructuredBuffer<uint4> g_InBuff : register( t1 );
Texture2D<float4> g_Input : register(t0);
StructuredBuffer<uint4> g_InBuff : register(t1);
RWStructuredBuffer<uint4> g_OutBuff : register( u0 );
RWStructuredBuffer<uint4> g_OutBuff : register(u0);
struct SharedData
{
@ -148,8 +148,8 @@ struct SharedData
groupshared SharedData shared_temp[THREAD_GROUP_SIZE];
[numthreads( THREAD_GROUP_SIZE, 1, 1 )]
void TryModeG10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
[numthreads(THREAD_GROUP_SIZE, 1, 1)]
void TryModeG10CS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
{
const uint MAX_USED_THREAD = 16;
uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD;
@ -172,11 +172,11 @@ void TryModeG10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
if (threadInBlock < 16)
{
shared_temp[GI].pixel = g_Input.Load( uint3( base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0 ) ).rgb;
uint3 pixel_h = float2half( shared_temp[GI].pixel );
shared_temp[GI].pixel = g_Input.Load(uint3(base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0)).rgb;
uint3 pixel_h = float2half(shared_temp[GI].pixel);
shared_temp[GI].pixel_hr = half2float(pixel_h);
shared_temp[GI].pixel_lum = dot(shared_temp[GI].pixel_hr, RGB2LUM);
shared_temp[GI].pixel_ph = start_quantize( pixel_h );
shared_temp[GI].pixel_ph = start_quantize(pixel_h);
shared_temp[GI].endPoint_low = shared_temp[GI].pixel_ph;
shared_temp[GI].endPoint_high = shared_temp[GI].pixel_ph;
@ -253,7 +253,7 @@ void TryModeG10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
#endif
//ergod mode_type 11:14
if ( threadInBlock == 0 )
if (threadInBlock == 0)
{
int2x3 endPoint;
// find_axis
@ -262,9 +262,9 @@ void TryModeG10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
//compute_index
float3 span = endPoint[1] - endPoint[0];// fixed a bug in v0.2
float span_norm_sqr = dot( span, span );// fixed a bug in v0.2
float dotProduct = dot( span, shared_temp[threadBase + 0].pixel_ph - endPoint[0] );// fixed a bug in v0.2
if ( span_norm_sqr > 0 && dotProduct >= 0 && uint( dotProduct * 63.49999 / span_norm_sqr ) > 32 )
float span_norm_sqr = dot(span, span);// fixed a bug in v0.2
float dotProduct = dot(span, shared_temp[threadBase + 0].pixel_ph - endPoint[0]);// fixed a bug in v0.2
if (span_norm_sqr > 0 && dotProduct >= 0 && uint(dotProduct * 63.49999 / span_norm_sqr) > 32)
{
swap(endPoint[0], endPoint[1]);
@ -283,11 +283,11 @@ void TryModeG10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
endPoint[1] = shared_temp[threadBase + 0].endPoint_high;
float3 span = endPoint[1] - endPoint[0];
float span_norm_sqr = dot( span, span );
float span_norm_sqr = dot(span, span);
uint4 prec = candidateModePrec[threadInBlock + 10];
int2x3 endPoint_q = endPoint;
quantize( endPoint_q, prec.x );
quantize(endPoint_q, prec.x);
bool transformed = candidateModeTransformed[threadInBlock + 10];
if (transformed)
@ -296,26 +296,26 @@ void TryModeG10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
}
bool bBadQuantize;
finish_quantize( bBadQuantize, endPoint_q, prec, transformed );
finish_quantize(bBadQuantize, endPoint_q, prec, transformed);
start_unquantize( endPoint_q, prec, transformed );
start_unquantize(endPoint_q, prec, transformed);
unquantize( endPoint_q, prec.x );
unquantize(endPoint_q, prec.x);
float error = 0;
[loop]for ( uint j = 0; j < 16; j ++ )
[loop] for (uint j = 0; j < 16; j++)
{
float dotProduct = dot( span, shared_temp[threadBase + j].pixel_ph - endPoint[0] );// fixed a bug in v0.2
uint index = ( span_norm_sqr <= 0 || dotProduct <= 0 ) ? 0
: ( ( dotProduct < span_norm_sqr ) ? aStep2[ uint( dotProduct * 63.49999 / span_norm_sqr ) ] : aStep2[63] );
float dotProduct = dot(span, shared_temp[threadBase + j].pixel_ph - endPoint[0]);// fixed a bug in v0.2
uint index = (span_norm_sqr <= 0 || dotProduct <= 0) ? 0
: ((dotProduct < span_norm_sqr) ? aStep2[uint(dotProduct * 63.49999 / span_norm_sqr)] : aStep2[63]);
uint3 pixel_rh;
generate_palette_unquantized16( pixel_rh, endPoint_q[0], endPoint_q[1], index );
float3 pixel_r = half2float( pixel_rh );
generate_palette_unquantized16(pixel_rh, endPoint_q[0], endPoint_q[1], index);
float3 pixel_r = half2float(pixel_rh);
pixel_r -= shared_temp[threadBase + j].pixel_hr;
error += dot(pixel_r, pixel_r);
}
if ( bBadQuantize )
if (bBadQuantize)
error = 1e20f;
shared_temp[GI].error = error;
@ -327,7 +327,7 @@ void TryModeG10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
if (threadInBlock < 2)
{
if ( shared_temp[GI].error > shared_temp[GI + 2].error )
if (shared_temp[GI].error > shared_temp[GI + 2].error)
{
shared_temp[GI].error = shared_temp[GI + 2].error;
shared_temp[GI].best_mode = shared_temp[GI + 2].best_mode;
@ -338,7 +338,7 @@ void TryModeG10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
#endif
if (threadInBlock < 1)
{
if ( shared_temp[GI].error > shared_temp[GI + 1].error )
if (shared_temp[GI].error > shared_temp[GI + 1].error)
{
shared_temp[GI].error = shared_temp[GI + 1].error;
shared_temp[GI].best_mode = shared_temp[GI + 1].best_mode;
@ -348,8 +348,8 @@ void TryModeG10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
}
}
[numthreads( THREAD_GROUP_SIZE, 1, 1 )]
void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
[numthreads(THREAD_GROUP_SIZE, 1, 1)]
void TryModeLE10CS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
{
const uint MAX_USED_THREAD = 32;
uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD;
@ -378,11 +378,11 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
if (threadInBlock < 16)
{
shared_temp[GI].pixel = g_Input.Load( uint3( base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0 ) ).rgb;
uint3 pixel_h = float2half( shared_temp[GI].pixel );
shared_temp[GI].pixel = g_Input.Load(uint3(base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0)).rgb;
uint3 pixel_h = float2half(shared_temp[GI].pixel);
shared_temp[GI].pixel_hr = half2float(pixel_h);
shared_temp[GI].pixel_lum = dot(shared_temp[GI].pixel_hr, RGB2LUM);
shared_temp[GI].pixel_ph = start_quantize( pixel_h );
shared_temp[GI].pixel_ph = start_quantize(pixel_h);
}
#ifdef REF_DEVICE
GroupMemoryBarrierWithGroupSync();
@ -405,11 +405,11 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
endPoint_lum[1][1] = MIN_FLOAT;
uint bit = candidateSectionBit[threadInBlock];
for ( uint i = 0; i < 16; i ++ )
for (uint i = 0; i < 16; i++)
{
int3 pixel_ph = shared_temp[threadBase + i].pixel_ph;
float pixel_lum = shared_temp[threadBase + i].pixel_lum;
if ( (bit >> i) & 1 ) //It gets error when using "candidateSection" as "endPoint_ph" index
if ((bit >> i) & 1) //It gets error when using "candidateSection" as "endPoint_ph" index
{
if (endPoint_lum[1][0] > pixel_lum)
{
@ -441,13 +441,13 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
float3 span[2];// fixed a bug in v0.2
float span_norm_sqr[2];// fixed a bug in v0.2
[unroll]
for (uint p = 0; p < 2; ++ p)
for (uint p = 0; p < 2; ++p)
{
span[p] = endPoint[p][1] - endPoint[p][0];
span_norm_sqr[p] = dot( span[p], span[p] );
span_norm_sqr[p] = dot(span[p], span[p]);
float dotProduct = dot( span[p], shared_temp[threadBase + (0 == p ? 0 : candidateFixUpIndex1D[threadInBlock])].pixel_ph - endPoint[p][0] );// fixed a bug in v0.2
if ( span_norm_sqr[p] > 0 && dotProduct >= 0 && uint( dotProduct * 63.49999 / span_norm_sqr[p] ) > 32 )
float dotProduct = dot(span[p], shared_temp[threadBase + (0 == p ? 0 : candidateFixUpIndex1D[threadInBlock])].pixel_ph - endPoint[p][0]);// fixed a bug in v0.2
if (span_norm_sqr[p] > 0 && dotProduct >= 0 && uint(dotProduct * 63.49999 / span_norm_sqr[p]) > 32)
{
span[p] = -span[p];
swap(endPoint[p][0], endPoint[p][1]);
@ -456,8 +456,8 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
uint4 prec = candidateModePrec[g_mode_id];
int2x3 endPoint_q[2] = endPoint;
quantize( endPoint_q[0], prec.x );
quantize( endPoint_q[1], prec.x );
quantize(endPoint_q[0], prec.x);
quantize(endPoint_q[1], prec.x);
bool transformed = candidateModeTransformed[g_mode_id];
if (transformed)
@ -468,38 +468,38 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
}
int bBadQuantize = 0;
finish_quantize_0( bBadQuantize, endPoint_q[0], prec, transformed );
finish_quantize_1( bBadQuantize, endPoint_q[1], prec, transformed );
finish_quantize_0(bBadQuantize, endPoint_q[0], prec, transformed);
finish_quantize_1(bBadQuantize, endPoint_q[1], prec, transformed);
start_unquantize( endPoint_q, prec, transformed );
start_unquantize(endPoint_q, prec, transformed);
unquantize( endPoint_q[0], prec.x );
unquantize( endPoint_q[1], prec.x );
unquantize(endPoint_q[0], prec.x);
unquantize(endPoint_q[1], prec.x);
float error = 0;
for ( uint j = 0; j < 16; j ++ )
for (uint j = 0; j < 16; j++)
{
uint3 pixel_rh;
if ((bit >> j) & 1)
{
float dotProduct = dot( span[1], shared_temp[threadBase + j].pixel_ph - endPoint[1][0] );// fixed a bug in v0.2
uint index = ( span_norm_sqr[1] <= 0 || dotProduct <= 0 ) ? 0
: ( ( dotProduct < span_norm_sqr[1] ) ? aStep1[ uint( dotProduct * 63.49999 / span_norm_sqr[1] ) ] : aStep1[63] );
generate_palette_unquantized8( pixel_rh, endPoint_q[1][0], endPoint_q[1][1], index );
float dotProduct = dot(span[1], shared_temp[threadBase + j].pixel_ph - endPoint[1][0]);// fixed a bug in v0.2
uint index = (span_norm_sqr[1] <= 0 || dotProduct <= 0) ? 0
: ((dotProduct < span_norm_sqr[1]) ? aStep1[uint(dotProduct * 63.49999 / span_norm_sqr[1])] : aStep1[63]);
generate_palette_unquantized8(pixel_rh, endPoint_q[1][0], endPoint_q[1][1], index);
}
else
{
float dotProduct = dot( span[0], shared_temp[threadBase + j].pixel_ph - endPoint[0][0] );// fixed a bug in v0.2
uint index = ( span_norm_sqr[0] <= 0 || dotProduct <= 0 ) ? 0
: ( ( dotProduct < span_norm_sqr[0] ) ? aStep1[ uint( dotProduct * 63.49999 / span_norm_sqr[0] ) ] : aStep1[63] );
generate_palette_unquantized8( pixel_rh, endPoint_q[0][0], endPoint_q[0][1], index );
float dotProduct = dot(span[0], shared_temp[threadBase + j].pixel_ph - endPoint[0][0]);// fixed a bug in v0.2
uint index = (span_norm_sqr[0] <= 0 || dotProduct <= 0) ? 0
: ((dotProduct < span_norm_sqr[0]) ? aStep1[uint(dotProduct * 63.49999 / span_norm_sqr[0])] : aStep1[63]);
generate_palette_unquantized8(pixel_rh, endPoint_q[0][0], endPoint_q[0][1], index);
}
float3 pixel_r = half2float( pixel_rh );
float3 pixel_r = half2float(pixel_rh);
pixel_r -= shared_temp[threadBase + j].pixel_hr;
error += dot(pixel_r, pixel_r);
}
if ( bBadQuantize )
if (bBadQuantize)
error = 1e20f;
shared_temp[GI].error = error;
@ -512,7 +512,7 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
if (threadInBlock < 16)
{
if ( shared_temp[GI].error > shared_temp[GI + 16].error )
if (shared_temp[GI].error > shared_temp[GI + 16].error)
{
shared_temp[GI].error = shared_temp[GI + 16].error;
shared_temp[GI].best_mode = shared_temp[GI + 16].best_mode;
@ -524,7 +524,7 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
#endif
if (threadInBlock < 8)
{
if ( shared_temp[GI].error > shared_temp[GI + 8].error )
if (shared_temp[GI].error > shared_temp[GI + 8].error)
{
shared_temp[GI].error = shared_temp[GI + 8].error;
shared_temp[GI].best_mode = shared_temp[GI + 8].best_mode;
@ -536,7 +536,7 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
#endif
if (threadInBlock < 4)
{
if ( shared_temp[GI].error > shared_temp[GI + 4].error )
if (shared_temp[GI].error > shared_temp[GI + 4].error)
{
shared_temp[GI].error = shared_temp[GI + 4].error;
shared_temp[GI].best_mode = shared_temp[GI + 4].best_mode;
@ -548,7 +548,7 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
#endif
if (threadInBlock < 2)
{
if ( shared_temp[GI].error > shared_temp[GI + 2].error )
if (shared_temp[GI].error > shared_temp[GI + 2].error)
{
shared_temp[GI].error = shared_temp[GI + 2].error;
shared_temp[GI].best_mode = shared_temp[GI + 2].best_mode;
@ -560,7 +560,7 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
#endif
if (threadInBlock < 1)
{
if ( shared_temp[GI].error > shared_temp[GI + 1].error )
if (shared_temp[GI].error > shared_temp[GI + 1].error)
{
shared_temp[GI].error = shared_temp[GI + 1].error;
shared_temp[GI].best_mode = shared_temp[GI + 1].best_mode;
@ -578,7 +578,7 @@ void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID )
}
}
[numthreads( THREAD_GROUP_SIZE, 1, 1 )]
[numthreads(THREAD_GROUP_SIZE, 1, 1)]
void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
{
const uint MAX_USED_THREAD = 32;
@ -602,10 +602,10 @@ void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
if (threadInBlock < 16)
{
shared_temp[GI].pixel = g_Input.Load( uint3( base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0 ) ).rgb;
shared_temp[GI].pixel = g_Input.Load(uint3(base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0)).rgb;
shared_temp[GI].pixel_lum = dot(shared_temp[GI].pixel, RGB2LUM);
uint3 pixel_h = float2half( shared_temp[GI].pixel );
shared_temp[GI].pixel_ph = start_quantize( pixel_h );
uint3 pixel_h = float2half(shared_temp[GI].pixel);
shared_temp[GI].pixel_ph = start_quantize(pixel_h);
}
#ifdef REF_DEVICE
GroupMemoryBarrierWithGroupSync();
@ -750,9 +750,9 @@ void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
}
float3 span = endPoint[1] - endPoint[0];
float span_norm_sqr = dot( span, span );
float dotProduct = dot( span, shared_temp[threadBase + fixup].pixel_ph - endPoint[0] );
if ( span_norm_sqr > 0 && dotProduct >= 0 && uint( dotProduct * 63.49999 / span_norm_sqr ) > 32 )
float span_norm_sqr = dot(span, span);
float dotProduct = dot(span, shared_temp[threadBase + fixup].pixel_ph - endPoint[0]);
if (span_norm_sqr > 0 && dotProduct >= 0 && uint(dotProduct * 63.49999 / span_norm_sqr) > 32)
{
swap(endPoint[0], endPoint[1]);
}
@ -781,19 +781,19 @@ void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
if ((bits >> threadInBlock) & 1)
{
span = shared_temp[threadBase + 1].endPoint_high - shared_temp[threadBase + 1].endPoint_low;
dotProduct = dot( span, shared_temp[threadBase + threadInBlock].pixel_ph - shared_temp[threadBase + 1].endPoint_low );
dotProduct = dot(span, shared_temp[threadBase + threadInBlock].pixel_ph - shared_temp[threadBase + 1].endPoint_low);
}
else
{
span = shared_temp[threadBase + 0].endPoint_high - shared_temp[threadBase + 0].endPoint_low;
dotProduct = dot( span, shared_temp[threadBase + threadInBlock].pixel_ph - shared_temp[threadBase + 0].endPoint_low );
dotProduct = dot(span, shared_temp[threadBase + threadInBlock].pixel_ph - shared_temp[threadBase + 0].endPoint_low);
}
float span_norm_sqr = dot( span, span );
float span_norm_sqr = dot(span, span);
if (best_mode > 10)
{
uint index = ( span_norm_sqr <= 0 || dotProduct <= 0 ) ? 0
: ( ( dotProduct < span_norm_sqr ) ? aStep2[ uint( dotProduct * 63.49999 / span_norm_sqr ) ] : aStep2[63] );
uint index = (span_norm_sqr <= 0 || dotProduct <= 0) ? 0
: ((dotProduct < span_norm_sqr) ? aStep2[uint(dotProduct * 63.49999 / span_norm_sqr)] : aStep2[63]);
if (threadInBlock == 0)
{
block.z |= index << 1;
@ -809,8 +809,8 @@ void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
}
else
{
uint index = ( span_norm_sqr <= 0 || dotProduct <= 0 ) ? 0
: ( ( dotProduct < span_norm_sqr ) ? aStep1[ uint( dotProduct * 63.49999 / span_norm_sqr ) ] : aStep1[63] );
uint index = (span_norm_sqr <= 0 || dotProduct <= 0) ? 0
: ((dotProduct < span_norm_sqr) ? aStep1[uint(dotProduct * 63.49999 / span_norm_sqr)] : aStep1[63]);
uint fixup = candidateFixUpIndex1D[best_partition];
int2 offset = int2((fixup != 2), (fixup == 15));
@ -889,7 +889,7 @@ void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
endPoint_q[0] = shared_temp[threadBase + 0].endPoint_low;
endPoint_q[1] = shared_temp[threadBase + 0].endPoint_high;
quantize( endPoint_q, prec.x );
quantize(endPoint_q, prec.x);
if (transformed)
{
endPoint_q[1] -= endPoint_q[0];
@ -910,7 +910,7 @@ void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
if (best_mode <= 10)
{
quantize( endPoint_q, prec.x );
quantize(endPoint_q, prec.x);
if (transformed)
{
endPoint_q[0] -= ep0;
@ -936,18 +936,18 @@ void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
{
if (best_mode > 10)
{
finish_quantize( bBadQuantize, endPoint_q, prec, transformed );
finish_quantize(bBadQuantize, endPoint_q, prec, transformed);
}
else
{
finish_quantize_0( bBadQuantize, endPoint_q, prec, transformed );
finish_quantize_0(bBadQuantize, endPoint_q, prec, transformed);
}
}
else // if (threadInBlock == 1)
{
if (best_mode <= 10)
{
finish_quantize_1( bBadQuantize, endPoint_q, prec, transformed );
finish_quantize_1(bBadQuantize, endPoint_q, prec, transformed);
}
}
@ -958,7 +958,7 @@ void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
GroupMemoryBarrierWithGroupSync();
#endif
if ( threadInBlock == 0 )
if (threadInBlock == 0)
{
int2x3 endPoint_q[2];
endPoint_q[0][0] = shared_temp[threadBase + 0].endPoint_low;
@ -966,20 +966,20 @@ void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID)
endPoint_q[1][0] = shared_temp[threadBase + 1].endPoint_low;
endPoint_q[1][1] = shared_temp[threadBase + 1].endPoint_high;
if ( best_mode > 10 )
if (best_mode > 10)
{
block_package( block, endPoint_q[0], best_mode );
block_package(block, endPoint_q[0], best_mode);
}
else
{
block_package( block, endPoint_q, best_mode, best_partition );
block_package(block, endPoint_q, best_mode, best_partition);
}
g_OutBuff[blockID] = block;
}
}
uint float2half1( float f )
uint float2half1(float f)
{
uint Result;
@ -1012,7 +1012,7 @@ uint float2half1( float f )
return (Result|Sign);
}
uint3 float2half( float3 endPoint_f )
uint3 float2half(float3 endPoint_f)
{
//uint3 sign = asuint(endPoint_f) & 0x80000000;
//uint3 expo = asuint(endPoint_f) & 0x7F800000;
@ -1027,140 +1027,140 @@ uint3 float2half( float3 endPoint_f )
// : ( ( sign >> 16 ) | ( ( ( expo - 0x38000000 ) | base ) >> 13 ) ) ) );
return uint3( float2half1( endPoint_f.x ), float2half1( endPoint_f.y ), float2half1( endPoint_f.z ) );
return uint3(float2half1(endPoint_f.x), float2half1(endPoint_f.y), float2half1(endPoint_f.z));
}
int3 start_quantize( uint3 pixel_h )
int3 start_quantize(uint3 pixel_h)
{
if ( g_format == UNSIGNED_F16 )
if (g_format == UNSIGNED_F16)
{
return asint( ( pixel_h << 6 ) / 31 );
return asint((pixel_h << 6) / 31);
}
else
{
return ( pixel_h < 0x8000 ) ? ( ( pixel_h == 0x7bff ) ? 0x7fff : asint( ( pixel_h << 5 ) / 31 ) )// fixed a bug in v0.2
: ( ( pixel_h == 0x7bff ) ? 0xffff8001 : -asint( ( ( 0x00007fff & pixel_h ) << 5 ) / 31 ) );// fixed a bug in v0.2
return (pixel_h < 0x8000) ? ((pixel_h == 0x7bff) ? 0x7fff : asint((pixel_h << 5) / 31))// fixed a bug in v0.2
: ((pixel_h == 0x7bff) ? 0xffff8001 : -asint(((0x00007fff & pixel_h) << 5) / 31));// fixed a bug in v0.2
}
}
void quantize( inout int2x3 endPoint, uint prec )
void quantize(inout int2x3 endPoint, uint prec)
{
int iprec = asint( prec );
if ( g_format == UNSIGNED_F16 )
int iprec = asint(prec);
if (g_format == UNSIGNED_F16)
{
endPoint = ( ( iprec >= 15 ) | ( endPoint == 0 ) ) ? endPoint
: ( ( endPoint == asint(0xFFFF) ) ? ( ( 1 << iprec ) - 1 )
: ( ( ( endPoint << iprec ) + asint(0x0000) ) >> 16 ) );
endPoint = ((iprec >= 15) | (endPoint == 0)) ? endPoint
: ((endPoint == asint(0xFFFF)) ? ((1 << iprec) - 1)
: (((endPoint << iprec) + asint(0x0000)) >> 16));
}
else
{
endPoint = ( ( iprec >= 16 ) | ( endPoint == 0 ) ) ? endPoint
: ( ( endPoint >= 0 ) ? ( ( endPoint == asint(0x7FFF) ) ? ( ( 1 << ( iprec - 1 ) ) - 1 ) : ( ( ( endPoint << ( iprec - 1 ) ) + asint(0x0000) ) >> 15 ) )
: ( ( -endPoint == asint(0x7FFF) ) ? -( ( 1 << ( iprec - 1 ) ) - 1 ) : -( ( ( -endPoint << ( iprec - 1 ) ) + asint(0x0000) ) >> 15 ) ) );
endPoint = ((iprec >= 16) | (endPoint == 0)) ? endPoint
: ((endPoint >= 0) ? ((endPoint == asint(0x7FFF)) ? ((1 << (iprec - 1)) - 1) : (((endPoint << (iprec - 1)) + asint(0x0000)) >> 15))
: ((-endPoint == asint(0x7FFF)) ? -((1 << (iprec - 1)) - 1) : -(((-endPoint << (iprec - 1)) + asint(0x0000)) >> 15)));
}
}
void finish_quantize_0( inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed )
void finish_quantize_0(inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed)
{
if ( transformed )
if (transformed)
{
bool3 bBadComponent = ( endPoint[1] >= 0 ) ? ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) )
: ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) );
bool3 bBadComponent = (endPoint[1] >= 0) ? (endPoint[1] >= (1 << (prec.yzw - 1)))
: (-endPoint[1] > (1 << (prec.yzw - 1)));
bBadQuantize |= any(bBadComponent);
endPoint[0] = endPoint[0] & ( ( 1 << prec.x ) - 1 );
endPoint[1] = ( endPoint[1] >= 0 ) ? ( ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) ) ? ( ( 1 << ( prec.yzw - 1 ) ) - 1 ) : endPoint[1] )
: ( ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) ) ? ( 1 << ( prec.yzw - 1 ) ) : ( endPoint[1] & ( ( 1 << prec.yzw ) - 1 ) ) );
endPoint[0] = endPoint[0] & ((1 << prec.x) - 1);
endPoint[1] = (endPoint[1] >= 0) ? ((endPoint[1] >= (1 << (prec.yzw - 1))) ? ((1 << (prec.yzw - 1)) - 1) : endPoint[1])
: ((-endPoint[1] > (1 << (prec.yzw - 1))) ? (1 << (prec.yzw - 1)) : (endPoint[1] & ((1 << prec.yzw) - 1)));
}
else
{
endPoint &= ( ( 1 << prec.x ) - 1 );
endPoint &= ((1 << prec.x) - 1);
}
}
void finish_quantize_1( inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed )
void finish_quantize_1(inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed)
{
if ( transformed )
if (transformed)
{
bool2x3 bBadComponent;
bBadComponent[0] = ( endPoint[0] >= 0 ) ? ( endPoint[0] >= ( 1 << ( prec.yzw - 1 ) ) )
: ( -endPoint[0] > ( 1 << ( prec.yzw - 1 ) ) );
bBadComponent[1] = ( endPoint[1] >= 0 ) ? ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) )
: ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) );
bBadComponent[0] = (endPoint[0] >= 0) ? (endPoint[0] >= (1 << (prec.yzw - 1)))
: (-endPoint[0] > (1 << (prec.yzw - 1)));
bBadComponent[1] = (endPoint[1] >= 0) ? (endPoint[1] >= (1 << (prec.yzw - 1)))
: (-endPoint[1] > (1 << (prec.yzw - 1)));
bBadQuantize |= any(bBadComponent);
endPoint[0] = ( endPoint[0] >= 0 ) ? ( ( endPoint[0] >= ( 1 << ( prec.yzw - 1 ) ) ) ? ( ( 1 << ( prec.yzw - 1 ) ) - 1 ) : endPoint[0] )
: ( ( -endPoint[0] > ( 1 << ( prec.yzw - 1 ) ) ) ? ( 1 << ( prec.yzw - 1 ) ) : ( endPoint[0] & ( ( 1 << prec.yzw ) - 1 ) ) );
endPoint[1] = ( endPoint[1] >= 0 ) ? ( ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) ) ? ( ( 1 << ( prec.yzw - 1 ) ) - 1 ) : endPoint[1] )
: ( ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) ) ? ( 1 << ( prec.yzw - 1 ) ) : ( endPoint[1] & ( ( 1 << prec.yzw ) - 1 ) ) );
endPoint[0] = (endPoint[0] >= 0) ? ((endPoint[0] >= (1 << (prec.yzw - 1))) ? ((1 << (prec.yzw - 1)) - 1) : endPoint[0])
: ((-endPoint[0] > (1 << (prec.yzw - 1))) ? (1 << (prec.yzw - 1)) : (endPoint[0] & ((1 << prec.yzw) - 1)));
endPoint[1] = (endPoint[1] >= 0) ? ((endPoint[1] >= (1 << (prec.yzw - 1))) ? ((1 << (prec.yzw - 1)) - 1) : endPoint[1])
: ((-endPoint[1] > (1 << (prec.yzw - 1))) ? (1 << (prec.yzw - 1)) : (endPoint[1] & ((1 << prec.yzw) - 1)));
}
else
{
endPoint &= ( ( 1 << prec.x ) - 1 );
endPoint &= ((1 << prec.x) - 1);
}
}
void finish_quantize( out bool bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed )
void finish_quantize(out bool bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed)
{
if ( transformed )
if (transformed)
{
bool3 bBadComponent;
bBadComponent = ( endPoint[1] >= 0 ) ? ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) )
: ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) );
bBadQuantize = any( bBadComponent );
bBadComponent = (endPoint[1] >= 0) ? (endPoint[1] >= (1 << (prec.yzw - 1)))
: (-endPoint[1] > (1 << (prec.yzw - 1)));
bBadQuantize = any(bBadComponent);
endPoint[0] = endPoint[0] & ( ( 1 << prec.x ) - 1 );
endPoint[1] = ( endPoint[1] >= 0 ) ? ( ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) ) ? ( ( 1 << ( prec.yzw - 1 ) ) - 1 ) : endPoint[1] )
: ( ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) ) ? ( 1 << ( prec.yzw - 1 ) ) : ( endPoint[1] & ( ( 1 << prec.yzw ) - 1 ) ) );
endPoint[0] = endPoint[0] & ((1 << prec.x) - 1);
endPoint[1] = (endPoint[1] >= 0) ? ((endPoint[1] >= (1 << (prec.yzw - 1))) ? ((1 << (prec.yzw - 1)) - 1) : endPoint[1])
: ((-endPoint[1] > (1 << (prec.yzw - 1))) ? (1 << (prec.yzw - 1)) : (endPoint[1] & ((1 << prec.yzw) - 1)));
}
else
{
endPoint &= ( ( 1 << prec.x ) - 1 );
endPoint &= ((1 << prec.x) - 1);
bBadQuantize = 0;
}
}
void SIGN_EXTEND( uint3 prec, inout int3 color )
void SIGN_EXTEND(uint3 prec, inout int3 color)
{
uint3 p = 1 << (prec - 1);
color = (color & p) ? (color & (p - 1)) - p : color;
}
void sign_extend( bool transformed, uint4 prec, inout int2x3 endPoint )
void sign_extend(bool transformed, uint4 prec, inout int2x3 endPoint)
{
if ( g_format == SIGNED_F16 )
SIGN_EXTEND( prec.x, endPoint[0] );
if ( g_format == SIGNED_F16 || transformed )
SIGN_EXTEND( prec.yzw, endPoint[1] );
if (g_format == SIGNED_F16)
SIGN_EXTEND(prec.x, endPoint[0]);
if (g_format == SIGNED_F16 || transformed)
SIGN_EXTEND(prec.yzw, endPoint[1]);
}
void sign_extend( bool transformed, uint4 prec, inout int2x3 endPoint[2] )
void sign_extend(bool transformed, uint4 prec, inout int2x3 endPoint[2])
{
if ( g_format == SIGNED_F16 )
SIGN_EXTEND( prec.x, endPoint[0][0] );
if ( g_format == SIGNED_F16 || transformed )
if (g_format == SIGNED_F16)
SIGN_EXTEND(prec.x, endPoint[0][0]);
if (g_format == SIGNED_F16 || transformed)
{
SIGN_EXTEND( prec.yzw, endPoint[0][1] );
SIGN_EXTEND( prec.yzw, endPoint[1][0] );
SIGN_EXTEND( prec.yzw, endPoint[1][1] );
SIGN_EXTEND(prec.yzw, endPoint[0][1]);
SIGN_EXTEND(prec.yzw, endPoint[1][0]);
SIGN_EXTEND(prec.yzw, endPoint[1][1]);
}
}
void start_unquantize( inout int2x3 endPoint[2], uint4 prec, bool transformed )
void start_unquantize(inout int2x3 endPoint[2], uint4 prec, bool transformed)
{
sign_extend( transformed, prec, endPoint );
if ( transformed )
sign_extend(transformed, prec, endPoint);
if (transformed)
{
endPoint[0][1] += endPoint[0][0];
endPoint[1][0] += endPoint[0][0];
endPoint[1][1] += endPoint[0][0];
}
}
void start_unquantize( inout int2x3 endPoint, uint4 prec, bool transformed )
void start_unquantize(inout int2x3 endPoint, uint4 prec, bool transformed)
{
sign_extend( transformed, prec, endPoint );
if ( transformed )
sign_extend(transformed, prec, endPoint);
if (transformed)
endPoint[1] += endPoint[0];
}
void unquantize( inout int2x3 color, uint prec )
void unquantize(inout int2x3 color, uint prec)
{
int iprec = asint( prec );
if (g_format == UNSIGNED_F16 )
int iprec = asint(prec);
if (g_format == UNSIGNED_F16)
{
if (prec < 15)
{
@ -1178,33 +1178,33 @@ void unquantize( inout int2x3 color, uint prec )
}
}
}
uint3 finish_unquantize( int3 color )
uint3 finish_unquantize(int3 color)
{
if ( g_format == UNSIGNED_F16 )
color = ( color * 31 ) >> 6;
if (g_format == UNSIGNED_F16)
color = (color * 31) >> 6;
else
{
color = ( color < 0 ) ? -( ( -color * 31 ) >> 5 ) : ( color * 31 ) >> 5;
color = ( color < 0 ) ? ( ( -color ) | 0x8000 ) : color;
color = (color < 0) ? -((-color * 31) >> 5) : (color * 31) >> 5;
color = (color < 0) ? ((-color) | 0x8000) : color;
}
return asuint(color);
}
void generate_palette_unquantized8( out uint3 palette, int3 low, int3 high, int i )
void generate_palette_unquantized8(out uint3 palette, int3 low, int3 high, int i)
{
static const int aWeight3[] = {0, 9, 18, 27, 37, 46, 55, 64};
static const int aWeight3[] = { 0, 9, 18, 27, 37, 46, 55, 64 };
int3 tmp = ( low * ( 64 - aWeight3[i] ) + high * aWeight3[i] + 32 ) >> 6;
palette = finish_unquantize( tmp );
int3 tmp = (low * (64 - aWeight3[i]) + high * aWeight3[i] + 32) >> 6;
palette = finish_unquantize(tmp);
}
void generate_palette_unquantized16( out uint3 palette, int3 low, int3 high, int i )
void generate_palette_unquantized16(out uint3 palette, int3 low, int3 high, int i)
{
static const int aWeight4[] = {0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64};
static const int aWeight4[] = { 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 };
int3 tmp = ( low * ( 64 - aWeight4[i] ) + high * aWeight4[i] + 32 ) >> 6;
palette = finish_unquantize( tmp );
int3 tmp = (low * (64 - aWeight4[i]) + high * aWeight4[i] + 32) >> 6;
palette = finish_unquantize(tmp);
}
float half2float1( uint Value )
float half2float1(uint Value)
{
uint Mantissa = (uint)(Value & 0x03FF);
@ -1238,7 +1238,7 @@ float half2float1( uint Value )
return asfloat(Result);
}
float3 half2float(uint3 color_h )
float3 half2float(uint3 color_h)
{
//uint3 sign = color_h & 0x8000;
//uint3 expo = color_h & 0x7C00;
@ -1246,17 +1246,17 @@ float3 half2float(uint3 color_h )
//return ( expo == 0 ) ? asfloat( ( sign << 16 ) | asuint( float3(base) / 16777216 ) ) //16777216 = 2^24
// : asfloat( ( sign << 16 ) | ( ( ( expo + 0x1C000 ) | base ) << 13 ) ); //0x1C000 = 0x1FC00 - 0x3C00
return float3( half2float1( color_h.x ), half2float1( color_h.y ), half2float1( color_h.z ) );
return float3(half2float1(color_h.x), half2float1(color_h.y), half2float1(color_h.z));
}
void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint partition_index ) // for mode 1 - 10
void block_package(inout uint4 block, int2x3 endPoint[2], uint mode_type, uint partition_index) // for mode 1 - 10
{
block.xy = 0;
block.z &= 0xFFFC0000;
//block.z |= (partition_index & 0x1f) << 13;
if ( mode_type == candidateModeFlag[0])
if (mode_type == candidateModeFlag[0])
{
/*block.x = candidateModeMemory[0];
block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 );
@ -1355,7 +1355,7 @@ void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint
block.z |= ((partition_index >> 3) & 1) << 16;
block.z |= ((partition_index >> 4) & 1) << 17;
}
else if ( mode_type == candidateModeFlag[1])
else if (mode_type == candidateModeFlag[1])
{
/*block.x = candidateModeMemory[1];
block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00000FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x003F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 );
@ -1453,7 +1453,7 @@ void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint
block.z |= ((partition_index >> 3) & 1) << 16;
block.z |= ((partition_index >> 4) & 1) << 17;
}
else if ( mode_type == candidateModeFlag[2])
else if (mode_type == candidateModeFlag[2])
{
/*block.x = candidateModeMemory[2];
block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 );
@ -1550,7 +1550,7 @@ void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint
block.z |= ((partition_index >> 3) & 1) << 16;
block.z |= ((partition_index >> 4) & 1) << 17;
}
else if ( mode_type == candidateModeFlag[3])
else if (mode_type == candidateModeFlag[3])
{
/*block.x = candidateModeMemory[3];
block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 );
@ -1651,7 +1651,7 @@ void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint
block.z |= ((partition_index >> 3) & 1) << 16;
block.z |= ((partition_index >> 4) & 1) << 17;
}
else if ( mode_type == candidateModeFlag[4])
else if (mode_type == candidateModeFlag[4])
{
/*block.x = candidateModeMemory[4];
block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 );
@ -1750,7 +1750,7 @@ void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint
block.z |= ((partition_index >> 3) & 1) << 16;
block.z |= ((partition_index >> 4) & 1) << 17;
}
else if ( mode_type == candidateModeFlag[5])
else if (mode_type == candidateModeFlag[5])
{
/*block.x = candidateModeMemory[5];
block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00003FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x00FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000);
@ -1849,7 +1849,7 @@ void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint
block.z |= ((partition_index >> 3) & 1) << 16;
block.z |= ((partition_index >> 4) & 1) << 17;
}
else if ( mode_type == candidateModeFlag[6])
else if (mode_type == candidateModeFlag[6])
{
/*block.x = candidateModeMemory[6];
block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00001FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x007F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 );
@ -1947,7 +1947,7 @@ void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint
block.z |= ((partition_index >> 3) & 1) << 16;
block.z |= ((partition_index >> 4) & 1) << 17;
}
else if ( mode_type == candidateModeFlag[7])
else if (mode_type == candidateModeFlag[7])
{
/*block.x = candidateModeMemory[7];
block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00001FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x007F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 );
@ -2047,7 +2047,7 @@ void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint
block.z |= ((partition_index >> 3) & 1) << 16;
block.z |= ((partition_index >> 4) & 1) << 17;
}
else if ( mode_type == candidateModeFlag[8])
else if (mode_type == candidateModeFlag[8])
{
/*block.x = candidateModeMemory[8];
block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00001FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x007F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 );
@ -2147,7 +2147,7 @@ void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint
block.z |= ((partition_index >> 3) & 1) << 16;
block.z |= ((partition_index >> 4) & 1) << 17;
}
else if ( mode_type == candidateModeFlag[9])
else if (mode_type == candidateModeFlag[9])
{
/*block.x = candidateModeMemory[9];
block.x |= ( ( endPoint[0][0].r << 5 ) & 0x000007E0 ) | ( ( endPoint[0][0].g << 15 ) & 0x001F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0x7E000000 );
@ -2246,7 +2246,7 @@ void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint
block.z |= ((partition_index >> 4) & 1) << 17;
}
}
void block_package( inout uint4 block, int2x3 endPoint, uint mode_type ) // for mode 11 - 14
void block_package(inout uint4 block, int2x3 endPoint, uint mode_type) // for mode 11 - 14
{
/*block.x = ( ( endPoint[0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0].b << 25 ) & 0xFE000000 );
block.y |= ( endPoint[0].b >> 7 ) & 0x00000007;*/
@ -2255,7 +2255,7 @@ void block_package( inout uint4 block, int2x3 endPoint, uint mode_type ) // for
block.z &= 0xFFFFFFFE;
if ( mode_type == candidateModeFlag[10])
if (mode_type == candidateModeFlag[10])
{
/* block.x |= candidateModeMemory[10];
block.y |= ( ( endPoint[1].r << 3 ) & 0x00001FF8 ) | ( ( endPoint[1].g << 13 ) & 0x007FE000 ) | ( ( endPoint[1].b << 23 ) & 0xFF800000 );

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@ namespace DirectX
XMGLOBALCONST XMVECTORF32 g_boxScale = { { { 0.25f, 0.25f, 0.25f, 0.25f } } };
XMGLOBALCONST XMVECTORF32 g_boxScale3D = { { { 0.125f, 0.125f, 0.125f, 0.125f } } };
#define AVERAGE4( res, p0, p1, p2, p3 ) \
#define AVERAGE4( res, p0, p1, p2, p3 ) \
{ \
XMVECTOR v = XMVectorAdd((p0), (p1)); \
v = XMVectorAdd(v, (p2)); \
@ -36,7 +36,7 @@ namespace DirectX
res = XMVectorMultiply(v, g_boxScale); \
}
#define AVERAGE8( res, p0, p1, p2, p3, p4, p5, p6, p7) \
#define AVERAGE8( res, p0, p1, p2, p3, p4, p5, p6, p7) \
{ \
XMVECTOR v = XMVectorAdd((p0), (p1)); \
v = XMVectorAdd(v, (p2)); \
@ -99,11 +99,11 @@ namespace DirectX
}
}
#define BILINEAR_INTERPOLATE( res, x, y, r0, r1 ) \
#define BILINEAR_INTERPOLATE( res, x, y, r0, r1 ) \
res = XMVectorAdd(XMVectorScale(XMVectorAdd(XMVectorScale((r0)[ x.u0 ], x.weight0), XMVectorScale((r0)[ x.u1 ], x.weight1)), y.weight0), \
XMVectorScale(XMVectorAdd(XMVectorScale((r1)[ x.u0 ], x.weight0), XMVectorScale((r1)[ x.u1 ], x.weight1)), y.weight1) );
#define TRILINEAR_INTERPOLATE( res, x, y, z, r0, r1, r2, r3 ) \
#define TRILINEAR_INTERPOLATE( res, x, y, z, r0, r1, r2, r3 ) \
{\
const XMVECTOR a0 = XMVectorScale(XMVectorAdd(XMVectorScale((r0)[ x.u0 ], x.weight0 ), XMVectorScale((r0)[ x.u1 ], x.weight1)), y.weight0); \
const XMVECTOR a1 = XMVectorScale(XMVectorAdd(XMVectorScale((r1)[ x.u0 ], x.weight0 ), XMVectorScale((r1)[ x.u1 ], x.weight1)), y.weight1); \
@ -189,7 +189,7 @@ namespace DirectX
}
}
#define CUBIC_INTERPOLATE( res, dx, p0, p1, p2, p3 ) \
#define CUBIC_INTERPOLATE( res, dx, p0, p1, p2, p3 ) \
{ \
const XMVECTOR a0 = (p1); \
const XMVECTOR d0 = XMVectorSubtract(p0, a0); \

View File

@ -29,7 +29,7 @@ inline ScopedAlignedArrayFloat make_AlignedArrayFloat(uint64_t count)
if (size > static_cast<uint64_t>(UINT32_MAX))
return nullptr;
auto ptr = aligned_alloc(16, static_cast<size_t>(size) );
auto ptr = aligned_alloc(16, static_cast<size_t>(size));
return ScopedAlignedArrayFloat(static_cast<float*>(ptr));
}

View File

@ -57,7 +57,7 @@ using Microsoft::WRL::ComPtr;
// Macros
//--------------------------------------------------------------------------------------
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
#endif /* defined(MAKEFOURCC) */
@ -69,9 +69,9 @@ using Microsoft::WRL::ComPtr;
//--------------------------------------------------------------------------------------
namespace
{
#pragma pack(push,1)
#pragma pack(push,1)
#define DDS_MAGIC 0x20534444 // "DDS "
#define DDS_MAGIC 0x20534444 // "DDS "
struct DDS_PIXELFORMAT
{
@ -85,20 +85,20 @@ namespace
uint32_t ABitMask;
};
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
#define DDS_RGB 0x00000040 // DDPF_RGB
#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE
#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
#define DDS_ALPHA 0x00000002 // DDPF_ALPHA
#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
#define DDS_RGB 0x00000040 // DDPF_RGB
#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE
#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
#define DDS_ALPHA 0x00000002 // DDPF_ALPHA
#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
struct DDS_HEADER
{
@ -127,7 +127,7 @@ namespace
uint32_t reserved;
};
#pragma pack(pop)
#pragma pack(pop)
const DDS_PIXELFORMAT DDSPF_DXT1 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
@ -574,13 +574,13 @@ namespace
numBytes = rowBytes * height;
}
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!");
if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX)
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
#else
#else
static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!");
#endif
#endif
if (outNumBytes)
{
@ -732,7 +732,7 @@ namespace
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
HRESULT hr = CoCreateInstance(
CLSID_WICImagingFactory2,
nullptr,
@ -758,14 +758,14 @@ namespace
);
return SUCCEEDED(hr) ? TRUE : FALSE;
}
#else
#else
return SUCCEEDED(CoCreateInstance(
CLSID_WICImagingFactory,
nullptr,
CLSCTX_INPROC_SERVER,
__uuidof(IWICImagingFactory),
ifactory)) ? TRUE : FALSE;
#endif
#endif
}
IWICImagingFactory* GetWIC() noexcept
@ -1092,7 +1092,7 @@ HRESULT DirectX::SaveWICTextureToFile(
// Screenshots don't typically include the alpha channel of the render target
switch (desc.Format)
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
case DXGI_FORMAT_R32G32B32A32_FLOAT:
case DXGI_FORMAT_R16G16B16A16_FLOAT:
if (g_WIC2)
@ -1104,7 +1104,7 @@ HRESULT DirectX::SaveWICTextureToFile(
targetGuid = GUID_WICPixelFormat24bppBGR;
}
break;
#endif
#endif
case DXGI_FORMAT_R16G16B16A16_UNORM: targetGuid = GUID_WICPixelFormat48bppBGR; break;
case DXGI_FORMAT_B5G5R5A1_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR555; break;

View File

@ -91,9 +91,9 @@ using Microsoft::WRL::ComPtr;
//--------------------------------------------------------------------------------------
namespace
{
#pragma pack(push,1)
#pragma pack(push,1)
#define DDS_MAGIC 0x20534444 // "DDS "
#define DDS_MAGIC 0x20534444 // "DDS "
struct DDS_PIXELFORMAT
{
@ -107,20 +107,20 @@ namespace
uint32_t ABitMask;
};
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
#define DDS_RGB 0x00000040 // DDPF_RGB
#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE
#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
#define DDS_ALPHA 0x00000002 // DDPF_ALPHA
#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
#define DDS_RGB 0x00000040 // DDPF_RGB
#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE
#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
#define DDS_ALPHA 0x00000002 // DDPF_ALPHA
#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
struct DDS_HEADER
{
@ -149,7 +149,7 @@ namespace
uint32_t reserved;
};
#pragma pack(pop)
#pragma pack(pop)
const DDS_PIXELFORMAT DDSPF_DXT1 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
@ -602,13 +602,13 @@ namespace
numBytes = rowBytes * height;
}
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!");
if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX)
return HRESULT_E_ARITHMETIC_OVERFLOW;
#else
#else
static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!");
#endif
#endif
if (outNumBytes)
{
@ -842,11 +842,11 @@ namespace
// Block until the copy is complete
while (fence->GetCompletedValue() < 1)
{
#ifdef WIN32
#ifdef WIN32
SwitchToThread();
#else
#else
std::this_thread::yield();
#endif
#endif
}
return S_OK;

View File

@ -51,7 +51,7 @@ using Microsoft::WRL::ComPtr;
// Macros
//--------------------------------------------------------------------------------------
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
#endif /* defined(MAKEFOURCC) */
@ -63,9 +63,9 @@ using Microsoft::WRL::ComPtr;
//--------------------------------------------------------------------------------------
namespace
{
#pragma pack(push,1)
#pragma pack(push,1)
#define DDS_MAGIC 0x20534444 // "DDS "
#define DDS_MAGIC 0x20534444 // "DDS "
struct DDS_PIXELFORMAT
{
@ -79,21 +79,21 @@ namespace
uint32_t ABitMask;
};
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
#define DDS_RGB 0x00000040 // DDPF_RGB
#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE
#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
#define DDS_ALPHA 0x00000002 // DDPF_ALPHA
#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV
#define DDS_BUMPLUMINANCE 0x00040000 // DDPF_BUMPLUMINANCE
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
#define DDS_RGB 0x00000040 // DDPF_RGB
#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE
#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS
#define DDS_ALPHA 0x00000002 // DDPF_ALPHA
#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV
#define DDS_BUMPLUMINANCE 0x00040000 // DDPF_BUMPLUMINANCE
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
struct DDS_HEADER
{
@ -113,7 +113,7 @@ namespace
uint32_t reserved2;
};
#pragma pack(pop)
#pragma pack(pop)
const DDS_PIXELFORMAT DDSPF_DXT1 =
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
@ -316,9 +316,9 @@ namespace
case D3DFMT_INDEX32:
case D3DFMT_G16R16F:
case D3DFMT_R32F:
#if !defined(D3D_DISABLE_9EX)
#if !defined(D3D_DISABLE_9EX)
case D3DFMT_D32_LOCKABLE:
#endif
#endif
return 32;
case D3DFMT_R8G8B8:
@ -354,9 +354,9 @@ namespace
case D3DFMT_P8:
case D3DFMT_L8:
case D3DFMT_A4L4:
#if !defined(D3D_DISABLE_9EX)
#if !defined(D3D_DISABLE_9EX)
case D3DFMT_S8_LOCKABLE:
#endif
#endif
return 8;
case D3DFMT_DXT1:
@ -374,10 +374,10 @@ namespace
case MAKEFOURCC('Y', 'V', '1', '2'):
return 12;
#if !defined(D3D_DISABLE_9EX)
#if !defined(D3D_DISABLE_9EX)
case D3DFMT_A1:
return 1;
#endif
#endif
default:
return 0;
@ -483,13 +483,13 @@ namespace
numBytes = rowBytes * height;
}
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!");
if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX)
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
#else
#else
static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!");
#endif
#endif
if (outNumBytes)
{
@ -513,7 +513,7 @@ namespace
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
HRESULT hr = CoCreateInstance(
CLSID_WICImagingFactory2,
nullptr,
@ -539,14 +539,14 @@ namespace
);
return SUCCEEDED(hr) ? TRUE : FALSE;
}
#else
#else
return SUCCEEDED(CoCreateInstance(
CLSID_WICImagingFactory,
nullptr,
CLSCTX_INPROC_SERVER,
__uuidof(IWICImagingFactory),
ifactory)) ? TRUE : FALSE;
#endif
#endif
}
IWICImagingFactory* GetWIC()
@ -795,14 +795,14 @@ HRESULT DirectX::SaveWICTextureToFile(
case D3DFMT_R32F: pfGuid = GUID_WICPixelFormat32bppGrayFloat; break;
case D3DFMT_A32B32G32R32F: pfGuid = GUID_WICPixelFormat128bppRGBAFloat; break;
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
case D3DFMT_X8B8G8R8:
if (g_WIC2)
pfGuid = GUID_WICPixelFormat32bppRGB;
else
HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
break;
#endif
#endif
default:
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
@ -874,7 +874,7 @@ HRESULT DirectX::SaveWICTextureToFile(
// Screenshots don't typically include the alpha channel of the render target
switch (desc.Format)
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
case D3DFMT_A32B32G32R32F:
case D3DFMT_A16B16G16R16F:
if (g_WIC2)
@ -886,7 +886,7 @@ HRESULT DirectX::SaveWICTextureToFile(
targetGuid = GUID_WICPixelFormat24bppBGR;
}
break;
#endif
#endif
case D3DFMT_A16B16G16R16: targetGuid = GUID_WICPixelFormat48bppBGR; break;
case D3DFMT_R5G6B5: targetGuid = GUID_WICPixelFormat16bppBGR565; break;

View File

@ -686,9 +686,9 @@ namespace
wprintf(L"Microsoft (R) DirectX Texture Assembler [DirectXTex] Version %ls\n", version);
wprintf(L"Copyright (C) Microsoft Corp.\n");
#ifdef _DEBUG
#ifdef _DEBUG
wprintf(L"*** Debug build ***\n");
#endif
#endif
wprintf(L"\n");
}
@ -785,10 +785,10 @@ namespace
case CODEC_HDR:
return SaveToHDRFile(img, szOutputFile);
#ifdef USE_OPENEXR
#ifdef USE_OPENEXR
case CODEC_EXR:
return SaveToEXRFile(img, szOutputFile);
#endif
#endif
default:
{
@ -1458,7 +1458,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
}
#ifdef USE_OPENEXR
#ifdef USE_OPENEXR
else if (_wcsicmp(ext, L".exr") == 0)
{
hr = LoadFromEXRFile(pConv->szSrc, &info, *image);
@ -1468,7 +1468,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
}
#endif
#endif
else
{
// WIC shares the same filter values for mode and dither
@ -1779,9 +1779,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
#ifndef NDEBUG
#ifndef NDEBUG
auto& tinfo = timage->GetMetadata();
#endif
#endif
assert(info.width == tinfo.width);
assert(info.height == tinfo.height);

View File

@ -45,12 +45,12 @@ namespace
{
blob.reset();
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr)));
#else
#else
ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN, nullptr)));
#endif
#endif
if (!hFile)
{
return HRESULT_FROM_WIN32(GetLastError());

View File

@ -82,12 +82,12 @@ namespace
{
blob.reset();
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr)));
#else
#else
ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN, nullptr)));
#endif
#endif
if (!hFile)
{
return HRESULT_FROM_WIN32(GetLastError());

View File

@ -839,9 +839,9 @@ namespace
wprintf(L"Microsoft (R) DirectX Texture Converter [DirectXTex] Version %ls\n", version);
wprintf(L"Copyright (C) Microsoft Corp.\n");
#ifdef _DEBUG
#ifdef _DEBUG
wprintf(L"*** Debug build ***\n");
#endif
#endif
wprintf(L"\n");
}
@ -928,9 +928,9 @@ namespace
wprintf(L" -wicmulti When writing images with WIC encode multiframe images\n");
wprintf(L"\n -nologo suppress copyright message\n");
wprintf(L" -timing Display elapsed processing time\n\n");
#ifdef _OPENMP
#ifdef _OPENMP
wprintf(L" -singleproc Do not use multi-threaded compression\n");
#endif
#endif
wprintf(L" -gpu <adapter> Select GPU for DirectCompute-based codecs (0 is default)\n");
wprintf(L" -nogpu Do not use DirectCompute-based codecs\n");
wprintf(
@ -1043,9 +1043,9 @@ namespace
};
UINT createDeviceFlags = 0;
#ifdef _DEBUG
#ifdef _DEBUG
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
#endif
ComPtr<IDXGIAdapter> pAdapter;
if (adapter >= 0)
@ -2088,7 +2088,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
continue;
}
}
#ifdef USE_OPENEXR
#ifdef USE_OPENEXR
else if (_wcsicmp(ext, L".exr") == 0)
{
hr = LoadFromEXRFile(pConv->szSrc, &info, *image);
@ -2099,7 +2099,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
continue;
}
}
#endif
#endif
else
{
// WIC shares the same filter values for mode and dither
@ -2489,9 +2489,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
#ifndef NDEBUG
#ifndef NDEBUG
auto& tinfo = timage->GetMetadata();
#endif
#endif
assert(info.width == tinfo.width);
assert(info.height == tinfo.height);
@ -2526,9 +2526,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
#ifndef NDEBUG
#ifndef NDEBUG
auto& tinfo = timage->GetMetadata();
#endif
#endif
assert(tinfo.format == DXGI_FORMAT_R16G16B16A16_FLOAT);
info.format = DXGI_FORMAT_R16G16B16A16_FLOAT;
@ -2759,9 +2759,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
#ifndef NDEBUG
#ifndef NDEBUG
auto& tinfo = timage->GetMetadata();
#endif
#endif
assert(info.width == tinfo.width);
assert(info.height == tinfo.height);
@ -2839,9 +2839,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
#ifndef NDEBUG
#ifndef NDEBUG
auto& tinfo = timage->GetMetadata();
#endif
#endif
assert(info.width == tinfo.width);
assert(info.height == tinfo.height);
@ -2986,9 +2986,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
#ifndef NDEBUG
#ifndef NDEBUG
auto& tinfo = timage->GetMetadata();
#endif
#endif
assert(info.width == tinfo.width);
assert(info.height == tinfo.height);
@ -3035,9 +3035,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
#ifndef NDEBUG
#ifndef NDEBUG
auto& tinfo = timage->GetMetadata();
#endif
#endif
assert(info.width == tinfo.width);
assert(info.height == tinfo.height);
@ -3096,9 +3096,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
#ifndef NDEBUG
#ifndef NDEBUG
auto& tinfo = timage->GetMetadata();
#endif
#endif
assert(info.width == tinfo.width);
assert(info.height == tinfo.height);
@ -3298,9 +3298,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
}
}
#ifndef NDEBUG
#ifndef NDEBUG
auto& tinfo = timage->GetMetadata();
#endif
#endif
assert(info.width == tinfo.width);
assert(info.height == tinfo.height);
@ -3435,12 +3435,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
}
TEX_COMPRESS_FLAGS cflags = dwCompress;
#ifdef _OPENMP
#ifdef _OPENMP
if (!(dwOptions & (uint64_t(1) << OPT_FORCE_SINGLEPROC)))
{
cflags |= TEX_COMPRESS_PARALLEL;
}
#endif
#endif
if ((img->width % 4) != 0 || (img->height % 4) != 0)
{
@ -3623,11 +3623,11 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
hr = SaveToPortablePixMapHDR(img[0], szDest);
break;
#ifdef USE_OPENEXR
#ifdef USE_OPENEXR
case CODEC_EXR:
hr = SaveToEXRFile(img[0], szDest);
break;
#endif
#endif
default:
{

View File

@ -644,9 +644,9 @@ namespace
wprintf(L"Microsoft (R) DirectX Texture Diagnostic Tool [DirectXTex] Version %ls\n", version);
wprintf(L"Copyright (C) Microsoft Corp.\n");
#ifdef _DEBUG
#ifdef _DEBUG
wprintf(L"*** Debug build ***\n");
#endif
#endif
wprintf(L"\n");
}
@ -782,12 +782,12 @@ namespace
{
return LoadFromHDRFile(fileName, &info, *image);
}
#ifdef USE_OPENEXR
#ifdef USE_OPENEXR
else if (_wcsicmp(ext, L".exr") == 0)
{
return LoadFromEXRFile(fileName, &info, *image);
}
#endif
#endif
else
{
// WIC shares the same filter values for mode and dither
@ -827,10 +827,10 @@ namespace
case CODEC_HDR:
return SaveToHDRFile(*image, fileName);
#ifdef USE_OPENEXR
#ifdef USE_OPENEXR
case CODEC_EXR:
return SaveToEXRFile(*image, fileName);
#endif
#endif
default:
return SaveToWICFile(*image, WIC_FLAGS_NONE, GetWICCodec(static_cast<WICCodecs>(codec)), fileName);
@ -1492,6 +1492,7 @@ namespace
return Convert(diffImage.GetImages(), diffImage.GetImageCount(), diffImage.GetMetadata(), format, dwFilter, TEX_THRESHOLD_DEFAULT, result);
}
#pragma region DumpBC
//--------------------------------------------------------------------------------------
// Partition, Shape, Fixup
const uint8_t g_aFixUp[3][64][3] =
@ -3209,6 +3210,7 @@ namespace
return S_OK;
}
#pragma endregion
}

View File

@ -65,12 +65,12 @@ namespace
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength]) noexcept
{
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
#else
#else
UNREFERENCED_PARAMETER(resource);
UNREFERENCED_PARAMETER(name);
#endif
#endif
}
//-------------------------------------------------------------------------------------
@ -116,7 +116,7 @@ namespace
const GUID& target;
};
constexpr WICConvert g_WICConvert [] =
constexpr WICConvert g_WICConvert[] =
{
// Note target GUID in this conversion table must be one of those directly supported formats (above).
@ -180,7 +180,7 @@ namespace
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID *ifactory) noexcept
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
HRESULT hr = CoCreateInstance(
CLSID_WICImagingFactory2,
nullptr,
@ -206,14 +206,14 @@ namespace
);
return SUCCEEDED(hr) ? TRUE : FALSE;
}
#else
#else
return SUCCEEDED(CoCreateInstance(
CLSID_WICImagingFactory,
nullptr,
CLSCTX_INPROC_SERVER,
__uuidof(IWICImagingFactory),
ifactory)) ? TRUE : FALSE;
#endif
#endif
}
IWICImagingFactory* GetWIC() noexcept
@ -242,13 +242,13 @@ namespace
return g_WICFormats[i].format;
}
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
if (g_WIC2)
{
if (memcmp(&GUID_WICPixelFormat96bppRGBFloat, &guid, sizeof(GUID)) == 0)
return DXGI_FORMAT_R32G32B32_FLOAT;
}
#endif
#endif
return DXGI_FORMAT_UNKNOWN;
}
@ -454,7 +454,7 @@ namespace
{
if (memcmp(&GUID_WICPixelFormat96bppRGBFixedPoint, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0)
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
if (g_WIC2)
{
memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat96bppRGBFloat, sizeof(GUID));
@ -462,7 +462,7 @@ namespace
bpp = 96;
}
else
#endif
#endif
{
memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat128bppRGBAFloat, sizeof(GUID));
format = DXGI_FORMAT_R32G32B32A32_FLOAT;
@ -493,7 +493,7 @@ namespace
bpp = WICBitsPerPixel(pixelFormat);
}
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
if ((format == DXGI_FORMAT_R32G32B32_FLOAT) && d3dContext && textureView)
{
// Special case test for optional device support for autogen mipchains for R32G32B32_FLOAT
@ -507,7 +507,7 @@ namespace
bpp = 128;
}
}
#endif
#endif
if (loadFlags & WIC_LOADER_FORCE_RGBA32)
{
@ -773,7 +773,7 @@ namespace
_In_opt_ ID3D11Resource** texture,
_In_opt_ ID3D11ShaderResourceView** textureView) noexcept
{
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
if (texture || textureView)
{
CHAR strFileA[MAX_PATH];
@ -815,11 +815,11 @@ namespace
}
}
}
#else
#else
UNREFERENCED_PARAMETER(fileName);
UNREFERENCED_PARAMETER(texture);
UNREFERENCED_PARAMETER(textureView);
#endif
#endif
}
} // anonymous namespace

View File

@ -107,7 +107,7 @@ namespace
const GUID& target;
};
constexpr WICConvert g_WICConvert [] =
constexpr WICConvert g_WICConvert[] =
{
// Note target GUID in this conversion table must be one of those directly supported formats (above).
@ -634,7 +634,7 @@ namespace
_In_z_ const wchar_t* fileName,
_In_ ID3D12Resource** texture) noexcept
{
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
if (texture && *texture)
{
const wchar_t* pstrName = wcsrchr(fileName, '\\');
@ -649,10 +649,10 @@ namespace
(*texture)->SetName(pstrName);
}
#else
#else
UNREFERENCED_PARAMETER(fileName);
UNREFERENCED_PARAMETER(texture);
#endif
#endif
}
} // anonymous namespace

View File

@ -95,7 +95,7 @@ namespace
const GUID& target;
};
constexpr WICConvert g_WICConvert [] =
constexpr WICConvert g_WICConvert[] =
{
// Note target GUID in this conversion table must be one of those directly supported formats (above).
@ -161,7 +161,7 @@ namespace
//--------------------------------------------------------------------------------------
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
HRESULT hr = CoCreateInstance(
CLSID_WICImagingFactory2,
nullptr,
@ -187,14 +187,14 @@ namespace
);
return SUCCEEDED(hr) ? TRUE : FALSE;
}
#else
#else
return SUCCEEDED(CoCreateInstance(
CLSID_WICImagingFactory,
nullptr,
CLSCTX_INPROC_SERVER,
__uuidof(IWICImagingFactory),
ifactory)) ? TRUE : FALSE;
#endif
#endif
}
IWICImagingFactory* GetWIC() noexcept