This commit is contained in:
Chuck Walbourn 2017-07-12 00:56:51 -07:00
Родитель 6bac563715
Коммит 31b6c9309c
20 изменённых файлов: 219 добавлений и 176 удалений

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

@ -329,7 +329,7 @@ namespace
assert(pColor && pBC); assert(pColor && pBC);
static_assert(sizeof(D3DX_BC1) == 8, "D3DX_BC1 should be 8 bytes"); static_assert(sizeof(D3DX_BC1) == 8, "D3DX_BC1 should be 8 bytes");
static XMVECTORF32 s_Scale = { 1.f / 31.f, 1.f / 63.f, 1.f / 31.f, 1.f }; static XMVECTORF32 s_Scale = { { { 1.f / 31.f, 1.f / 63.f, 1.f / 31.f, 1.f } } };
XMVECTOR clr0 = XMLoadU565(reinterpret_cast<const XMU565*>(&pBC->rgb[0])); XMVECTOR clr0 = XMLoadU565(reinterpret_cast<const XMU565*>(&pBC->rgb[0]));
XMVECTOR clr1 = XMLoadU565(reinterpret_cast<const XMU565*>(&pBC->rgb[1])); XMVECTOR clr1 = XMLoadU565(reinterpret_cast<const XMU565*>(&pBC->rgb[1]));

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

@ -1043,20 +1043,20 @@ const D3DX_BC6H::ModeDescriptor D3DX_BC6H::ms_aDesc[14][82] =
// Mode, Partitions, Transformed, IndexPrec, RGBAPrec // Mode, Partitions, Transformed, IndexPrec, RGBAPrec
const D3DX_BC6H::ModeInfo D3DX_BC6H::ms_aInfo[] = const D3DX_BC6H::ModeInfo D3DX_BC6H::ms_aInfo[] =
{ {
{0x00, 1, true, 3, LDRColorA(10,10,10,0), LDRColorA( 5, 5, 5,0), LDRColorA(5,5,5,0), LDRColorA(5,5,5,0)}, // Mode 1 {0x00, 1, true, 3, { { LDRColorA(10,10,10,0), LDRColorA( 5, 5, 5,0) }, { LDRColorA(5,5,5,0), LDRColorA(5,5,5,0) } } }, // Mode 1
{0x01, 1, true, 3, LDRColorA( 7, 7, 7,0), LDRColorA( 6, 6, 6,0), LDRColorA(6,6,6,0), LDRColorA(6,6,6,0)}, // Mode 2 {0x01, 1, true, 3, { { LDRColorA( 7, 7, 7,0), LDRColorA( 6, 6, 6,0) }, { LDRColorA(6,6,6,0), LDRColorA(6,6,6,0) } } }, // Mode 2
{0x02, 1, true, 3, LDRColorA(11,11,11,0), LDRColorA( 5, 4, 4,0), LDRColorA(5,4,4,0), LDRColorA(5,4,4,0)}, // Mode 3 {0x02, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA( 5, 4, 4,0) }, { LDRColorA(5,4,4,0), LDRColorA(5,4,4,0) } } }, // Mode 3
{0x06, 1, true, 3, LDRColorA(11,11,11,0), LDRColorA( 4, 5, 4,0), LDRColorA(4,5,4,0), LDRColorA(4,5,4,0)}, // Mode 4 {0x06, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA( 4, 5, 4,0) }, { LDRColorA(4,5,4,0), LDRColorA(4,5,4,0) } } }, // Mode 4
{0x0a, 1, true, 3, LDRColorA(11,11,11,0), LDRColorA( 4, 4, 5,0), LDRColorA(4,4,5,0), LDRColorA(4,4,5,0)}, // Mode 5 {0x0a, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA( 4, 4, 5,0) }, { LDRColorA(4,4,5,0), LDRColorA(4,4,5,0) } } }, // Mode 5
{0x0e, 1, true, 3, LDRColorA( 9, 9, 9,0), LDRColorA( 5, 5, 5,0), LDRColorA(5,5,5,0), LDRColorA(5,5,5,0)}, // Mode 6 {0x0e, 1, true, 3, { { LDRColorA( 9, 9, 9,0), LDRColorA( 5, 5, 5,0) }, { LDRColorA(5,5,5,0), LDRColorA(5,5,5,0) } } }, // Mode 6
{0x12, 1, true, 3, LDRColorA( 8, 8, 8,0), LDRColorA( 6, 5, 5,0), LDRColorA(6,5,5,0), LDRColorA(6,5,5,0)}, // Mode 7 {0x12, 1, true, 3, { { LDRColorA( 8, 8, 8,0), LDRColorA( 6, 5, 5,0) }, { LDRColorA(6,5,5,0), LDRColorA(6,5,5,0) } } }, // Mode 7
{0x16, 1, true, 3, LDRColorA( 8, 8, 8,0), LDRColorA( 5, 6, 5,0), LDRColorA(5,6,5,0), LDRColorA(5,6,5,0)}, // Mode 8 {0x16, 1, true, 3, { { LDRColorA( 8, 8, 8,0), LDRColorA( 5, 6, 5,0) }, { LDRColorA(5,6,5,0), LDRColorA(5,6,5,0) } } }, // Mode 8
{0x1a, 1, true, 3, LDRColorA( 8, 8, 8,0), LDRColorA( 5, 5, 6,0), LDRColorA(5,5,6,0), LDRColorA(5,5,6,0)}, // Mode 9 {0x1a, 1, true, 3, { { LDRColorA( 8, 8, 8,0), LDRColorA( 5, 5, 6,0) }, { LDRColorA(5,5,6,0), LDRColorA(5,5,6,0) } } }, // Mode 9
{0x1e, 1, false, 3, LDRColorA( 6, 6, 6,0), LDRColorA( 6, 6, 6,0), LDRColorA(6,6,6,0), LDRColorA(6,6,6,0)}, // Mode 10 {0x1e, 1, false, 3, { { LDRColorA( 6, 6, 6,0), LDRColorA( 6, 6, 6,0) }, { LDRColorA(6,6,6,0), LDRColorA(6,6,6,0) } } }, // Mode 10
{0x03, 0, false, 4, LDRColorA(10,10,10,0), LDRColorA(10,10,10,0), LDRColorA(0,0,0,0), LDRColorA(0,0,0,0)}, // Mode 11 {0x03, 0, false, 4, { { LDRColorA(10,10,10,0), LDRColorA(10,10,10,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 11
{0x07, 0, true, 4, LDRColorA(11,11,11,0), LDRColorA( 9, 9, 9,0), LDRColorA(0,0,0,0), LDRColorA(0,0,0,0)}, // Mode 12 {0x07, 0, true, 4, { { LDRColorA(11,11,11,0), LDRColorA( 9, 9, 9,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 12
{0x0b, 0, true, 4, LDRColorA(12,12,12,0), LDRColorA( 8, 8, 8,0), LDRColorA(0,0,0,0), LDRColorA(0,0,0,0)}, // Mode 13 {0x0b, 0, true, 4, { { LDRColorA(12,12,12,0), LDRColorA( 8, 8, 8,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 13
{0x0f, 0, true, 4, LDRColorA(16,16,16,0), LDRColorA( 4, 4, 4,0), LDRColorA(0,0,0,0), LDRColorA(0,0,0,0)}, // Mode 14 {0x0f, 0, true, 4, { { LDRColorA(16,16,16,0), LDRColorA( 4, 4, 4,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 14
}; };
const int D3DX_BC6H::ms_aModeToInfo[] = const int D3DX_BC6H::ms_aModeToInfo[] =
@ -1574,7 +1574,7 @@ namespace
if (uIndexPrec2 == 0) if (uIndexPrec2 == 0)
{ {
for (register size_t i = 0; i < uNumIndices && fBestErr > 0; i++) for (size_t i = 0; i < uNumIndices && fBestErr > 0; i++)
{ {
XMVECTOR tpixel = XMLoadUByte4(reinterpret_cast<const XMUBYTE4*>(&aPalette[i])); XMVECTOR tpixel = XMLoadUByte4(reinterpret_cast<const XMUBYTE4*>(&aPalette[i]));
// Compute ErrorMetric // Compute ErrorMetric
@ -1593,7 +1593,7 @@ namespace
} }
else else
{ {
for (register size_t i = 0; i < uNumIndices && fBestErr > 0; i++) for (size_t i = 0; i < uNumIndices && fBestErr > 0; i++)
{ {
XMVECTOR tpixel = XMLoadUByte4(reinterpret_cast<const XMUBYTE4*>(&aPalette[i])); XMVECTOR tpixel = XMLoadUByte4(reinterpret_cast<const XMUBYTE4*>(&aPalette[i]));
// Compute ErrorMetricRGB // Compute ErrorMetricRGB
@ -1610,7 +1610,7 @@ namespace
} }
fTotalErr += fBestErr; fTotalErr += fBestErr;
fBestErr = FLT_MAX; fBestErr = FLT_MAX;
for (register size_t i = 0; i < uNumIndices2 && fBestErr > 0; i++) for (size_t i = 0; i < uNumIndices2 && fBestErr > 0; i++)
{ {
// Compute ErrorMetricAlpha // Compute ErrorMetricAlpha
float ea = float(pixel.a) - float(aPalette[i].a); float ea = float(pixel.a) - float(aPalette[i].a);
@ -1837,9 +1837,9 @@ void D3DX_BC6H::Encode(bool bSigned, const HDRColorA* const pIn)
} }
// Bubble up the first uItems items // Bubble up the first uItems items
for (register size_t i = 0; i < uItems; i++) for (size_t i = 0; i < uItems; i++)
{ {
for (register size_t j = i + 1; j < uShapes; j++) for (size_t j = i + 1; j < uShapes; j++)
{ {
if (afRoughMSE[i] > afRoughMSE[j]) if (afRoughMSE[i] > afRoughMSE[j])
{ {
@ -2423,7 +2423,7 @@ void D3DX_BC6H::GeneratePaletteUnquantized(const EncodeParams* pEP, size_t uRegi
return; return;
} }
for (register size_t i = 0; i < uNumIndices; ++i) for (size_t i = 0; i < uNumIndices; ++i)
{ {
aPalette[i].r = (endPts.A.r * (BC67_WEIGHT_MAX - aWeights[i]) + endPts.B.r * aWeights[i] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT; aPalette[i].r = (endPts.A.r * (BC67_WEIGHT_MAX - aWeights[i]) + endPts.B.r * aWeights[i] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT;
aPalette[i].g = (endPts.A.g * (BC67_WEIGHT_MAX - aWeights[i]) + endPts.B.g * aWeights[i] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT; aPalette[i].g = (endPts.A.g * (BC67_WEIGHT_MAX - aWeights[i]) + endPts.B.g * aWeights[i] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT;
@ -2476,7 +2476,7 @@ float D3DX_BC6H::RoughMSE(EncodeParams* pEP) const
for (size_t p = 0; p <= uPartitions; ++p) for (size_t p = 0; p <= uPartitions; ++p)
{ {
size_t np = 0; size_t np = 0;
for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{ {
if (g_aPartitionTable[uPartitions][pEP->uShape][i] == p) if (g_aPartitionTable[uPartitions][pEP->uShape][i] == p)
{ {
@ -2542,7 +2542,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const
const uint8_t uNumEndPts = (uPartitions + 1) << 1; const uint8_t uNumEndPts = (uPartitions + 1) << 1;
const uint8_t uIndexPrec = ms_aInfo[uMode].uIndexPrec; const uint8_t uIndexPrec = ms_aInfo[uMode].uIndexPrec;
const uint8_t uIndexPrec2 = ms_aInfo[uMode].uIndexPrec2; const uint8_t uIndexPrec2 = ms_aInfo[uMode].uIndexPrec2;
register size_t i; size_t i;
size_t uStartBit = uMode + 1; size_t uStartBit = uMode + 1;
uint8_t P[6]; uint8_t P[6];
uint8_t uShape = GetBits(uStartBit, ms_aInfo[uMode].uPartitionBits); uint8_t uShape = GetBits(uStartBit, ms_aInfo[uMode].uPartitionBits);
@ -2643,7 +2643,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const
for (i = 0; i < uNumEndPts; i++) for (i = 0; i < uNumEndPts; i++)
{ {
size_t pi = i * ms_aInfo[uMode].uPBits / uNumEndPts; size_t pi = i * ms_aInfo[uMode].uPBits / uNumEndPts;
for (register uint8_t ch = 0; ch < BC7_NUM_CHANNELS; ch++) for (uint8_t ch = 0; ch < BC7_NUM_CHANNELS; ch++)
{ {
if (RGBAPrec[ch] != RGBAPrecWithP[ch]) if (RGBAPrec[ch] != RGBAPrecWithP[ch])
{ {
@ -2780,9 +2780,9 @@ void D3DX_BC7::Encode(DWORD flags, const HDRColorA* const pIn)
{ {
switch (r) switch (r)
{ {
case 1: for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].r, EP.aLDRPixels[i].a); break; case 1: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].r, EP.aLDRPixels[i].a); break;
case 2: for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].g, EP.aLDRPixels[i].a); break; case 2: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].g, EP.aLDRPixels[i].a); break;
case 3: for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].b, EP.aLDRPixels[i].a); break; case 3: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].b, EP.aLDRPixels[i].a); break;
} }
for (size_t im = 0; im < uNumIdxMode && fMSEBest > 0; ++im) for (size_t im = 0; im < uNumIdxMode && fMSEBest > 0; ++im)
@ -2820,9 +2820,9 @@ void D3DX_BC7::Encode(DWORD flags, const HDRColorA* const pIn)
switch (r) switch (r)
{ {
case 1: for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].r, EP.aLDRPixels[i].a); break; case 1: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].r, EP.aLDRPixels[i].a); break;
case 2: for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].g, EP.aLDRPixels[i].a); break; case 2: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].g, EP.aLDRPixels[i].a); break;
case 3: for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].b, EP.aLDRPixels[i].a); break; case 3: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].b, EP.aLDRPixels[i].a); break;
} }
} }
} }
@ -2849,14 +2849,14 @@ void D3DX_BC7::GeneratePaletteQuantized(const EncodeParams* pEP, size_t uIndexMo
LDRColorA b = Unquantize(endPts.B, ms_aInfo[pEP->uMode].RGBAPrecWithP); LDRColorA b = Unquantize(endPts.B, ms_aInfo[pEP->uMode].RGBAPrecWithP);
if (uIndexPrec2 == 0) if (uIndexPrec2 == 0)
{ {
for (register size_t i = 0; i < uNumIndices; i++) for (size_t i = 0; i < uNumIndices; i++)
LDRColorA::Interpolate(a, b, i, i, uIndexPrec, uIndexPrec, aPalette[i]); LDRColorA::Interpolate(a, b, i, i, uIndexPrec, uIndexPrec, aPalette[i]);
} }
else else
{ {
for (register size_t i = 0; i < uNumIndices; i++) for (size_t i = 0; i < uNumIndices; i++)
LDRColorA::InterpolateRGB(a, b, i, uIndexPrec, aPalette[i]); LDRColorA::InterpolateRGB(a, b, i, uIndexPrec, aPalette[i]);
for (register size_t i = 0; i < uNumIndices2; i++) for (size_t i = 0; i < uNumIndices2; i++)
LDRColorA::InterpolateA(a, b, i, uIndexPrec2, aPalette[i]); LDRColorA::InterpolateA(a, b, i, uIndexPrec2, aPalette[i]);
} }
} }
@ -3055,7 +3055,7 @@ void D3DX_BC7::OptimizeEndPoints(const EncodeParams* pEP, size_t uShape, size_t
{ {
// collect the pixels in the region // collect the pixels in the region
size_t np = 0; size_t np = 0;
for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
if (g_aPartitionTable[uPartitions][uShape][i] == p) if (g_aPartitionTable[uPartitions][uShape][i] == p)
aPixels[np++] = pEP->aLDRPixels[i]; aPixels[np++] = pEP->aLDRPixels[i];
@ -3094,7 +3094,7 @@ void D3DX_BC7::AssignIndices(const EncodeParams* pEP, size_t uShape, size_t uInd
afTotErr[p] = 0; afTotErr[p] = 0;
} }
for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++)
{ {
uint8_t uRegion = g_aPartitionTable[uPartitions][uShape][i]; uint8_t uRegion = g_aPartitionTable[uPartitions][uShape][i];
assert(uRegion < BC7_MAX_REGIONS); assert(uRegion < BC7_MAX_REGIONS);
@ -3105,12 +3105,12 @@ void D3DX_BC7::AssignIndices(const EncodeParams* pEP, size_t uShape, size_t uInd
// swap endpoints as needed to ensure that the indices at index_positions have a 0 high-order bit // swap endpoints as needed to ensure that the indices at index_positions have a 0 high-order bit
if (uIndexPrec2 == 0) if (uIndexPrec2 == 0)
{ {
for (register size_t p = 0; p <= uPartitions; p++) for (size_t p = 0; p <= uPartitions; p++)
{ {
if (aIndices[g_aFixUp[uPartitions][uShape][p]] & uHighestIndexBit) if (aIndices[g_aFixUp[uPartitions][uShape][p]] & uHighestIndexBit)
{ {
std::swap(endPts[p].A, endPts[p].B); std::swap(endPts[p].A, endPts[p].B);
for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++)
if (g_aPartitionTable[uPartitions][uShape][i] == p) if (g_aPartitionTable[uPartitions][uShape][i] == p)
aIndices[i] = uNumIndices - 1 - aIndices[i]; aIndices[i] = uNumIndices - 1 - aIndices[i];
} }
@ -3119,14 +3119,14 @@ void D3DX_BC7::AssignIndices(const EncodeParams* pEP, size_t uShape, size_t uInd
} }
else else
{ {
for (register size_t p = 0; p <= uPartitions; p++) for (size_t p = 0; p <= uPartitions; p++)
{ {
if (aIndices[g_aFixUp[uPartitions][uShape][p]] & uHighestIndexBit) if (aIndices[g_aFixUp[uPartitions][uShape][p]] & uHighestIndexBit)
{ {
std::swap(endPts[p].A.r, endPts[p].B.r); std::swap(endPts[p].A.r, endPts[p].B.r);
std::swap(endPts[p].A.g, endPts[p].B.g); std::swap(endPts[p].A.g, endPts[p].B.g);
std::swap(endPts[p].A.b, endPts[p].B.b); std::swap(endPts[p].A.b, endPts[p].B.b);
for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++)
if (g_aPartitionTable[uPartitions][uShape][i] == p) if (g_aPartitionTable[uPartitions][uShape][i] == p)
aIndices[i] = uNumIndices - 1 - aIndices[i]; aIndices[i] = uNumIndices - 1 - aIndices[i];
} }
@ -3135,7 +3135,7 @@ void D3DX_BC7::AssignIndices(const EncodeParams* pEP, size_t uShape, size_t uInd
if (aIndices2[0] & uHighestIndexBit2) if (aIndices2[0] & uHighestIndexBit2)
{ {
std::swap(endPts[p].A.a, endPts[p].B.a); std::swap(endPts[p].A.a, endPts[p].B.a);
for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++)
aIndices2[i] = uNumIndices2 - 1 - aIndices2[i]; aIndices2[i] = uNumIndices2 - 1 - aIndices2[i];
} }
assert((aIndices2[0] & uHighestIndexBit2) == 0); assert((aIndices2[0] & uHighestIndexBit2) == 0);
@ -3156,7 +3156,7 @@ void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotatio
const size_t uIndexPrec2 = ms_aInfo[pEP->uMode].uIndexPrec2; const size_t uIndexPrec2 = ms_aInfo[pEP->uMode].uIndexPrec2;
const LDRColorA RGBAPrec = ms_aInfo[pEP->uMode].RGBAPrec; const LDRColorA RGBAPrec = ms_aInfo[pEP->uMode].RGBAPrec;
const LDRColorA RGBAPrecWithP = ms_aInfo[pEP->uMode].RGBAPrecWithP; const LDRColorA RGBAPrecWithP = ms_aInfo[pEP->uMode].RGBAPrecWithP;
register size_t i; size_t i;
size_t uStartBit = 0; size_t uStartBit = 0;
SetBits(uStartBit, pEP->uMode, 0); SetBits(uStartBit, pEP->uMode, 0);
SetBits(uStartBit, 1, 1); SetBits(uStartBit, 1, 1);
@ -3251,7 +3251,7 @@ float D3DX_BC7::Refine(const EncodeParams* pEP, size_t uShape, size_t uRotation,
float aOrgErr[BC7_MAX_REGIONS]; float aOrgErr[BC7_MAX_REGIONS];
float aOptErr[BC7_MAX_REGIONS]; float aOptErr[BC7_MAX_REGIONS];
for(register size_t p = 0; p <= uPartitions; p++) for(size_t p = 0; p <= uPartitions; p++)
{ {
aOrgEndPts[p].A = Quantize(aEndPts[p].A, ms_aInfo[pEP->uMode].RGBAPrecWithP); aOrgEndPts[p].A = Quantize(aEndPts[p].A, ms_aInfo[pEP->uMode].RGBAPrecWithP);
aOrgEndPts[p].B = Quantize(aEndPts[p].B, ms_aInfo[pEP->uMode].RGBAPrecWithP); aOrgEndPts[p].B = Quantize(aEndPts[p].B, ms_aInfo[pEP->uMode].RGBAPrecWithP);
@ -3262,7 +3262,7 @@ float D3DX_BC7::Refine(const EncodeParams* pEP, size_t uShape, size_t uRotation,
AssignIndices(pEP, uShape, uIndexMode, aOptEndPts, aOptIdx, aOptIdx2, aOptErr); AssignIndices(pEP, uShape, uIndexMode, aOptEndPts, aOptIdx, aOptIdx2, aOptErr);
float fOrgTotErr = 0, fOptTotErr = 0; float fOrgTotErr = 0, fOptTotErr = 0;
for(register size_t p = 0; p <= uPartitions; p++) for(size_t p = 0; p <= uPartitions; p++)
{ {
fOrgTotErr += aOrgErr[p]; fOrgTotErr += aOrgErr[p];
fOptTotErr += aOptErr[p]; fOptTotErr += aOptErr[p];
@ -3289,7 +3289,7 @@ float D3DX_BC7::MapColors(const EncodeParams* pEP, const LDRColorA aColors[], si
float fTotalErr = 0; float fTotalErr = 0;
GeneratePaletteQuantized(pEP, uIndexMode, endPts, aPalette); GeneratePaletteQuantized(pEP, uIndexMode, endPts, aPalette);
for (register size_t i = 0; i < np; ++i) for (size_t i = 0; i < np; ++i)
{ {
fTotalErr += ComputeError(aColors[i], aPalette, uIndexPrec, uIndexPrec2); fTotalErr += ComputeError(aColors[i], aPalette, uIndexPrec, uIndexPrec2);
if (fTotalErr > fMinErr) // check for early exit if (fTotalErr > fMinErr) // check for early exit
@ -3324,7 +3324,7 @@ float D3DX_BC7::RoughMSE(EncodeParams* pEP, size_t uShape, size_t uIndexMode)
for (size_t p = 0; p <= uPartitions; p++) for (size_t p = 0; p <= uPartitions; p++)
{ {
size_t np = 0; size_t np = 0;
for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++)
{ {
if (g_aPartitionTable[uPartitions][uShape][i] == p) if (g_aPartitionTable[uPartitions][uShape][i] == p)
{ {
@ -3361,7 +3361,7 @@ float D3DX_BC7::RoughMSE(EncodeParams* pEP, size_t uShape, size_t uIndexMode)
else else
{ {
uint8_t uMinAlpha = 255, uMaxAlpha = 0; uint8_t uMinAlpha = 255, uMaxAlpha = 0;
for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
{ {
uMinAlpha = std::min<uint8_t>(uMinAlpha, pEP->aLDRPixels[auPixIdx[i]].a); uMinAlpha = std::min<uint8_t>(uMinAlpha, pEP->aLDRPixels[auPixIdx[i]].a);
uMaxAlpha = std::max<uint8_t>(uMaxAlpha, pEP->aLDRPixels[auPixIdx[i]].a); uMaxAlpha = std::max<uint8_t>(uMaxAlpha, pEP->aLDRPixels[auPixIdx[i]].a);
@ -3383,22 +3383,22 @@ float D3DX_BC7::RoughMSE(EncodeParams* pEP, size_t uShape, size_t uIndexMode)
if (uIndexPrec2 == 0) if (uIndexPrec2 == 0)
{ {
for (size_t p = 0; p <= uPartitions; p++) for (size_t p = 0; p <= uPartitions; p++)
for (register size_t i = 0; i < uNumIndices; i++) for (size_t i = 0; i < uNumIndices; i++)
LDRColorA::Interpolate(aEndPts[p].A, aEndPts[p].B, i, i, uIndexPrec, uIndexPrec, aPalette[p][i]); LDRColorA::Interpolate(aEndPts[p].A, aEndPts[p].B, i, i, uIndexPrec, uIndexPrec, aPalette[p][i]);
} }
else else
{ {
for (size_t p = 0; p <= uPartitions; p++) for (size_t p = 0; p <= uPartitions; p++)
{ {
for (register size_t i = 0; i < uNumIndices; i++) for (size_t i = 0; i < uNumIndices; i++)
LDRColorA::InterpolateRGB(aEndPts[p].A, aEndPts[p].B, i, uIndexPrec, aPalette[p][i]); LDRColorA::InterpolateRGB(aEndPts[p].A, aEndPts[p].B, i, uIndexPrec, aPalette[p][i]);
for (register size_t i = 0; i < uNumIndices2; i++) for (size_t i = 0; i < uNumIndices2; i++)
LDRColorA::InterpolateA(aEndPts[p].A, aEndPts[p].B, i, uIndexPrec2, aPalette[p][i]); LDRColorA::InterpolateA(aEndPts[p].A, aEndPts[p].B, i, uIndexPrec2, aPalette[p][i]);
} }
} }
float fTotalErr = 0; float fTotalErr = 0;
for (register size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++)
{ {
uint8_t uRegion = g_aPartitionTable[uPartitions][uShape][i]; uint8_t uRegion = g_aPartitionTable[uPartitions][uShape][i];
fTotalErr += ComputeError(pEP->aLDRPixels[i], aPalette[uRegion], uIndexPrec, uIndexPrec2); fTotalErr += ComputeError(pEP->aLDRPixels[i], aPalette[uRegion], uIndexPrec, uIndexPrec2);

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

@ -28,20 +28,20 @@ namespace
{ {
inline DWORD GetBCFlags(_In_ DWORD compress) inline DWORD GetBCFlags(_In_ DWORD compress)
{ {
static_assert(TEX_COMPRESS_RGB_DITHER == BC_FLAGS_DITHER_RGB, "TEX_COMPRESS_* flags should match BC_FLAGS_*"); static_assert(static_cast<int>(TEX_COMPRESS_RGB_DITHER) == static_cast<int>(BC_FLAGS_DITHER_RGB), "TEX_COMPRESS_* flags should match BC_FLAGS_*");
static_assert(TEX_COMPRESS_A_DITHER == BC_FLAGS_DITHER_A, "TEX_COMPRESS_* flags should match BC_FLAGS_*"); static_assert(static_cast<int>(TEX_COMPRESS_A_DITHER) == static_cast<int>(BC_FLAGS_DITHER_A), "TEX_COMPRESS_* flags should match BC_FLAGS_*");
static_assert(TEX_COMPRESS_DITHER == (BC_FLAGS_DITHER_RGB | BC_FLAGS_DITHER_A), "TEX_COMPRESS_* flags should match BC_FLAGS_*"); static_assert(static_cast<int>(TEX_COMPRESS_DITHER) == static_cast<int>(BC_FLAGS_DITHER_RGB | BC_FLAGS_DITHER_A), "TEX_COMPRESS_* flags should match BC_FLAGS_*");
static_assert(TEX_COMPRESS_UNIFORM == BC_FLAGS_UNIFORM, "TEX_COMPRESS_* flags should match BC_FLAGS_*"); static_assert(static_cast<int>(TEX_COMPRESS_UNIFORM) == static_cast<int>(BC_FLAGS_UNIFORM), "TEX_COMPRESS_* flags should match BC_FLAGS_*");
static_assert(TEX_COMPRESS_BC7_USE_3SUBSETS == BC_FLAGS_USE_3SUBSETS, "TEX_COMPRESS_* flags should match BC_FLAGS_*"); static_assert(static_cast<int>(TEX_COMPRESS_BC7_USE_3SUBSETS) == static_cast<int>(BC_FLAGS_USE_3SUBSETS), "TEX_COMPRESS_* flags should match BC_FLAGS_*");
static_assert(TEX_COMPRESS_BC7_QUICK == BC_FLAGS_FORCE_BC7_MODE6, "TEX_COMPRESS_* flags should match BC_FLAGS_*"); static_assert(static_cast<int>(TEX_COMPRESS_BC7_QUICK) == static_cast<int>(BC_FLAGS_FORCE_BC7_MODE6), "TEX_COMPRESS_* flags should match BC_FLAGS_*");
return (compress & (BC_FLAGS_DITHER_RGB | BC_FLAGS_DITHER_A | BC_FLAGS_UNIFORM | BC_FLAGS_USE_3SUBSETS | BC_FLAGS_FORCE_BC7_MODE6)); return (compress & (BC_FLAGS_DITHER_RGB | BC_FLAGS_DITHER_A | BC_FLAGS_UNIFORM | BC_FLAGS_USE_3SUBSETS | BC_FLAGS_FORCE_BC7_MODE6));
} }
inline DWORD GetSRGBFlags(_In_ DWORD compress) inline DWORD GetSRGBFlags(_In_ DWORD compress)
{ {
static_assert(TEX_COMPRESS_SRGB_IN == TEX_FILTER_SRGB_IN, "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_COMPRESS_SRGB_IN) == static_cast<int>(TEX_FILTER_SRGB_IN), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*");
static_assert(TEX_COMPRESS_SRGB_OUT == TEX_FILTER_SRGB_OUT, "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_COMPRESS_SRGB_OUT) == static_cast<int>(TEX_FILTER_SRGB_OUT), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*");
static_assert(TEX_COMPRESS_SRGB == TEX_FILTER_SRGB, "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_COMPRESS_SRGB) == static_cast<int>(TEX_FILTER_SRGB), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*");
return (compress & TEX_COMPRESS_SRGB); return (compress & TEX_COMPRESS_SRGB);
} }
@ -532,7 +532,7 @@ namespace DirectX
} }
// Scan blocks for non-opaque alpha // Scan blocks for non-opaque alpha
static const XMVECTORF32 threshold = { 0.99f, 0.99f, 0.99f, 0.99f }; static const XMVECTORF32 threshold = { { { 0.99f, 0.99f, 0.99f, 0.99f } } };
__declspec(align(16)) XMVECTOR temp[16]; __declspec(align(16)) XMVECTOR temp[16];
const uint8_t *pPixels = cImage.pixels; const uint8_t *pPixels = cImage.pixels;

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

@ -23,9 +23,9 @@ namespace
{ {
inline DWORD GetSRGBFlags(_In_ DWORD compress) inline DWORD GetSRGBFlags(_In_ DWORD compress)
{ {
static_assert(TEX_COMPRESS_SRGB_IN == TEX_FILTER_SRGB_IN, "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_COMPRESS_SRGB_IN) == static_cast<int>(TEX_FILTER_SRGB_IN), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*");
static_assert(TEX_COMPRESS_SRGB_OUT == TEX_FILTER_SRGB_OUT, "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_COMPRESS_SRGB_OUT) == static_cast<int>(TEX_FILTER_SRGB_OUT), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*");
static_assert(TEX_COMPRESS_SRGB == TEX_FILTER_SRGB, "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_COMPRESS_SRGB) == static_cast<int>(TEX_FILTER_SRGB), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*");
return (compress & TEX_COMPRESS_SRGB); return (compress & TEX_COMPRESS_SRGB);
} }

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

@ -192,10 +192,10 @@ namespace
} }
#endif #endif
const XMVECTORF32 g_Grayscale = { 0.2125f, 0.7154f, 0.0721f, 0.0f }; const XMVECTORF32 g_Grayscale = { { { 0.2125f, 0.7154f, 0.0721f, 0.0f } } };
const XMVECTORF32 g_HalfMin = { -65504.f, -65504.f, -65504.f, -65504.f }; const XMVECTORF32 g_HalfMin = { { { -65504.f, -65504.f, -65504.f, -65504.f } } };
const XMVECTORF32 g_HalfMax = { 65504.f, 65504.f, 65504.f, 65504.f }; const XMVECTORF32 g_HalfMax = { { { 65504.f, 65504.f, 65504.f, 65504.f } } };
const XMVECTORF32 g_8BitBias = { 0.5f / 255.f, 0.5f / 255.f, 0.5f / 255.f, 0.5f / 255.f }; const XMVECTORF32 g_8BitBias = { { { 0.5f / 255.f, 0.5f / 255.f, 0.5f / 255.f, 0.5f / 255.f } } };
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
@ -707,9 +707,10 @@ bool DirectX::_ExpandScanline(
return true; return true;
} }
return false; return false;
}
default:
return false; return false;
}
} }
@ -1209,7 +1210,7 @@ _Use_decl_annotations_ bool DirectX::_LoadScanline(
case DXGI_FORMAT_B5G6R5_UNORM: case DXGI_FORMAT_B5G6R5_UNORM:
if (size >= sizeof(XMU565)) if (size >= sizeof(XMU565))
{ {
static const XMVECTORF32 s_Scale = { 1.f / 31.f, 1.f / 63.f, 1.f / 31.f, 1.f }; static const XMVECTORF32 s_Scale = { { { 1.f / 31.f, 1.f / 63.f, 1.f / 31.f, 1.f } } };
const XMU565 * __restrict sPtr = reinterpret_cast<const XMU565*>(pSource); const XMU565 * __restrict sPtr = reinterpret_cast<const XMU565*>(pSource);
for (size_t icount = 0; icount < (size - sizeof(XMU565) + 1); icount += sizeof(XMU565)) for (size_t icount = 0; icount < (size - sizeof(XMU565) + 1); icount += sizeof(XMU565))
{ {
@ -1226,7 +1227,7 @@ _Use_decl_annotations_ bool DirectX::_LoadScanline(
case DXGI_FORMAT_B5G5R5A1_UNORM: case DXGI_FORMAT_B5G5R5A1_UNORM:
if (size >= sizeof(XMU555)) if (size >= sizeof(XMU555))
{ {
static const XMVECTORF32 s_Scale = { 1.f / 31.f, 1.f / 31.f, 1.f / 31.f, 1.f }; static const XMVECTORF32 s_Scale = { { { 1.f / 31.f, 1.f / 31.f, 1.f / 31.f, 1.f } } };
const XMU555 * __restrict sPtr = reinterpret_cast<const XMU555*>(pSource); const XMU555 * __restrict sPtr = reinterpret_cast<const XMU555*>(pSource);
for (size_t icount = 0; icount < (size - sizeof(XMU555) + 1); icount += sizeof(XMU555)) for (size_t icount = 0; icount < (size - sizeof(XMU555) + 1); icount += sizeof(XMU555))
{ {
@ -1493,7 +1494,7 @@ _Use_decl_annotations_ bool DirectX::_LoadScanline(
case DXGI_FORMAT_B4G4R4A4_UNORM: case DXGI_FORMAT_B4G4R4A4_UNORM:
if (size >= sizeof(XMUNIBBLE4)) if (size >= sizeof(XMUNIBBLE4))
{ {
static const XMVECTORF32 s_Scale = { 1.f / 15.f, 1.f / 15.f, 1.f / 15.f, 1.f / 15.f }; static const XMVECTORF32 s_Scale = { { { 1.f / 15.f, 1.f / 15.f, 1.f / 15.f, 1.f / 15.f } } };
const XMUNIBBLE4 * __restrict sPtr = reinterpret_cast<const XMUNIBBLE4*>(pSource); const XMUNIBBLE4 * __restrict sPtr = reinterpret_cast<const XMUNIBBLE4*>(pSource);
for (size_t icount = 0; icount < (size - sizeof(XMUNIBBLE4) + 1); icount += sizeof(XMUNIBBLE4)) for (size_t icount = 0; icount < (size - sizeof(XMUNIBBLE4) + 1); icount += sizeof(XMUNIBBLE4))
{ {
@ -1515,12 +1516,12 @@ _Use_decl_annotations_ bool DirectX::_LoadScanline(
{ {
if (dPtr >= ePtr) break; if (dPtr >= ePtr) break;
XMVECTORF32 vResult = { XMVECTORF32 vResult = { { {
FloatFrom7e3(sPtr->x), FloatFrom7e3(sPtr->x),
FloatFrom7e3(sPtr->y), FloatFrom7e3(sPtr->y),
FloatFrom7e3(sPtr->z), FloatFrom7e3(sPtr->z),
(float)(sPtr->v >> 30) / 3.0f (float)(sPtr->v >> 30) / 3.0f
}; } } };
++sPtr; ++sPtr;
@ -1539,12 +1540,12 @@ _Use_decl_annotations_ bool DirectX::_LoadScanline(
{ {
if (dPtr >= ePtr) break; if (dPtr >= ePtr) break;
XMVECTORF32 vResult = { XMVECTORF32 vResult = { { {
FloatFrom6e4(sPtr->x), FloatFrom6e4(sPtr->x),
FloatFrom6e4(sPtr->y), FloatFrom6e4(sPtr->y),
FloatFrom6e4(sPtr->z), FloatFrom6e4(sPtr->z),
(float)(sPtr->v >> 30) / 3.0f (float)(sPtr->v >> 30) / 3.0f
}; } } };
++sPtr; ++sPtr;
@ -1562,7 +1563,7 @@ _Use_decl_annotations_ bool DirectX::_LoadScanline(
// Xbox One specific format // Xbox One specific format
if (size >= sizeof(uint8_t)) if (size >= sizeof(uint8_t))
{ {
static const XMVECTORF32 s_Scale = { 1.f / 15.f, 1.f / 15.f, 0.f, 0.f }; static const XMVECTORF32 s_Scale = { { { 1.f / 15.f, 1.f / 15.f, 0.f, 0.f } } };
const uint8_t * __restrict sPtr = reinterpret_cast<const uint8_t*>(pSource); const uint8_t * __restrict sPtr = reinterpret_cast<const uint8_t*>(pSource);
for (size_t icount = 0; icount < (size - sizeof(uint8_t) + 1); icount += sizeof(uint8_t)) for (size_t icount = 0; icount < (size - sizeof(uint8_t) + 1); icount += sizeof(uint8_t))
{ {
@ -1810,7 +1811,7 @@ bool DirectX::_StoreScanline(
case DXGI_FORMAT_D24_UNORM_S8_UINT: case DXGI_FORMAT_D24_UNORM_S8_UINT:
if (size >= sizeof(uint32_t)) if (size >= sizeof(uint32_t))
{ {
static const XMVECTORF32 clamp = { 1.f, 255.f, 0.f, 0.f }; static const XMVECTORF32 clamp = { { { 1.f, 255.f, 0.f, 0.f } } };
XMVECTOR zero = XMVectorZero(); XMVECTOR zero = XMVectorZero();
uint32_t *dPtr = reinterpret_cast<uint32_t*>(pDestination); uint32_t *dPtr = reinterpret_cast<uint32_t*>(pDestination);
for (size_t icount = 0; icount < (size - sizeof(uint32_t) + 1); icount += sizeof(uint32_t)) for (size_t icount = 0; icount < (size - sizeof(uint32_t) + 1); icount += sizeof(uint32_t))
@ -2035,7 +2036,7 @@ bool DirectX::_StoreScanline(
case DXGI_FORMAT_G8R8_G8B8_UNORM: case DXGI_FORMAT_G8R8_G8B8_UNORM:
if (size >= sizeof(XMUBYTEN4)) if (size >= sizeof(XMUBYTEN4))
{ {
static XMVECTORU32 select1101 = { XM_SELECT_1, XM_SELECT_1, XM_SELECT_0, XM_SELECT_1 }; static XMVECTORU32 select1101 = { { { XM_SELECT_1, XM_SELECT_1, XM_SELECT_0, XM_SELECT_1 } } };
XMUBYTEN4 * __restrict dPtr = reinterpret_cast<XMUBYTEN4*>(pDestination); XMUBYTEN4 * __restrict dPtr = reinterpret_cast<XMUBYTEN4*>(pDestination);
for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4))
@ -2054,7 +2055,7 @@ bool DirectX::_StoreScanline(
case DXGI_FORMAT_B5G6R5_UNORM: case DXGI_FORMAT_B5G6R5_UNORM:
if (size >= sizeof(XMU565)) if (size >= sizeof(XMU565))
{ {
static const XMVECTORF32 s_Scale = { 31.f, 63.f, 31.f, 1.f }; static const XMVECTORF32 s_Scale = { { { 31.f, 63.f, 31.f, 1.f } } };
XMU565 * __restrict dPtr = reinterpret_cast<XMU565*>(pDestination); XMU565 * __restrict dPtr = reinterpret_cast<XMU565*>(pDestination);
for (size_t icount = 0; icount < (size - sizeof(XMU565) + 1); icount += sizeof(XMU565)) for (size_t icount = 0; icount < (size - sizeof(XMU565) + 1); icount += sizeof(XMU565))
{ {
@ -2070,7 +2071,7 @@ bool DirectX::_StoreScanline(
case DXGI_FORMAT_B5G5R5A1_UNORM: case DXGI_FORMAT_B5G5R5A1_UNORM:
if (size >= sizeof(XMU555)) if (size >= sizeof(XMU555))
{ {
static const XMVECTORF32 s_Scale = { 31.f, 31.f, 31.f, 1.f }; static const XMVECTORF32 s_Scale = { { { 31.f, 31.f, 31.f, 1.f } } };
XMU555 * __restrict dPtr = reinterpret_cast<XMU555*>(pDestination); XMU555 * __restrict dPtr = reinterpret_cast<XMU555*>(pDestination);
for (size_t icount = 0; icount < (size - sizeof(XMU555) + 1); icount += sizeof(XMU555)) for (size_t icount = 0; icount < (size - sizeof(XMU555) + 1); icount += sizeof(XMU555))
{ {
@ -2358,7 +2359,7 @@ bool DirectX::_StoreScanline(
case DXGI_FORMAT_B4G4R4A4_UNORM: case DXGI_FORMAT_B4G4R4A4_UNORM:
if (size >= sizeof(XMUNIBBLE4)) if (size >= sizeof(XMUNIBBLE4))
{ {
static const XMVECTORF32 s_Scale = { 15.f, 15.f, 15.f, 15.f }; static const XMVECTORF32 s_Scale = { { { 15.f, 15.f, 15.f, 15.f } } };
XMUNIBBLE4 * __restrict dPtr = reinterpret_cast<XMUNIBBLE4*>(pDestination); XMUNIBBLE4 * __restrict dPtr = reinterpret_cast<XMUNIBBLE4*>(pDestination);
for (size_t icount = 0; icount < (size - sizeof(XMUNIBBLE4) + 1); icount += sizeof(XMUNIBBLE4)) for (size_t icount = 0; icount < (size - sizeof(XMUNIBBLE4) + 1); icount += sizeof(XMUNIBBLE4))
{ {
@ -2375,8 +2376,8 @@ bool DirectX::_StoreScanline(
// Xbox One specific 7e3 format with alpha // Xbox One specific 7e3 format with alpha
if (size >= sizeof(XMUDECN4)) if (size >= sizeof(XMUDECN4))
{ {
static const XMVECTORF32 Scale = { 1.0f, 1.0f, 1.0f, 3.0f }; static const XMVECTORF32 Scale = { { { 1.0f, 1.0f, 1.0f, 3.0f } } };
static const XMVECTORF32 C = { 31.875f, 31.875f, 31.875f, 3.f }; static const XMVECTORF32 C = { { { 31.875f, 31.875f, 31.875f, 3.f } } };
XMUDECN4 * __restrict dPtr = reinterpret_cast<XMUDECN4*>(pDestination); XMUDECN4 * __restrict dPtr = reinterpret_cast<XMUDECN4*>(pDestination);
for (size_t icount = 0; icount < (size - sizeof(XMUDECN4) + 1); icount += sizeof(XMUDECN4)) for (size_t icount = 0; icount < (size - sizeof(XMUDECN4) + 1); icount += sizeof(XMUDECN4))
@ -2403,8 +2404,8 @@ bool DirectX::_StoreScanline(
// Xbox One specific 6e4 format with alpha // Xbox One specific 6e4 format with alpha
if (size >= sizeof(XMUDECN4)) if (size >= sizeof(XMUDECN4))
{ {
static const XMVECTORF32 Scale = { 1.0f, 1.0f, 1.0f, 3.0f }; static const XMVECTORF32 Scale = { { { 1.0f, 1.0f, 1.0f, 3.0f } } };
static const XMVECTORF32 C = { 508.f, 508.f, 508.f, 3.f }; static const XMVECTORF32 C = { { { 508.f, 508.f, 508.f, 3.f } } };
XMUDECN4 * __restrict dPtr = reinterpret_cast<XMUDECN4*>(pDestination); XMUDECN4 * __restrict dPtr = reinterpret_cast<XMUDECN4*>(pDestination);
for (size_t icount = 0; icount < (size - sizeof(XMUDECN4) + 1); icount += sizeof(XMUDECN4)) for (size_t icount = 0; icount < (size - sizeof(XMUDECN4) + 1); icount += sizeof(XMUDECN4))
@ -2435,7 +2436,7 @@ bool DirectX::_StoreScanline(
// Xbox One specific format // Xbox One specific format
if (size >= sizeof(uint8_t)) if (size >= sizeof(uint8_t))
{ {
static const XMVECTORF32 s_Scale = { 15.f, 15.f, 0.f, 0.f }; static const XMVECTORF32 s_Scale = { { { 15.f, 15.f, 0.f, 0.f } } };
uint8_t * __restrict dPtr = reinterpret_cast<uint8_t*>(pDestination); uint8_t * __restrict dPtr = reinterpret_cast<uint8_t*>(pDestination);
for (size_t icount = 0; icount < (size - sizeof(uint8_t) + 1); icount += sizeof(uint8_t)) for (size_t icount = 0; icount < (size - sizeof(uint8_t) + 1); icount += sizeof(uint8_t))
{ {
@ -2974,6 +2975,9 @@ void DirectX::_ConvertScanline(
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
flags &= ~TEX_FILTER_SRGB_IN; flags &= ~TEX_FILTER_SRGB_IN;
break; break;
default:
break;
} }
switch (outFormat) switch (outFormat)
@ -2992,6 +2996,9 @@ void DirectX::_ConvertScanline(
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
flags &= ~TEX_FILTER_SRGB_OUT; flags &= ~TEX_FILTER_SRGB_OUT;
break; break;
default:
break;
} }
if ((flags & (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) == (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) if ((flags & (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) == (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT))
@ -3025,7 +3032,7 @@ void DirectX::_ConvertScanline(
if (in->flags & CONVF_STENCIL) if (in->flags & CONVF_STENCIL)
{ {
// Stencil -> Alpha // Stencil -> Alpha
static const XMVECTORF32 S = { 1.f, 1.f, 1.f, 255.f }; static const XMVECTORF32 S = { { { 1.f, 1.f, 1.f, 255.f } } };
if (out->flags & CONVF_UNORM) if (out->flags & CONVF_UNORM)
{ {
@ -3206,8 +3213,8 @@ void DirectX::_ConvertScanline(
if (out->flags & CONVF_STENCIL) if (out->flags & CONVF_STENCIL)
{ {
// Alpha -> Stencil (green channel) // Alpha -> Stencil (green channel)
static const XMVECTORU32 select0100 = { XM_SELECT_0, XM_SELECT_1, XM_SELECT_0, XM_SELECT_0 }; static const XMVECTORU32 select0100 = { { { XM_SELECT_0, XM_SELECT_1, XM_SELECT_0, XM_SELECT_0 } } };
static const XMVECTORF32 S = { 255.f, 255.f, 255.f, 255.f }; static const XMVECTORF32 S = { { { 255.f, 255.f, 255.f, 255.f } } };
if (in->flags & CONVF_UNORM) if (in->flags & CONVF_UNORM)
{ {
@ -3613,20 +3620,20 @@ namespace
-0.468750f, 0.031250f, -0.343750f, 0.156250f, -0.468750f, 0.031250f, -0.343750f, 0.156250f, -0.468750f, 0.031250f, -0.343750f, 0.156250f, -0.468750f, 0.031250f, -0.343750f, 0.156250f,
}; };
const XMVECTORF32 g_Scale16pc = { 65535.f, 65535.f, 65535.f, 65535.f }; const XMVECTORF32 g_Scale16pc = { { { 65535.f, 65535.f, 65535.f, 65535.f } } };
const XMVECTORF32 g_Scale15pc = { 32767.f, 32767.f, 32767.f, 32767.f }; const XMVECTORF32 g_Scale15pc = { { { 32767.f, 32767.f, 32767.f, 32767.f } } };
const XMVECTORF32 g_Scale10pc = { 1023.f, 1023.f, 1023.f, 3.f }; const XMVECTORF32 g_Scale10pc = { { { 1023.f, 1023.f, 1023.f, 3.f } } };
const XMVECTORF32 g_Scale9pc = { 511.f, 511.f, 511.f, 3.f }; const XMVECTORF32 g_Scale9pc = { { { 511.f, 511.f, 511.f, 3.f } } };
const XMVECTORF32 g_Scale8pc = { 255.f, 255.f, 255.f, 255.f }; const XMVECTORF32 g_Scale8pc = { { { 255.f, 255.f, 255.f, 255.f } } };
const XMVECTORF32 g_Scale7pc = { 127.f, 127.f, 127.f, 127.f }; const XMVECTORF32 g_Scale7pc = { { { 127.f, 127.f, 127.f, 127.f } } };
const XMVECTORF32 g_Scale565pc = { 31.f, 63.f, 31.f, 1.f }; const XMVECTORF32 g_Scale565pc = { { { 31.f, 63.f, 31.f, 1.f } } };
const XMVECTORF32 g_Scale5551pc = { 31.f, 31.f, 31.f, 1.f }; const XMVECTORF32 g_Scale5551pc = { { { 31.f, 31.f, 31.f, 1.f } } };
const XMVECTORF32 g_Scale4pc = { 15.f, 15.f, 15.f, 15.f }; const XMVECTORF32 g_Scale4pc = { { { 15.f, 15.f, 15.f, 15.f } } };
const XMVECTORF32 g_ErrorWeight3 = { 3.f / 16.f, 3.f / 16.f, 3.f / 16.f, 3.f / 16.f }; const XMVECTORF32 g_ErrorWeight3 = { { { 3.f / 16.f, 3.f / 16.f, 3.f / 16.f, 3.f / 16.f } } };
const XMVECTORF32 g_ErrorWeight5 = { 5.f / 16.f, 5.f / 16.f, 5.f / 16.f, 5.f / 16.f }; const XMVECTORF32 g_ErrorWeight5 = { { { 5.f / 16.f, 5.f / 16.f, 5.f / 16.f, 5.f / 16.f } } };
const XMVECTORF32 g_ErrorWeight1 = { 1.f / 16.f, 1.f / 16.f, 1.f / 16.f, 1.f / 16.f }; const XMVECTORF32 g_ErrorWeight1 = { { { 1.f / 16.f, 1.f / 16.f, 1.f / 16.f, 1.f / 16.f } } };
const XMVECTORF32 g_ErrorWeight7 = { 7.f / 16.f, 7.f / 16.f, 7.f / 16.f, 7.f / 16.f }; const XMVECTORF32 g_ErrorWeight7 = { { { 7.f / 16.f, 7.f / 16.f, 7.f / 16.f, 7.f / 16.f } } };
#define STORE_SCANLINE( type, scalev, clampzero, norm, itype, mask, row, bgr ) \ #define STORE_SCANLINE( type, scalev, clampzero, norm, itype, mask, row, bgr ) \
if ( size >= sizeof(type) ) \ if ( size >= sizeof(type) ) \
@ -3868,10 +3875,10 @@ bool DirectX::_StoreScanlineDither(
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
if (size >= sizeof(XMUDEC4)) if (size >= sizeof(XMUDEC4))
{ {
static const XMVECTORF32 Scale = { 510.0f, 510.0f, 510.0f, 3.0f }; static const XMVECTORF32 Scale = { { { 510.0f, 510.0f, 510.0f, 3.0f } } };
static const XMVECTORF32 Bias = { 384.0f, 384.0f, 384.0f, 0.0f }; static const XMVECTORF32 Bias = { { { 384.0f, 384.0f, 384.0f, 0.0f } } };
static const XMVECTORF32 MinXR = { -0.7529f, -0.7529f, -0.7529f, 0.f }; static const XMVECTORF32 MinXR = { { { -0.7529f, -0.7529f, -0.7529f, 0.f } } };
static const XMVECTORF32 MaxXR = { 1.2529f, 1.2529f, 1.2529f, 1.0f }; static const XMVECTORF32 MaxXR = { { { 1.2529f, 1.2529f, 1.2529f, 1.0f } } };
XMUDEC4 * __restrict dest = reinterpret_cast<XMUDEC4*>(pDestination); XMUDEC4 * __restrict dest = reinterpret_cast<XMUDEC4*>(pDestination);
for (size_t i = 0; i < count; ++i) for (size_t i = 0; i < count; ++i)
@ -3947,9 +3954,9 @@ bool DirectX::_StoreScanlineDither(
case DXGI_FORMAT_D24_UNORM_S8_UINT: case DXGI_FORMAT_D24_UNORM_S8_UINT:
if (size >= sizeof(uint32_t)) if (size >= sizeof(uint32_t))
{ {
static const XMVECTORF32 Clamp = { 1.f, 255.f, 0.f, 0.f }; static const XMVECTORF32 Clamp = { { { 1.f, 255.f, 0.f, 0.f } } };
static const XMVECTORF32 Scale = { 16777215.f, 1.f, 0.f, 0.f }; static const XMVECTORF32 Scale = { { { 16777215.f, 1.f, 0.f, 0.f } } };
static const XMVECTORF32 Scale2 = { 16777215.f, 255.f, 0.f, 0.f }; static const XMVECTORF32 Scale2 = { { { 16777215.f, 255.f, 0.f, 0.f } } };
uint32_t * __restrict dest = reinterpret_cast<uint32_t*>(pDestination); uint32_t * __restrict dest = reinterpret_cast<uint32_t*>(pDestination);
for (size_t i = 0; i < count; ++i) for (size_t i = 0; i < count; ++i)

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

@ -26,9 +26,9 @@
using namespace DirectX; using namespace DirectX;
using Microsoft::WRL::ComPtr; using Microsoft::WRL::ComPtr;
static_assert(TEX_DIMENSION_TEXTURE1D == D3D11_RESOURCE_DIMENSION_TEXTURE1D, "header enum mismatch"); static_assert(static_cast<int>(TEX_DIMENSION_TEXTURE1D) == static_cast<int>(D3D11_RESOURCE_DIMENSION_TEXTURE1D), "header enum mismatch");
static_assert(TEX_DIMENSION_TEXTURE2D == D3D11_RESOURCE_DIMENSION_TEXTURE2D, "header enum mismatch"); static_assert(static_cast<int>(TEX_DIMENSION_TEXTURE2D) == static_cast<int>(D3D11_RESOURCE_DIMENSION_TEXTURE2D), "header enum mismatch");
static_assert(TEX_DIMENSION_TEXTURE3D == D3D11_RESOURCE_DIMENSION_TEXTURE3D, "header enum mismatch"); static_assert(static_cast<int>(TEX_DIMENSION_TEXTURE3D) == static_cast<int>(D3D11_RESOURCE_DIMENSION_TEXTURE3D), "header enum mismatch");
namespace namespace
{ {
@ -240,6 +240,9 @@ bool DirectX::IsSupportedTexture(
if (fl < D3D_FEATURE_LEVEL_11_0) if (fl < D3D_FEATURE_LEVEL_11_0)
return false; return false;
break; break;
default:
break;
} }
// Validate miplevel count // Validate miplevel count

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

@ -28,9 +28,9 @@
using namespace DirectX; using namespace DirectX;
using Microsoft::WRL::ComPtr; using Microsoft::WRL::ComPtr;
static_assert(TEX_DIMENSION_TEXTURE1D == D3D12_RESOURCE_DIMENSION_TEXTURE1D, "header enum mismatch"); static_assert(static_cast<int>(TEX_DIMENSION_TEXTURE1D) == static_cast<int>(D3D12_RESOURCE_DIMENSION_TEXTURE1D), "header enum mismatch");
static_assert(TEX_DIMENSION_TEXTURE2D == D3D12_RESOURCE_DIMENSION_TEXTURE2D, "header enum mismatch"); static_assert(static_cast<int>(TEX_DIMENSION_TEXTURE2D) == static_cast<int>(D3D12_RESOURCE_DIMENSION_TEXTURE2D), "header enum mismatch");
static_assert(TEX_DIMENSION_TEXTURE3D == D3D12_RESOURCE_DIMENSION_TEXTURE3D, "header enum mismatch"); static_assert(static_cast<int>(TEX_DIMENSION_TEXTURE3D) == static_cast<int>(D3D12_RESOURCE_DIMENSION_TEXTURE3D), "header enum mismatch");
namespace namespace
{ {

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

@ -19,9 +19,9 @@
using namespace DirectX; using namespace DirectX;
static_assert(TEX_DIMENSION_TEXTURE1D == DDS_DIMENSION_TEXTURE1D, "header enum mismatch"); static_assert(static_cast<int>(TEX_DIMENSION_TEXTURE1D) == static_cast<int>(DDS_DIMENSION_TEXTURE1D), "header enum mismatch");
static_assert(TEX_DIMENSION_TEXTURE2D == DDS_DIMENSION_TEXTURE2D, "header enum mismatch"); static_assert(static_cast<int>(TEX_DIMENSION_TEXTURE2D) == static_cast<int>(DDS_DIMENSION_TEXTURE2D), "header enum mismatch");
static_assert(TEX_DIMENSION_TEXTURE3D == DDS_DIMENSION_TEXTURE3D, "header enum mismatch"); static_assert(static_cast<int>(TEX_DIMENSION_TEXTURE3D) == static_cast<int>(DDS_DIMENSION_TEXTURE3D), "header enum mismatch");
namespace namespace
{ {
@ -316,7 +316,7 @@ namespace
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
} }
static_assert(TEX_MISC_TEXTURECUBE == DDS_RESOURCE_MISC_TEXTURECUBE, "DDS header mismatch"); static_assert(static_cast<int>(TEX_MISC_TEXTURECUBE) == static_cast<int>(DDS_RESOURCE_MISC_TEXTURECUBE), "DDS header mismatch");
metadata.miscFlags = d3d10ext->miscFlag & ~TEX_MISC_TEXTURECUBE; metadata.miscFlags = d3d10ext->miscFlag & ~TEX_MISC_TEXTURECUBE;
@ -368,13 +368,13 @@ namespace
return HRESULT_FROM_WIN32(ERROR_INVALID_DATA); return HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
} }
static_assert(TEX_MISC2_ALPHA_MODE_MASK == DDS_MISC_FLAGS2_ALPHA_MODE_MASK, "DDS header mismatch"); static_assert(static_cast<int>(TEX_MISC2_ALPHA_MODE_MASK) == static_cast<int>(DDS_MISC_FLAGS2_ALPHA_MODE_MASK), "DDS header mismatch");
static_assert(TEX_ALPHA_MODE_UNKNOWN == DDS_ALPHA_MODE_UNKNOWN, "DDS header mismatch"); static_assert(static_cast<int>(TEX_ALPHA_MODE_UNKNOWN) == static_cast<int>(DDS_ALPHA_MODE_UNKNOWN), "DDS header mismatch");
static_assert(TEX_ALPHA_MODE_STRAIGHT == DDS_ALPHA_MODE_STRAIGHT, "DDS header mismatch"); static_assert(static_cast<int>(TEX_ALPHA_MODE_STRAIGHT) == static_cast<int>(DDS_ALPHA_MODE_STRAIGHT), "DDS header mismatch");
static_assert(TEX_ALPHA_MODE_PREMULTIPLIED == DDS_ALPHA_MODE_PREMULTIPLIED, "DDS header mismatch"); static_assert(static_cast<int>(TEX_ALPHA_MODE_PREMULTIPLIED) == static_cast<int>(DDS_ALPHA_MODE_PREMULTIPLIED), "DDS header mismatch");
static_assert(TEX_ALPHA_MODE_OPAQUE == DDS_ALPHA_MODE_OPAQUE, "DDS header mismatch"); static_assert(static_cast<int>(TEX_ALPHA_MODE_OPAQUE) == static_cast<int>(DDS_ALPHA_MODE_OPAQUE), "DDS header mismatch");
static_assert(TEX_ALPHA_MODE_CUSTOM == DDS_ALPHA_MODE_CUSTOM, "DDS header mismatch"); static_assert(static_cast<int>(TEX_ALPHA_MODE_CUSTOM) == static_cast<int>(DDS_ALPHA_MODE_CUSTOM), "DDS header mismatch");
metadata.miscFlags2 = d3d10ext->miscFlags2; metadata.miscFlags2 = d3d10ext->miscFlags2;
} }
@ -436,6 +436,9 @@ namespace
metadata.format = DXGI_FORMAT_R16G16B16A16_UNORM; metadata.format = DXGI_FORMAT_R16G16B16A16_UNORM;
convFlags |= CONV_FLAGS_L16 | CONV_FLAGS_EXPAND; convFlags |= CONV_FLAGS_L16 | CONV_FLAGS_EXPAND;
break; break;
default:
break;
} }
} }
} }
@ -474,6 +477,9 @@ namespace
metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
convFlags |= CONV_FLAGS_SWIZZLE | CONV_FLAGS_NOALPHA; convFlags |= CONV_FLAGS_SWIZZLE | CONV_FLAGS_NOALPHA;
break; break;
default:
break;
} }
} }
@ -489,6 +495,9 @@ namespace
convFlags |= CONV_FLAGS_EXPAND; convFlags |= CONV_FLAGS_EXPAND;
if (metadata.format == DXGI_FORMAT_B5G6R5_UNORM) if (metadata.format == DXGI_FORMAT_B5G6R5_UNORM)
convFlags |= CONV_FLAGS_NOALPHA; convFlags |= CONV_FLAGS_NOALPHA;
default:
break;
} }
} }
@ -583,6 +592,9 @@ HRESULT DirectX::_EncodeDDSHeader(
case DXGI_FORMAT_R16_FLOAT: case DXGI_FORMAT_R16_FLOAT:
ddpf.dwSize = sizeof(DDS_PIXELFORMAT); ddpf.dwFlags = DDS_FOURCC; ddpf.dwFourCC = 111; // D3DFMT_R16F ddpf.dwSize = sizeof(DDS_PIXELFORMAT); ddpf.dwFlags = DDS_FOURCC; ddpf.dwFourCC = 111; // D3DFMT_R16F
break; break;
default:
break;
} }
} }
@ -695,7 +707,7 @@ HRESULT DirectX::_EncodeDDSHeader(
if (metadata.arraySize > UINT16_MAX) if (metadata.arraySize > UINT16_MAX)
return E_INVALIDARG; return E_INVALIDARG;
static_assert(TEX_MISC_TEXTURECUBE == DDS_RESOURCE_MISC_TEXTURECUBE, "DDS header mismatch"); static_assert(static_cast<int>(TEX_MISC_TEXTURECUBE) == static_cast<int>(DDS_RESOURCE_MISC_TEXTURECUBE), "DDS header mismatch");
ext->miscFlag = metadata.miscFlags & ~TEX_MISC_TEXTURECUBE; ext->miscFlag = metadata.miscFlags & ~TEX_MISC_TEXTURECUBE;
@ -710,13 +722,13 @@ HRESULT DirectX::_EncodeDDSHeader(
ext->arraySize = static_cast<UINT>(metadata.arraySize); ext->arraySize = static_cast<UINT>(metadata.arraySize);
} }
static_assert(TEX_MISC2_ALPHA_MODE_MASK == DDS_MISC_FLAGS2_ALPHA_MODE_MASK, "DDS header mismatch"); static_assert(static_cast<int>(TEX_MISC2_ALPHA_MODE_MASK) == static_cast<int>(DDS_MISC_FLAGS2_ALPHA_MODE_MASK), "DDS header mismatch");
static_assert(TEX_ALPHA_MODE_UNKNOWN == DDS_ALPHA_MODE_UNKNOWN, "DDS header mismatch"); static_assert(static_cast<int>(TEX_ALPHA_MODE_UNKNOWN) == static_cast<int>(DDS_ALPHA_MODE_UNKNOWN), "DDS header mismatch");
static_assert(TEX_ALPHA_MODE_STRAIGHT == DDS_ALPHA_MODE_STRAIGHT, "DDS header mismatch"); static_assert(static_cast<int>(TEX_ALPHA_MODE_STRAIGHT) == static_cast<int>(DDS_ALPHA_MODE_STRAIGHT), "DDS header mismatch");
static_assert(TEX_ALPHA_MODE_PREMULTIPLIED == DDS_ALPHA_MODE_PREMULTIPLIED, "DDS header mismatch"); static_assert(static_cast<int>(TEX_ALPHA_MODE_PREMULTIPLIED) == static_cast<int>(DDS_ALPHA_MODE_PREMULTIPLIED), "DDS header mismatch");
static_assert(TEX_ALPHA_MODE_OPAQUE == DDS_ALPHA_MODE_OPAQUE, "DDS header mismatch"); static_assert(static_cast<int>(TEX_ALPHA_MODE_OPAQUE) == static_cast<int>(DDS_ALPHA_MODE_OPAQUE), "DDS header mismatch");
static_assert(TEX_ALPHA_MODE_CUSTOM == DDS_ALPHA_MODE_CUSTOM, "DDS header mismatch"); static_assert(static_cast<int>(TEX_ALPHA_MODE_CUSTOM) == static_cast<int>(DDS_ALPHA_MODE_CUSTOM), "DDS header mismatch");
if (flags & DDS_FLAGS_FORCE_DX10_EXT_MISC2) if (flags & DDS_FLAGS_FORCE_DX10_EXT_MISC2)
{ {
@ -867,6 +879,9 @@ namespace
return true; return true;
} }
return false; return false;
default:
return false;
} }
break; break;
@ -980,6 +995,9 @@ namespace
return true; return true;
} }
return false; return false;
default:
return false;
} }
break; break;
@ -1078,10 +1096,11 @@ namespace
return true; return true;
} }
return false; return false;
}
default:
return false; return false;
} }
}
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
@ -1617,7 +1636,7 @@ HRESULT DirectX::LoadFromDDSFile(
if (!(convFlags & CONV_FLAGS_DX10)) if (!(convFlags & CONV_FLAGS_DX10))
{ {
// Must reset file position since we read more than the standard header above // Must reset file position since we read more than the standard header above
LARGE_INTEGER filePos = { sizeof(uint32_t) + sizeof(DDS_HEADER), 0 }; LARGE_INTEGER filePos = { { sizeof(uint32_t) + sizeof(DDS_HEADER), 0 } };
if (!SetFilePointerEx(hFile.get(), filePos, 0, FILE_BEGIN)) if (!SetFilePointerEx(hFile.get(), filePos, 0, FILE_BEGIN))
{ {
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());

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

@ -157,12 +157,12 @@ HRESULT DirectX::FlipRotate(
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
} }
static_assert(TEX_FR_ROTATE0 == WICBitmapTransformRotate0, "TEX_FR_ROTATE0 no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_ROTATE0) == static_cast<int>(WICBitmapTransformRotate0), "TEX_FR_ROTATE0 no longer matches WIC");
static_assert(TEX_FR_ROTATE90 == WICBitmapTransformRotate90, "TEX_FR_ROTATE90 no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_ROTATE90) == static_cast<int>(WICBitmapTransformRotate90), "TEX_FR_ROTATE90 no longer matches WIC");
static_assert(TEX_FR_ROTATE180 == WICBitmapTransformRotate180, "TEX_FR_ROTATE180 no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_ROTATE180) == static_cast<int>(WICBitmapTransformRotate180), "TEX_FR_ROTATE180 no longer matches WIC");
static_assert(TEX_FR_ROTATE270 == WICBitmapTransformRotate270, "TEX_FR_ROTATE270 no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_ROTATE270) == static_cast<int>(WICBitmapTransformRotate270), "TEX_FR_ROTATE270 no longer matches WIC");
static_assert(TEX_FR_FLIP_HORIZONTAL == WICBitmapTransformFlipHorizontal, "TEX_FR_FLIP_HORIZONTAL no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_FLIP_HORIZONTAL) == static_cast<int>(WICBitmapTransformFlipHorizontal), "TEX_FR_FLIP_HORIZONTAL no longer matches WIC");
static_assert(TEX_FR_FLIP_VERTICAL == WICBitmapTransformFlipVertical, "TEX_FR_FLIP_VERTICAL no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_FLIP_VERTICAL) == static_cast<int>(WICBitmapTransformFlipVertical), "TEX_FR_FLIP_VERTICAL no longer matches WIC");
// Only supports 90, 180, 270, or no rotation flags... not a combination of rotation flags // Only supports 90, 180, 270, or no rotation flags... not a combination of rotation flags
switch (flags & (TEX_FR_ROTATE90 | TEX_FR_ROTATE180 | TEX_FR_ROTATE270)) switch (flags & (TEX_FR_ROTATE90 | TEX_FR_ROTATE180 | TEX_FR_ROTATE270))
@ -239,12 +239,12 @@ HRESULT DirectX::FlipRotate(
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
} }
static_assert(TEX_FR_ROTATE0 == WICBitmapTransformRotate0, "TEX_FR_ROTATE0 no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_ROTATE0) == static_cast<int>(WICBitmapTransformRotate0), "TEX_FR_ROTATE0 no longer matches WIC");
static_assert(TEX_FR_ROTATE90 == WICBitmapTransformRotate90, "TEX_FR_ROTATE90 no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_ROTATE90) == static_cast<int>(WICBitmapTransformRotate90), "TEX_FR_ROTATE90 no longer matches WIC");
static_assert(TEX_FR_ROTATE180 == WICBitmapTransformRotate180, "TEX_FR_ROTATE180 no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_ROTATE180) == static_cast<int>(WICBitmapTransformRotate180), "TEX_FR_ROTATE180 no longer matches WIC");
static_assert(TEX_FR_ROTATE270 == WICBitmapTransformRotate270, "TEX_FR_ROTATE270 no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_ROTATE270) == static_cast<int>(WICBitmapTransformRotate270), "TEX_FR_ROTATE270 no longer matches WIC");
static_assert(TEX_FR_FLIP_HORIZONTAL == WICBitmapTransformFlipHorizontal, "TEX_FR_FLIP_HORIZONTAL no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_FLIP_HORIZONTAL) == static_cast<int>(WICBitmapTransformFlipHorizontal), "TEX_FR_FLIP_HORIZONTAL no longer matches WIC");
static_assert(TEX_FR_FLIP_VERTICAL == WICBitmapTransformFlipVertical, "TEX_FR_FLIP_VERTICAL no longer matches WIC"); static_assert(static_cast<int>(TEX_FR_FLIP_VERTICAL) == static_cast<int>(WICBitmapTransformFlipVertical), "TEX_FR_FLIP_VERTICAL no longer matches WIC");
// Only supports 90, 180, 270, or no rotation flags... not a combination of rotation flags // Only supports 90, 180, 270, or no rotation flags... not a combination of rotation flags
switch (flags & (TEX_FR_ROTATE90 | TEX_FR_ROTATE180 | TEX_FR_ROTATE270)) switch (flags & (TEX_FR_ROTATE90 | TEX_FR_ROTATE180 | TEX_FR_ROTATE270))

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

@ -486,7 +486,8 @@ namespace
{ {
if (spanPtr[(runLen - 1) * 4] != spanPtr[runLen * 4]) if (spanPtr[(runLen - 1) * 4] != spanPtr[runLen * 4])
{ {
scan[runLen++] = spanPtr[runLen * 4]; scan[runLen] = spanPtr[runLen * 4];
runLen++;
} }
else else
break; break;

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

@ -768,7 +768,7 @@ bool ScratchImage::IsAlphaAllOpaque() const
if (!scanline) if (!scanline)
return false; return false;
static const XMVECTORF32 threshold = { 0.99f, 0.99f, 0.99f, 0.99f }; static const XMVECTORF32 threshold = { { { 0.99f, 0.99f, 0.99f, 0.99f } } };
for (size_t index = 0; index < m_nimages; ++index) for (size_t index = 0; index < m_nimages; ++index)
{ {

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

@ -1294,7 +1294,7 @@ namespace
{ {
// Need to slightly bias results for floating-point error accumulation which can // Need to slightly bias results for floating-point error accumulation which can
// be visible with harshly quantized values // be visible with harshly quantized values
static const XMVECTORF32 Bias = { 0.f, 0.f, 0.f, 0.1f }; static const XMVECTORF32 Bias = { { { 0.f, 0.f, 0.f, 0.1f } } };
XMVECTOR* ptr = pAccSrc; XMVECTOR* ptr = pAccSrc;
for (size_t i = 0; i < dest->width; ++i, ++ptr) for (size_t i = 0; i < dest->width; ++i, ++ptr)
@ -2474,7 +2474,7 @@ namespace
{ {
// Need to slightly bias results for floating-point error accumulation which can // Need to slightly bias results for floating-point error accumulation which can
// be visible with harshly quantized values // be visible with harshly quantized values
static const XMVECTORF32 Bias = { 0.f, 0.f, 0.f, 0.1f }; static const XMVECTORF32 Bias = { { { 0.f, 0.f, 0.f, 0.1f } } };
XMVECTOR* ptr = pAccSrc; XMVECTOR* ptr = pAccSrc;
for (size_t i = 0; i < dest->width; ++i, ++ptr) for (size_t i = 0; i < dest->width; ++i, ++ptr)

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

@ -19,7 +19,7 @@ using namespace DirectX;
namespace namespace
{ {
const XMVECTORF32 g_Gamma22 = { 2.2f, 2.2f, 2.2f, 1.f }; const XMVECTORF32 g_Gamma22 = { { { 2.2f, 2.2f, 2.2f, 1.f } } };
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
HRESULT ComputeMSE_( HRESULT ComputeMSE_(
@ -60,6 +60,9 @@ namespace
case DXGI_FORMAT_BC7_UNORM_SRGB: case DXGI_FORMAT_BC7_UNORM_SRGB:
flags |= CMSE_IMAGE1_SRGB; flags |= CMSE_IMAGE1_SRGB;
break; break;
default:
break;
} }
switch (image2.format) switch (image2.format)
@ -80,6 +83,9 @@ namespace
case DXGI_FORMAT_BC7_UNORM_SRGB: case DXGI_FORMAT_BC7_UNORM_SRGB:
flags |= CMSE_IMAGE2_SRGB; flags |= CMSE_IMAGE2_SRGB;
break; break;
default:
break;
} }
const uint8_t *pSrc1 = image1.pixels; const uint8_t *pSrc1 = image1.pixels;
@ -89,7 +95,7 @@ namespace
const size_t rowPitch2 = image2.rowPitch; const size_t rowPitch2 = image2.rowPitch;
XMVECTOR acc = g_XMZero; XMVECTOR acc = g_XMZero;
static XMVECTORF32 two = { 2.0f, 2.0f, 2.0f, 2.0f }; static XMVECTORF32 two = { { { 2.0f, 2.0f, 2.0f, 2.0f } } };
for (size_t h = 0; h < image1.height; ++h) for (size_t h = 0; h < image1.height; ++h)
{ {

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

@ -25,7 +25,7 @@ namespace
{ {
XMFLOAT4A f; XMFLOAT4A f;
static XMVECTORF32 lScale = { 0.2125f, 0.7154f, 0.0721f, 1.f }; static XMVECTORF32 lScale = { { { 0.2125f, 0.7154f, 0.0721f, 1.f } } };
static_assert(CNMAP_CHANNEL_RED == 0x1, "CNMAP_CHANNEL_ flag values don't match mask"); static_assert(CNMAP_CHANNEL_RED == 0x1, "CNMAP_CHANNEL_ flag values don't match mask");
switch (flags & 0xf) switch (flags & 0xf)

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

@ -97,8 +97,8 @@ namespace DirectX
{ {
static_assert( TEX_FILTER_DITHER == 0x10000, "TEX_FILTER_DITHER* flag values don't match mask" ); static_assert( TEX_FILTER_DITHER == 0x10000, "TEX_FILTER_DITHER* flag values don't match mask" );
static_assert( TEX_FILTER_DITHER == WIC_FLAGS_DITHER, "TEX_FILTER_DITHER* should match WIC_FLAGS_DITHER*" ); static_assert(static_cast<int>(TEX_FILTER_DITHER) == static_cast<int>(WIC_FLAGS_DITHER), "TEX_FILTER_DITHER* should match WIC_FLAGS_DITHER*");
static_assert( TEX_FILTER_DITHER_DIFFUSION == WIC_FLAGS_DITHER_DIFFUSION, "TEX_FILTER_DITHER* should match WIC_FLAGS_DITHER*" ); static_assert(static_cast<int>(TEX_FILTER_DITHER_DIFFUSION) == static_cast<int>(WIC_FLAGS_DITHER_DIFFUSION), "TEX_FILTER_DITHER* should match WIC_FLAGS_DITHER*");
switch( flags & 0xF0000 ) switch( flags & 0xF0000 )
{ {
@ -117,10 +117,10 @@ namespace DirectX
{ {
static_assert( TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MASK" ); static_assert( TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MASK" );
static_assert( TEX_FILTER_POINT == WIC_FLAGS_FILTER_POINT, "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*" ); static_assert(static_cast<int>(TEX_FILTER_POINT) == static_cast<int>(WIC_FLAGS_FILTER_POINT), "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*");
static_assert( TEX_FILTER_LINEAR == WIC_FLAGS_FILTER_LINEAR, "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*" ); static_assert(static_cast<int>(TEX_FILTER_LINEAR) == static_cast<int>(WIC_FLAGS_FILTER_LINEAR), "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*");
static_assert( TEX_FILTER_CUBIC == WIC_FLAGS_FILTER_CUBIC, "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*" ); static_assert(static_cast<int>(TEX_FILTER_CUBIC) == static_cast<int>(WIC_FLAGS_FILTER_CUBIC), "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*");
static_assert( TEX_FILTER_FANT == WIC_FLAGS_FILTER_FANT, "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*" ); static_assert(static_cast<int>(TEX_FILTER_FANT) == static_cast<int>(WIC_FLAGS_FILTER_FANT), "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*");
switch( flags & TEX_FILTER_MASK ) switch( flags & TEX_FILTER_MASK )
{ {

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

@ -64,9 +64,9 @@ namespace
assert(srcImage.width == destImage.width); assert(srcImage.width == destImage.width);
assert(srcImage.height == destImage.height); assert(srcImage.height == destImage.height);
static_assert(TEX_PMALPHA_SRGB_IN == TEX_FILTER_SRGB_IN, "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_PMALPHA_SRGB_IN) == static_cast<int>(TEX_FILTER_SRGB_IN), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*");
static_assert(TEX_PMALPHA_SRGB_OUT == TEX_FILTER_SRGB_OUT, "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_PMALPHA_SRGB_OUT) == static_cast<int>(TEX_FILTER_SRGB_OUT), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*");
static_assert(TEX_PMALPHA_SRGB == TEX_FILTER_SRGB, "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_PMALPHA_SRGB) == static_cast<int>(TEX_FILTER_SRGB), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*");
flags &= TEX_PMALPHA_SRGB; flags &= TEX_PMALPHA_SRGB;
ScopedAlignedArrayXMVECTOR scanline(reinterpret_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16))); ScopedAlignedArrayXMVECTOR scanline(reinterpret_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16)));
@ -147,9 +147,9 @@ namespace
assert(srcImage.width == destImage.width); assert(srcImage.width == destImage.width);
assert(srcImage.height == destImage.height); assert(srcImage.height == destImage.height);
static_assert(TEX_PMALPHA_SRGB_IN == TEX_FILTER_SRGB_IN, "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_PMALPHA_SRGB_IN) == static_cast<int>(TEX_FILTER_SRGB_IN), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*");
static_assert(TEX_PMALPHA_SRGB_OUT == TEX_FILTER_SRGB_OUT, "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_PMALPHA_SRGB_OUT) == static_cast<int>(TEX_FILTER_SRGB_OUT), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*");
static_assert(TEX_PMALPHA_SRGB == TEX_FILTER_SRGB, "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); static_assert(static_cast<int>(TEX_PMALPHA_SRGB) == static_cast<int>(TEX_FILTER_SRGB), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*");
flags &= TEX_PMALPHA_SRGB; flags &= TEX_PMALPHA_SRGB;
ScopedAlignedArrayXMVECTOR scanline(reinterpret_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16))); ScopedAlignedArrayXMVECTOR scanline(reinterpret_cast<XMVECTOR*>(_aligned_malloc((sizeof(XMVECTOR)*srcImage.width), 16)));

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

@ -758,7 +758,7 @@ namespace
{ {
// Need to slightly bias results for floating-point error accumulation which can // Need to slightly bias results for floating-point error accumulation which can
// be visible with harshly quantized values // be visible with harshly quantized values
static const XMVECTORF32 Bias = { 0.f, 0.f, 0.f, 0.1f }; static const XMVECTORF32 Bias = { { { 0.f, 0.f, 0.f, 0.1f } } };
XMVECTOR* ptr = pAccSrc; XMVECTOR* ptr = pAccSrc;
for (size_t i = 0; i < destImage.width; ++i, ++ptr) for (size_t i = 0; i < destImage.width; ++i, ++ptr)

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

@ -1040,7 +1040,7 @@ HRESULT DirectX::LoadFromTGAFile(
if (offset > sizeof(TGA_HEADER)) if (offset > sizeof(TGA_HEADER))
{ {
// Skip past the id string // Skip past the id string
LARGE_INTEGER filePos = { static_cast<DWORD>(offset), 0 }; LARGE_INTEGER filePos = { { static_cast<DWORD>(offset), 0 } };
if (!SetFilePointerEx(hFile.get(), filePos, 0, FILE_BEGIN)) if (!SetFilePointerEx(hFile.get(), filePos, 0, FILE_BEGIN))
{ {
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
@ -1184,6 +1184,9 @@ HRESULT DirectX::LoadFromTGAFile(
} }
} }
break; break;
default:
break;
} }
} }
else // RLE || EXPAND || INVERTX || !INVERTY else // RLE || EXPAND || INVERTX || !INVERTY

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

@ -234,6 +234,10 @@ namespace
if (pConvert) if (pConvert)
memcpy(pConvert, &GUID_WICPixelFormat8bppGray, sizeof(WICPixelFormatGUID)); memcpy(pConvert, &GUID_WICPixelFormat8bppGray, sizeof(WICPixelFormatGUID));
} }
break;
default:
break;
} }
return format; return format;
@ -1153,7 +1157,7 @@ HRESULT DirectX::SaveToWICMemory(
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
LARGE_INTEGER li = { 0 }; LARGE_INTEGER li = { { 0 } };
hr = stream->Seek(li, STREAM_SEEK_SET, 0); hr = stream->Seek(li, STREAM_SEEK_SET, 0);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
@ -1210,7 +1214,7 @@ HRESULT DirectX::SaveToWICMemory(
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
LARGE_INTEGER li = { 0 }; LARGE_INTEGER li = { { 0 } };
hr = stream->Seek(li, STREAM_SEEK_SET, 0); hr = stream->Seek(li, STREAM_SEEK_SET, 0);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;

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

@ -27,8 +27,8 @@ namespace DirectX
// Box filtering helpers // Box filtering helpers
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
XMGLOBALCONST XMVECTORF32 g_boxScale = { 0.25f, 0.25f, 0.25f, 0.25f }; XMGLOBALCONST XMVECTORF32 g_boxScale = { { { 0.25f, 0.25f, 0.25f, 0.25f } } };
XMGLOBALCONST XMVECTORF32 g_boxScale3D = { 0.125f, 0.125f, 0.125f, 0.125f }; XMGLOBALCONST XMVECTORF32 g_boxScale3D = { { { 0.125f, 0.125f, 0.125f, 0.125f } } };
#define AVERAGE4( res, p0, p1, p2, p3 ) \ #define AVERAGE4( res, p0, p1, p2, p3 ) \
{ \ { \
@ -116,9 +116,9 @@ inline void _CreateLinearFilter(_In_ size_t source, _In_ size_t dest, _In_ bool
// Cubic filtering helpers // Cubic filtering helpers
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
XMGLOBALCONST XMVECTORF32 g_cubicThird = { 1.f/3.f, 1.f/3.f, 1.f/3.f, 1.f/3.f }; XMGLOBALCONST XMVECTORF32 g_cubicThird = { { { 1.f / 3.f, 1.f / 3.f, 1.f / 3.f, 1.f / 3.f } } };
XMGLOBALCONST XMVECTORF32 g_cubicSixth = { 1.f/6.f, 1.f/6.f, 1.f/6.f, 1.f/6.f }; XMGLOBALCONST XMVECTORF32 g_cubicSixth = { { { 1.f / 6.f, 1.f / 6.f, 1.f / 6.f, 1.f / 6.f } } };
XMGLOBALCONST XMVECTORF32 g_cubicHalf = { 1.f/2.f, 1.f/2.f, 1.f/2.f, 1.f/2.f }; XMGLOBALCONST XMVECTORF32 g_cubicHalf = { { { 1.f / 2.f, 1.f / 2.f, 1.f / 2.f, 1.f / 2.f } } };
inline ptrdiff_t bounduvw(ptrdiff_t u, ptrdiff_t maxu, bool wrap, bool mirror) inline ptrdiff_t bounduvw(ptrdiff_t u, ptrdiff_t maxu, bool wrap, bool mirror)
{ {