Make C++ Exceptions usage standard compliant (#144)
Some checks failed
CMake (WSL) / build (x64-Debug-Linux, 10) (push) Failing after 15s
CMake (WSL) / build (x64-Debug-Linux, 11) (push) Failing after 16s
CMake (WSL) / build (x64-Debug-Linux, 12) (push) Failing after 15s
CMake (WSL) / build (x64-Release-Linux, 10) (push) Failing after 15s
CMake (WSL) / build (x64-Release-Linux, 12) (push) Failing after 15s
CMake (WSL) / build (x64-Release-Linux, 11) (push) Failing after 15s
CodeQL / Analyze (C/C++) (push) Has been cancelled
CMake (Windows) / build (amd64, x64-Debug, windows-2019) (push) Has been cancelled
CMake (Windows) / build (amd64, x64-Debug, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64, x64-Debug-Clang, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64, x64-Debug-MinGW, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64, x64-Release, windows-2019) (push) Has been cancelled
CMake (Windows) / build (amd64, x64-Release, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64, x64-Release-Clang, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64, x64-Release-MinGW, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64_arm64, arm64-Debug, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64_arm64, arm64-Release, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64_arm64, arm64ec-Debug, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64_arm64, arm64ec-Release, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64_x86, x86-Debug, windows-2019) (push) Has been cancelled
CMake (Windows) / build (amd64_x86, x86-Debug, windows-2022) (push) Has been cancelled
CMake (Windows) / build (amd64_x86, x86-Release, windows-2019) (push) Has been cancelled
CMake (Windows) / build (amd64_x86, x86-Release, windows-2022) (push) Has been cancelled
Microsoft C++ Code Analysis / Analyze (push) Has been cancelled

This commit is contained in:
Chuck Walbourn 2024-11-08 09:27:47 -08:00 committed by GitHub
parent b6b858a193
commit af64c154b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,9 +21,12 @@
#include <wsl/winadapter.h>
#endif
#include "d3dx12_property_format_table.h"
#include <assert.h>
#include <algorithm>
#include <cassert>
#include "D3D12TokenizedProgramFormat.hpp"
#if defined(__cpp_exceptions) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)
#include <stdexcept>
#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;
}