Add CMake project and fix clang warnings (#139)
This commit is contained in:
parent
c833ac5022
commit
5f125c6b8d
3
.gitignore
vendored
3
.gitignore
vendored
@ -25,4 +25,5 @@ Profile
|
|||||||
Release
|
Release
|
||||||
x64
|
x64
|
||||||
/Tests
|
/Tests
|
||||||
/wiki
|
/wiki
|
||||||
|
/DirectXTex/out
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
// Experiemental encoding variants, not enabled by default
|
// Experiemental encoding variants, not enabled by default
|
||||||
//#define COLOR_WEIGHTS
|
//#define COLOR_WEIGHTS
|
||||||
@ -398,11 +398,11 @@ namespace
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uSteps = (uColorKey > 0) ? 3 : 4;
|
uSteps = (uColorKey > 0) ? 3u : 4u;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uSteps = 4;
|
uSteps = 4u;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quantize block to R56B5, using Floyd Stienberg error diffusion. This
|
// Quantize block to R56B5, using Floyd Stienberg error diffusion. This
|
||||||
@ -929,12 +929,12 @@ void DirectX::D3DXDecodeBC3(XMVECTOR *pColor, const uint8_t *pBC)
|
|||||||
fAlpha[7] = 1.0f;
|
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)
|
for (size_t i = 0; i < 8; ++i, dw >>= 3)
|
||||||
pColor[i] = XMVectorSetW(pColor[i], fAlpha[dw & 0x7]);
|
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)
|
for (size_t i = 8; i < NUM_PIXELS_PER_BLOCK; ++i, dw >>= 3)
|
||||||
pColor[i] = XMVectorSetW(pColor[i], fAlpha[dw & 0x7]);
|
pColor[i] = XMVectorSetW(pColor[i], fAlpha[dw & 0x7]);
|
||||||
@ -1027,7 +1027,7 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Optimize and Quantize Min and Max values
|
// 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;
|
float fAlphaA, fAlphaB;
|
||||||
OptimizeAlpha<false>(&fAlphaA, &fAlphaB, fAlpha, uSteps);
|
OptimizeAlpha<false>(&fAlphaA, &fAlphaB, fAlpha, uSteps);
|
||||||
@ -1106,9 +1106,9 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags)
|
|||||||
|
|
||||||
uint32_t iStep;
|
uint32_t iStep;
|
||||||
if (fDot <= 0.0f)
|
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)
|
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
|
else
|
||||||
iStep = uint32_t(pSteps[uint32_t(fDot + 0.5f)]);
|
iStep = uint32_t(pSteps[uint32_t(fDot + 0.5f)]);
|
||||||
|
|
||||||
|
@ -249,9 +249,9 @@ template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPo
|
|||||||
|
|
||||||
uint32_t iStep;
|
uint32_t iStep;
|
||||||
if (fDot <= 0.0f)
|
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)
|
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
|
else
|
||||||
iStep = uint32_t(fDot + 0.5f);
|
iStep = uint32_t(fDot + 0.5f);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
#include "BC.h"
|
#include "BC.h"
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ namespace
|
|||||||
{
|
{
|
||||||
const uint32_t dwMostNeg = (1 << (8 * sizeof(int8_t) - 1));
|
const uint32_t dwMostNeg = (1 << (8 * sizeof(int8_t) - 1));
|
||||||
|
|
||||||
if (_isnan(fVal))
|
if (isnan(fVal))
|
||||||
fVal = 0;
|
fVal = 0;
|
||||||
else
|
else
|
||||||
if (fVal > 1)
|
if (fVal > 1)
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
#include "BC.h"
|
#include "BC.h"
|
||||||
|
|
||||||
@ -583,7 +583,7 @@ namespace
|
|||||||
assert(uStartBit < 128);
|
assert(uStartBit < 128);
|
||||||
_Analysis_assume_(uStartBit < 128);
|
_Analysis_assume_(uStartBit < 128);
|
||||||
size_t uIndex = uStartBit >> 3;
|
size_t uIndex = uStartBit >> 3;
|
||||||
uint8_t ret = (m_uBits[uIndex] >> (uStartBit - (uIndex << 3))) & 0x01;
|
auto ret = static_cast<uint8_t>((m_uBits[uIndex] >> (uStartBit - (uIndex << 3))) & 0x01);
|
||||||
uStartBit++;
|
uStartBit++;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -604,7 +604,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = (m_uBits[uIndex] >> uBase) & ((1 << uNumBits) - 1);
|
ret = static_cast<uint8_t>((m_uBits[uIndex] >> uBase) & ((1 << uNumBits) - 1));
|
||||||
}
|
}
|
||||||
assert(ret < (1 << uNumBits));
|
assert(ret < (1 << uNumBits));
|
||||||
uStartBit += uNumBits;
|
uStartBit += uNumBits;
|
||||||
@ -794,7 +794,7 @@ namespace
|
|||||||
{
|
{
|
||||||
assert(0 < uPrec && uPrec <= 8);
|
assert(0 < uPrec && uPrec <= 8);
|
||||||
uint8_t rnd = std::min<uint8_t>(255u, static_cast<uint8_t>(unsigned(comp) + (1u << (7 - uPrec))));
|
uint8_t rnd = std::min<uint8_t>(255u, static_cast<uint8_t>(unsigned(comp) + (1u << (7 - uPrec))));
|
||||||
return rnd >> (8 - uPrec);
|
return uint8_t(rnd >> (8u - uPrec));
|
||||||
}
|
}
|
||||||
|
|
||||||
static LDRColorA Quantize(_In_ const LDRColorA& c, _In_ const LDRColorA& RGBAPrec)
|
static LDRColorA Quantize(_In_ const LDRColorA& c, _In_ const LDRColorA& RGBAPrec)
|
||||||
@ -814,7 +814,7 @@ namespace
|
|||||||
{
|
{
|
||||||
assert(0 < uPrec && uPrec <= 8);
|
assert(0 < uPrec && uPrec <= 8);
|
||||||
comp = static_cast<uint8_t>(unsigned(comp) << (8 - uPrec));
|
comp = static_cast<uint8_t>(unsigned(comp) << (8 - uPrec));
|
||||||
return comp | (comp >> uPrec);
|
return uint8_t(comp | (comp >> uPrec));
|
||||||
}
|
}
|
||||||
|
|
||||||
static LDRColorA Unquantize(_In_ const LDRColorA& c, _In_ const LDRColorA& RGBAPrec)
|
static LDRColorA Unquantize(_In_ const LDRColorA& c, _In_ const LDRColorA& RGBAPrec)
|
||||||
@ -823,7 +823,7 @@ namespace
|
|||||||
q.r = Unquantize(c.r, RGBAPrec.r);
|
q.r = Unquantize(c.r, RGBAPrec.r);
|
||||||
q.g = Unquantize(c.g, RGBAPrec.g);
|
q.g = Unquantize(c.g, RGBAPrec.g);
|
||||||
q.b = Unquantize(c.b, RGBAPrec.b);
|
q.b = Unquantize(c.b, RGBAPrec.b);
|
||||||
q.a = RGBAPrec.a > 0 ? Unquantize(c.a, RGBAPrec.a) : 255;
|
q.a = RGBAPrec.a > 0 ? Unquantize(c.a, RGBAPrec.a) : 255u;
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1649,7 +1649,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const
|
|||||||
assert(pOut);
|
assert(pOut);
|
||||||
|
|
||||||
size_t uStartBit = 0;
|
size_t uStartBit = 0;
|
||||||
uint8_t uMode = GetBits(uStartBit, 2);
|
uint8_t uMode = GetBits(uStartBit, 2u);
|
||||||
if (uMode != 0x00 && uMode != 0x01)
|
if (uMode != 0x00 && uMode != 0x01)
|
||||||
{
|
{
|
||||||
uMode = static_cast<uint8_t>((unsigned(GetBits(uStartBit, 3)) << 2) | uMode);
|
uMode = static_cast<uint8_t>((unsigned(GetBits(uStartBit, 3)) << 2) | uMode);
|
||||||
@ -1672,7 +1672,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const
|
|||||||
uint32_t uShape = 0;
|
uint32_t uShape = 0;
|
||||||
|
|
||||||
// Read header
|
// Read header
|
||||||
const size_t uHeaderBits = info.uPartitions > 0 ? 82 : 65;
|
const size_t uHeaderBits = info.uPartitions > 0 ? 82u : 65u;
|
||||||
while (uStartBit < uHeaderBits)
|
while (uStartBit < uHeaderBits)
|
||||||
{
|
{
|
||||||
size_t uCurBit = uStartBit;
|
size_t uCurBit = uStartBit;
|
||||||
@ -1736,7 +1736,7 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const
|
|||||||
// Read indices
|
// Read indices
|
||||||
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
||||||
{
|
{
|
||||||
size_t uNumBits = IsFixUpOffset(info.uPartitions, uShape, i) ? info.uIndexPrec - 1 : info.uIndexPrec;
|
size_t uNumBits = IsFixUpOffset(info.uPartitions, uShape, i) ? info.uIndexPrec - 1u : info.uIndexPrec;
|
||||||
if (uStartBit + uNumBits > 128)
|
if (uStartBit + uNumBits > 128)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@ -1813,10 +1813,10 @@ void D3DX_BC6H::Encode(bool bSigned, const HDRColorA* const pIn)
|
|||||||
|
|
||||||
for (EP.uMode = 0; EP.uMode < ARRAYSIZE(ms_aInfo) && EP.fBestErr > 0; ++EP.uMode)
|
for (EP.uMode = 0; EP.uMode < ARRAYSIZE(ms_aInfo) && EP.fBestErr > 0; ++EP.uMode)
|
||||||
{
|
{
|
||||||
const uint8_t uShapes = ms_aInfo[EP.uMode].uPartitions ? 32 : 1;
|
const uint8_t uShapes = ms_aInfo[EP.uMode].uPartitions ? 32u : 1u;
|
||||||
// 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>(1u, size_t(uShapes >> 2));
|
||||||
float afRoughMSE[BC6H_MAX_SHAPES];
|
float afRoughMSE[BC6H_MAX_SHAPES];
|
||||||
uint8_t auShape[BC6H_MAX_SHAPES];
|
uint8_t auShape[BC6H_MAX_SHAPES];
|
||||||
|
|
||||||
@ -2301,7 +2301,7 @@ void D3DX_BC6H::EmitBlock(const EncodeParams* pEP, const INTEndPntPair aEndPts[]
|
|||||||
const uint8_t uRealMode = ms_aInfo[pEP->uMode].uMode;
|
const uint8_t uRealMode = ms_aInfo[pEP->uMode].uMode;
|
||||||
const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions;
|
const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions;
|
||||||
const uint8_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec;
|
const uint8_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec;
|
||||||
const size_t uHeaderBits = uPartitions > 0 ? 82 : 65;
|
const size_t uHeaderBits = uPartitions > 0 ? 82u : 65u;
|
||||||
const ModeDescriptor* desc = ms_aDesc[pEP->uMode];
|
const ModeDescriptor* desc = ms_aDesc[pEP->uMode];
|
||||||
size_t uStartBit = 0;
|
size_t uStartBit = 0;
|
||||||
|
|
||||||
@ -2309,20 +2309,20 @@ void D3DX_BC6H::EmitBlock(const EncodeParams* pEP, const INTEndPntPair aEndPts[]
|
|||||||
{
|
{
|
||||||
switch (desc[uStartBit].m_eField)
|
switch (desc[uStartBit].m_eField)
|
||||||
{
|
{
|
||||||
case M: SetBit(uStartBit, uint8_t(uRealMode >> desc[uStartBit].m_uBit) & 0x01); break;
|
case M: SetBit(uStartBit, uint8_t(uRealMode >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case D: SetBit(uStartBit, uint8_t(pEP->uShape >> desc[uStartBit].m_uBit) & 0x01); break;
|
case D: SetBit(uStartBit, uint8_t(pEP->uShape >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case RW: SetBit(uStartBit, uint8_t(aEndPts[0].A.r >> desc[uStartBit].m_uBit) & 0x01); break;
|
case RW: SetBit(uStartBit, uint8_t(aEndPts[0].A.r >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case RX: SetBit(uStartBit, uint8_t(aEndPts[0].B.r >> desc[uStartBit].m_uBit) & 0x01); break;
|
case RX: SetBit(uStartBit, uint8_t(aEndPts[0].B.r >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case RY: SetBit(uStartBit, uint8_t(aEndPts[1].A.r >> desc[uStartBit].m_uBit) & 0x01); break;
|
case RY: SetBit(uStartBit, uint8_t(aEndPts[1].A.r >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case RZ: SetBit(uStartBit, uint8_t(aEndPts[1].B.r >> desc[uStartBit].m_uBit) & 0x01); break;
|
case RZ: SetBit(uStartBit, uint8_t(aEndPts[1].B.r >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case GW: SetBit(uStartBit, uint8_t(aEndPts[0].A.g >> desc[uStartBit].m_uBit) & 0x01); break;
|
case GW: SetBit(uStartBit, uint8_t(aEndPts[0].A.g >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case GX: SetBit(uStartBit, uint8_t(aEndPts[0].B.g >> desc[uStartBit].m_uBit) & 0x01); break;
|
case GX: SetBit(uStartBit, uint8_t(aEndPts[0].B.g >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case GY: SetBit(uStartBit, uint8_t(aEndPts[1].A.g >> desc[uStartBit].m_uBit) & 0x01); break;
|
case GY: SetBit(uStartBit, uint8_t(aEndPts[1].A.g >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case GZ: SetBit(uStartBit, uint8_t(aEndPts[1].B.g >> desc[uStartBit].m_uBit) & 0x01); break;
|
case GZ: SetBit(uStartBit, uint8_t(aEndPts[1].B.g >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case BW: SetBit(uStartBit, uint8_t(aEndPts[0].A.b >> desc[uStartBit].m_uBit) & 0x01); break;
|
case BW: SetBit(uStartBit, uint8_t(aEndPts[0].A.b >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case BX: SetBit(uStartBit, uint8_t(aEndPts[0].B.b >> desc[uStartBit].m_uBit) & 0x01); break;
|
case BX: SetBit(uStartBit, uint8_t(aEndPts[0].B.b >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case BY: SetBit(uStartBit, uint8_t(aEndPts[1].A.b >> desc[uStartBit].m_uBit) & 0x01); break;
|
case BY: SetBit(uStartBit, uint8_t(aEndPts[1].A.b >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
case BZ: SetBit(uStartBit, uint8_t(aEndPts[1].B.b >> desc[uStartBit].m_uBit) & 0x01); break;
|
case BZ: SetBit(uStartBit, uint8_t(aEndPts[1].B.b >> desc[uStartBit].m_uBit) & 0x01u); break;
|
||||||
default: assert(false);
|
default: assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2330,7 +2330,7 @@ void D3DX_BC6H::EmitBlock(const EncodeParams* pEP, const INTEndPntPair aEndPts[]
|
|||||||
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
||||||
{
|
{
|
||||||
if (IsFixUpOffset(ms_aInfo[pEP->uMode].uPartitions, pEP->uShape, i))
|
if (IsFixUpOffset(ms_aInfo[pEP->uMode].uPartitions, pEP->uShape, i))
|
||||||
SetBits(uStartBit, uIndexPrec - 1, static_cast<uint8_t>(aIndices[i]));
|
SetBits(uStartBit, uIndexPrec - 1u, static_cast<uint8_t>(aIndices[i]));
|
||||||
else
|
else
|
||||||
SetBits(uStartBit, uIndexPrec, static_cast<uint8_t>(aIndices[i]));
|
SetBits(uStartBit, uIndexPrec, static_cast<uint8_t>(aIndices[i]));
|
||||||
}
|
}
|
||||||
@ -2610,7 +2610,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
c[i].a = RGBAPrec.a ? GetBits(uStartBit, RGBAPrec.a) : 255;
|
c[i].a = RGBAPrec.a ? GetBits(uStartBit, RGBAPrec.a) : 255u;
|
||||||
}
|
}
|
||||||
|
|
||||||
// P-bits
|
// P-bits
|
||||||
@ -2655,7 +2655,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const
|
|||||||
// read color indices
|
// read color indices
|
||||||
for (i = 0; i < NUM_PIXELS_PER_BLOCK; i++)
|
for (i = 0; i < NUM_PIXELS_PER_BLOCK; i++)
|
||||||
{
|
{
|
||||||
size_t uNumBits = IsFixUpOffset(ms_aInfo[uMode].uPartitions, uShape, i) ? uIndexPrec - 1 : uIndexPrec;
|
size_t uNumBits = IsFixUpOffset(ms_aInfo[uMode].uPartitions, uShape, i) ? uIndexPrec - 1u : uIndexPrec;
|
||||||
if (uStartBit + uNumBits > 128)
|
if (uStartBit + uNumBits > 128)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@ -2672,7 +2672,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const
|
|||||||
{
|
{
|
||||||
for (i = 0; i < NUM_PIXELS_PER_BLOCK; i++)
|
for (i = 0; i < NUM_PIXELS_PER_BLOCK; i++)
|
||||||
{
|
{
|
||||||
size_t uNumBits = i ? uIndexPrec2 : uIndexPrec2 - 1;
|
size_t uNumBits = i ? uIndexPrec2 : uIndexPrec2 - 1u;
|
||||||
if (uStartBit + uNumBits > 128)
|
if (uStartBit + uNumBits > 128)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@ -3033,7 +3033,7 @@ void D3DX_BC7::OptimizeOne(const EncodeParams* pEP, const LDRColorA aColors[], s
|
|||||||
else
|
else
|
||||||
copt_b = cnew_b;
|
copt_b = cnew_b;
|
||||||
fOptErr = fErr;
|
fOptErr = fErr;
|
||||||
do_b = 1 - do_b; // now move the other endpoint
|
do_b = 1u - do_b; // now move the other endpoint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3085,8 +3085,8 @@ void D3DX_BC7::AssignIndices(const EncodeParams* pEP, size_t uShape, size_t uInd
|
|||||||
assert((uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES));
|
assert((uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES));
|
||||||
_Analysis_assume_((uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES));
|
_Analysis_assume_((uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES));
|
||||||
|
|
||||||
const uint8_t uHighestIndexBit = uNumIndices >> 1;
|
const uint8_t uHighestIndexBit = uint8_t(uNumIndices >> 1);
|
||||||
const uint8_t uHighestIndexBit2 = uNumIndices2 >> 1;
|
const uint8_t uHighestIndexBit2 = uint8_t(uNumIndices2 >> 1);
|
||||||
LDRColorA aPalette[BC7_MAX_REGIONS][BC7_MAX_INDICES];
|
LDRColorA aPalette[BC7_MAX_REGIONS][BC7_MAX_INDICES];
|
||||||
|
|
||||||
// build list of possibles
|
// build list of possibles
|
||||||
@ -3183,8 +3183,8 @@ void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotatio
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetBits(uStartBit, RGBAPrec[ch], aEndPts[i].A[ch] >> 1);
|
SetBits(uStartBit, RGBAPrec[ch], uint8_t(aEndPts[i].A[ch] >> 1));
|
||||||
SetBits(uStartBit, RGBAPrec[ch], aEndPts[i].B[ch] >> 1);
|
SetBits(uStartBit, RGBAPrec[ch], uint8_t(aEndPts[i].B[ch] >> 1));
|
||||||
size_t idx = ep++ * uPBits / uNumEP;
|
size_t idx = ep++ * uPBits / uNumEP;
|
||||||
assert(idx < (BC7_MAX_REGIONS << 1));
|
assert(idx < (BC7_MAX_REGIONS << 1));
|
||||||
_Analysis_assume_(idx < (BC7_MAX_REGIONS << 1));
|
_Analysis_assume_(idx < (BC7_MAX_REGIONS << 1));
|
||||||
@ -3201,7 +3201,7 @@ void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotatio
|
|||||||
|
|
||||||
for (i = 0; i < uPBits; i++)
|
for (i = 0; i < uPBits; i++)
|
||||||
{
|
{
|
||||||
SetBits(uStartBit, 1, aPVote[i] > (aCount[i] >> 1) ? 1 : 0);
|
SetBits(uStartBit, 1, aPVote[i] > (aCount[i] >> 1) ? 1u : 0u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3264,8 +3264,8 @@ void D3DX_BC7::FixEndpointPBits(const EncodeParams* pEP, const LDREndPntPair *pO
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pFixedEndpoints[i].A[ch] = pOrigEndpoints[i].A[ch] >> 1;
|
pFixedEndpoints[i].A[ch] = uint8_t(pOrigEndpoints[i].A[ch] >> 1);
|
||||||
pFixedEndpoints[i].B[ch] = pOrigEndpoints[i].B[ch] >> 1;
|
pFixedEndpoints[i].B[ch] = uint8_t(pOrigEndpoints[i].B[ch] >> 1);
|
||||||
|
|
||||||
size_t idx = ep++ * uPBits / uNumEP;
|
size_t idx = ep++ * uPBits / uNumEP;
|
||||||
assert(idx < (BC7_MAX_REGIONS << 1));
|
assert(idx < (BC7_MAX_REGIONS << 1));
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
#include "BCDirectCompute.h"
|
#include "BCDirectCompute.h"
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ HRESULT GPUCompressBC::Compress(const Image& srcImage, const Image& destImage)
|
|||||||
|
|
||||||
auto num_total_blocks = static_cast<UINT>(xblocks * yblocks);
|
auto num_total_blocks = static_cast<UINT>(xblocks * yblocks);
|
||||||
UINT num_blocks = num_total_blocks;
|
UINT num_blocks = num_total_blocks;
|
||||||
int start_block_id = 0;
|
UINT start_block_id = 0;
|
||||||
while (num_blocks > 0)
|
while (num_blocks > 0)
|
||||||
{
|
{
|
||||||
UINT n = std::min<UINT>(num_blocks, MAX_BLOCK_BATCH);
|
UINT n = std::min<UINT>(num_blocks, MAX_BLOCK_BATCH);
|
||||||
@ -449,7 +449,7 @@ HRESULT GPUCompressBC::Compress(const Image& srcImage, const Image& destImage)
|
|||||||
ConstantsBC6HBC7 param;
|
ConstantsBC6HBC7 param;
|
||||||
param.tex_width = static_cast<UINT>(srcImage.width);
|
param.tex_width = static_cast<UINT>(srcImage.width);
|
||||||
param.num_block_x = static_cast<UINT>(xblocks);
|
param.num_block_x = static_cast<UINT>(xblocks);
|
||||||
param.format = m_bcformat;
|
param.format = static_cast<UINT>(m_bcformat);
|
||||||
param.mode_id = 0;
|
param.mode_id = 0;
|
||||||
param.start_block_id = start_block_id;
|
param.start_block_id = start_block_id;
|
||||||
param.num_total_blocks = num_total_blocks;
|
param.num_total_blocks = num_total_blocks;
|
||||||
@ -487,7 +487,7 @@ HRESULT GPUCompressBC::Compress(const Image& srcImage, const Image& destImage)
|
|||||||
ConstantsBC6HBC7 param;
|
ConstantsBC6HBC7 param;
|
||||||
param.tex_width = static_cast<UINT>(srcImage.width);
|
param.tex_width = static_cast<UINT>(srcImage.width);
|
||||||
param.num_block_x = static_cast<UINT>(xblocks);
|
param.num_block_x = static_cast<UINT>(xblocks);
|
||||||
param.format = m_bcformat;
|
param.format = static_cast<UINT>(m_bcformat);
|
||||||
param.mode_id = modes[i];
|
param.mode_id = modes[i];
|
||||||
param.start_block_id = start_block_id;
|
param.start_block_id = start_block_id;
|
||||||
param.num_total_blocks = num_total_blocks;
|
param.num_total_blocks = num_total_blocks;
|
||||||
@ -522,7 +522,7 @@ HRESULT GPUCompressBC::Compress(const Image& srcImage, const Image& destImage)
|
|||||||
ConstantsBC6HBC7 param;
|
ConstantsBC6HBC7 param;
|
||||||
param.tex_width = static_cast<UINT>(srcImage.width);
|
param.tex_width = static_cast<UINT>(srcImage.width);
|
||||||
param.num_block_x = static_cast<UINT>(xblocks);
|
param.num_block_x = static_cast<UINT>(xblocks);
|
||||||
param.format = m_bcformat;
|
param.format = static_cast<UINT>(m_bcformat);
|
||||||
param.mode_id = modes[i];
|
param.mode_id = modes[i];
|
||||||
param.start_block_id = start_block_id;
|
param.start_block_id = start_block_id;
|
||||||
param.num_total_blocks = num_total_blocks;
|
param.num_total_blocks = num_total_blocks;
|
||||||
@ -562,7 +562,7 @@ HRESULT GPUCompressBC::Compress(const Image& srcImage, const Image& destImage)
|
|||||||
ConstantsBC6HBC7 param;
|
ConstantsBC6HBC7 param;
|
||||||
param.tex_width = static_cast<UINT>(srcImage.width);
|
param.tex_width = static_cast<UINT>(srcImage.width);
|
||||||
param.num_block_x = static_cast<UINT>(xblocks);
|
param.num_block_x = static_cast<UINT>(xblocks);
|
||||||
param.format = m_bcformat;
|
param.format = static_cast<UINT>(m_bcformat);
|
||||||
param.mode_id = i;
|
param.mode_id = i;
|
||||||
param.start_block_id = start_block_id;
|
param.start_block_id = start_block_id;
|
||||||
param.num_total_blocks = num_total_blocks;
|
param.num_total_blocks = num_total_blocks;
|
||||||
|
64
DirectXTex/CMakeLists.txt
Normal file
64
DirectXTex/CMakeLists.txt
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# DirectX Texture Library
|
||||||
|
#
|
||||||
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
# Licensed under the MIT License.
|
||||||
|
#
|
||||||
|
# http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
|
|
||||||
|
cmake_minimum_required (VERSION 3.8)
|
||||||
|
project (DirectXTex_CMake LANGUAGES CXX)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||||
|
|
||||||
|
add_library (directxtex STATIC
|
||||||
|
BC.h
|
||||||
|
BCDirectCompute.h
|
||||||
|
d3dx12.h
|
||||||
|
DDS.h
|
||||||
|
DirectXTex.h
|
||||||
|
DirectXTexP.h
|
||||||
|
filters.h
|
||||||
|
scoped.h
|
||||||
|
BC.cpp
|
||||||
|
BC4BC5.cpp
|
||||||
|
BC6HBC7.cpp
|
||||||
|
BCDirectCompute.cpp
|
||||||
|
DirectXTexCompress.cpp
|
||||||
|
DirectXTexCompressGPU.cpp
|
||||||
|
DirectXTexConvert.cpp
|
||||||
|
DirectXTexD3D11.cpp
|
||||||
|
DirectXTexD3D12.cpp
|
||||||
|
DirectXTexDDS.cpp
|
||||||
|
DirectXTexFlipRotate.cpp
|
||||||
|
DirectXTexHDR.cpp
|
||||||
|
DirectXTexImage.cpp
|
||||||
|
DirectXTexMipmaps.cpp
|
||||||
|
DirectXTexMisc.cpp
|
||||||
|
DirectXTexNormalMaps.cpp
|
||||||
|
DirectXTexPMAlpha.cpp
|
||||||
|
DirectXTexResize.cpp
|
||||||
|
DirectXTexTGA.cpp
|
||||||
|
DirectXTexUtil.cpp
|
||||||
|
DirectXTexWIC.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_options( directxtex PRIVATE /fp:fast )
|
||||||
|
|
||||||
|
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||||
|
target_compile_options( directxtex PRIVATE -Wall -Wpedantic -Wextra )
|
||||||
|
if (${CMAKE_SIZEOF_VOID_P} EQUAL "4")
|
||||||
|
target_compile_options( directxtex PRIVATE /arch:SSE2 )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
|
||||||
|
target_compile_options( directxtex PRIVATE /Wall /permissive- /Zc:__cplusplus )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Windows 10 is used here to build the DirectX 12 code paths as well as 11
|
||||||
|
add_compile_definitions(_UNICODE UNICODE _WIN32_WINNT=0x0A00)
|
52
DirectXTex/CMakeSettings.json
Normal file
52
DirectXTex/CMakeSettings.json
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "x86-Clang-Debug",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "Debug",
|
||||||
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
|
"cmakeCommandArgs": "",
|
||||||
|
"buildCommandArgs": "-v",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"inheritEnvironments": [ "clang_cl_x86" ],
|
||||||
|
"variables": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x86-Clang-Release",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "RelWithDebInfo",
|
||||||
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
|
"cmakeCommandArgs": "",
|
||||||
|
"buildCommandArgs": "-v",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"inheritEnvironments": [ "clang_cl_x86" ],
|
||||||
|
"variables": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-Debug",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "Debug",
|
||||||
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
|
"cmakeCommandArgs": "",
|
||||||
|
"buildCommandArgs": "-v",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"inheritEnvironments": [ "clang_cl_x64" ],
|
||||||
|
"variables": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x64-Clang-Release",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "RelWithDebInfo",
|
||||||
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
|
"cmakeCommandArgs": "",
|
||||||
|
"buildCommandArgs": "-v",
|
||||||
|
"ctestCommandArgs": "",
|
||||||
|
"inheritEnvironments": [ "clang_cl_x64" ],
|
||||||
|
"variables": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -131,7 +131,7 @@ namespace DirectX
|
|||||||
// Helper for miscFlags
|
// Helper for miscFlags
|
||||||
|
|
||||||
bool __cdecl IsPMAlpha() const { return ((miscFlags2 & TEX_MISC2_ALPHA_MODE_MASK) == TEX_ALPHA_MODE_PREMULTIPLIED) != 0; }
|
bool __cdecl IsPMAlpha() const { return ((miscFlags2 & TEX_MISC2_ALPHA_MODE_MASK) == TEX_ALPHA_MODE_PREMULTIPLIED) != 0; }
|
||||||
void __cdecl SetAlphaMode(TEX_ALPHA_MODE mode) { miscFlags2 = (miscFlags2 & ~TEX_MISC2_ALPHA_MODE_MASK) | static_cast<uint32_t>(mode); }
|
void __cdecl SetAlphaMode(TEX_ALPHA_MODE mode) { miscFlags2 = (miscFlags2 & ~static_cast<uint32_t>(TEX_MISC2_ALPHA_MODE_MASK)) | static_cast<uint32_t>(mode); }
|
||||||
TEX_ALPHA_MODE __cdecl GetAlphaMode() const { return static_cast<TEX_ALPHA_MODE>(miscFlags2 & TEX_MISC2_ALPHA_MODE_MASK); }
|
TEX_ALPHA_MODE __cdecl GetAlphaMode() const { return static_cast<TEX_ALPHA_MODE>(miscFlags2 & TEX_MISC2_ALPHA_MODE_MASK); }
|
||||||
// Helpers for miscFlags2
|
// Helpers for miscFlags2
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
@ -120,25 +120,25 @@ namespace
|
|||||||
|
|
||||||
ptrdiff_t bytesLeft = pEnd - sptr;
|
ptrdiff_t bytesLeft = pEnd - sptr;
|
||||||
assert(bytesLeft > 0);
|
assert(bytesLeft > 0);
|
||||||
size_t bytesToRead = std::min<size_t>(rowPitch, bytesLeft);
|
size_t bytesToRead = std::min<size_t>(rowPitch, static_cast<size_t>(bytesLeft));
|
||||||
if (!_LoadScanline(&temp[0], pw, sptr, bytesToRead, format))
|
if (!_LoadScanline(&temp[0], pw, sptr, bytesToRead, format))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
if (ph > 1)
|
if (ph > 1)
|
||||||
{
|
{
|
||||||
bytesToRead = std::min<size_t>(rowPitch, bytesLeft - rowPitch);
|
bytesToRead = std::min<size_t>(rowPitch, static_cast<size_t>(bytesLeft) - rowPitch);
|
||||||
if (!_LoadScanline(&temp[4], pw, sptr + rowPitch, bytesToRead, format))
|
if (!_LoadScanline(&temp[4], pw, sptr + rowPitch, bytesToRead, format))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
if (ph > 2)
|
if (ph > 2)
|
||||||
{
|
{
|
||||||
bytesToRead = std::min<size_t>(rowPitch, bytesLeft - rowPitch * 2);
|
bytesToRead = std::min<size_t>(rowPitch, static_cast<size_t>(bytesLeft) - rowPitch * 2);
|
||||||
if (!_LoadScanline(&temp[8], pw, sptr + rowPitch * 2, bytesToRead, format))
|
if (!_LoadScanline(&temp[8], pw, sptr + rowPitch * 2, bytesToRead, format))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
if (ph > 3)
|
if (ph > 3)
|
||||||
{
|
{
|
||||||
bytesToRead = std::min<size_t>(rowPitch, bytesLeft - rowPitch * 3);
|
bytesToRead = std::min<size_t>(rowPitch, static_cast<size_t>(bytesLeft) - rowPitch * 3);
|
||||||
if (!_LoadScanline(&temp[12], pw, sptr + rowPitch * 3, bytesToRead, format))
|
if (!_LoadScanline(&temp[12], pw, sptr + rowPitch * 3, bytesToRead, format))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
@ -260,7 +260,7 @@ namespace
|
|||||||
|
|
||||||
ptrdiff_t bytesLeft = pEnd - pSrc;
|
ptrdiff_t bytesLeft = pEnd - pSrc;
|
||||||
assert(bytesLeft > 0);
|
assert(bytesLeft > 0);
|
||||||
size_t bytesToRead = std::min<size_t>(rowPitch, bytesLeft);
|
size_t bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft));
|
||||||
|
|
||||||
__declspec(align(16)) XMVECTOR temp[16];
|
__declspec(align(16)) XMVECTOR temp[16];
|
||||||
if (!_LoadScanline(&temp[0], pw, pSrc, bytesToRead, format))
|
if (!_LoadScanline(&temp[0], pw, pSrc, bytesToRead, format))
|
||||||
@ -268,19 +268,19 @@ namespace
|
|||||||
|
|
||||||
if (ph > 1)
|
if (ph > 1)
|
||||||
{
|
{
|
||||||
bytesToRead = std::min<size_t>(rowPitch, bytesLeft - rowPitch);
|
bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft - rowPitch));
|
||||||
if (!_LoadScanline(&temp[4], pw, pSrc + rowPitch, bytesToRead, format))
|
if (!_LoadScanline(&temp[4], pw, pSrc + rowPitch, bytesToRead, format))
|
||||||
fail = true;
|
fail = true;
|
||||||
|
|
||||||
if (ph > 2)
|
if (ph > 2)
|
||||||
{
|
{
|
||||||
bytesToRead = std::min<size_t>(rowPitch, bytesLeft - rowPitch * 2);
|
bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft - rowPitch * 2));
|
||||||
if (!_LoadScanline(&temp[8], pw, pSrc + rowPitch * 2, bytesToRead, format))
|
if (!_LoadScanline(&temp[8], pw, pSrc + rowPitch * 2, bytesToRead, format))
|
||||||
fail = true;
|
fail = true;
|
||||||
|
|
||||||
if (ph > 3)
|
if (ph > 3)
|
||||||
{
|
{
|
||||||
bytesToRead = std::min<size_t>(rowPitch, bytesLeft - rowPitch * 3);
|
bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft - rowPitch * 3));
|
||||||
if (!_LoadScanline(&temp[12], pw, pSrc + rowPitch * 3, bytesToRead, format))
|
if (!_LoadScanline(&temp[12], pw, pSrc + rowPitch * 3, bytesToRead, format))
|
||||||
fail = true;
|
fail = true;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
#include "BCDirectCompute.h"
|
#include "BCDirectCompute.h"
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
using namespace DirectX::PackedVector;
|
using namespace DirectX::PackedVector;
|
||||||
@ -392,7 +392,7 @@ void DirectX::_CopyScanline(
|
|||||||
size_t size = std::min<size_t>(outSize, inSize);
|
size_t size = std::min<size_t>(outSize, inSize);
|
||||||
for (size_t count = 0; count < (size - 1); count += 2)
|
for (size_t count = 0; count < (size - 1); count += 2)
|
||||||
{
|
{
|
||||||
*(dPtr++) = *(sPtr++) | 0x8000;
|
*(dPtr++) = uint16_t(*(sPtr++) | 0x8000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,7 +422,7 @@ void DirectX::_CopyScanline(
|
|||||||
size_t size = std::min<size_t>(outSize, inSize);
|
size_t size = std::min<size_t>(outSize, inSize);
|
||||||
for (size_t count = 0; count < (size - 1); count += 2)
|
for (size_t count = 0; count < (size - 1); count += 2)
|
||||||
{
|
{
|
||||||
*(dPtr++) = *(sPtr++) | 0xF000;
|
*(dPtr++) = uint16_t(*(sPtr++) | 0xF000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -644,9 +644,9 @@ bool DirectX::_ExpandScanline(
|
|||||||
{
|
{
|
||||||
uint16_t t = *(sPtr++);
|
uint16_t t = *(sPtr++);
|
||||||
|
|
||||||
uint32_t t1 = ((t & 0xf800) >> 8) | ((t & 0xe000) >> 13);
|
uint32_t t1 = uint32_t(((t & 0xf800) >> 8) | ((t & 0xe000) >> 13));
|
||||||
uint32_t t2 = ((t & 0x07e0) << 5) | ((t & 0x0600) >> 5);
|
uint32_t t2 = uint32_t(((t & 0x07e0) << 5) | ((t & 0x0600) >> 5));
|
||||||
uint32_t t3 = ((t & 0x001f) << 19) | ((t & 0x001c) << 14);
|
uint32_t t3 = uint32_t(((t & 0x001f) << 19) | ((t & 0x001c) << 14));
|
||||||
|
|
||||||
*(dPtr++) = t1 | t2 | t3 | 0xff000000;
|
*(dPtr++) = t1 | t2 | t3 | 0xff000000;
|
||||||
}
|
}
|
||||||
@ -668,9 +668,9 @@ bool DirectX::_ExpandScanline(
|
|||||||
{
|
{
|
||||||
uint16_t t = *(sPtr++);
|
uint16_t t = *(sPtr++);
|
||||||
|
|
||||||
uint32_t t1 = ((t & 0x7c00) >> 7) | ((t & 0x7000) >> 12);
|
uint32_t t1 = uint32_t(((t & 0x7c00) >> 7) | ((t & 0x7000) >> 12));
|
||||||
uint32_t t2 = ((t & 0x03e0) << 6) | ((t & 0x0380) << 1);
|
uint32_t t2 = uint32_t(((t & 0x03e0) << 6) | ((t & 0x0380) << 1));
|
||||||
uint32_t t3 = ((t & 0x001f) << 19) | ((t & 0x001c) << 14);
|
uint32_t t3 = uint32_t(((t & 0x001f) << 19) | ((t & 0x001c) << 14));
|
||||||
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : ((t & 0x8000) ? 0xff000000 : 0);
|
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : ((t & 0x8000) ? 0xff000000 : 0);
|
||||||
|
|
||||||
*(dPtr++) = t1 | t2 | t3 | ta;
|
*(dPtr++) = t1 | t2 | t3 | ta;
|
||||||
@ -693,10 +693,10 @@ bool DirectX::_ExpandScanline(
|
|||||||
{
|
{
|
||||||
uint16_t t = *(sPtr++);
|
uint16_t t = *(sPtr++);
|
||||||
|
|
||||||
uint32_t t1 = ((t & 0x0f00) >> 4) | ((t & 0x0f00) >> 8);
|
uint32_t t1 = uint32_t(((t & 0x0f00) >> 4) | ((t & 0x0f00) >> 8));
|
||||||
uint32_t t2 = ((t & 0x00f0) << 8) | ((t & 0x00f0) << 4);
|
uint32_t t2 = uint32_t(((t & 0x00f0) << 8) | ((t & 0x00f0) << 4));
|
||||||
uint32_t t3 = ((t & 0x000f) << 20) | ((t & 0x000f) << 16);
|
uint32_t t3 = uint32_t(((t & 0x000f) << 20) | ((t & 0x000f) << 16));
|
||||||
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : (((t & 0xf000) << 16) | ((t & 0xf000) << 12));
|
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : uint32_t(((t & 0xf000) << 16) | ((t & 0xf000) << 12));
|
||||||
|
|
||||||
*(dPtr++) = t1 | t2 | t3 | ta;
|
*(dPtr++) = t1 | t2 | t3 | ta;
|
||||||
}
|
}
|
||||||
@ -1348,7 +1348,7 @@ _Use_decl_annotations_ bool DirectX::_LoadScanline(
|
|||||||
int64_t u = int64_t(sPtr->x) - 32768;
|
int64_t u = int64_t(sPtr->x) - 32768;
|
||||||
int64_t y = int64_t(sPtr->y) - 4096;
|
int64_t y = int64_t(sPtr->y) - 4096;
|
||||||
int64_t v = int64_t(sPtr->z) - 32768;
|
int64_t v = int64_t(sPtr->z) - 32768;
|
||||||
unsigned int a = sPtr->w;
|
auto a = static_cast<int>(sPtr->w);
|
||||||
++sPtr;
|
++sPtr;
|
||||||
|
|
||||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578.aspx
|
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578.aspx
|
||||||
@ -2075,7 +2075,7 @@ bool DirectX::_StoreScanline(
|
|||||||
XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*sPtr++);
|
XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*sPtr++);
|
||||||
v = XMVectorMultiply(v, s_Scale);
|
v = XMVectorMultiply(v, s_Scale);
|
||||||
XMStoreU555(dPtr, v);
|
XMStoreU555(dPtr, v);
|
||||||
dPtr->w = (XMVectorGetW(v) > threshold) ? 1 : 0;
|
dPtr->w = (XMVectorGetW(v) > threshold) ? 1u : 0u;
|
||||||
++dPtr;
|
++dPtr;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -2774,7 +2774,7 @@ bool DirectX::_StoreScanlineLinear(
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// can't treat A8, XR, Depth, SNORM, UINT, or SINT as sRGB
|
// can't treat A8, XR, Depth, SNORM, UINT, or SINT as sRGB
|
||||||
flags &= ~TEX_FILTER_SRGB;
|
flags &= ~static_cast<uint32_t>(TEX_FILTER_SRGB);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2849,7 +2849,7 @@ bool DirectX::_LoadScanlineLinear(
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// can't treat A8, XR, Depth, SNORM, UINT, or SINT as sRGB
|
// can't treat A8, XR, Depth, SNORM, UINT, or SINT as sRGB
|
||||||
flags &= ~TEX_FILTER_SRGB;
|
flags &= ~static_cast<uint32_t>(TEX_FILTER_SRGB);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3060,7 +3060,7 @@ void DirectX::_ConvertScanline(
|
|||||||
|
|
||||||
case DXGI_FORMAT_A8_UNORM:
|
case DXGI_FORMAT_A8_UNORM:
|
||||||
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
|
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
|
||||||
flags &= ~TEX_FILTER_SRGB_IN;
|
flags &= ~static_cast<uint32_t>(TEX_FILTER_SRGB_IN);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -3081,7 +3081,7 @@ void DirectX::_ConvertScanline(
|
|||||||
|
|
||||||
case DXGI_FORMAT_A8_UNORM:
|
case DXGI_FORMAT_A8_UNORM:
|
||||||
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
|
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
|
||||||
flags &= ~TEX_FILTER_SRGB_OUT;
|
flags &= ~static_cast<uint32_t>(TEX_FILTER_SRGB_OUT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -3090,7 +3090,7 @@ void DirectX::_ConvertScanline(
|
|||||||
|
|
||||||
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))
|
||||||
{
|
{
|
||||||
flags &= ~(TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT);
|
flags &= ~static_cast<uint32_t>(TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sRGB input processing (sRGB -> Linear RGB)
|
// sRGB input processing (sRGB -> Linear RGB)
|
||||||
@ -3255,7 +3255,12 @@ void DirectX::_ConvertScanline(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
__fallthrough;
|
__fallthrough;
|
||||||
|
#endif
|
||||||
|
#ifdef __clang__
|
||||||
|
[[clang::fallthrough]];
|
||||||
|
#endif
|
||||||
|
|
||||||
case TEX_FILTER_RGB_COPY_RED:
|
case TEX_FILTER_RGB_COPY_RED:
|
||||||
{
|
{
|
||||||
@ -3539,7 +3544,12 @@ void DirectX::_ConvertScanline(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
__fallthrough;
|
__fallthrough;
|
||||||
|
#endif
|
||||||
|
#ifdef __clang__
|
||||||
|
[[clang::fallthrough]];
|
||||||
|
#endif
|
||||||
|
|
||||||
case TEX_FILTER_RGB_COPY_RED:
|
case TEX_FILTER_RGB_COPY_RED:
|
||||||
{
|
{
|
||||||
@ -3632,7 +3642,12 @@ void DirectX::_ConvertScanline(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
__fallthrough;
|
__fallthrough;
|
||||||
|
#endif
|
||||||
|
#ifdef __clang__
|
||||||
|
[[clang::fallthrough]];
|
||||||
|
#endif
|
||||||
|
|
||||||
case TEX_FILTER_RGB_COPY_RED:
|
case TEX_FILTER_RGB_COPY_RED:
|
||||||
// Leave data unchanged and the store will handle this...
|
// Leave data unchanged and the store will handle this...
|
||||||
@ -3768,10 +3783,10 @@ namespace
|
|||||||
\
|
\
|
||||||
auto dPtr = &dest[ index ]; \
|
auto dPtr = &dest[ index ]; \
|
||||||
if (dPtr >= ePtr) break; \
|
if (dPtr >= ePtr) break; \
|
||||||
dPtr->x = static_cast<itype>(tmp.x) & mask; \
|
dPtr->x = itype(static_cast<itype>(tmp.x) & mask); \
|
||||||
dPtr->y = static_cast<itype>(tmp.y) & mask; \
|
dPtr->y = itype(static_cast<itype>(tmp.y) & mask); \
|
||||||
dPtr->z = static_cast<itype>(tmp.z) & mask; \
|
dPtr->z = itype(static_cast<itype>(tmp.z) & mask); \
|
||||||
dPtr->w = static_cast<itype>(tmp.w) & mask; \
|
dPtr->w = itype(static_cast<itype>(tmp.w) & mask); \
|
||||||
} \
|
} \
|
||||||
return true; \
|
return true; \
|
||||||
} \
|
} \
|
||||||
@ -3823,8 +3838,8 @@ namespace
|
|||||||
\
|
\
|
||||||
auto dPtr = &dest[ index ]; \
|
auto dPtr = &dest[ index ]; \
|
||||||
if (dPtr >= ePtr) break; \
|
if (dPtr >= ePtr) break; \
|
||||||
dPtr->x = static_cast<itype>(tmp.x) & mask; \
|
dPtr->x = itype(static_cast<itype>(tmp.x) & mask); \
|
||||||
dPtr->y = static_cast<itype>(tmp.y) & mask; \
|
dPtr->y = itype(static_cast<itype>(tmp.y) & mask); \
|
||||||
} \
|
} \
|
||||||
return true; \
|
return true; \
|
||||||
} \
|
} \
|
||||||
@ -3873,7 +3888,7 @@ namespace
|
|||||||
\
|
\
|
||||||
auto dPtr = &dest[ index ]; \
|
auto dPtr = &dest[ index ]; \
|
||||||
if (dPtr >= ePtr) break; \
|
if (dPtr >= ePtr) break; \
|
||||||
*dPtr = static_cast<type>((selectw) ? XMVectorGetW(target) : XMVectorGetX(target)) & mask; \
|
*dPtr = type(static_cast<type>((selectw) ? XMVectorGetW(target) : XMVectorGetX(target)) & mask); \
|
||||||
} \
|
} \
|
||||||
return true; \
|
return true; \
|
||||||
} \
|
} \
|
||||||
@ -4004,9 +4019,9 @@ bool DirectX::_StoreScanlineDither(
|
|||||||
|
|
||||||
auto dPtr = &dest[index];
|
auto dPtr = &dest[index];
|
||||||
if (dPtr >= ePtr) break;
|
if (dPtr >= ePtr) break;
|
||||||
dPtr->x = static_cast<uint16_t>(tmp.x) & 0x3FF;
|
dPtr->x = uint16_t(static_cast<uint16_t>(tmp.x) & 0x3FF);
|
||||||
dPtr->y = static_cast<uint16_t>(tmp.y) & 0x3FF;
|
dPtr->y = uint16_t(static_cast<uint16_t>(tmp.y) & 0x3FF);
|
||||||
dPtr->z = static_cast<uint16_t>(tmp.z) & 0x3FF;
|
dPtr->z = uint16_t(static_cast<uint16_t>(tmp.z) & 0x3FF);
|
||||||
dPtr->w = static_cast<uint16_t>(tmp.w);
|
dPtr->w = static_cast<uint16_t>(tmp.w);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -4170,9 +4185,9 @@ bool DirectX::_StoreScanlineDither(
|
|||||||
|
|
||||||
auto dPtr = &dest[index];
|
auto dPtr = &dest[index];
|
||||||
if (dPtr >= ePtr) break;
|
if (dPtr >= ePtr) break;
|
||||||
dPtr->x = static_cast<uint16_t>(tmp.x) & 0x1F;
|
dPtr->x = uint16_t(static_cast<uint16_t>(tmp.x) & 0x1F);
|
||||||
dPtr->y = static_cast<uint16_t>(tmp.y) & 0x3F;
|
dPtr->y = uint16_t(static_cast<uint16_t>(tmp.y) & 0x3F);
|
||||||
dPtr->z = static_cast<uint16_t>(tmp.z) & 0x1F;
|
dPtr->z = uint16_t(static_cast<uint16_t>(tmp.z) & 0x1F);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -4219,10 +4234,10 @@ bool DirectX::_StoreScanlineDither(
|
|||||||
|
|
||||||
auto dPtr = &dest[index];
|
auto dPtr = &dest[index];
|
||||||
if (dPtr >= ePtr) break;
|
if (dPtr >= ePtr) break;
|
||||||
dPtr->x = static_cast<uint16_t>(tmp.x) & 0x1F;
|
dPtr->x = uint16_t(static_cast<uint16_t>(tmp.x) & 0x1F);
|
||||||
dPtr->y = static_cast<uint16_t>(tmp.y) & 0x1F;
|
dPtr->y = uint16_t(static_cast<uint16_t>(tmp.y) & 0x1F);
|
||||||
dPtr->z = static_cast<uint16_t>(tmp.z) & 0x1F;
|
dPtr->z = uint16_t(static_cast<uint16_t>(tmp.z) & 0x1F);
|
||||||
dPtr->w = (XMVectorGetW(target) > threshold) ? 1 : 0;
|
dPtr->w = (XMVectorGetW(target) > threshold) ? 1u : 0u;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -4274,9 +4289,9 @@ bool DirectX::_StoreScanlineDither(
|
|||||||
|
|
||||||
auto dPtr = &dest[index];
|
auto dPtr = &dest[index];
|
||||||
if (dPtr >= ePtr) break;
|
if (dPtr >= ePtr) break;
|
||||||
dPtr->x = static_cast<uint8_t>(tmp.x) & 0xFF;
|
dPtr->x = uint8_t(static_cast<uint8_t>(tmp.x) & 0xFF);
|
||||||
dPtr->y = static_cast<uint8_t>(tmp.y) & 0xFF;
|
dPtr->y = uint8_t(static_cast<uint8_t>(tmp.y) & 0xFF);
|
||||||
dPtr->z = static_cast<uint8_t>(tmp.z) & 0xFF;
|
dPtr->z = uint8_t(static_cast<uint8_t>(tmp.z) & 0xFF);
|
||||||
dPtr->w = 0;
|
dPtr->w = 0;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -4487,7 +4502,7 @@ namespace
|
|||||||
|
|
||||||
if ((filter & (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) == (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT))
|
if ((filter & (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) == (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT))
|
||||||
{
|
{
|
||||||
filter &= ~(TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT);
|
filter &= ~static_cast<uint32_t>(TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD wicsrgb = _CheckWICColorSpace(pfGUID, targetGUID);
|
DWORD wicsrgb = _CheckWICColorSpace(pfGUID, targetGUID);
|
||||||
@ -4547,7 +4562,7 @@ namespace
|
|||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
hr = FC->Initialize(source.Get(), targetGUID, _GetWICDither(filter), nullptr, threshold * 100.0, WICBitmapPaletteTypeMedianCut);
|
hr = FC->Initialize(source.Get(), targetGUID, _GetWICDither(filter), nullptr, static_cast<double>(threshold) * 100.0, WICBitmapPaletteTypeMedianCut);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
#if !defined(_XBOX_ONE) || !defined(_TITLE)
|
#if !defined(_XBOX_ONE) || !defined(_TITLE)
|
||||||
#include <d3d10.h>
|
#include <d3d10.h>
|
||||||
@ -553,7 +553,7 @@ HRESULT DirectX::CreateTextureEx(
|
|||||||
desc.Usage = usage;
|
desc.Usage = usage;
|
||||||
desc.BindFlags = bindFlags;
|
desc.BindFlags = bindFlags;
|
||||||
desc.CPUAccessFlags = cpuAccessFlags;
|
desc.CPUAccessFlags = cpuAccessFlags;
|
||||||
desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE;
|
desc.MiscFlags = miscFlags & ~static_cast<uint32_t>(D3D11_RESOURCE_MISC_TEXTURECUBE);
|
||||||
|
|
||||||
hr = pDevice->CreateTexture1D(&desc, initData.get(), reinterpret_cast<ID3D11Texture1D**>(ppResource));
|
hr = pDevice->CreateTexture1D(&desc, initData.get(), reinterpret_cast<ID3D11Texture1D**>(ppResource));
|
||||||
}
|
}
|
||||||
@ -575,7 +575,7 @@ HRESULT DirectX::CreateTextureEx(
|
|||||||
if (metadata.IsCubemap())
|
if (metadata.IsCubemap())
|
||||||
desc.MiscFlags = miscFlags | D3D11_RESOURCE_MISC_TEXTURECUBE;
|
desc.MiscFlags = miscFlags | D3D11_RESOURCE_MISC_TEXTURECUBE;
|
||||||
else
|
else
|
||||||
desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE;
|
desc.MiscFlags = miscFlags & ~static_cast<uint32_t>(D3D11_RESOURCE_MISC_TEXTURECUBE);
|
||||||
|
|
||||||
hr = pDevice->CreateTexture2D(&desc, initData.get(), reinterpret_cast<ID3D11Texture2D**>(ppResource));
|
hr = pDevice->CreateTexture2D(&desc, initData.get(), reinterpret_cast<ID3D11Texture2D**>(ppResource));
|
||||||
}
|
}
|
||||||
@ -592,7 +592,7 @@ HRESULT DirectX::CreateTextureEx(
|
|||||||
desc.Usage = usage;
|
desc.Usage = usage;
|
||||||
desc.BindFlags = bindFlags;
|
desc.BindFlags = bindFlags;
|
||||||
desc.CPUAccessFlags = cpuAccessFlags;
|
desc.CPUAccessFlags = cpuAccessFlags;
|
||||||
desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE;
|
desc.MiscFlags = miscFlags & ~static_cast<uint32_t>(D3D11_RESOURCE_MISC_TEXTURECUBE);
|
||||||
|
|
||||||
hr = pDevice->CreateTexture3D(&desc, initData.get(), reinterpret_cast<ID3D11Texture3D**>(ppResource));
|
hr = pDevice->CreateTexture3D(&desc, initData.get(), reinterpret_cast<ID3D11Texture3D**>(ppResource));
|
||||||
}
|
}
|
||||||
@ -883,7 +883,7 @@ HRESULT DirectX::CaptureTexture(
|
|||||||
mdata.depth = 1;
|
mdata.depth = 1;
|
||||||
mdata.arraySize = desc.ArraySize;
|
mdata.arraySize = desc.ArraySize;
|
||||||
mdata.mipLevels = desc.MipLevels;
|
mdata.mipLevels = desc.MipLevels;
|
||||||
mdata.miscFlags = (desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE) ? TEX_MISC_TEXTURECUBE : 0;
|
mdata.miscFlags = (desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE) ? TEX_MISC_TEXTURECUBE : 0u;
|
||||||
mdata.miscFlags2 = 0;
|
mdata.miscFlags2 = 0;
|
||||||
mdata.format = desc.Format;
|
mdata.format = desc.Format;
|
||||||
mdata.dimension = TEX_DIMENSION_TEXTURE2D;
|
mdata.dimension = TEX_DIMENSION_TEXTURE2D;
|
||||||
|
@ -9,7 +9,12 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wsign-conversion"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_XBOX_ONE) && defined(_TITLE)
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
#include "d3dx12_x.h"
|
#include "d3dx12_x.h"
|
||||||
@ -18,6 +23,10 @@
|
|||||||
#include "d3dx12.h"
|
#include "d3dx12.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef IID_GRAPHICS_PPV_ARGS
|
#ifndef IID_GRAPHICS_PPV_ARGS
|
||||||
#define IID_GRAPHICS_PPV_ARGS(x) IID_PPV_ARGS(x)
|
#define IID_GRAPHICS_PPV_ARGS(x) IID_PPV_ARGS(x)
|
||||||
#endif
|
#endif
|
||||||
@ -31,7 +40,7 @@ static_assert(static_cast<int>(TEX_DIMENSION_TEXTURE3D) == static_cast<int>(D3D1
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
template<typename T> void AdjustPlaneResource(
|
template<typename T, typename PT> void AdjustPlaneResource(
|
||||||
_In_ DXGI_FORMAT fmt,
|
_In_ DXGI_FORMAT fmt,
|
||||||
_In_ size_t height,
|
_In_ size_t height,
|
||||||
_In_ size_t slicePlane,
|
_In_ size_t slicePlane,
|
||||||
@ -48,13 +57,13 @@ namespace
|
|||||||
if (!slicePlane)
|
if (!slicePlane)
|
||||||
{
|
{
|
||||||
// Plane 0
|
// Plane 0
|
||||||
res.SlicePitch = res.RowPitch * height;
|
res.SlicePitch = res.RowPitch * static_cast<PT>(height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Plane 1
|
// Plane 1
|
||||||
res.pData = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(res.pData) + res.RowPitch * height);
|
res.pData = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(res.pData) + res.RowPitch * PT(height));
|
||||||
res.SlicePitch = res.RowPitch * ((height + 1) >> 1);
|
res.SlicePitch = res.RowPitch * static_cast<PT>((height + 1) >> 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -62,14 +71,14 @@ namespace
|
|||||||
if (!slicePlane)
|
if (!slicePlane)
|
||||||
{
|
{
|
||||||
// Plane 0
|
// Plane 0
|
||||||
res.SlicePitch = res.RowPitch * height;
|
res.SlicePitch = res.RowPitch * static_cast<PT>(height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Plane 1
|
// Plane 1
|
||||||
res.pData = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(res.pData) + res.RowPitch * height);
|
res.pData = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(res.pData) + res.RowPitch * PT(height));
|
||||||
res.RowPitch = (res.RowPitch >> 1);
|
res.RowPitch = (res.RowPitch >> 1);
|
||||||
res.SlicePitch = res.RowPitch * height;
|
res.SlicePitch = res.RowPitch * static_cast<PT>(height);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -132,7 +141,7 @@ namespace
|
|||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
numberOfResources = (desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D)
|
numberOfResources = (desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D)
|
||||||
? 1 : desc.DepthOrArraySize;
|
? 1u : desc.DepthOrArraySize;
|
||||||
numberOfResources *= desc.MipLevels;
|
numberOfResources *= desc.MipLevels;
|
||||||
numberOfResources *= numberOfPlanes;
|
numberOfResources *= numberOfPlanes;
|
||||||
|
|
||||||
@ -576,7 +585,7 @@ HRESULT DirectX::PrepareUpload(
|
|||||||
static_cast<LONG_PTR>(img.slicePitch)
|
static_cast<LONG_PTR>(img.slicePitch)
|
||||||
};
|
};
|
||||||
|
|
||||||
AdjustPlaneResource(metadata.format, img.height, plane, res);
|
AdjustPlaneResource<D3D12_SUBRESOURCE_DATA, intptr_t>(metadata.format, img.height, plane, res);
|
||||||
|
|
||||||
subresources.emplace_back(res);
|
subresources.emplace_back(res);
|
||||||
|
|
||||||
@ -613,7 +622,7 @@ HRESULT DirectX::PrepareUpload(
|
|||||||
static_cast<LONG_PTR>(img.slicePitch)
|
static_cast<LONG_PTR>(img.slicePitch)
|
||||||
};
|
};
|
||||||
|
|
||||||
AdjustPlaneResource(metadata.format, img.height, plane, res);
|
AdjustPlaneResource<D3D12_SUBRESOURCE_DATA, intptr_t>(metadata.format, img.height, plane, res);
|
||||||
|
|
||||||
subresources.emplace_back(res);
|
subresources.emplace_back(res);
|
||||||
}
|
}
|
||||||
@ -696,7 +705,7 @@ HRESULT DirectX::CaptureTexture(
|
|||||||
mdata.depth = 1;
|
mdata.depth = 1;
|
||||||
mdata.arraySize = desc.DepthOrArraySize;
|
mdata.arraySize = desc.DepthOrArraySize;
|
||||||
mdata.mipLevels = desc.MipLevels;
|
mdata.mipLevels = desc.MipLevels;
|
||||||
mdata.miscFlags = isCubeMap ? TEX_MISC_TEXTURECUBE : 0;
|
mdata.miscFlags = isCubeMap ? TEX_MISC_TEXTURECUBE : 0u;
|
||||||
mdata.miscFlags2 = 0;
|
mdata.miscFlags2 = 0;
|
||||||
mdata.format = desc.Format;
|
mdata.format = desc.Format;
|
||||||
mdata.dimension = TEX_DIMENSION_TEXTURE2D;
|
mdata.dimension = TEX_DIMENSION_TEXTURE2D;
|
||||||
@ -776,7 +785,7 @@ HRESULT DirectX::CaptureTexture(
|
|||||||
|
|
||||||
D3D12_MEMCPY_DEST destData = { img->pixels, img->rowPitch, img->slicePitch };
|
D3D12_MEMCPY_DEST destData = { img->pixels, img->rowPitch, img->slicePitch };
|
||||||
|
|
||||||
AdjustPlaneResource(img->format, img->height, plane, destData);
|
AdjustPlaneResource<D3D12_MEMCPY_DEST, uintptr_t>(img->format, img->height, plane, destData);
|
||||||
|
|
||||||
D3D12_SUBRESOURCE_DATA srcData =
|
D3D12_SUBRESOURCE_DATA srcData =
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
#include "DDS.h"
|
#include "DDS.h"
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ namespace
|
|||||||
|
|
||||||
static_assert(static_cast<int>(TEX_MISC_TEXTURECUBE) == static_cast<int>(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 & ~static_cast<uint32_t>(TEX_MISC_TEXTURECUBE);
|
||||||
|
|
||||||
switch (d3d10ext->resourceDimension)
|
switch (d3d10ext->resourceDimension)
|
||||||
{
|
{
|
||||||
@ -722,7 +722,7 @@ HRESULT DirectX::_EncodeDDSHeader(
|
|||||||
|
|
||||||
static_assert(static_cast<int>(TEX_MISC_TEXTURECUBE) == static_cast<int>(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 & ~static_cast<uint32_t>(TEX_MISC_TEXTURECUBE);
|
||||||
|
|
||||||
if (metadata.miscFlags & TEX_MISC_TEXTURECUBE)
|
if (metadata.miscFlags & TEX_MISC_TEXTURECUBE)
|
||||||
{
|
{
|
||||||
@ -837,9 +837,9 @@ namespace
|
|||||||
for (size_t ocount = 0, icount = 0; ((icount < (inSize - 2)) && (ocount < (outSize - 3))); icount += 3, ocount += 4)
|
for (size_t ocount = 0, icount = 0; ((icount < (inSize - 2)) && (ocount < (outSize - 3))); icount += 3, ocount += 4)
|
||||||
{
|
{
|
||||||
// 24bpp Direct3D 9 files are actually BGR, so need to swizzle as well
|
// 24bpp Direct3D 9 files are actually BGR, so need to swizzle as well
|
||||||
uint32_t t1 = (*(sPtr) << 16);
|
uint32_t t1 = uint32_t(*(sPtr) << 16);
|
||||||
uint32_t t2 = (*(sPtr + 1) << 8);
|
uint32_t t2 = uint32_t(*(sPtr + 1) << 8);
|
||||||
uint32_t t3 = *(sPtr + 2);
|
uint32_t t3 = uint32_t(*(sPtr + 2));
|
||||||
|
|
||||||
*(dPtr++) = t1 | t2 | t3 | 0xff000000;
|
*(dPtr++) = t1 | t2 | t3 | 0xff000000;
|
||||||
sPtr += 3;
|
sPtr += 3;
|
||||||
@ -862,9 +862,9 @@ namespace
|
|||||||
{
|
{
|
||||||
uint8_t t = *(sPtr++);
|
uint8_t t = *(sPtr++);
|
||||||
|
|
||||||
uint32_t t1 = (t & 0xe0) | ((t & 0xe0) >> 3) | ((t & 0xc0) >> 6);
|
uint32_t t1 = uint32_t((t & 0xe0) | ((t & 0xe0) >> 3) | ((t & 0xc0) >> 6));
|
||||||
uint32_t t2 = ((t & 0x1c) << 11) | ((t & 0x1c) << 8) | ((t & 0x18) << 5);
|
uint32_t t2 = uint32_t(((t & 0x1c) << 11) | ((t & 0x1c) << 8) | ((t & 0x18) << 5));
|
||||||
uint32_t t3 = ((t & 0x03) << 22) | ((t & 0x03) << 20) | ((t & 0x03) << 18) | ((t & 0x03) << 16);
|
uint32_t t3 = uint32_t(((t & 0x03) << 22) | ((t & 0x03) << 20) | ((t & 0x03) << 18) | ((t & 0x03) << 16));
|
||||||
|
|
||||||
*(dPtr++) = t1 | t2 | t3 | 0xff000000;
|
*(dPtr++) = t1 | t2 | t3 | 0xff000000;
|
||||||
}
|
}
|
||||||
@ -911,10 +911,10 @@ namespace
|
|||||||
{
|
{
|
||||||
uint16_t t = *(sPtr++);
|
uint16_t t = *(sPtr++);
|
||||||
|
|
||||||
uint32_t t1 = (t & 0x00e0) | ((t & 0x00e0) >> 3) | ((t & 0x00c0) >> 6);
|
uint32_t t1 = uint32_t((t & 0x00e0) | ((t & 0x00e0) >> 3) | ((t & 0x00c0) >> 6));
|
||||||
uint32_t t2 = ((t & 0x001c) << 11) | ((t & 0x001c) << 8) | ((t & 0x0018) << 5);
|
uint32_t t2 = uint32_t(((t & 0x001c) << 11) | ((t & 0x001c) << 8) | ((t & 0x0018) << 5));
|
||||||
uint32_t t3 = ((t & 0x0003) << 22) | ((t & 0x0003) << 20) | ((t & 0x0003) << 18) | ((t & 0x0003) << 16);
|
uint32_t t3 = uint32_t(((t & 0x0003) << 22) | ((t & 0x0003) << 20) | ((t & 0x0003) << 18) | ((t & 0x0003) << 16));
|
||||||
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : ((t & 0xff00) << 16);
|
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : uint32_t((t & 0xff00) << 16);
|
||||||
|
|
||||||
*(dPtr++) = t1 | t2 | t3 | ta;
|
*(dPtr++) = t1 | t2 | t3 | ta;
|
||||||
}
|
}
|
||||||
@ -957,7 +957,7 @@ namespace
|
|||||||
uint16_t t = *(sPtr++);
|
uint16_t t = *(sPtr++);
|
||||||
|
|
||||||
uint32_t t1 = pal8[t & 0xff];
|
uint32_t t1 = pal8[t & 0xff];
|
||||||
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : ((t & 0xff00) << 16);
|
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : uint32_t((t & 0xff00) << 16);
|
||||||
|
|
||||||
*(dPtr++) = t1 | ta;
|
*(dPtr++) = t1 | ta;
|
||||||
}
|
}
|
||||||
@ -999,8 +999,8 @@ namespace
|
|||||||
{
|
{
|
||||||
uint8_t t = *(sPtr++);
|
uint8_t t = *(sPtr++);
|
||||||
|
|
||||||
uint32_t t1 = ((t & 0x0f) << 4) | (t & 0x0f);
|
uint32_t t1 = uint32_t(((t & 0x0f) << 4) | (t & 0x0f));
|
||||||
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : (((t & 0xf0) << 24) | ((t & 0xf0) << 20));
|
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : uint32_t(((t & 0xf0) << 24) | ((t & 0xf0) << 20));
|
||||||
|
|
||||||
*(dPtr++) = t1 | (t1 << 8) | (t1 << 16) | ta;
|
*(dPtr++) = t1 | (t1 << 8) | (t1 << 16) | ta;
|
||||||
}
|
}
|
||||||
@ -1024,12 +1024,12 @@ namespace
|
|||||||
|
|
||||||
for (size_t ocount = 0, icount = 0; ((icount < (inSize - 1)) && (ocount < (outSize - 3))); icount += 2, ocount += 4)
|
for (size_t ocount = 0, icount = 0; ((icount < (inSize - 1)) && (ocount < (outSize - 3))); icount += 2, ocount += 4)
|
||||||
{
|
{
|
||||||
uint16_t t = *(sPtr++);
|
uint32_t t = *(sPtr++);
|
||||||
|
|
||||||
uint32_t t1 = ((t & 0x0f00) >> 4) | ((t & 0x0f00) >> 8);
|
uint32_t t1 = uint32_t((t & 0x0f00) >> 4) | ((t & 0x0f00) >> 8);
|
||||||
uint32_t t2 = ((t & 0x00f0) << 8) | ((t & 0x00f0) << 4);
|
uint32_t t2 = uint32_t((t & 0x00f0) << 8) | ((t & 0x00f0) << 4);
|
||||||
uint32_t t3 = ((t & 0x000f) << 20) | ((t & 0x000f) << 16);
|
uint32_t t3 = uint32_t((t & 0x000f) << 20) | ((t & 0x000f) << 16);
|
||||||
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : (((t & 0xf000) << 16) | ((t & 0xf000) << 12));
|
uint32_t ta = uint32_t((flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : (((t & 0xf000) << 16) | ((t & 0xf000) << 12)));
|
||||||
|
|
||||||
*(dPtr++) = t1 | t2 | t3 | ta;
|
*(dPtr++) = t1 | t2 | t3 | ta;
|
||||||
}
|
}
|
||||||
@ -1097,10 +1097,10 @@ namespace
|
|||||||
{
|
{
|
||||||
uint16_t t = *(sPtr++);
|
uint16_t t = *(sPtr++);
|
||||||
|
|
||||||
uint32_t t1 = (t & 0xff);
|
uint32_t t1 = uint32_t(t & 0xff);
|
||||||
uint32_t t2 = (t1 << 8);
|
uint32_t t2 = uint32_t(t1 << 8);
|
||||||
uint32_t t3 = (t1 << 16);
|
uint32_t t3 = uint32_t(t1 << 16);
|
||||||
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : ((t & 0xff00) << 16);
|
uint32_t ta = (flags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : uint32_t((t & 0xff00) << 16);
|
||||||
|
|
||||||
*(dPtr++) = t1 | t2 | t3 | ta;
|
*(dPtr++) = t1 | t2 | t3 | ta;
|
||||||
}
|
}
|
||||||
@ -1184,7 +1184,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD tflags = (convFlags & CONV_FLAGS_NOALPHA) ? TEXP_SCANLINE_SETALPHA : 0;
|
DWORD tflags = (convFlags & CONV_FLAGS_NOALPHA) ? TEXP_SCANLINE_SETALPHA : 0u;
|
||||||
if (convFlags & CONV_FLAGS_SWIZZLE)
|
if (convFlags & CONV_FLAGS_SWIZZLE)
|
||||||
tflags |= TEXP_SCANLINE_LEGACY;
|
tflags |= TEXP_SCANLINE_LEGACY;
|
||||||
|
|
||||||
@ -1406,7 +1406,7 @@ namespace
|
|||||||
if (IsPlanar(metadata.format))
|
if (IsPlanar(metadata.format))
|
||||||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||||
|
|
||||||
DWORD tflags = (convFlags & CONV_FLAGS_NOALPHA) ? TEXP_SCANLINE_SETALPHA : 0;
|
DWORD tflags = (convFlags & CONV_FLAGS_NOALPHA) ? TEXP_SCANLINE_SETALPHA : 0u;
|
||||||
if (convFlags & CONV_FLAGS_SWIZZLE)
|
if (convFlags & CONV_FLAGS_SWIZZLE)
|
||||||
tflags |= TEXP_SCANLINE_LEGACY;
|
tflags |= TEXP_SCANLINE_LEGACY;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
using Microsoft::WRL::ComPtr;
|
using Microsoft::WRL::ComPtr;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// In theory HDR (RGBE) Radiance files can have any of the following data orientations
|
// In theory HDR (RGBE) Radiance files can have any of the following data orientations
|
||||||
@ -176,7 +176,7 @@ namespace
|
|||||||
strncpy_s(buff, info, std::min<size_t>(31, len));
|
strncpy_s(buff, info, std::min<size_t>(31, len));
|
||||||
|
|
||||||
auto newExposure = static_cast<float>(atof(buff));
|
auto newExposure = static_cast<float>(atof(buff));
|
||||||
if ((newExposure >= 1e-12) && (newExposure <= 1e12))
|
if ((newExposure >= 1e-12f) && (newExposure <= 1e12f))
|
||||||
{
|
{
|
||||||
// Note that we ignore strange exposure values (like EXPOSURE=0)
|
// Note that we ignore strange exposure values (like EXPOSURE=0)
|
||||||
exposure *= newExposure;
|
exposure *= newExposure;
|
||||||
@ -219,8 +219,8 @@ namespace
|
|||||||
{
|
{
|
||||||
// We only support the -Y +X orientation (see top of file)
|
// We only support the -Y +X orientation (see top of file)
|
||||||
return HRESULT_FROM_WIN32(
|
return HRESULT_FROM_WIN32(
|
||||||
((orientation[0] == '+' || orientation[0] == '-') && (orientation[1] == 'X' || orientation[1] == 'Y'))
|
static_cast<unsigned long>(((orientation[0] == '+' || orientation[0] == '-') && (orientation[1] == 'X' || orientation[1] == 'Y'))
|
||||||
? ERROR_NOT_SUPPORTED : ERROR_INVALID_DATA
|
? ERROR_NOT_SUPPORTED : ERROR_INVALID_DATA)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = info - static_cast<const char*>(pSource);
|
offset = size_t(info - static_cast<const char*>(pSource));
|
||||||
|
|
||||||
metadata.width = width;
|
metadata.width = width;
|
||||||
metadata.height = height;
|
metadata.height = height;
|
||||||
@ -291,7 +291,7 @@ namespace
|
|||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
inline void FloatToRGBE(_Out_writes_(width*4) uint8_t* pDestination, _In_reads_(width*fpp) const float* pSource, size_t width, _In_range_(3, 4) int fpp)
|
inline void FloatToRGBE(_Out_writes_(width*4) uint8_t* pDestination, _In_reads_(width*fpp) const float* pSource, size_t width, _In_range_(3, 4) int fpp)
|
||||||
{
|
{
|
||||||
auto ePtr = pSource + width * fpp;
|
auto ePtr = pSource + width * size_t(fpp);
|
||||||
|
|
||||||
for (size_t j = 0; j < width; ++j)
|
for (size_t j = 0; j < width; ++j)
|
||||||
{
|
{
|
||||||
@ -304,7 +304,7 @@ namespace
|
|||||||
const float max_xy = (r > g) ? r : g;
|
const float max_xy = (r > g) ? r : g;
|
||||||
float max_xyz = (max_xy > b) ? max_xy : b;
|
float max_xyz = (max_xy > b) ? max_xy : b;
|
||||||
|
|
||||||
if (max_xyz > 1e-32)
|
if (max_xyz > 1e-32f)
|
||||||
{
|
{
|
||||||
int e;
|
int e;
|
||||||
max_xyz = frexpf(max_xyz, &e) * 256.f / max_xyz;
|
max_xyz = frexpf(max_xyz, &e) * 256.f / max_xyz;
|
||||||
@ -317,7 +317,7 @@ namespace
|
|||||||
pDestination[0] = red;
|
pDestination[0] = red;
|
||||||
pDestination[1] = green;
|
pDestination[1] = green;
|
||||||
pDestination[2] = blue;
|
pDestination[2] = blue;
|
||||||
pDestination[3] = (red || green || blue) ? uint8_t(e & 0xff) : 0;
|
pDestination[3] = (red || green || blue) ? uint8_t(e & 0xff) : 0u;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -473,7 +473,7 @@ namespace
|
|||||||
if (encSize + 2 > rowPitch)
|
if (encSize + 2 > rowPitch)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
enc[0] = 128 + spanLen;
|
enc[0] = 128u + spanLen;
|
||||||
enc[1] = *spanPtr;
|
enc[1] = *spanPtr;
|
||||||
enc += 2;
|
enc += 2;
|
||||||
encSize += 2;
|
encSize += 2;
|
||||||
@ -953,7 +953,7 @@ HRESULT DirectX::SaveToHDRMemory(const Image& image, Blob& blob)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hr = blob.Trim(dPtr - static_cast<uint8_t*>(blob.GetBufferPointer()));
|
hr = blob.Trim(size_t(dPtr - static_cast<uint8_t*>(blob.GetBufferPointer())));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
blob.Release();
|
blob.Release();
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
namespace DirectX
|
namespace DirectX
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ HRESULT DirectX::CopyRectangle(
|
|||||||
if (((pSrc + copyW) > pEndSrc) || (pDest > pEndDest))
|
if (((pSrc + copyW) > pEndSrc) || (pDest > pEndDest))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
memcpy_s(pDest, pEndDest - pDest, pSrc, copyW);
|
memcpy_s(pDest, size_t(pEndDest - pDest), pSrc, copyW);
|
||||||
|
|
||||||
pSrc += srcImage.rowPitch;
|
pSrc += srcImage.rowPitch;
|
||||||
pDest += dstImage.rowPitch;
|
pDest += dstImage.rowPitch;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
|
|
||||||
|
@ -51,6 +51,24 @@
|
|||||||
// warning #161: unrecognized #pragma
|
// warning #161: unrecognized #pragma
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#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 "-Wglobal-constructors"
|
||||||
|
#pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
|
||||||
|
#pragma clang diagnostic ignored "-Wlanguage-extension-token"
|
||||||
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||||
|
#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
|
||||||
|
#pragma clang diagnostic ignored "-Wnested-anon-types"
|
||||||
|
#pragma clang diagnostic ignored "-Wreserved-id-macro"
|
||||||
|
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||||
|
#pragma clang diagnostic ignored "-Wtautological-type-limit-compare"
|
||||||
|
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||||
|
#endif
|
||||||
|
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4005)
|
#pragma warning(disable : 4005)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// The implementation here has the following limitations:
|
// The implementation here has the following limitations:
|
||||||
@ -373,7 +373,7 @@ namespace
|
|||||||
if (sPtr + 1 >= endPtr)
|
if (sPtr + 1 >= endPtr)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
auto t = static_cast<uint16_t>(unsigned(*sPtr) | (*(sPtr + 1u) << 8));
|
auto t = static_cast<uint16_t>(uint32_t(*sPtr) | uint32_t(*(sPtr + 1u) << 8));
|
||||||
if (t & 0x8000)
|
if (t & 0x8000)
|
||||||
nonzeroa = true;
|
nonzeroa = true;
|
||||||
sPtr += 2;
|
sPtr += 2;
|
||||||
@ -405,7 +405,7 @@ namespace
|
|||||||
if (x >= image->width)
|
if (x >= image->width)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
auto t = static_cast<uint16_t>(unsigned(*sPtr) | (*(sPtr + 1u) << 8));
|
auto t = static_cast<uint16_t>(uint32_t(*sPtr) | uint32_t(*(sPtr + 1u) << 8));
|
||||||
if (t & 0x8000)
|
if (t & 0x8000)
|
||||||
nonzeroa = true;
|
nonzeroa = true;
|
||||||
sPtr += 2;
|
sPtr += 2;
|
||||||
@ -462,7 +462,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
// BGR -> RGBA
|
// BGR -> RGBA
|
||||||
t = (*sPtr << 16) | (*(sPtr + 1) << 8) | (*(sPtr + 2)) | 0xFF000000;
|
t = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | 0xFF000000;
|
||||||
sPtr += 3;
|
sPtr += 3;
|
||||||
|
|
||||||
nonzeroa = true;
|
nonzeroa = true;
|
||||||
@ -475,7 +475,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
// BGRA -> RGBA
|
// BGRA -> RGBA
|
||||||
t = (*sPtr << 16) | (*(sPtr + 1) << 8) | (*(sPtr + 2)) | (*(sPtr + 3) << 24);
|
t = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | uint32_t(*(sPtr + 3) << 24);
|
||||||
|
|
||||||
if (*(sPtr + 3) > 0)
|
if (*(sPtr + 3) > 0)
|
||||||
nonzeroa = true;
|
nonzeroa = true;
|
||||||
@ -526,7 +526,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
// BGR -> RGBA
|
// BGR -> RGBA
|
||||||
*dPtr = (*sPtr << 16) | (*(sPtr + 1) << 8) | (*(sPtr + 2)) | 0xFF000000;
|
*dPtr = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | 0xFF000000;
|
||||||
sPtr += 3;
|
sPtr += 3;
|
||||||
|
|
||||||
nonzeroa = true;
|
nonzeroa = true;
|
||||||
@ -539,7 +539,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
// BGRA -> RGBA
|
// BGRA -> RGBA
|
||||||
*dPtr = (*sPtr << 16) | (*(sPtr + 1) << 8) | (*(sPtr + 2)) | (*(sPtr + 3) << 24);
|
*dPtr = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | uint32_t(*(sPtr + 3) << 24);
|
||||||
|
|
||||||
if (*(sPtr + 3) > 0)
|
if (*(sPtr + 3) > 0)
|
||||||
nonzeroa = true;
|
nonzeroa = true;
|
||||||
@ -652,7 +652,7 @@ namespace
|
|||||||
if (sPtr + 1 >= endPtr)
|
if (sPtr + 1 >= endPtr)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
auto t = static_cast<uint16_t>(unsigned(*sPtr) | (*(sPtr + 1u) << 8));
|
auto t = static_cast<uint16_t>(uint32_t(*sPtr) | uint32_t(*(sPtr + 1u) << 8));
|
||||||
sPtr += 2;
|
sPtr += 2;
|
||||||
*dPtr = t;
|
*dPtr = t;
|
||||||
|
|
||||||
@ -698,7 +698,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
// BGR -> RGBA
|
// BGR -> RGBA
|
||||||
*dPtr = (*sPtr << 16) | (*(sPtr + 1) << 8) | (*(sPtr + 2)) | 0xFF000000;
|
*dPtr = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | 0xFF000000;
|
||||||
sPtr += 3;
|
sPtr += 3;
|
||||||
|
|
||||||
nonzeroa = true;
|
nonzeroa = true;
|
||||||
@ -711,7 +711,7 @@ namespace
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
// BGRA -> RGBA
|
// BGRA -> RGBA
|
||||||
*dPtr = (*sPtr << 16) | (*(sPtr + 1) << 8) | (*(sPtr + 2)) | (*(sPtr + 3) << 24);
|
*dPtr = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | uint32_t(*(sPtr + 3) << 24);
|
||||||
|
|
||||||
if (*(sPtr + 3) > 0)
|
if (*(sPtr + 3) > 0)
|
||||||
nonzeroa = true;
|
nonzeroa = true;
|
||||||
|
@ -222,7 +222,7 @@ DWORD DirectX::_CheckWICColorSpace(_In_ const GUID& sourceGUID, _In_ const GUID&
|
|||||||
|
|
||||||
if ((srgb & (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) == (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT))
|
if ((srgb & (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) == (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT))
|
||||||
{
|
{
|
||||||
srgb &= ~(TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT);
|
srgb &= ~static_cast<uint32_t>(TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return srgb;
|
return srgb;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "DirectXTexp.h"
|
#include "DirectXTexP.h"
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// IStream support for WIC Memory routines
|
// IStream support for WIC Memory routines
|
||||||
|
@ -78,12 +78,12 @@ inline void _CreateLinearFilter(_In_ size_t source, _In_ size_t dest, _In_ bool
|
|||||||
|
|
||||||
if (isrcA < 0)
|
if (isrcA < 0)
|
||||||
{
|
{
|
||||||
isrcA = (wrap) ? (source - 1) : 0;
|
isrcA = (wrap) ? (ptrdiff_t(source) - 1) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size_t(isrcB) >= source)
|
if (size_t(isrcB) >= source)
|
||||||
{
|
{
|
||||||
isrcB = (wrap) ? 0 : (source - 1);
|
isrcB = (wrap) ? 0 : (ptrdiff_t(source) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
float weight = 1.0f + float(isrcB) - srcB;
|
float weight = 1.0f + float(isrcB) - srcB;
|
||||||
@ -171,10 +171,10 @@ inline void _CreateCubicFilter(_In_ size_t source, _In_ size_t dest, _In_ bool w
|
|||||||
{
|
{
|
||||||
float srcB = (float(u) + 0.5f) * scale - 0.5f;
|
float srcB = (float(u) + 0.5f) * scale - 0.5f;
|
||||||
|
|
||||||
ptrdiff_t isrcB = bounduvw(ptrdiff_t(srcB), source - 1, wrap, mirror);
|
ptrdiff_t isrcB = bounduvw(ptrdiff_t(srcB), ptrdiff_t(source) - 1, wrap, mirror);
|
||||||
ptrdiff_t isrcA = bounduvw(isrcB - 1, source - 1, wrap, mirror);
|
ptrdiff_t isrcA = bounduvw(isrcB - 1, ptrdiff_t(source) - 1, wrap, mirror);
|
||||||
ptrdiff_t isrcC = bounduvw(isrcB + 1, source - 1, wrap, mirror);
|
ptrdiff_t isrcC = bounduvw(isrcB + 1, ptrdiff_t(source) - 1, wrap, mirror);
|
||||||
ptrdiff_t isrcD = bounduvw(isrcB + 2, source - 1, wrap, mirror);
|
ptrdiff_t isrcD = bounduvw(isrcB + 2, ptrdiff_t(source) - 1, wrap, mirror);
|
||||||
|
|
||||||
auto& entry = cf[u];
|
auto& entry = cf[u];
|
||||||
entry.u0 = size_t(isrcA);
|
entry.u0 = size_t(isrcA);
|
||||||
|
Loading…
Reference in New Issue
Block a user