Start using refactored fast compressor.

Fix error with DX10 headers.
This commit is contained in:
castano
2007-09-04 22:46:15 +00:00
parent d1d71dd2b3
commit a19df8721d
5 changed files with 19 additions and 12 deletions

View File

@ -851,6 +851,10 @@
RelativePath="..\..\..\src\nvimage\nvtt\OutputOptions.cpp" RelativePath="..\..\..\src\nvimage\nvtt\OutputOptions.cpp"
> >
</File> </File>
<File
RelativePath="..\..\..\src\nvimage\nvtt\QuickCompressDXT.cpp"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
@ -893,6 +897,10 @@
RelativePath="..\..\..\src\nvimage\nvtt\nvtt.h" RelativePath="..\..\..\src\nvimage\nvtt\nvtt.h"
> >
</File> </File>
<File
RelativePath="..\..\..\src\nvimage\nvtt\QuickCompressDXT.h"
>
</File>
<File <File
RelativePath=".\resource.h" RelativePath=".\resource.h"
> >

View File

@ -967,7 +967,7 @@ uint DirectDrawSurface::faceSize() const
uint DirectDrawSurface::offset(const uint face, const uint mipmap) uint DirectDrawSurface::offset(const uint face, const uint mipmap)
{ {
uint size = sizeof(DDSHeader); uint size = 128; //sizeof(DDSHeader);
if (face != 0) if (face != 0)
{ {

View File

@ -67,9 +67,7 @@ void nv::fastCompressDXT1(const Image * image, const OutputOptions & outputOptio
for (uint x = 0; x < w; x += 4) { for (uint x = 0; x < w; x += 4) {
rgba.init(image, x, y); rgba.init(image, x, y);
//QuickCompress::compressDXT1(rgba, &block); QuickCompress::compressDXT1(rgba, &block);
compressBlock_BoundsRange(rgba, &block);
optimizeEndPoints(rgba, &block); optimizeEndPoints(rgba, &block);

View File

@ -47,7 +47,7 @@ inline static void extractColorBlockRGB(const ColorBlock & rgba, Vector3 block[1
inline static void findMinMaxColorsBox(Vector3 block[16], Vector3 * __restrict maxColor, Vector3 * __restrict minColor) inline static void findMinMaxColorsBox(Vector3 block[16], Vector3 * __restrict maxColor, Vector3 * __restrict minColor)
{ {
*maxColor = Vector3(0, 0, 0); *maxColor = Vector3(0, 0, 0);
*minColor = Vector3(1, 1, 1); *minColor = Vector3(255, 255, 255);
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
@ -92,9 +92,9 @@ inline static void insetBBox(Vector3 * __restrict maxColor, Vector3 * __restrict
inline static uint16 roundAndExpand(Vector3 * v) inline static uint16 roundAndExpand(Vector3 * v)
{ {
uint r = clamp(v->x() * (31.0f / 255.0f), 0.0f, 31.0f); uint r = clamp(v->x() * (31.0f / 255.0f), 0.0f, 31.0f) + 0.5f;
uint g = clamp(v->y() * (63.0f / 255.0f), 0.0f, 63.0f); uint g = clamp(v->y() * (63.0f / 255.0f), 0.0f, 63.0f) + 0.5f;
uint b = clamp(v->z() * (31.0f / 255.0f), 0.0f, 31.0f); uint b = clamp(v->z() * (31.0f / 255.0f), 0.0f, 31.0f) + 0.5f;
uint16 w = (r << 11) | (g << 5) | b; uint16 w = (r << 11) | (g << 5) | b;
@ -154,18 +154,18 @@ void QuickCompress::compressDXT1(const ColorBlock & rgba, BlockDXT1 * dxtBlock)
Vector3 maxColor, minColor; Vector3 maxColor, minColor;
findMinMaxColorsBox(block, &maxColor, &minColor); findMinMaxColorsBox(block, &maxColor, &minColor);
//selectDiagonal(block, &maxColor, &minColor); selectDiagonal(block, &maxColor, &minColor);
//insetBBox(&minColor, &maxColor); insetBBox(&maxColor, &minColor);
uint16 color0 = roundAndExpand(&maxColor); uint16 color0 = roundAndExpand(&maxColor);
uint16 color1 = roundAndExpand(&minColor); uint16 color1 = roundAndExpand(&minColor);
/*if (color0 < color1) if (color0 < color1)
{ {
swap(maxColor, minColor); swap(maxColor, minColor);
swap(color0, color1); swap(color0, color1);
}*/ }
// @@ Optimize endpoints. // @@ Optimize endpoints.

View File

@ -74,6 +74,7 @@ struct Error
void addSample(float e) void addSample(float e)
{ {
if (fabsf(e) >= 255) nvDebugBreak();
samples++; samples++;
mabse += fabsf(e); mabse += fabsf(e);
maxabse = nv::max(maxabse, fabsf(e)); maxabse = nv::max(maxabse, fabsf(e));