mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-15 06:20:14 +02:00
DirectXTex: Code review feedback
- /analyze work focused on VS 2012 with SAL2 rather than VS 2010
This commit is contained in:
parent
91654fc9df
commit
e4e6c6c008
@ -370,7 +370,6 @@ inline static void DecodeBC1( _Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColo
|
|||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
#pragma warning(disable: 4616 6001 6201)
|
|
||||||
|
|
||||||
static void EncodeBC1(_Out_ D3DX_BC1 *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor,
|
static void EncodeBC1(_Out_ D3DX_BC1 *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor,
|
||||||
_In_ bool bColorKey, _In_ float alphaRef, _In_ DWORD flags)
|
_In_ bool bColorKey, _In_ float alphaRef, _In_ DWORD flags)
|
||||||
|
@ -529,9 +529,6 @@ private:
|
|||||||
uint8_t m_uBits[ SizeInBytes ];
|
uint8_t m_uBits[ SizeInBytes ];
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable : 4127 4480 4512)
|
|
||||||
|
|
||||||
// BC6H compression (16 bits per texel)
|
// BC6H compression (16 bits per texel)
|
||||||
class D3DX_BC6H : private CBits< 16 >
|
class D3DX_BC6H : private CBits< 16 >
|
||||||
{
|
{
|
||||||
@ -540,6 +537,8 @@ public:
|
|||||||
void Encode(_In_ bool bSigned, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn);
|
void Encode(_In_ bool bSigned, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4480)
|
||||||
enum EField : uint8_t
|
enum EField : uint8_t
|
||||||
{
|
{
|
||||||
NA, // N/A
|
NA, // N/A
|
||||||
@ -558,6 +557,7 @@ private:
|
|||||||
BY,
|
BY,
|
||||||
BZ,
|
BZ,
|
||||||
};
|
};
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
struct ModeDescriptor
|
struct ModeDescriptor
|
||||||
{
|
{
|
||||||
@ -574,6 +574,8 @@ private:
|
|||||||
LDRColorA RGBAPrec[BC6H_MAX_REGIONS][2];
|
LDRColorA RGBAPrec[BC6H_MAX_REGIONS][2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4512)
|
||||||
struct EncodeParams
|
struct EncodeParams
|
||||||
{
|
{
|
||||||
float fBestErr;
|
float fBestErr;
|
||||||
@ -593,6 +595,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
static int Quantize(_In_ int iValue, _In_ int prec, _In_ bool bSigned);
|
static int Quantize(_In_ int iValue, _In_ int prec, _In_ bool bSigned);
|
||||||
static int Unquantize(_In_ int comp, _In_ uint8_t uBitsPerComp, _In_ bool bSigned);
|
static int Unquantize(_In_ int comp, _In_ uint8_t uBitsPerComp, _In_ bool bSigned);
|
||||||
@ -651,6 +654,8 @@ private:
|
|||||||
LDRColorA RGBAPrecWithP;
|
LDRColorA RGBAPrecWithP;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4512)
|
||||||
struct EncodeParams
|
struct EncodeParams
|
||||||
{
|
{
|
||||||
uint8_t uMode;
|
uint8_t uMode;
|
||||||
@ -660,6 +665,7 @@ private:
|
|||||||
|
|
||||||
EncodeParams(const HDRColorA* const aOriginal) : aHDRPixels(aOriginal) {}
|
EncodeParams(const HDRColorA* const aOriginal) : aHDRPixels(aOriginal) {}
|
||||||
};
|
};
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
static uint8_t Quantize(_In_ uint8_t comp, _In_ uint8_t uPrec)
|
static uint8_t Quantize(_In_ uint8_t comp, _In_ uint8_t uPrec)
|
||||||
{
|
{
|
||||||
@ -713,7 +719,7 @@ private:
|
|||||||
_Out_writes_(BC7_MAX_REGIONS) LDREndPntPair opt_endpts[]) const;
|
_Out_writes_(BC7_MAX_REGIONS) LDREndPntPair opt_endpts[]) const;
|
||||||
void AssignIndices(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode,
|
void AssignIndices(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode,
|
||||||
_In_reads_(BC7_MAX_REGIONS) LDREndPntPair endpts[],
|
_In_reads_(BC7_MAX_REGIONS) LDREndPntPair endpts[],
|
||||||
_Inout_updates_all_(NUM_PIXELS_PER_BLOCK) size_t aIndices[], _Inout_updates_all_(NUM_PIXELS_PER_BLOCK) size_t aIndices2[],
|
_Out_writes_(NUM_PIXELS_PER_BLOCK) size_t aIndices[], _Out_writes_(NUM_PIXELS_PER_BLOCK) size_t aIndices2[],
|
||||||
_Out_writes_(BC7_MAX_REGIONS) float afTotErr[]) const;
|
_Out_writes_(BC7_MAX_REGIONS) float afTotErr[]) const;
|
||||||
void EmitBlock(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uRotation, _In_ size_t uIndexMode,
|
void EmitBlock(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uRotation, _In_ size_t uIndexMode,
|
||||||
_In_reads_(BC7_MAX_REGIONS) const LDREndPntPair aEndPts[],
|
_In_reads_(BC7_MAX_REGIONS) const LDREndPntPair aEndPts[],
|
||||||
@ -730,6 +736,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4127)
|
||||||
template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPoints, size_t cSteps)
|
template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPoints, size_t cSteps)
|
||||||
{
|
{
|
||||||
static const float pC6[] = { 5.0f/5.0f, 4.0f/5.0f, 3.0f/5.0f, 2.0f/5.0f, 1.0f/5.0f, 0.0f/5.0f };
|
static const float pC6[] = { 5.0f/5.0f, 4.0f/5.0f, 3.0f/5.0f, 2.0f/5.0f, 1.0f/5.0f, 0.0f/5.0f };
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
#include "BC.h"
|
#include "BC.h"
|
||||||
|
|
||||||
#pragma warning(disable : 4201)
|
|
||||||
|
|
||||||
namespace DirectX
|
namespace DirectX
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -37,6 +35,9 @@ namespace DirectX
|
|||||||
// Structures
|
// Structures
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4201)
|
||||||
|
|
||||||
// BC4U/BC5U
|
// BC4U/BC5U
|
||||||
struct BC4_UNORM
|
struct BC4_UNORM
|
||||||
{
|
{
|
||||||
@ -152,6 +153,7 @@ struct BC4_SNORM
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// Convert a floating point value to an 8-bit SNORM
|
// Convert a floating point value to an 8-bit SNORM
|
||||||
|
@ -1014,13 +1014,12 @@ static float OptimizeRGBA(_In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* cons
|
|||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
#pragma warning(disable: 4616 6001 6297)
|
|
||||||
|
|
||||||
static float ComputeError(_Inout_ const LDRColorA& pixel, _In_reads_(1 << uIndexPrec) const LDRColorA aPalette[],
|
static float ComputeError(_Inout_ const LDRColorA& pixel, _In_reads_(1 << uIndexPrec) const LDRColorA aPalette[],
|
||||||
_In_ uint8_t uIndexPrec, _In_ uint8_t uIndexPrec2, _Out_opt_ size_t* pBestIndex = nullptr, _Out_opt_ size_t* pBestIndex2 = nullptr)
|
_In_ uint8_t uIndexPrec, _In_ uint8_t uIndexPrec2, _Out_opt_ size_t* pBestIndex = nullptr, _Out_opt_ size_t* pBestIndex2 = nullptr)
|
||||||
{
|
{
|
||||||
const size_t uNumIndices = 1 << uIndexPrec;
|
const size_t uNumIndices = size_t(1) << uIndexPrec;
|
||||||
const size_t uNumIndices2 = 1 << uIndexPrec2;
|
const size_t uNumIndices2 = size_t(1) << uIndexPrec2;
|
||||||
float fTotalErr = 0;
|
float fTotalErr = 0;
|
||||||
float fBestErr = FLT_MAX;
|
float fBestErr = FLT_MAX;
|
||||||
|
|
||||||
@ -1419,7 +1418,7 @@ void D3DX_BC6H::GeneratePaletteQuantized(const EncodeParams* pEP, const INTEndPn
|
|||||||
{
|
{
|
||||||
assert( pEP );
|
assert( pEP );
|
||||||
const size_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec;
|
const size_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec;
|
||||||
const size_t uNumIndices = 1 << uIndexPrec;
|
const size_t uNumIndices = size_t(1) << uIndexPrec;
|
||||||
assert( uNumIndices > 0 );
|
assert( uNumIndices > 0 );
|
||||||
_Analysis_assume_( uNumIndices > 0 );
|
_Analysis_assume_( uNumIndices > 0 );
|
||||||
const LDRColorA& Prec = ms_aInfo[pEP->uMode].RGBAPrec[0][0];
|
const LDRColorA& Prec = ms_aInfo[pEP->uMode].RGBAPrec[0][0];
|
||||||
@ -1625,7 +1624,7 @@ void D3DX_BC6H::SwapIndices(const EncodeParams* pEP, INTEndPntPair aEndPts[], si
|
|||||||
{
|
{
|
||||||
assert( pEP );
|
assert( pEP );
|
||||||
const size_t uPartitions = ms_aInfo[pEP->uMode].uPartitions;
|
const size_t uPartitions = ms_aInfo[pEP->uMode].uPartitions;
|
||||||
const size_t uNumIndices = 1 << ms_aInfo[pEP->uMode].uIndexPrec;
|
const size_t uNumIndices = size_t(1) << ms_aInfo[pEP->uMode].uIndexPrec;
|
||||||
const size_t uHighIndexBit = uNumIndices >> 1;
|
const size_t uHighIndexBit = uNumIndices >> 1;
|
||||||
|
|
||||||
assert( uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES );
|
assert( uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES );
|
||||||
@ -2150,12 +2149,12 @@ void D3DX_BC7::Encode(const HDRColorA* const pIn)
|
|||||||
|
|
||||||
for(EP.uMode = 0; EP.uMode < 8 && fMSEBest > 0; ++EP.uMode)
|
for(EP.uMode = 0; EP.uMode < 8 && fMSEBest > 0; ++EP.uMode)
|
||||||
{
|
{
|
||||||
const size_t uShapes = 1 << ms_aInfo[EP.uMode].uPartitionBits;
|
const size_t uShapes = size_t(1) << ms_aInfo[EP.uMode].uPartitionBits;
|
||||||
assert( uShapes <= BC7_MAX_SHAPES );
|
assert( uShapes <= BC7_MAX_SHAPES );
|
||||||
_Analysis_assume_( uShapes <= BC7_MAX_SHAPES );
|
_Analysis_assume_( uShapes <= BC7_MAX_SHAPES );
|
||||||
|
|
||||||
const size_t uNumRots = 1 << ms_aInfo[EP.uMode].uRotationBits;
|
const size_t uNumRots = size_t(1) << ms_aInfo[EP.uMode].uRotationBits;
|
||||||
const size_t uNumIdxMode = 1 << ms_aInfo[EP.uMode].uIndexModeBits;
|
const size_t uNumIdxMode = size_t(1) << ms_aInfo[EP.uMode].uIndexModeBits;
|
||||||
// Number of rough cases to look at. reasonable values of this are 1, uShapes/4, and uShapes
|
// Number of rough cases to look at. reasonable values of this are 1, uShapes/4, and uShapes
|
||||||
// uShapes/4 gets nearly all the cases; you can increase that a bit (say by 3 or 4) if you really want to squeeze the last bit out
|
// uShapes/4 gets nearly all the cases; you can increase that a bit (say by 3 or 4) if you really want to squeeze the last bit out
|
||||||
const size_t uItems = std::max<size_t>(1, uShapes >> 2);
|
const size_t uItems = std::max<size_t>(1, uShapes >> 2);
|
||||||
@ -2224,8 +2223,8 @@ void D3DX_BC7::GeneratePaletteQuantized(const EncodeParams* pEP, size_t uIndexMo
|
|||||||
assert( pEP );
|
assert( pEP );
|
||||||
const size_t uIndexPrec = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec2 : ms_aInfo[pEP->uMode].uIndexPrec;
|
const size_t uIndexPrec = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec2 : ms_aInfo[pEP->uMode].uIndexPrec;
|
||||||
const size_t uIndexPrec2 = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec : ms_aInfo[pEP->uMode].uIndexPrec2;
|
const size_t uIndexPrec2 = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec : ms_aInfo[pEP->uMode].uIndexPrec2;
|
||||||
const size_t uNumIndices = 1 << uIndexPrec;
|
const size_t uNumIndices = size_t(1) << uIndexPrec;
|
||||||
const size_t uNumIndices2 = 1 << uIndexPrec2;
|
const size_t uNumIndices2 = size_t(1) << uIndexPrec2;
|
||||||
assert( uNumIndices > 0 && uNumIndices2 > 0 );
|
assert( uNumIndices > 0 && uNumIndices2 > 0 );
|
||||||
_Analysis_assume_( uNumIndices > 0 && uNumIndices2 > 0 );
|
_Analysis_assume_( uNumIndices > 0 && uNumIndices2 > 0 );
|
||||||
assert( (uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES) );
|
assert( (uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES) );
|
||||||
@ -2553,7 +2552,7 @@ void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotatio
|
|||||||
|
|
||||||
if(uPBits)
|
if(uPBits)
|
||||||
{
|
{
|
||||||
const size_t uNumEP = (1 + uPartitions) << 1;
|
const size_t uNumEP = size_t(1 + uPartitions) << 1;
|
||||||
uint8_t aPVote[BC7_MAX_REGIONS << 1] = {0,0,0,0,0,0};
|
uint8_t aPVote[BC7_MAX_REGIONS << 1] = {0,0,0,0,0,0};
|
||||||
uint8_t aCount[BC7_MAX_REGIONS << 1] = {0,0,0,0,0,0};
|
uint8_t aCount[BC7_MAX_REGIONS << 1] = {0,0,0,0,0,0};
|
||||||
for(uint8_t ch = 0; ch < BC7_NUM_CHANNELS; ch++)
|
for(uint8_t ch = 0; ch < BC7_NUM_CHANNELS; ch++)
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#pragma warning(disable : 4616 6001 6993)
|
#pragma warning(disable : 4616 6993)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "bc.h"
|
#include "bc.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user