Skip to content

Commit

Permalink
Update DirectXTex, DirectXMesh for May 2019 release
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Jun 3, 2019
1 parent ea292e0 commit e068355
Show file tree
Hide file tree
Showing 38 changed files with 311 additions and 241 deletions.
8 changes: 4 additions & 4 deletions DirectXMesh/DirectXMesh.h
Expand Up @@ -26,7 +26,7 @@
#endif
#endif

#include <directxmath.h>
#include <DirectXMath.h>

#define DIRECTX_MESH_VERSION 130

Expand Down Expand Up @@ -232,7 +232,7 @@ namespace DirectX
//---------------------------------------------------------------------------------
// Normals, Tangents, and Bi-Tangents Computation

enum CNORM_FLAGS
enum CNORM_FLAGS : uint32_t
{
CNORM_DEFAULT = 0x0,
// Default is to compute normals using weight-by-angle
Expand Down Expand Up @@ -304,7 +304,7 @@ namespace DirectX
//---------------------------------------------------------------------------------
// Mesh clean-up and validation

enum VALIDATE_FLAGS
enum VALIDATE_FLAGS : uint32_t
{
VALIDATE_DEFAULT = 0x0,

Expand Down Expand Up @@ -369,7 +369,7 @@ namespace DirectX
_Out_writes_(nFaces) uint32_t* faceRemap);
// Reorders faces by attribute id

enum OPTFACES
enum OPTFACES : uint32_t
{
OPTFACES_V_DEFAULT = 12,
OPTFACES_R_DEFAULT = 7,
Expand Down
7 changes: 4 additions & 3 deletions DirectXMesh/DirectXMeshAdjacency.cpp
Expand Up @@ -173,9 +173,10 @@ namespace

for (size_t vert = 0; vert < nVerts; ++vert)
{
uint32_t hashKey = (*reinterpret_cast<const uint32_t*>(&positions[vert].x)
+ *reinterpret_cast<const uint32_t*>(&positions[vert].y)
+ *reinterpret_cast<const uint32_t*>(&positions[vert].z)) % uint32_t(hashSize);
auto px = reinterpret_cast<const uint32_t*>(&positions[vert].x);
auto py = reinterpret_cast<const uint32_t*>(&positions[vert].y);
auto pz = reinterpret_cast<const uint32_t*>(&positions[vert].z);
uint32_t hashKey = (*px + *py + *pz) % uint32_t(hashSize);

uint32_t found = UNUSED32;

Expand Down
10 changes: 4 additions & 6 deletions DirectXMesh/DirectXMeshOptimizeLRU.cpp
Expand Up @@ -22,13 +22,13 @@ namespace

// code for computing vertex score was taken, as much as possible
// directly from the original publication.
float ComputeVertexCacheScore(int cachePosition, uint32_t vertexCacheSize)
float ComputeVertexCacheScore(uint32_t cachePosition, uint32_t vertexCacheSize)
{
const float FindVertexScore_CacheDecayPower = 1.5f;
const float FindVertexScore_LastTriScore = 0.75f;

float score = 0.0f;
if (cachePosition < 0)
if (cachePosition >= vertexCacheSize)
{
// Vertex is not in FIFO cache - no score.
}
Expand All @@ -46,8 +46,6 @@ namespace
}
else
{
assert(cachePosition < int(vertexCacheSize));

// Points for being high in the cache.
const float scaler = 1.0f / (vertexCacheSize - 3);
score = 1.0f - (cachePosition - 3) * scaler;
Expand Down Expand Up @@ -172,8 +170,8 @@ namespace
const OptimizeVertexData<IndexType> *vA = _vertexData + size_t(a) * 3;
const OptimizeVertexData<IndexType> *vB = _vertexData + size_t(b) * 3;

int aValence = vA[0].activeFaceListSize + vA[1].activeFaceListSize + vA[2].activeFaceListSize;
int bValence = vB[0].activeFaceListSize + vB[1].activeFaceListSize + vB[2].activeFaceListSize;
uint32_t aValence = vA[0].activeFaceListSize + vA[1].activeFaceListSize + vA[2].activeFaceListSize;
uint32_t bValence = vB[0].activeFaceListSize + vB[1].activeFaceListSize + vB[2].activeFaceListSize;

// higher scoring faces are those with lower valence totals

Expand Down
15 changes: 12 additions & 3 deletions DirectXMesh/DirectXMeshP.h
Expand Up @@ -46,6 +46,15 @@
#pragma warning(disable : 4643)
// C4643 Forward declaring in namespace std is not permitted by the C++ Standard

#ifdef __clang__
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wc++98-compat-local-type-template-args"
#pragma clang diagnostic ignored "-Wcovered-switch-default"
#pragma clang diagnostic ignored "-Wfloat-equal"
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#endif

#pragma warning(push)
#pragma warning(disable : 4005)
#define WIN32_LEAN_AND_MEAN
Expand All @@ -62,7 +71,7 @@
#define _WIN32_WINNT_WIN10 0x0A00
#endif

#include <windows.h>
#include <Windows.h>

#if defined(_XBOX_ONE) && defined(_TITLE)
#include <d3d12_x.h>
Expand All @@ -76,8 +85,8 @@

#define _XM_NO_XMVECTOR_OVERLOADS_

#include <directxmath.h>
#include <directxpackedvector.h>
#include <DirectXMath.h>
#include <DirectXPackedVector.h>

#include <assert.h>
#include <malloc.h>
Expand Down
2 changes: 1 addition & 1 deletion DirectXMesh/DirectXMeshUtil.cpp
Expand Up @@ -403,7 +403,7 @@ std::vector<std::pair<size_t, size_t>> DirectX::ComputeSubsets(const uint32_t* a

if (!attributes)
{
subsets.emplace_back(std::pair<size_t, size_t>(0, nFaces));
subsets.emplace_back(std::pair<size_t, size_t>(0u, nFaces));
return subsets;
}

Expand Down
2 changes: 1 addition & 1 deletion DirectXMesh/DirectXMeshVBWriter.cpp
Expand Up @@ -565,7 +565,7 @@ HRESULT VBWriter::Impl::Write(const XMVECTOR* buffer, const char* semanticName,
}
v = XMVectorMultiply(v, s_Scale);
XMStoreU555(reinterpret_cast<XMU555*>(ptr), v);
reinterpret_cast<XMU555*>(ptr)->w = (XMVectorGetW(v) > 0.5f) ? 1 : 0;
reinterpret_cast<XMU555*>(ptr)->w = (XMVectorGetW(v) > 0.5f) ? 1u : 0u;
ptr += stride;
}
}
Expand Down
6 changes: 5 additions & 1 deletion DirectXMesh/ReadMe.txt
Expand Up @@ -3,7 +3,7 @@ DIRECTX MESH LIBRARY (DirectXMesh)

Copyright (c) Microsoft Corporation. All rights reserved.

April 26, 2019
May 30, 2019

This package contains DirectXMesh, a shared source library for performing various geometry
content processing operations including generating normals and tangent frames, triangle
Expand Down Expand Up @@ -79,6 +79,10 @@ RELEASE NOTES
RELEASE HISTORY
---------------

May 30, 2019
Added CMake project files
Code cleanup

April 26, 2019
Added VS 2019 desktop projects
Officially dropped Windows Vista support
Expand Down
16 changes: 8 additions & 8 deletions DirectXTex/BC.cpp
Expand Up @@ -9,7 +9,7 @@
// http://go.microsoft.com/fwlink/?LinkId=248926
//-------------------------------------------------------------------------------------

#include "DirectXTexp.h"
#include "DirectXTexP.h"

// Experiemental encoding variants, not enabled by default
//#define COLOR_WEIGHTS
Expand Down Expand Up @@ -398,11 +398,11 @@ namespace
return;
}

uSteps = (uColorKey > 0) ? 3 : 4;
uSteps = (uColorKey > 0) ? 3u : 4u;
}
else
{
uSteps = 4;
uSteps = 4u;
}

// Quantize block to R56B5, using Floyd Stienberg error diffusion. This
Expand Down Expand Up @@ -929,12 +929,12 @@ void DirectX::D3DXDecodeBC3(XMVECTOR *pColor, const uint8_t *pBC)
fAlpha[7] = 1.0f;
}

DWORD dw = pBC3->bitmap[0] | (pBC3->bitmap[1] << 8) | (pBC3->bitmap[2] << 16);
DWORD dw = uint32_t(pBC3->bitmap[0]) | uint32_t(pBC3->bitmap[1] << 8) | uint32_t(pBC3->bitmap[2] << 16);

for (size_t i = 0; i < 8; ++i, dw >>= 3)
pColor[i] = XMVectorSetW(pColor[i], fAlpha[dw & 0x7]);

dw = pBC3->bitmap[3] | (pBC3->bitmap[4] << 8) | (pBC3->bitmap[5] << 16);
dw = uint32_t(pBC3->bitmap[3]) | uint32_t(pBC3->bitmap[4] << 8) | uint32_t(pBC3->bitmap[5] << 16);

for (size_t i = 8; i < NUM_PIXELS_PER_BLOCK; ++i, dw >>= 3)
pColor[i] = XMVectorSetW(pColor[i], fAlpha[dw & 0x7]);
Expand Down Expand Up @@ -1027,7 +1027,7 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags)
}

// Optimize and Quantize Min and Max values
uint32_t uSteps = ((0.0f == fMinAlpha) || (1.0f == fMaxAlpha)) ? 6 : 8;
uint32_t uSteps = ((0.0f == fMinAlpha) || (1.0f == fMaxAlpha)) ? 6u : 8u;

float fAlphaA, fAlphaB;
OptimizeAlpha<false>(&fAlphaA, &fAlphaB, fAlpha, uSteps);
Expand Down Expand Up @@ -1106,9 +1106,9 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags)

uint32_t iStep;
if (fDot <= 0.0f)
iStep = ((6 == uSteps) && (fAlph <= fStep[0] * 0.5f)) ? 6 : 0;
iStep = ((6 == uSteps) && (fAlph <= fStep[0] * 0.5f)) ? 6u : 0u;
else if (fDot >= fSteps)
iStep = ((6 == uSteps) && (fAlph >= (fStep[1] + 1.0f) * 0.5f)) ? 7 : 1;
iStep = ((6 == uSteps) && (fAlph >= (fStep[1] + 1.0f) * 0.5f)) ? 7u : 1u;
else
iStep = uint32_t(pSteps[uint32_t(fDot + 0.5f)]);

Expand Down
4 changes: 2 additions & 2 deletions DirectXTex/BC.h
Expand Up @@ -249,9 +249,9 @@ template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPo

uint32_t iStep;
if (fDot <= 0.0f)
iStep = ((6 == cSteps) && (pPoints[iPoint] <= fX * 0.5f)) ? 6 : 0;
iStep = ((6 == cSteps) && (pPoints[iPoint] <= fX * 0.5f)) ? 6u : 0u;
else if (fDot >= fSteps)
iStep = ((6 == cSteps) && (pPoints[iPoint] >= (fY + 1.0f) * 0.5f)) ? 7 : (cSteps - 1);
iStep = ((6 == cSteps) && (pPoints[iPoint] >= (fY + 1.0f) * 0.5f)) ? 7u : (cSteps - 1);
else
iStep = uint32_t(fDot + 0.5f);

Expand Down
4 changes: 2 additions & 2 deletions DirectXTex/BC4BC5.cpp
Expand Up @@ -9,7 +9,7 @@
// http://go.microsoft.com/fwlink/?LinkId=248926
//-------------------------------------------------------------------------------------

#include "DirectXTexp.h"
#include "DirectXTexP.h"

#include "BC.h"

Expand Down Expand Up @@ -159,7 +159,7 @@ namespace
{
const uint32_t dwMostNeg = (1 << (8 * sizeof(int8_t) - 1));

if (_isnan(fVal))
if (isnan(fVal))
fVal = 0;
else
if (fVal > 1)
Expand Down

0 comments on commit e068355

Please sign in to comment.