This commit is contained in:
Chuck Walbourn 2019-12-12 23:15:17 -08:00
Родитель 63b2f447c1
Коммит d34cb9f4b2
16 изменённых файлов: 343 добавлений и 197 удалений

Просмотреть файл

@ -98,7 +98,7 @@ namespace DirectX
// Does not support VB decls with D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA
#endif
HRESULT __cdecl AddStream(_In_reads_bytes_(stride*nVerts) const void* vb, _In_ size_t nVerts, _In_ size_t inputSlot, _In_ size_t stride = 0);
HRESULT __cdecl AddStream(_In_reads_bytes_(stride*nVerts) const void* vb, _In_ size_t nVerts, _In_ size_t inputSlot, _In_ size_t stride = 0) noexcept;
// Add vertex buffer to reader
HRESULT __cdecl Read(_Out_writes_(count) XMVECTOR* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const;
@ -154,7 +154,7 @@ namespace DirectX
// Does not support VB decls with D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA
#endif
HRESULT __cdecl AddStream(_Out_writes_bytes_(stride*nVerts) void* vb, _In_ size_t nVerts, _In_ size_t inputSlot, _In_ size_t stride = 0);
HRESULT __cdecl AddStream(_Out_writes_bytes_(stride*nVerts) void* vb, _In_ size_t nVerts, _In_ size_t inputSlot, _In_ size_t stride = 0) noexcept;
// Add vertex buffer to writer
HRESULT __cdecl Write(_In_reads_(count) const XMVECTOR* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const;
@ -221,12 +221,12 @@ namespace DirectX
_In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces,
_In_reads_(nVerts) const uint32_t* pointRep,
_In_reads_(nFaces * 3) const uint32_t* adjacency, _In_ size_t nVerts,
_Out_writes_(nFaces * 6) uint16_t* indicesAdj);
_Out_writes_(nFaces * 6) uint16_t* indicesAdj) noexcept;
HRESULT __cdecl GenerateGSAdjacency(
_In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces,
_In_reads_(nVerts) const uint32_t* pointRep,
_In_reads_(nFaces * 3) const uint32_t* adjacency, _In_ size_t nVerts,
_Out_writes_(nFaces * 6) uint32_t* indicesAdj);
_Out_writes_(nFaces * 6) uint32_t* indicesAdj) noexcept;
// Generates an IB suitable for Geometry Shader using D3D1x_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ
//---------------------------------------------------------------------------------
@ -251,12 +251,12 @@ namespace DirectX
_In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces,
_In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts,
_In_ DWORD flags,
_Out_writes_(nVerts) XMFLOAT3* normals);
_Out_writes_(nVerts) XMFLOAT3* normals) noexcept;
HRESULT __cdecl ComputeNormals(
_In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces,
_In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts,
_In_ DWORD flags,
_Out_writes_(nVerts) XMFLOAT3* normals);
_Out_writes_(nVerts) XMFLOAT3* normals) noexcept;
// Computes vertex normals
HRESULT __cdecl ComputeTangentFrame(
@ -265,40 +265,40 @@ namespace DirectX
_In_reads_(nVerts) const XMFLOAT3* normals,
_In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts,
_Out_writes_opt_(nVerts) XMFLOAT3* tangents,
_Out_writes_opt_(nVerts) XMFLOAT3* bitangents);
_Out_writes_opt_(nVerts) XMFLOAT3* bitangents) noexcept;
HRESULT __cdecl ComputeTangentFrame(
_In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces,
_In_reads_(nVerts) const XMFLOAT3* positions,
_In_reads_(nVerts) const XMFLOAT3* normals,
_In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts,
_Out_writes_opt_(nVerts) XMFLOAT3* tangents,
_Out_writes_opt_(nVerts) XMFLOAT3* bitangents);
_Out_writes_opt_(nVerts) XMFLOAT3* bitangents) noexcept;
HRESULT __cdecl ComputeTangentFrame(
_In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces,
_In_reads_(nVerts) const XMFLOAT3* positions,
_In_reads_(nVerts) const XMFLOAT3* normals,
_In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts,
_Out_writes_opt_(nVerts) XMFLOAT4* tangents,
_Out_writes_opt_(nVerts) XMFLOAT3* bitangents);
_Out_writes_opt_(nVerts) XMFLOAT3* bitangents) noexcept;
HRESULT __cdecl ComputeTangentFrame(
_In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces,
_In_reads_(nVerts) const XMFLOAT3* positions,
_In_reads_(nVerts) const XMFLOAT3* normals,
_In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts,
_Out_writes_opt_(nVerts) XMFLOAT4* tangents,
_Out_writes_opt_(nVerts) XMFLOAT3* bitangents);
_Out_writes_opt_(nVerts) XMFLOAT3* bitangents) noexcept;
HRESULT __cdecl ComputeTangentFrame(
_In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces,
_In_reads_(nVerts) const XMFLOAT3* positions,
_In_reads_(nVerts) const XMFLOAT3* normals,
_In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts,
_Out_writes_(nVerts) XMFLOAT4* tangents);
_Out_writes_(nVerts) XMFLOAT4* tangents) noexcept;
HRESULT __cdecl ComputeTangentFrame(
_In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces,
_In_reads_(nVerts) const XMFLOAT3* positions,
_In_reads_(nVerts) const XMFLOAT3* normals,
_In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts,
_Out_writes_(nVerts) XMFLOAT4* tangents);
_Out_writes_(nVerts) XMFLOAT4* tangents) noexcept;
// Computes tangents and/or bi-tangents (optionally with handedness stored in .w)
//---------------------------------------------------------------------------------
@ -432,10 +432,10 @@ namespace DirectX
HRESULT __cdecl OptimizeVertices(
_In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, _In_ size_t nVerts,
_Out_writes_(nVerts) uint32_t* vertexRemap, _Out_opt_ size_t* trailingUnused = nullptr);
_Out_writes_(nVerts) uint32_t* vertexRemap, _Out_opt_ size_t* trailingUnused = nullptr) noexcept;
HRESULT __cdecl OptimizeVertices(
_In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, _In_ size_t nVerts,
_Out_writes_(nVerts) uint32_t* vertexRemap, _Out_opt_ size_t* trailingUnused = nullptr);
_Out_writes_(nVerts) uint32_t* vertexRemap, _Out_opt_ size_t* trailingUnused = nullptr) noexcept;
// Reorders vertices in order of use
//---------------------------------------------------------------------------------
@ -444,59 +444,59 @@ namespace DirectX
HRESULT __cdecl ReorderIB(
_In_reads_(nFaces * 3) const uint16_t* ibin, _In_ size_t nFaces,
_In_reads_(nFaces) const uint32_t* faceRemap,
_Out_writes_(nFaces * 3) uint16_t* ibout);
_Out_writes_(nFaces * 3) uint16_t* ibout) noexcept;
HRESULT __cdecl ReorderIB(
_Inout_updates_all_(nFaces * 3) uint16_t* ib, _In_ size_t nFaces,
_In_reads_(nFaces) const uint32_t* faceRemap);
_In_reads_(nFaces) const uint32_t* faceRemap) noexcept;
HRESULT __cdecl ReorderIB(
_In_reads_(nFaces * 3) const uint32_t* ibin, _In_ size_t nFaces,
_In_reads_(nFaces) const uint32_t* faceRemap,
_Out_writes_(nFaces * 3) uint32_t* ibout);
_Out_writes_(nFaces * 3) uint32_t* ibout) noexcept;
HRESULT __cdecl ReorderIB(
_Inout_updates_all_(nFaces * 3) uint32_t* ib, _In_ size_t nFaces,
_In_reads_(nFaces) const uint32_t* faceRemap);
_In_reads_(nFaces) const uint32_t* faceRemap) noexcept;
// Applies a face remap reordering to an index buffer
HRESULT __cdecl ReorderIBAndAdjacency(
_In_reads_(nFaces * 3) const uint16_t* ibin, _In_ size_t nFaces, _In_reads_(nFaces * 3) const uint32_t* adjin,
_In_reads_(nFaces) const uint32_t* faceRemap,
_Out_writes_(nFaces * 3) uint16_t* ibout, _Out_writes_(nFaces * 3) uint32_t* adjout);
_Out_writes_(nFaces * 3) uint16_t* ibout, _Out_writes_(nFaces * 3) uint32_t* adjout) noexcept;
HRESULT __cdecl ReorderIBAndAdjacency(
_Inout_updates_all_(nFaces * 3) uint16_t* ib, _In_ size_t nFaces, _Inout_updates_all_(nFaces * 3) uint32_t* adj,
_In_reads_(nFaces) const uint32_t* faceRemap);
_In_reads_(nFaces) const uint32_t* faceRemap) noexcept;
HRESULT __cdecl ReorderIBAndAdjacency(
_In_reads_(nFaces * 3) const uint32_t* ibin, _In_ size_t nFaces, _In_reads_(nFaces * 3) const uint32_t* adjin,
_In_reads_(nFaces) const uint32_t* faceRemap,
_Out_writes_(nFaces * 3) uint32_t* ibout, _Out_writes_(nFaces * 3) uint32_t* adjout);
_Out_writes_(nFaces * 3) uint32_t* ibout, _Out_writes_(nFaces * 3) uint32_t* adjout) noexcept;
HRESULT __cdecl ReorderIBAndAdjacency(
_Inout_updates_all_(nFaces * 3) uint32_t* ib, _In_ size_t nFaces, _Inout_updates_all_(nFaces * 3) uint32_t* adj,
_In_reads_(nFaces) const uint32_t* faceRemap);
_In_reads_(nFaces) const uint32_t* faceRemap) noexcept;
// Applies a face remap reordering to an index buffer and adjacency
HRESULT __cdecl FinalizeIB(
_In_reads_(nFaces * 3) const uint16_t* ibin, _In_ size_t nFaces,
_In_reads_(nVerts) const uint32_t* vertexRemap, _In_ size_t nVerts,
_Out_writes_(nFaces * 3) uint16_t* ibout);
_Out_writes_(nFaces * 3) uint16_t* ibout) noexcept;
HRESULT __cdecl FinalizeIB(
_Inout_updates_all_(nFaces * 3) uint16_t* ib, _In_ size_t nFaces,
_In_reads_(nVerts) const uint32_t* vertexRemap, _In_ size_t nVerts);
_In_reads_(nVerts) const uint32_t* vertexRemap, _In_ size_t nVerts) noexcept;
HRESULT __cdecl FinalizeIB(
_In_reads_(nFaces * 3) const uint32_t* ibin, _In_ size_t nFaces,
_In_reads_(nVerts) const uint32_t* vertexRemap, _In_ size_t nVerts,
_Out_writes_(nFaces * 3) uint32_t* ibout);
_Out_writes_(nFaces * 3) uint32_t* ibout) noexcept;
HRESULT __cdecl FinalizeIB(
_Inout_updates_all_(nFaces * 3) uint32_t* ib, _In_ size_t nFaces,
_In_reads_(nVerts) const uint32_t* vertexRemap, _In_ size_t nVerts);
_In_reads_(nVerts) const uint32_t* vertexRemap, _In_ size_t nVerts) noexcept;
// Applies a vertex remap reordering to an index buffer
HRESULT __cdecl FinalizeVB(
_In_reads_bytes_(nVerts*stride) const void* vbin, _In_ size_t stride, _In_ size_t nVerts,
_In_reads_opt_(nDupVerts) const uint32_t* dupVerts, _In_ size_t nDupVerts,
_In_reads_opt_(nVerts + nDupVerts) const uint32_t* vertexRemap,
_Out_writes_bytes_((nVerts + nDupVerts)*stride) void* vbout);
_Out_writes_bytes_((nVerts + nDupVerts)*stride) void* vbout) noexcept;
HRESULT __cdecl FinalizeVB(
_Inout_updates_bytes_all_(nVerts*stride) void* vb, _In_ size_t stride, _In_ size_t nVerts,
_In_reads_(nVerts) const uint32_t* vertexRemap);
_In_reads_(nVerts) const uint32_t* vertexRemap) noexcept;
// Applies a vertex remap and/or a vertex duplication set to a vertex buffer
HRESULT __cdecl FinalizeVBAndPointReps(
@ -505,18 +505,18 @@ namespace DirectX
_In_reads_opt_(nDupVerts) const uint32_t* dupVerts, _In_ size_t nDupVerts,
_In_reads_opt_(nVerts + nDupVerts) const uint32_t* vertexRemap,
_Out_writes_bytes_((nVerts + nDupVerts)*stride) void* vbout,
_Out_writes_(nVerts + nDupVerts) uint32_t* prout);
_Out_writes_(nVerts + nDupVerts) uint32_t* prout) noexcept;
HRESULT __cdecl FinalizeVBAndPointReps(
_Inout_updates_bytes_all_(nVerts*stride) void* vb, _In_ size_t stride, _In_ size_t nVerts,
_Inout_updates_all_(nVerts) uint32_t* pointRep,
_In_reads_(nVerts) const uint32_t* vertexRemap);
_In_reads_(nVerts) const uint32_t* vertexRemap) noexcept;
// Applies a vertex remap and/or a vertex duplication set to a vertex buffer and point representatives
HRESULT __cdecl CompactVB(
_In_reads_bytes_(nVerts*stride) const void* vbin, _In_ size_t stride, _In_ size_t nVerts,
_In_ size_t trailingUnused,
_In_reads_opt_(nVerts) const uint32_t* vertexRemap,
_Out_writes_bytes_((nVerts - trailingUnused)*stride) void* vbout);
_Out_writes_bytes_((nVerts - trailingUnused)*stride) void* vbout) noexcept;
// Applies a vertex remap which contains a known number of unused entries at the end
#include "DirectXMesh.inl"

Просмотреть файл

@ -37,7 +37,7 @@ namespace
// <algorithm> std::make_heap doesn't match D3DX10 so we use the same algorithm here
void MakeXHeap(
_Out_writes_(nVerts) uint32_t *index,
_In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts)
_In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts) noexcept
{
for (uint32_t vert = 0; vert < nVerts; ++vert)
{
@ -624,10 +624,13 @@ namespace
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::GenerateAdjacencyAndPointReps(
const uint16_t* indices, size_t nFaces,
const XMFLOAT3* positions, size_t nVerts,
const uint16_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
size_t nVerts,
float epsilon,
uint32_t* pointRep, uint32_t* adjacency)
uint32_t* pointRep,
uint32_t* adjacency)
{
if (!indices || !nFaces || !positions || !nVerts)
return E_INVALIDARG;
@ -663,10 +666,13 @@ HRESULT DirectX::GenerateAdjacencyAndPointReps(
_Use_decl_annotations_
HRESULT DirectX::GenerateAdjacencyAndPointReps(
const uint32_t* indices, size_t nFaces,
const XMFLOAT3* positions, size_t nVerts,
const uint32_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
size_t nVerts,
float epsilon,
uint32_t* pointRep, uint32_t* adjacency)
uint32_t* pointRep,
uint32_t* adjacency)
{
if (!indices || !nFaces || !positions || !nVerts)
return E_INVALIDARG;
@ -704,8 +710,10 @@ HRESULT DirectX::GenerateAdjacencyAndPointReps(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ConvertPointRepsToAdjacency(
const uint16_t* indices, size_t nFaces,
const XMFLOAT3* positions, size_t nVerts,
const uint16_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
size_t nVerts,
const uint32_t* pointRep,
uint32_t* adjacency)
{
@ -738,8 +746,10 @@ HRESULT DirectX::ConvertPointRepsToAdjacency(
_Use_decl_annotations_
HRESULT DirectX::ConvertPointRepsToAdjacency(
const uint32_t* indices, size_t nFaces,
const XMFLOAT3* positions, size_t nVerts,
const uint32_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
size_t nVerts,
const uint32_t* pointRep,
uint32_t* adjacency)
{

Просмотреть файл

@ -408,10 +408,13 @@ namespace
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::Clean(
uint16_t* indices, size_t nFaces,
uint16_t* indices,
size_t nFaces,
size_t nVerts,
uint32_t* adjacency, const uint32_t* attributes,
std::vector<uint32_t>& dupVerts, bool breakBowties)
uint32_t* adjacency,
const uint32_t* attributes,
std::vector<uint32_t>& dupVerts,
bool breakBowties)
{
HRESULT hr = Validate(indices, nFaces, nVerts, adjacency, VALIDATE_DEFAULT);
if (FAILED(hr))
@ -424,10 +427,13 @@ HRESULT DirectX::Clean(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::Clean(
uint32_t* indices, size_t nFaces,
uint32_t* indices,
size_t nFaces,
size_t nVerts,
uint32_t* adjacency, const uint32_t* attributes,
std::vector<uint32_t>& dupVerts, bool breakBowties)
uint32_t* adjacency,
const uint32_t* attributes,
std::vector<uint32_t>& dupVerts,
bool breakBowties)
{
HRESULT hr = Validate(indices, nFaces, nVerts, adjacency, VALIDATE_DEFAULT);
if (FAILED(hr))

Просмотреть файл

@ -25,7 +25,7 @@ namespace
_In_reads_(nFaces * 3) const index_t* indices, _In_ size_t nFaces,
_In_reads_(nVerts) const uint32_t* pointRep,
_In_reads_(nFaces * 3) const uint32_t* adjacency, _In_ size_t nVerts,
_Out_writes_(nFaces * 6) index_t* indicesAdj)
_Out_writes_(nFaces * 6) index_t* indicesAdj) noexcept
{
if (!indices || !nFaces || !pointRep || !adjacency || !nVerts || !indicesAdj)
return E_INVALIDARG;
@ -134,10 +134,12 @@ namespace
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::GenerateGSAdjacency(
const uint16_t* indices, size_t nFaces,
const uint16_t* indices,
size_t nFaces,
const uint32_t* pointRep,
const uint32_t* adjacency, size_t nVerts,
uint16_t* indicesAdj)
const uint32_t* adjacency,
size_t nVerts,
uint16_t* indicesAdj) noexcept
{
return GenerateGSAdjacencyImpl<uint16_t>(indices, nFaces, pointRep, adjacency, nVerts, indicesAdj);
}
@ -146,10 +148,12 @@ HRESULT DirectX::GenerateGSAdjacency(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::GenerateGSAdjacency(
const uint32_t* indices, size_t nFaces,
const uint32_t* indices,
size_t nFaces,
const uint32_t* pointRep,
const uint32_t* adjacency, size_t nVerts,
uint32_t* indicesAdj)
const uint32_t* adjacency,
size_t nVerts,
uint32_t* indicesAdj) noexcept
{
return GenerateGSAdjacencyImpl<uint32_t>(indices, nFaces, pointRep, adjacency, nVerts, indicesAdj);
}

Просмотреть файл

@ -22,7 +22,7 @@ namespace
HRESULT ComputeNormalsEqualWeight(
_In_reads_(nFaces * 3) const index_t* indices, size_t nFaces,
_In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts,
bool cw, _Out_writes_(nVerts) XMFLOAT3* normals)
bool cw, _Out_writes_(nVerts) XMFLOAT3* normals) noexcept
{
ScopedAlignedArrayXMVECTOR temp(static_cast<XMVECTOR*>(_aligned_malloc(sizeof(XMVECTOR) * nVerts, 16)));
if (!temp)
@ -91,7 +91,7 @@ namespace
HRESULT ComputeNormalsWeightedByAngle(
_In_reads_(nFaces * 3) const index_t* indices, size_t nFaces,
_In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts,
bool cw, _Out_writes_(nVerts) XMFLOAT3* normals)
bool cw, _Out_writes_(nVerts) XMFLOAT3* normals) noexcept
{
ScopedAlignedArrayXMVECTOR temp(static_cast<XMVECTOR*>(_aligned_malloc(sizeof(XMVECTOR) * nVerts, 16)));
if (!temp)
@ -181,7 +181,7 @@ namespace
HRESULT ComputeNormalsWeightedByArea(
_In_reads_(nFaces * 3) const index_t* indices, size_t nFaces,
_In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts,
bool cw, _Out_writes_(nVerts) XMFLOAT3* normals)
bool cw, _Out_writes_(nVerts) XMFLOAT3* normals) noexcept
{
ScopedAlignedArrayXMVECTOR temp(static_cast<XMVECTOR*>(_aligned_malloc(sizeof(XMVECTOR) * nVerts, 16)));
if (!temp)
@ -266,10 +266,12 @@ namespace
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ComputeNormals(
const uint16_t* indices, size_t nFaces,
const XMFLOAT3* positions, size_t nVerts,
const uint16_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
size_t nVerts,
DWORD flags,
XMFLOAT3* normals)
XMFLOAT3* normals) noexcept
{
if (!indices || !positions || !nFaces || !nVerts || !normals)
return E_INVALIDARG;
@ -298,10 +300,12 @@ HRESULT DirectX::ComputeNormals(
_Use_decl_annotations_
HRESULT DirectX::ComputeNormals(
const uint32_t* indices, size_t nFaces,
const XMFLOAT3* positions, size_t nVerts,
const uint32_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
size_t nVerts,
DWORD flags,
XMFLOAT3* normals)
XMFLOAT3* normals) noexcept
{
if (!indices || !positions || !nFaces || !nVerts || !normals)
return E_INVALIDARG;

Просмотреть файл

@ -19,7 +19,7 @@ namespace
HRESULT OptimizeVerticesImpl(
_In_reads_(nFaces * 3) const index_t* indices, size_t nFaces,
size_t nVerts, _Out_writes_(nVerts) uint32_t* vertexRemap,
_Out_opt_ size_t* trailingUnused)
_Out_opt_ size_t* trailingUnused) noexcept
{
if (!indices || !nFaces || !nVerts || !vertexRemap)
return E_INVALIDARG;
@ -94,7 +94,9 @@ namespace
_Use_decl_annotations_
HRESULT DirectX::AttributeSort(
size_t nFaces, uint32_t* attributes, uint32_t* faceRemap)
size_t nFaces,
uint32_t* attributes,
uint32_t* faceRemap)
{
if (!nFaces || !attributes || !faceRemap)
return E_INVALIDARG;
@ -111,7 +113,7 @@ HRESULT DirectX::AttributeSort(
list.emplace_back(intpair_t(attributes[j], j));
}
std::stable_sort(list.begin(), list.end(), [](const intpair_t& a, const intpair_t& b) -> bool
std::stable_sort(list.begin(), list.end(), [](const intpair_t& a, const intpair_t& b) noexcept -> bool
{
return (a.first < b.first);
});
@ -130,16 +132,22 @@ HRESULT DirectX::AttributeSort(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::OptimizeVertices(
const uint16_t* indices, size_t nFaces,
size_t nVerts, uint32_t* vertexRemap, size_t* trailingUnused)
const uint16_t* indices,
size_t nFaces,
size_t nVerts,
uint32_t* vertexRemap,
size_t* trailingUnused) noexcept
{
return OptimizeVerticesImpl<uint16_t>(indices, nFaces, nVerts, vertexRemap, trailingUnused);
}
_Use_decl_annotations_
HRESULT DirectX::OptimizeVertices(
const uint32_t* indices, size_t nFaces,
size_t nVerts, uint32_t* vertexRemap, size_t* trailingUnused)
const uint32_t* indices,
size_t nFaces,
size_t nVerts,
uint32_t* vertexRemap,
size_t* trailingUnused) noexcept
{
return OptimizeVerticesImpl<uint32_t>(indices, nFaces, nVerts, vertexRemap, trailingUnused);
}

Просмотреть файл

@ -22,7 +22,7 @@ namespace
// code for computing vertex score was taken, as much as possible
// directly from the original publication.
float ComputeVertexCacheScore(uint32_t cachePosition, uint32_t vertexCacheSize)
float ComputeVertexCacheScore(uint32_t cachePosition, uint32_t vertexCacheSize) noexcept
{
const float FindVertexScore_CacheDecayPower = 1.5f;
const float FindVertexScore_LastTriScore = 0.75f;
@ -56,7 +56,7 @@ namespace
return score;
}
float ComputeVertexValenceScore(uint32_t numActiveFaces)
float ComputeVertexValenceScore(uint32_t numActiveFaces) noexcept
{
const float FindVertexScore_ValenceBoostScale = 2.0f;
const float FindVertexScore_ValenceBoostPower = 0.5f;
@ -80,7 +80,7 @@ namespace
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
BOOL WINAPI ComputeVertexScores(PINIT_ONCE, PVOID, PVOID*)
BOOL WINAPI ComputeVertexScores(PINIT_ONCE, PVOID, PVOID*) noexcept
{
for (uint32_t cacheSize = 0; cacheSize <= kMaxVertexCacheSize; ++cacheSize)
{
@ -98,7 +98,7 @@ namespace
return TRUE;
}
float FindVertexScore(uint32_t numActiveFaces, uint32_t cachePosition, uint32_t vertexCacheSize)
float FindVertexScore(uint32_t numActiveFaces, uint32_t cachePosition, uint32_t vertexCacheSize) noexcept
{
if (numActiveFaces == 0)
{
@ -144,9 +144,9 @@ namespace
{
const IndexType *_indexData;
IndexSortCompareIndexed(const IndexType *indexData) : _indexData(indexData) { }
IndexSortCompareIndexed(const IndexType *indexData) noexcept : _indexData(indexData) { }
bool operator()(T a, T b) const
bool operator()(T a, T b) const noexcept
{
IndexType indexA = _indexData[a];
IndexType indexB = _indexData[b];
@ -163,9 +163,9 @@ namespace
{
const OptimizeVertexData<IndexType> *_vertexData;
FaceValenceSort(const OptimizeVertexData<IndexType> *vertexData) : _vertexData(vertexData) { }
FaceValenceSort(const OptimizeVertexData<IndexType> *vertexData) noexcept : _vertexData(vertexData) { }
bool operator()(T a, T b) const
bool operator()(T a, T b) const noexcept
{
const OptimizeVertexData<IndexType> *vA = _vertexData + size_t(a) * 3;
const OptimizeVertexData<IndexType> *vB = _vertexData + size_t(b) * 3;
@ -496,8 +496,10 @@ namespace
_Use_decl_annotations_
HRESULT DirectX::OptimizeFacesLRU(
const uint16_t* indices, size_t nFaces,
uint32_t* faceRemap, uint32_t lruCacheSize)
const uint16_t* indices,
size_t nFaces,
uint32_t* faceRemap,
uint32_t lruCacheSize)
{
if (!indices || !nFaces || !faceRemap)
return E_INVALIDARG;
@ -515,8 +517,10 @@ HRESULT DirectX::OptimizeFacesLRU(
_Use_decl_annotations_
HRESULT DirectX::OptimizeFacesLRU(
const uint32_t* indices, size_t nFaces,
uint32_t* faceRemap, uint32_t lruCacheSize)
const uint32_t* indices,
size_t nFaces,
uint32_t* faceRemap,
uint32_t lruCacheSize)
{
if (!indices || !nFaces || !faceRemap)
return E_INVALIDARG;
@ -536,8 +540,11 @@ HRESULT DirectX::OptimizeFacesLRU(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::OptimizeFacesLRUEx(
const uint16_t* indices, size_t nFaces, const uint32_t* attributes,
uint32_t* faceRemap, uint32_t lruCacheSize)
const uint16_t* indices,
size_t nFaces,
const uint32_t* attributes,
uint32_t* faceRemap,
uint32_t lruCacheSize)
{
if (!indices || !nFaces || !attributes || !faceRemap)
return E_INVALIDARG;
@ -582,8 +589,11 @@ HRESULT DirectX::OptimizeFacesLRUEx(
_Use_decl_annotations_
HRESULT DirectX::OptimizeFacesLRUEx(
const uint32_t* indices, size_t nFaces, const uint32_t* attributes,
uint32_t* faceRemap, uint32_t lruCacheSize)
const uint32_t* indices,
size_t nFaces,
const uint32_t* attributes,
uint32_t* faceRemap,
uint32_t lruCacheSize)
{
if (!indices || !nFaces || !attributes || !faceRemap)
return E_INVALIDARG;

Просмотреть файл

@ -162,7 +162,7 @@ namespace
HRESULT setSubset(
_In_reads_(nFaces * 3) const index_t* indices, size_t nFaces,
size_t faceOffset, size_t faceCount)
size_t faceOffset, size_t faceCount) noexcept
{
if (!faceCount || !indices || !nFaces)
return E_INVALIDARG;
@ -226,21 +226,21 @@ namespace
return S_OK;
}
bool isprocessed(uint32_t face) const
bool isprocessed(uint32_t face) const noexcept
{
assert(face < mTotalFaces);
assert((face >= mFaceOffset) || (face < (mFaceOffset + mFaceCount)));
return mListElements[face - mFaceOffset].processed;
}
uint32_t unprocessed_count(uint32_t face) const
uint32_t unprocessed_count(uint32_t face) const noexcept
{
assert(face < mTotalFaces);
assert((face >= mFaceOffset) || (face < (mFaceOffset + mFaceCount)));
return mListElements[face - mFaceOffset].unprocessed;
}
uint32_t find_initial() const
uint32_t find_initial() const noexcept
{
for (size_t j = 0; j < 4; ++j)
{
@ -251,7 +251,7 @@ namespace
return UNUSED32;
}
void mark(uint32_t face)
void mark(uint32_t face) noexcept
{
assert(face < mTotalFaces);
assert((face >= mFaceOffset) || (face < (mFaceOffset + mFaceCount)));
@ -273,7 +273,7 @@ namespace
}
}
uint32_t find_next(uint32_t face) const
uint32_t find_next(uint32_t face) const noexcept
{
assert(face < mTotalFaces);
assert((face >= mFaceOffset) || (face < (mFaceOffset + mFaceCount)));
@ -325,7 +325,7 @@ namespace
return iret;
}
uint32_t get_neighbors(uint32_t face, uint32_t n) const
uint32_t get_neighbors(uint32_t face, uint32_t n) const noexcept
{
assert(face < mTotalFaces);
assert(n < 3);
@ -334,14 +334,14 @@ namespace
return mPhysicalNeighbors[face].neighbors[n];
}
const uint32_t* get_neighborsPtr(uint32_t face) const
const uint32_t* get_neighborsPtr(uint32_t face) const noexcept
{
assert(face < mTotalFaces);
return &mPhysicalNeighbors[face].neighbors[0];
}
private:
void push_front(uint32_t faceIndex)
void push_front(uint32_t faceIndex) noexcept
{
assert(faceIndex < mFaceCount);
@ -358,7 +358,7 @@ namespace
mListElements[faceIndex].prev = UNUSED32;
}
void remove(uint32_t faceIndex)
void remove(uint32_t faceIndex) noexcept
{
assert(faceIndex < mFaceCount);
@ -395,7 +395,7 @@ namespace
mListElements[faceIndex].next = UNUSED32;
}
void decrement(uint32_t face)
void decrement(uint32_t face) noexcept
{
assert(face < mTotalFaces);
assert((face >= mFaceOffset) || (face < (mFaceOffset + mFaceCount)));
@ -439,7 +439,7 @@ namespace
typedef std::pair<uint32_t, uint32_t> facecorner_t;
template<class index_t>
inline facecorner_t counterclockwise_corner(facecorner_t corner, mesh_status<index_t>& status)
inline facecorner_t counterclockwise_corner(facecorner_t corner, mesh_status<index_t>& status) noexcept
{
assert(corner.second != UNUSED32);
uint32_t edge = (corner.second + 2) % 3;
@ -455,7 +455,7 @@ namespace
public:
sim_vcache() noexcept : mTail(0), mCacheSize(0) {}
HRESULT initialize(uint32_t cacheSize)
HRESULT initialize(uint32_t cacheSize) noexcept
{
if (!cacheSize)
return E_INVALIDARG;
@ -471,14 +471,14 @@ namespace
return S_OK;
}
void clear()
void clear() noexcept
{
assert(mFIFO != nullptr);
mTail = 0;
memset(mFIFO.get(), 0xff, sizeof(uint32_t) * mCacheSize);
}
bool access(uint32_t vertex)
bool access(uint32_t vertex) noexcept
{
assert(vertex != UNUSED32);
assert(mFIFO != nullptr);
@ -770,8 +770,12 @@ namespace
_Use_decl_annotations_
HRESULT DirectX::OptimizeFaces(
const uint16_t* indices, size_t nFaces, const uint32_t* adjacency,
uint32_t* faceRemap, uint32_t vertexCache, uint32_t restart)
const uint16_t* indices,
size_t nFaces,
const uint32_t* adjacency,
uint32_t* faceRemap,
uint32_t vertexCache,
uint32_t restart)
{
if (!indices || !nFaces || !adjacency || !faceRemap)
return E_INVALIDARG;
@ -794,8 +798,12 @@ HRESULT DirectX::OptimizeFaces(
_Use_decl_annotations_
HRESULT DirectX::OptimizeFaces(
const uint32_t* indices, size_t nFaces, const uint32_t* adjacency,
uint32_t* faceRemap, uint32_t vertexCache, uint32_t restart)
const uint32_t* indices,
size_t nFaces,
const uint32_t* adjacency,
uint32_t* faceRemap,
uint32_t vertexCache,
uint32_t restart)
{
if (!indices || !nFaces || !adjacency || !faceRemap)
return E_INVALIDARG;
@ -820,8 +828,13 @@ HRESULT DirectX::OptimizeFaces(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::OptimizeFacesEx(
const uint16_t* indices, size_t nFaces, const uint32_t* adjacency, const uint32_t* attributes,
uint32_t* faceRemap, uint32_t vertexCache, uint32_t restart)
const uint16_t* indices,
size_t nFaces,
const uint32_t* adjacency,
const uint32_t* attributes,
uint32_t* faceRemap,
uint32_t vertexCache,
uint32_t restart)
{
if (!indices || !nFaces || !adjacency || !attributes || !faceRemap)
return E_INVALIDARG;
@ -844,8 +857,13 @@ HRESULT DirectX::OptimizeFacesEx(
_Use_decl_annotations_
HRESULT DirectX::OptimizeFacesEx(
const uint32_t* indices, size_t nFaces, const uint32_t* adjacency, const uint32_t* attributes,
uint32_t* faceRemap, uint32_t vertexCache, uint32_t restart)
const uint32_t* indices,
size_t nFaces,
const uint32_t* adjacency,
const uint32_t* attributes,
uint32_t* faceRemap,
uint32_t vertexCache,
uint32_t restart)
{
if (!indices || !nFaces || !adjacency || !attributes || !faceRemap)
return E_INVALIDARG;

Просмотреть файл

@ -141,7 +141,7 @@ namespace DirectX
CCW
};
orbit_iterator(_In_reads_(nFaces * 3) const uint32_t* adjacency, _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces) :
orbit_iterator(_In_reads_(nFaces * 3) const uint32_t* adjacency, _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces) noexcept :
m_face(UNUSED32),
m_pointIndex(UNUSED32),
m_currentFace(UNUSED32),
@ -153,7 +153,7 @@ namespace DirectX
m_clockWise(false),
m_stopOnBoundary(false) {}
void initialize(uint32_t face, uint32_t point, WalkType wtype)
void initialize(uint32_t face, uint32_t point, WalkType wtype) noexcept
{
m_face = m_currentFace = face;
m_pointIndex = point;
@ -172,7 +172,7 @@ namespace DirectX
m_currentEdge = m_nextEdge;
}
uint32_t find(uint32_t face, uint32_t point)
uint32_t find(uint32_t face, uint32_t point) noexcept
{
assert(face < m_nFaces);
_Analysis_assume_(face < m_nFaces);
@ -188,7 +188,7 @@ namespace DirectX
}
}
uint32_t nextFace()
uint32_t nextFace() noexcept
{
assert(!done());
@ -261,7 +261,7 @@ namespace DirectX
return ret;
}
bool moveToCCW()
bool moveToCCW() noexcept
{
m_currentFace = m_face;
@ -316,8 +316,8 @@ namespace DirectX
return ret;
}
bool done() const { return (m_currentFace == UNUSED32); }
uint32_t getpoint() const { return m_clockWise ? m_currentEdge : ((m_currentEdge + 1) % 3); }
bool done() const noexcept { return (m_currentFace == UNUSED32); }
uint32_t getpoint() const noexcept { return m_clockWise ? m_currentEdge : ((m_currentEdge + 1) % 3); }
private:
uint32_t m_face;
@ -337,7 +337,7 @@ namespace DirectX
//-------------------------------------------------------------------------------------
template<class index_t>
inline uint32_t find_edge(_In_reads_(3) const index_t* indices, index_t search)
inline uint32_t find_edge(_In_reads_(3) const index_t* indices, index_t search) noexcept
{
assert(indices != nullptr);

Просмотреть файл

@ -35,7 +35,7 @@ namespace
_In_reads_opt_(nFaces * 3) const uint32_t* adjin,
_In_reads_(nFaces) const uint32_t* faceRemap,
_Out_writes_(nFaces * 3) index_t* ibout,
_Out_writes_opt_(nFaces * 3) uint32_t* adjout)
_Out_writes_opt_(nFaces * 3) uint32_t* adjout) noexcept
{
assert(ibin != nullptr && faceRemap != nullptr && ibout != nullptr && ibin != ibout);
_Analysis_assume_(ibin != nullptr && faceRemap != nullptr && ibout != nullptr && ibin != ibout);
@ -78,7 +78,7 @@ namespace
HRESULT SwapFaces(
_Inout_updates_all_(nFaces * 3) index_t* ib, _In_ size_t nFaces,
_Inout_updates_all_opt_(nFaces * 3) uint32_t* adj,
_In_reads_(nFaces) const uint32_t* faceRemap)
_In_reads_(nFaces) const uint32_t* faceRemap) noexcept
{
assert(ib != nullptr && faceRemap != nullptr);
_Analysis_assume_(ib != nullptr && faceRemap != nullptr);
@ -168,7 +168,7 @@ namespace
//---------------------------------------------------------------------------------
HRESULT SwapVertices(
_Inout_updates_bytes_all_(nVerts*stride) void* vb, size_t stride, size_t nVerts,
_Inout_updates_all_opt_(nVerts) uint32_t* pointRep, _In_reads_(nVerts) const uint32_t* vertexRemap)
_Inout_updates_all_opt_(nVerts) uint32_t* pointRep, _In_reads_(nVerts) const uint32_t* vertexRemap) noexcept
{
if (!vb || !stride || !nVerts || !vertexRemap)
return E_INVALIDARG;
@ -279,7 +279,7 @@ namespace
HRESULT FinalizeIBImpl(
_In_reads_(nFaces * 3) const index_t* ibin, size_t nFaces,
_In_reads_(nVerts) const uint32_t* vertexRemap, size_t nVerts,
_Out_writes_(nFaces * 3) index_t* ibout)
_Out_writes_(nFaces * 3) index_t* ibout) noexcept
{
if (!ibin || !nFaces || !vertexRemap || !nVerts || !ibout)
return E_INVALIDARG;
@ -342,7 +342,7 @@ namespace
template<class index_t>
HRESULT FinalizeIBImpl(
_Inout_updates_all_(nFaces * 3) index_t* ib, size_t nFaces,
_In_reads_(nVerts) const uint32_t* vertexRemap, size_t nVerts)
_In_reads_(nVerts) const uint32_t* vertexRemap, size_t nVerts) noexcept
{
if (!ib || !nFaces || !vertexRemap || !nVerts)
return E_INVALIDARG;
@ -404,8 +404,10 @@ namespace
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ReorderIB(
const uint16_t* ibin, size_t nFaces, const uint32_t* faceRemap,
uint16_t* ibout)
const uint16_t* ibin,
size_t nFaces,
const uint32_t* faceRemap,
uint16_t* ibout) noexcept
{
if (!ibin || !nFaces || !faceRemap || !ibout)
return E_INVALIDARG;
@ -421,8 +423,9 @@ HRESULT DirectX::ReorderIB(
_Use_decl_annotations_
HRESULT DirectX::ReorderIB(
uint16_t* ib, size_t nFaces,
const uint32_t* faceRemap)
uint16_t* ib,
size_t nFaces,
const uint32_t* faceRemap) noexcept
{
if (!ib || !nFaces || !faceRemap)
return E_INVALIDARG;
@ -437,8 +440,10 @@ HRESULT DirectX::ReorderIB(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ReorderIB(
const uint32_t* ibin, size_t nFaces, const uint32_t* faceRemap,
uint32_t* ibout)
const uint32_t* ibin,
size_t nFaces,
const uint32_t* faceRemap,
uint32_t* ibout) noexcept
{
if (!ibin || !nFaces || !faceRemap || !ibout)
return E_INVALIDARG;
@ -454,7 +459,9 @@ HRESULT DirectX::ReorderIB(
_Use_decl_annotations_
HRESULT DirectX::ReorderIB(
uint32_t* ib, size_t nFaces, const uint32_t* faceRemap)
uint32_t* ib,
size_t nFaces,
const uint32_t* faceRemap) noexcept
{
if (!ib || !nFaces || !faceRemap)
return E_INVALIDARG;
@ -471,8 +478,12 @@ HRESULT DirectX::ReorderIB(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ReorderIBAndAdjacency(
const uint16_t* ibin, size_t nFaces, const uint32_t* adjin, const uint32_t* faceRemap,
uint16_t* ibout, uint32_t* adjout)
const uint16_t* ibin,
size_t nFaces,
const uint32_t* adjin,
const uint32_t* faceRemap,
uint16_t* ibout,
uint32_t* adjout) noexcept
{
if (!ibin || !nFaces || !adjin || !faceRemap || !ibout || !adjout)
return E_INVALIDARG;
@ -488,8 +499,10 @@ HRESULT DirectX::ReorderIBAndAdjacency(
_Use_decl_annotations_
HRESULT DirectX::ReorderIBAndAdjacency(
uint16_t* ib, size_t nFaces, uint32_t* adj,
const uint32_t* faceRemap)
uint16_t* ib,
size_t nFaces,
uint32_t* adj,
const uint32_t* faceRemap) noexcept
{
if (!ib || !nFaces || !adj || !faceRemap)
return E_INVALIDARG;
@ -504,8 +517,12 @@ HRESULT DirectX::ReorderIBAndAdjacency(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ReorderIBAndAdjacency(
const uint32_t* ibin, size_t nFaces, const uint32_t* adjin, const uint32_t* faceRemap,
uint32_t* ibout, uint32_t* adjout)
const uint32_t* ibin,
size_t nFaces,
const uint32_t* adjin,
const uint32_t* faceRemap,
uint32_t* ibout,
uint32_t* adjout) noexcept
{
if (!ibin || !nFaces || !adjin || !faceRemap || !ibout || !adjout)
return E_INVALIDARG;
@ -521,8 +538,10 @@ HRESULT DirectX::ReorderIBAndAdjacency(
_Use_decl_annotations_
HRESULT DirectX::ReorderIBAndAdjacency(
uint32_t* ib, size_t nFaces, uint32_t* adj,
const uint32_t* faceRemap)
uint32_t* ib,
size_t nFaces,
uint32_t* adj,
const uint32_t* faceRemap) noexcept
{
if (!ib || !nFaces || !adj || !faceRemap)
return E_INVALIDARG;
@ -539,17 +558,21 @@ HRESULT DirectX::ReorderIBAndAdjacency(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::FinalizeIB(
const uint16_t* ibin, size_t nFaces,
const uint32_t* vertexRemap, size_t nVerts,
uint16_t* ibout)
const uint16_t* ibin,
size_t nFaces,
const uint32_t* vertexRemap,
size_t nVerts,
uint16_t* ibout) noexcept
{
return FinalizeIBImpl<uint16_t>(ibin, nFaces, vertexRemap, nVerts, ibout);
}
_Use_decl_annotations_
HRESULT DirectX::FinalizeIB(
uint16_t* ib, size_t nFaces,
const uint32_t* vertexRemap, size_t nVerts)
uint16_t* ib,
size_t nFaces,
const uint32_t* vertexRemap,
size_t nVerts) noexcept
{
return FinalizeIBImpl<uint16_t>(ib, nFaces, vertexRemap, nVerts);
}
@ -558,17 +581,21 @@ HRESULT DirectX::FinalizeIB(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::FinalizeIB(
const uint32_t* ibin, size_t nFaces,
const uint32_t* vertexRemap, size_t nVerts,
uint32_t* ibout)
const uint32_t* ibin,
size_t nFaces,
const uint32_t* vertexRemap,
size_t nVerts,
uint32_t* ibout) noexcept
{
return FinalizeIBImpl<uint32_t>(ibin, nFaces, vertexRemap, nVerts, ibout);
}
_Use_decl_annotations_
HRESULT DirectX::FinalizeIB(
uint32_t* ib, size_t nFaces,
const uint32_t* vertexRemap, size_t nVerts)
uint32_t* ib,
size_t nFaces,
const uint32_t* vertexRemap,
size_t nVerts) noexcept
{
return FinalizeIBImpl<uint32_t>(ib, nFaces, vertexRemap, nVerts);
}
@ -582,9 +609,13 @@ HRESULT DirectX::FinalizeIB(
_Use_decl_annotations_
HRESULT DirectX::FinalizeVB(
const void* vbin, size_t stride, size_t nVerts,
const uint32_t* dupVerts, size_t nDupVerts,
const uint32_t* vertexRemap, void* vbout)
const void* vbin,
size_t stride,
size_t nVerts,
const uint32_t* dupVerts,
size_t nDupVerts,
const uint32_t* vertexRemap,
void* vbout) noexcept
{
if (!vbin || !stride || !nVerts || !vbout)
return E_INVALIDARG;
@ -653,8 +684,10 @@ HRESULT DirectX::FinalizeVB(
_Use_decl_annotations_
HRESULT DirectX::FinalizeVB(
void* vb, size_t stride,
size_t nVerts, const uint32_t* vertexRemap)
void* vb,
size_t stride,
size_t nVerts,
const uint32_t* vertexRemap) noexcept
{
if (nVerts >= UINT32_MAX)
return E_INVALIDARG;
@ -672,9 +705,15 @@ HRESULT DirectX::FinalizeVB(
_Use_decl_annotations_
HRESULT DirectX::FinalizeVBAndPointReps(
const void* vbin, size_t stride, size_t nVerts, const uint32_t* prin,
const uint32_t* dupVerts, size_t nDupVerts, const uint32_t* vertexRemap,
void* vbout, uint32_t* prout)
const void* vbin,
size_t stride,
size_t nVerts,
const uint32_t* prin,
const uint32_t* dupVerts,
size_t nDupVerts,
const uint32_t* vertexRemap,
void* vbout,
uint32_t* prout) noexcept
{
if (!vbin || !stride || !nVerts || !prin || !vbout || !prout)
return E_INVALIDARG;
@ -730,8 +769,12 @@ HRESULT DirectX::FinalizeVBAndPointReps(
memset(vbout, 0, newVerts * stride);
#endif
std::unique_ptr<uint32_t[]> pointRep(new uint32_t[nVerts + nDupVerts]);
std::unique_ptr<uint32_t[]> pointRep(new (std::nothrow) uint32_t[nVerts + nDupVerts]);
if (!pointRep)
return E_OUTOFMEMORY;
memcpy(pointRep.get(), prin, sizeof(uint32_t) * nVerts);
for (size_t i = 0; i < nDupVerts; ++i)
{
pointRep[i + nVerts] = prin[dupVerts[i]];
@ -795,8 +838,11 @@ HRESULT DirectX::FinalizeVBAndPointReps(
_Use_decl_annotations_
HRESULT DirectX::FinalizeVBAndPointReps(
void* vb, size_t stride, size_t nVerts,
uint32_t* pointRep, const uint32_t* vertexRemap)
void* vb,
size_t stride,
size_t nVerts,
uint32_t* pointRep,
const uint32_t* vertexRemap) noexcept
{
if (nVerts >= UINT32_MAX)
return E_INVALIDARG;
@ -824,9 +870,12 @@ HRESULT DirectX::FinalizeVBAndPointReps(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::CompactVB(
const void* vbin, size_t stride, size_t nVerts,
const void* vbin,
size_t stride,
size_t nVerts,
size_t trailingUnused,
const uint32_t* vertexRemap, void* vbout)
const uint32_t* vertexRemap,
void* vbout) noexcept
{
if (!vbin || !stride || !nVerts || !vbout || !vertexRemap)
return E_INVALIDARG;

Просмотреть файл

@ -27,7 +27,7 @@ namespace
size_t nVerts,
_Out_writes_opt_(nVerts) XMFLOAT3* tangents3,
_Out_writes_opt_(nVerts) XMFLOAT4* tangents4,
_Out_writes_opt_(nVerts) XMFLOAT3* bitangents)
_Out_writes_opt_(nVerts) XMFLOAT3* bitangents) noexcept
{
if (!indices || !nFaces || !positions || !normals || !texcoords || !nVerts)
return E_INVALIDARG;
@ -192,9 +192,14 @@ namespace
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ComputeTangentFrame(
const uint16_t* indices, size_t nFaces,
const XMFLOAT3* positions, const XMFLOAT3* normals, const XMFLOAT2* texcoords,
size_t nVerts, XMFLOAT3* tangents, XMFLOAT3* bitangents)
const uint16_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
const XMFLOAT3* normals,
const XMFLOAT2* texcoords,
size_t nVerts,
XMFLOAT3* tangents,
XMFLOAT3* bitangents) noexcept
{
if (!tangents && !bitangents)
return E_INVALIDARG;
@ -206,9 +211,13 @@ HRESULT DirectX::ComputeTangentFrame(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ComputeTangentFrame(
const uint32_t* indices, size_t nFaces,
const XMFLOAT3* positions, const XMFLOAT3* normals, const XMFLOAT2* texcoords,
size_t nVerts, XMFLOAT3* tangents, XMFLOAT3* bitangents)
const uint32_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
const XMFLOAT3* normals, const XMFLOAT2* texcoords,
size_t nVerts,
XMFLOAT3* tangents,
XMFLOAT3* bitangents) noexcept
{
if (!tangents && !bitangents)
return E_INVALIDARG;
@ -220,9 +229,14 @@ HRESULT DirectX::ComputeTangentFrame(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ComputeTangentFrame(
const uint16_t* indices, size_t nFaces,
const XMFLOAT3* positions, const XMFLOAT3* normals, const XMFLOAT2* texcoords,
size_t nVerts, XMFLOAT4* tangents, XMFLOAT3* bitangents)
const uint16_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
const XMFLOAT3* normals,
const XMFLOAT2* texcoords,
size_t nVerts,
XMFLOAT4* tangents,
XMFLOAT3* bitangents) noexcept
{
if (!tangents && !bitangents)
return E_INVALIDARG;
@ -234,9 +248,14 @@ HRESULT DirectX::ComputeTangentFrame(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ComputeTangentFrame(
const uint32_t* indices, size_t nFaces,
const XMFLOAT3* positions, const XMFLOAT3* normals, const XMFLOAT2* texcoords,
size_t nVerts, XMFLOAT4* tangents, XMFLOAT3* bitangents)
const uint32_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
const XMFLOAT3* normals,
const XMFLOAT2* texcoords,
size_t nVerts,
XMFLOAT4* tangents,
XMFLOAT3* bitangents) noexcept
{
if (!tangents && !bitangents)
return E_INVALIDARG;
@ -248,9 +267,13 @@ HRESULT DirectX::ComputeTangentFrame(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ComputeTangentFrame(
const uint16_t* indices, size_t nFaces,
const XMFLOAT3* positions, const XMFLOAT3* normals, const XMFLOAT2* texcoords,
size_t nVerts, XMFLOAT4* tangents)
const uint16_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
const XMFLOAT3* normals,
const XMFLOAT2* texcoords,
size_t nVerts,
XMFLOAT4* tangents) noexcept
{
if (!tangents)
return E_INVALIDARG;
@ -262,9 +285,13 @@ HRESULT DirectX::ComputeTangentFrame(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::ComputeTangentFrame(
const uint32_t* indices, size_t nFaces,
const XMFLOAT3* positions, const XMFLOAT3* normals, const XMFLOAT2* texcoords,
size_t nVerts, XMFLOAT4* tangents)
const uint32_t* indices,
size_t nFaces,
const XMFLOAT3* positions,
const XMFLOAT3* normals,
const XMFLOAT2* texcoords,
size_t nVerts,
XMFLOAT4* tangents) noexcept
{
if (!tangents)
return E_INVALIDARG;

Просмотреть файл

@ -64,7 +64,7 @@ public:
mTempSize(0) {}
HRESULT Initialize(_In_reads_(nDecl) const InputElementDesc* vbDecl, size_t nDecl);
HRESULT AddStream(_In_reads_bytes_(stride*nVerts) const void* vb, size_t nVerts, size_t inputSlot, size_t stride);
HRESULT AddStream(_In_reads_bytes_(stride*nVerts) const void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept;
HRESULT Read(_Out_writes_(count) XMVECTOR* buffer, _In_z_ const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const;
void Release() noexcept
@ -95,7 +95,7 @@ public:
return &mInputDesc[it->second];
}
XMVECTOR* GetTemporaryBuffer(size_t count) const
XMVECTOR* GetTemporaryBuffer(size_t count) const noexcept
{
if (!mTempBuffer || (mTempSize < count))
{
@ -193,7 +193,7 @@ HRESULT VBReader::Impl::Initialize(const InputElementDesc* vbDecl, size_t nDecl)
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT VBReader::Impl::AddStream(const void* vb, size_t nVerts, size_t inputSlot, size_t stride)
HRESULT VBReader::Impl::AddStream(const void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept
{
if (!vb || !nVerts)
return E_INVALIDARG;
@ -689,7 +689,7 @@ HRESULT VBReader::Initialize(const D3D12_INPUT_LAYOUT_DESC& vbDecl)
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT VBReader::AddStream(const void* vb, size_t nVerts, size_t inputSlot, size_t stride)
HRESULT VBReader::AddStream(const void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept
{
return pImpl->AddStream(vb, nVerts, inputSlot, stride);
}

Просмотреть файл

@ -64,7 +64,7 @@ public:
mTempSize(0) {}
HRESULT Initialize(_In_reads_(nDecl) const InputElementDesc* vbDecl, size_t nDecl);
HRESULT AddStream(_Out_writes_bytes_(stride*nVerts) void* vb, size_t nVerts, size_t inputSlot, size_t stride);
HRESULT AddStream(_Out_writes_bytes_(stride*nVerts) void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept;
HRESULT Write(_In_reads_(count) const XMVECTOR* buffer, _In_z_ const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const;
void Release() noexcept
@ -95,7 +95,7 @@ public:
return &mInputDesc[it->second];
}
XMVECTOR* GetTemporaryBuffer(size_t count) const
XMVECTOR* GetTemporaryBuffer(size_t count) const noexcept
{
if (!mTempBuffer || (mTempSize < count))
{
@ -192,7 +192,7 @@ HRESULT VBWriter::Impl::Initialize(const InputElementDesc* vbDecl, size_t nDecl)
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT VBWriter::Impl::AddStream(void* vb, size_t nVerts, size_t inputSlot, size_t stride)
HRESULT VBWriter::Impl::AddStream(void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept
{
if (!vb || !nVerts)
return E_INVALIDARG;
@ -687,7 +687,7 @@ HRESULT VBWriter::Initialize(const D3D12_INPUT_LAYOUT_DESC& vbDecl)
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT VBWriter::AddStream(void* vb, size_t nVerts, size_t inputSlot, size_t stride)
HRESULT VBWriter::AddStream(void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept
{
return pImpl->AddStream(vb, nVerts, inputSlot, stride);
}

Просмотреть файл

@ -357,8 +357,12 @@ namespace
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::Validate(
const uint16_t* indices, size_t nFaces, size_t nVerts,
const uint32_t* adjacency, DWORD flags, std::wstring* msgs)
const uint16_t* indices,
size_t nFaces,
size_t nVerts,
const uint32_t* adjacency,
DWORD flags,
std::wstring* msgs)
{
if (!indices || !nFaces || !nVerts)
return E_INVALIDARG;
@ -390,8 +394,12 @@ HRESULT DirectX::Validate(
//-------------------------------------------------------------------------------------
_Use_decl_annotations_
HRESULT DirectX::Validate(
const uint32_t* indices, size_t nFaces, size_t nVerts,
const uint32_t* adjacency, DWORD flags, std::wstring* msgs)
const uint32_t* indices,
size_t nFaces,
size_t nVerts,
const uint32_t* adjacency,
DWORD flags,
std::wstring* msgs)
{
if (!indices || !nFaces || !nVerts)
return E_INVALIDARG;

Просмотреть файл

@ -145,8 +145,10 @@ namespace
_Use_decl_annotations_
HRESULT DirectX::WeldVertices(
uint16_t* indices, size_t nFaces,
size_t nVerts, const uint32_t* pointRep,
uint16_t* indices,
size_t nFaces,
size_t nVerts,
const uint32_t* pointRep,
uint32_t* vertexRemap,
std::function<bool __cdecl(uint32_t v0, uint32_t v1)> weldTest)
{

Просмотреть файл

@ -14,15 +14,15 @@
#include <malloc.h>
//---------------------------------------------------------------------------------
struct aligned_deleter { void operator()(void* p) { _aligned_free(p); } };
struct aligned_deleter { void operator()(void* p) noexcept { _aligned_free(p); } };
typedef std::unique_ptr<float[], aligned_deleter> ScopedAlignedArrayFloat;
typedef std::unique_ptr<DirectX::XMVECTOR[], aligned_deleter> ScopedAlignedArrayXMVECTOR;
//---------------------------------------------------------------------------------
struct handle_closer { void operator()(HANDLE h) { assert(h != INVALID_HANDLE_VALUE); if (h) CloseHandle(h); } };
struct handle_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) CloseHandle(h); } };
typedef std::unique_ptr<void, handle_closer> ScopedHandle;
inline HANDLE safe_handle(HANDLE h) { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }