Skip to content

Commit ab623b6

Browse files
committed
Fix a few more DXGI_FORMAT_UNKNOWN cases to return E_INVALIDARG
1 parent 6b059bc commit ab623b6

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

DDSTextureLoader/DDSTextureLoader11.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ namespace
502502
_In_ size_t width,
503503
_In_ size_t height,
504504
_In_ DXGI_FORMAT fmt,
505-
size_t* outNumBytes,
505+
_Out_opt_ size_t* outNumBytes,
506506
_Out_opt_ size_t* outRowBytes,
507507
_Out_opt_ size_t* outNumRows) noexcept
508508
{
@@ -516,6 +516,9 @@ namespace
516516
size_t bpe = 0;
517517
switch (fmt)
518518
{
519+
case DXGI_FORMAT_UNKNOWN:
520+
return E_INVALIDARG;
521+
519522
case DXGI_FORMAT_BC1_TYPELESS:
520523
case DXGI_FORMAT_BC1_UNORM:
521524
case DXGI_FORMAT_BC1_UNORM_SRGB:
@@ -569,6 +572,15 @@ namespace
569572
bpe = 2;
570573
break;
571574

575+
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
576+
577+
case DXGI_FORMAT_P208:
578+
planar = true;
579+
bpe = 2;
580+
break;
581+
582+
#endif
583+
572584
case DXGI_FORMAT_P010:
573585
case DXGI_FORMAT_P016:
574586
if ((height % 2) != 0)

DDSTextureLoader/DDSTextureLoader12.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ namespace
581581
_In_ size_t width,
582582
_In_ size_t height,
583583
_In_ DXGI_FORMAT fmt,
584-
size_t* outNumBytes,
584+
_Out_opt_ size_t* outNumBytes,
585585
_Out_opt_ size_t* outRowBytes,
586586
_Out_opt_ size_t* outNumRows) noexcept
587587
{
@@ -595,6 +595,9 @@ namespace
595595
size_t bpe = 0;
596596
switch (fmt)
597597
{
598+
case DXGI_FORMAT_UNKNOWN:
599+
return E_INVALIDARG;
600+
598601
case DXGI_FORMAT_BC1_TYPELESS:
599602
case DXGI_FORMAT_BC1_UNORM:
600603
case DXGI_FORMAT_BC1_UNORM_SRGB:

DDSTextureLoader/DDSTextureLoader9.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ namespace
416416
_In_ size_t width,
417417
_In_ size_t height,
418418
_In_ D3DFORMAT fmt,
419-
size_t* outNumBytes,
419+
_Out_opt_ size_t* outNumBytes,
420420
_Out_opt_ size_t* outRowBytes,
421421
_Out_opt_ size_t* outNumRows) noexcept
422422
{
@@ -429,6 +429,9 @@ namespace
429429
size_t bpe = 0;
430430
switch (static_cast<int>(fmt))
431431
{
432+
case D3DFMT_UNKNOWN:
433+
return E_INVALIDARG;
434+
432435
case D3DFMT_DXT1:
433436
bc = true;
434437
bpe = 8;

DirectXTex/DirectXTexUtil.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,9 @@ HRESULT DirectX::ComputePitch(DXGI_FORMAT fmt, size_t width, size_t height,
972972

973973
switch (static_cast<int>(fmt))
974974
{
975+
case DXGI_FORMAT_UNKNOWN:
976+
return E_INVALIDARG;
977+
975978
case DXGI_FORMAT_BC1_TYPELESS:
976979
case DXGI_FORMAT_BC1_UNORM:
977980
case DXGI_FORMAT_BC1_UNORM_SRGB:
@@ -1192,6 +1195,9 @@ size_t DirectX::ComputeScanlines(DXGI_FORMAT fmt, size_t height) noexcept
11921195
{
11931196
switch (static_cast<int>(fmt))
11941197
{
1198+
case DXGI_FORMAT_UNKNOWN:
1199+
return 0;
1200+
11951201
case DXGI_FORMAT_BC1_TYPELESS:
11961202
case DXGI_FORMAT_BC1_UNORM:
11971203
case DXGI_FORMAT_BC1_UNORM_SRGB:

0 commit comments

Comments
 (0)