diff --git a/src/d3dx12_property_format_table.cpp b/src/d3dx12_property_format_table.cpp index 457085e..7c9ff07 100644 --- a/src/d3dx12_property_format_table.cpp +++ b/src/d3dx12_property_format_table.cpp @@ -21,9 +21,12 @@ #include #endif #include "d3dx12_property_format_table.h" -#include #include +#include #include "D3D12TokenizedProgramFormat.hpp" +#if defined(__cpp_exceptions) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0) +#include +#endif #if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606) #ifndef ASSUME #define ASSUME(x) assert(x) @@ -1409,7 +1412,7 @@ UINT D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::Sequential2AbsoluteComponentIndex( DXGI n++; } } - return UINT(-1); + return UINT( -1 ); } //--------------------------------------------------------------------------------------------------------------------------------- @@ -1471,14 +1474,18 @@ D3D_FORMAT_LAYOUT D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetLayout(DXGI_FORMAT Form // GetComponentName D3D_FORMAT_COMPONENT_NAME D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetComponentName(DXGI_FORMAT Format, UINT AbsoluteComponentIndex) { - D3D_FORMAT_COMPONENT_NAME name; + D3D_FORMAT_COMPONENT_NAME name = {}; switch( AbsoluteComponentIndex ) { case 0: name = s_FormatDetail[GetDetailTableIndexNoThrow( Format )].ComponentName0; break; case 1: name = s_FormatDetail[GetDetailTableIndexNoThrow( Format )].ComponentName1; break; case 2: name = s_FormatDetail[GetDetailTableIndexNoThrow( Format )].ComponentName2; break; case 3: name = s_FormatDetail[GetDetailTableIndexNoThrow( Format )].ComponentName3; break; - default: throw E_FAIL; +#if defined(__cpp_exceptions) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0) + default: throw std::invalid_argument("AbsoluteComponentIndex"); +#else + default: break; +#endif } return name; } @@ -1488,7 +1495,11 @@ UINT D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetBitsPerComponent(DXGI_FORMAT Format, { if( AbsoluteComponentIndex > 3 ) { - throw E_FAIL; +#if defined(__cpp_exceptions) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0) + throw std::invalid_argument("AbsoluteComponentIndex"); +#else + return UINT( -1 ); +#endif } return s_FormatDetail[GetDetailTableIndexNoThrow( Format )].BitsPerComponent[AbsoluteComponentIndex]; } @@ -1505,7 +1516,11 @@ D3D_FORMAT_COMPONENT_INTERPRETATION D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetForma case 1: interp = s_FormatDetail[GetDetailTableIndexNoThrow( Format )].ComponentInterpretation1; break; case 2: interp = s_FormatDetail[GetDetailTableIndexNoThrow( Format )].ComponentInterpretation2; break; case 3: interp = s_FormatDetail[GetDetailTableIndexNoThrow( Format )].ComponentInterpretation3; break; -// default: throw E_FAIL; +#if defined(__cpp_exceptions) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0) + default: throw std::invalid_argument("AbsoluteComponentIndex"); +#else + default: break; +#endif } return interp; } @@ -1547,13 +1562,15 @@ bool D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::FamilySupportsStencil(DXGI_FORMAT Forma //--------------------------------------------------------------------------------------------------------------------------------- // GetDetailTableIndexThrow -UINT D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetDetailTableIndexThrow(DXGI_FORMAT Format) +UINT D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::GetDetailTableIndexThrow(DXGI_FORMAT Format) { UINT Index = GetDetailTableIndex( Format ); +#if defined(__cpp_exceptions) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0) if(UINT( -1 ) == Index ) { - throw E_FAIL; + throw std::invalid_argument("Format"); } +#endif return Index; }