Added TEX_THRESHOLD_DEFAULT constant
This commit is contained in:
parent
1dec86435d
commit
9290fcdf04
@ -377,7 +377,7 @@ namespace
|
||||
_Out_ D3DX_BC1 *pBC,
|
||||
_In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor,
|
||||
bool bColorKey,
|
||||
float alphaRef,
|
||||
float threshold,
|
||||
DWORD flags)
|
||||
{
|
||||
assert(pBC && pColor);
|
||||
@ -392,7 +392,7 @@ namespace
|
||||
|
||||
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
||||
{
|
||||
if (pColor[i].a < alphaRef)
|
||||
if (pColor[i].a < threshold)
|
||||
uColorKey++;
|
||||
}
|
||||
|
||||
@ -604,7 +604,7 @@ namespace
|
||||
|
||||
for (i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
||||
{
|
||||
if ((3 == uSteps) && (pColor[i].a < alphaRef))
|
||||
if ((3 == uSteps) && (pColor[i].a < threshold))
|
||||
{
|
||||
dw = (3 << 30) | (dw >> 2);
|
||||
}
|
||||
@ -735,7 +735,7 @@ void DirectX::D3DXDecodeBC1(XMVECTOR *pColor, const uint8_t *pBC)
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
void DirectX::D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float alphaRef, DWORD flags)
|
||||
void DirectX::D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float threshold, DWORD flags)
|
||||
{
|
||||
assert(pBC && pColor);
|
||||
|
||||
@ -792,7 +792,7 @@ void DirectX::D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float alphaRef
|
||||
}
|
||||
|
||||
auto pBC1 = reinterpret_cast<D3DX_BC1 *>(pBC);
|
||||
EncodeBC1(pBC1, Color, true, alphaRef, flags);
|
||||
EncodeBC1(pBC1, Color, true, threshold, flags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -875,7 +875,7 @@ void D3DXDecodeBC6HU(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_re
|
||||
void D3DXDecodeBC6HS(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC);
|
||||
void D3DXDecodeBC7(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC);
|
||||
|
||||
void D3DXEncodeBC1(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float alphaRef, _In_ DWORD flags);
|
||||
void D3DXEncodeBC1(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float threshold, _In_ DWORD flags);
|
||||
// BC1 requires one additional parameter, so it doesn't match signature of BC_ENCODE above
|
||||
|
||||
void D3DXEncodeBC2(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ DWORD flags);
|
||||
|
@ -451,6 +451,9 @@ namespace DirectX
|
||||
// Resize the image to width x height. Defaults to Fant filtering.
|
||||
// Note for a complex resize, the result will always have mipLevels == 1
|
||||
|
||||
const float TEX_THRESHOLD_DEFAULT = 0.5f;
|
||||
// Default value for alpha threshold used when converting to 1-bit alpha
|
||||
|
||||
HRESULT __cdecl Convert( _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD filter, _In_ float threshold,
|
||||
_Out_ ScratchImage& image );
|
||||
HRESULT __cdecl Convert( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||
@ -527,11 +530,11 @@ namespace DirectX
|
||||
// Compress is free to use multithreading to improve performance (by default it does not use multithreading)
|
||||
};
|
||||
|
||||
HRESULT __cdecl Compress( _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaRef,
|
||||
HRESULT __cdecl Compress( _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float threshold,
|
||||
_Out_ ScratchImage& cImage );
|
||||
HRESULT __cdecl Compress( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata,
|
||||
_In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaRef, _Out_ ScratchImage& cImages );
|
||||
// Note that alphaRef is only used by BC1. 0.5f is a typical value to use
|
||||
_In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float threshold, _Out_ ScratchImage& cImages );
|
||||
// Note that threshold is only used by BC1. TEX_THRESHOLD_DEFAULT is a typical value to use
|
||||
|
||||
HRESULT __cdecl Compress( _In_ ID3D11Device* pDevice, _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ DWORD compress,
|
||||
_In_ float alphaWeight, _Out_ ScratchImage& image );
|
||||
|
@ -75,7 +75,7 @@ namespace
|
||||
const Image& result,
|
||||
DWORD bcflags,
|
||||
DWORD srgb,
|
||||
float alphaRef)
|
||||
float threshold)
|
||||
{
|
||||
if (!image.pixels || !result.pixels)
|
||||
return E_POINTER;
|
||||
@ -183,7 +183,7 @@ namespace
|
||||
if (pfEncode)
|
||||
pfEncode(dptr, temp, bcflags);
|
||||
else
|
||||
D3DXEncodeBC1(dptr, temp, alphaRef, bcflags);
|
||||
D3DXEncodeBC1(dptr, temp, threshold, bcflags);
|
||||
|
||||
sptr += sbpp * 4;
|
||||
dptr += blocksize;
|
||||
@ -204,7 +204,7 @@ namespace
|
||||
const Image& result,
|
||||
DWORD bcflags,
|
||||
DWORD srgb,
|
||||
float alphaRef)
|
||||
float threshold)
|
||||
{
|
||||
if (!image.pixels || !result.pixels)
|
||||
return E_POINTER;
|
||||
@ -323,7 +323,7 @@ namespace
|
||||
if (pfEncode)
|
||||
pfEncode(pDest, temp, bcflags);
|
||||
else
|
||||
D3DXEncodeBC1(pDest, temp, alphaRef, bcflags);
|
||||
D3DXEncodeBC1(pDest, temp, threshold, bcflags);
|
||||
}
|
||||
|
||||
return (fail) ? E_FAIL : S_OK;
|
||||
@ -594,7 +594,7 @@ HRESULT DirectX::Compress(
|
||||
const Image& srcImage,
|
||||
DXGI_FORMAT format,
|
||||
DWORD compress,
|
||||
float alphaRef,
|
||||
float threshold,
|
||||
ScratchImage& image)
|
||||
{
|
||||
if (IsCompressed(srcImage.format) || !IsCompressed(format))
|
||||
@ -622,12 +622,12 @@ HRESULT DirectX::Compress(
|
||||
#ifndef _OPENMP
|
||||
return E_NOTIMPL;
|
||||
#else
|
||||
hr = CompressBC_Parallel(srcImage, *img, GetBCFlags(compress), GetSRGBFlags(compress), alphaRef);
|
||||
hr = CompressBC_Parallel(srcImage, *img, GetBCFlags(compress), GetSRGBFlags(compress), threshold);
|
||||
#endif // _OPENMP
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = CompressBC(srcImage, *img, GetBCFlags(compress), GetSRGBFlags(compress), alphaRef);
|
||||
hr = CompressBC(srcImage, *img, GetBCFlags(compress), GetSRGBFlags(compress), threshold);
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
@ -643,7 +643,7 @@ HRESULT DirectX::Compress(
|
||||
const TexMetadata& metadata,
|
||||
DXGI_FORMAT format,
|
||||
DWORD compress,
|
||||
float alphaRef,
|
||||
float threshold,
|
||||
ScratchImage& cImages)
|
||||
{
|
||||
if (!srcImages || !nimages)
|
||||
@ -696,7 +696,7 @@ HRESULT DirectX::Compress(
|
||||
#else
|
||||
if (compress & TEX_COMPRESS_PARALLEL)
|
||||
{
|
||||
hr = CompressBC_Parallel(src, dest[index], GetBCFlags(compress), GetSRGBFlags(compress), alphaRef);
|
||||
hr = CompressBC_Parallel(src, dest[index], GetBCFlags(compress), GetSRGBFlags(compress), threshold);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
cImages.Release();
|
||||
@ -707,7 +707,7 @@ HRESULT DirectX::Compress(
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = CompressBC(src, dest[index], GetBCFlags(compress), GetSRGBFlags(compress), alphaRef);
|
||||
hr = CompressBC(src, dest[index], GetBCFlags(compress), GetSRGBFlags(compress), threshold);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
cImages.Release();
|
||||
|
@ -759,7 +759,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
hr = Convert(image->GetImages(), image->GetImageCount(), image->GetMetadata(), format, dwFilter | dwFilterOpts, 0.5f, *timage.get());
|
||||
hr = Convert(image->GetImages(), image->GetImageCount(), image->GetMetadata(), format,
|
||||
dwFilter | dwFilterOpts, TEX_THRESHOLD_DEFAULT, *timage.get());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
wprintf(L" FAILED [convert] (%x)\n", hr);
|
||||
|
@ -1707,7 +1707,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
hr = Convert(image->GetImages(), image->GetImageCount(), image->GetMetadata(), tformat, dwFilter | dwFilterOpts | dwSRGB, 0.5f, *timage);
|
||||
hr = Convert(image->GetImages(), image->GetImageCount(), image->GetMetadata(), tformat,
|
||||
dwFilter | dwFilterOpts | dwSRGB, TEX_THRESHOLD_DEFAULT, *timage);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
wprintf(L" FAILED [convert] (%x)\n", hr);
|
||||
@ -2069,7 +2070,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = Compress(img, nimg, info, tformat, cflags | dwSRGB, 0.5f, *timage);
|
||||
hr = Compress(img, nimg, info, tformat, cflags | dwSRGB, TEX_THRESHOLD_DEFAULT, *timage);
|
||||
}
|
||||
if (FAILED(hr))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user