mirror of
https://github.com/microsoft/DirectXTex
synced 2024-12-26 03:11:02 +00:00
DirectXTex updated with DDS_FLAGS_ALLOW_LARGE_FILES (#188)
This commit is contained in:
parent
81ab7997ec
commit
d980fb6576
@ -172,6 +172,8 @@ namespace DirectX
|
||||
DDS_FLAGS_FORCE_DX9_LEGACY = 0x40000,
|
||||
// Force use of legacy header for DDS writer (will fail if unable to write as such)
|
||||
|
||||
DDS_FLAGS_ALLOW_LARGE_FILES = 0x1000000,
|
||||
// Enables the loader to read large dimension .dds files (i.e. greater than known hardware requirements)
|
||||
};
|
||||
|
||||
enum WIC_FLAGS : unsigned long
|
||||
|
@ -525,6 +525,25 @@ namespace
|
||||
metadata.SetAlphaMode(TEX_ALPHA_MODE_PREMULTIPLIED);
|
||||
}
|
||||
|
||||
// Check for .dds files that exceed known hardware support
|
||||
if (!(flags & DDS_FLAGS_ALLOW_LARGE_FILES))
|
||||
{
|
||||
// 16k is the maximum required resource size supported by Direct3D
|
||||
if (metadata.width > 16384u /* D3D12_REQ_TEXTURE1D_U_DIMENSION, D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION */
|
||||
|| metadata.height > 16384u /* D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION */
|
||||
|| metadata.mipLevels > 15u /* D3D12_REQ_MIP_LEVELS */)
|
||||
{
|
||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
// 2048 is the maximum required depth/array size supported by Direct3D
|
||||
if (metadata.arraySize > 2048u /* D3D12_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION, D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION */
|
||||
|| metadata.depth > 2048u /* D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION */)
|
||||
{
|
||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
@ -1068,7 +1068,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
case CMD_V_STRIP:
|
||||
if (_wcsicmp(ext, L".dds") == 0)
|
||||
{
|
||||
hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_NONE, &info, *image);
|
||||
hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_ALLOW_LARGE_FILES, &info, *image);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
wprintf(L" FAILED (%x)\n", static_cast<unsigned int>(hr));
|
||||
@ -1095,7 +1095,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
case CMD_ARRAY_STRIP:
|
||||
if (_wcsicmp(ext, L".dds") == 0)
|
||||
{
|
||||
hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_NONE, &info, *image);
|
||||
hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_ALLOW_LARGE_FILES, &info, *image);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
wprintf(L" FAILED (%x)\n", static_cast<unsigned int>(hr));
|
||||
@ -1118,7 +1118,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
default:
|
||||
if (_wcsicmp(ext, L".dds") == 0)
|
||||
{
|
||||
hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_NONE, &info, *image);
|
||||
hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_ALLOW_LARGE_FILES, &info, *image);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
wprintf(L" FAILED (%x)\n", static_cast<unsigned int>(hr));
|
||||
|
@ -1672,7 +1672,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
|
||||
if (_wcsicmp(ext, L".dds") == 0)
|
||||
{
|
||||
DDS_FLAGS ddsFlags = DDS_FLAGS_NONE;
|
||||
DDS_FLAGS ddsFlags = DDS_FLAGS_ALLOW_LARGE_FILES;
|
||||
if (dwOptions & (DWORD64(1) << OPT_DDS_DWORD_ALIGN))
|
||||
ddsFlags |= DDS_FLAGS_LEGACY_DWORD;
|
||||
if (dwOptions & (DWORD64(1) << OPT_EXPAND_LUMINANCE))
|
||||
|
@ -592,7 +592,7 @@ namespace
|
||||
|
||||
if (_wcsicmp(ext, L".dds") == 0)
|
||||
{
|
||||
DDS_FLAGS ddsFlags = DDS_FLAGS_NONE;
|
||||
DDS_FLAGS ddsFlags = DDS_FLAGS_ALLOW_LARGE_FILES;
|
||||
if (dwOptions & (1 << OPT_DDS_DWORD_ALIGN))
|
||||
ddsFlags |= DDS_FLAGS_LEGACY_DWORD;
|
||||
if (dwOptions & (1 << OPT_EXPAND_LUMINANCE))
|
||||
|
Loading…
Reference in New Issue
Block a user