More progress in DDS input support.
This commit is contained in:
parent
de94fce1ce
commit
d0f711c0ae
@ -99,48 +99,40 @@ public:
|
||||
}
|
||||
friend Stream & operator<<( Stream & s, uint16 & c ) {
|
||||
nvStaticCheck(sizeof(uint16) == 2);
|
||||
s.byteOrderSerialize( &c, 2 );
|
||||
return s;
|
||||
return s.byteOrderSerialize( &c, 2 );
|
||||
}
|
||||
friend Stream & operator<<( Stream & s, int16 & c ) {
|
||||
nvStaticCheck(sizeof(int16) == 2);
|
||||
s.byteOrderSerialize( &c, 2 );
|
||||
return s;
|
||||
return s.byteOrderSerialize( &c, 2 );
|
||||
}
|
||||
friend Stream & operator<<( Stream & s, uint32 & c ) {
|
||||
nvStaticCheck(sizeof(uint32) == 4);
|
||||
s.byteOrderSerialize( &c, 4 );
|
||||
return s;
|
||||
return s.byteOrderSerialize( &c, 4 );
|
||||
}
|
||||
friend Stream & operator<<( Stream & s, int32 & c ) {
|
||||
nvStaticCheck(sizeof(int32) == 4);
|
||||
s.byteOrderSerialize( &c, 4 );
|
||||
return s;
|
||||
return s.byteOrderSerialize( &c, 4 );
|
||||
}
|
||||
friend Stream & operator<<( Stream & s, uint64 & c ) {
|
||||
nvStaticCheck(sizeof(uint64) == 8);
|
||||
s.byteOrderSerialize( &c, 8 );
|
||||
return s;
|
||||
return s.byteOrderSerialize( &c, 8 );
|
||||
}
|
||||
friend Stream & operator<<( Stream & s, int64 & c ) {
|
||||
nvStaticCheck(sizeof(int64) == 8);
|
||||
s.byteOrderSerialize( &c, 8 );
|
||||
return s;
|
||||
return s.byteOrderSerialize( &c, 8 );
|
||||
}
|
||||
friend Stream & operator<<( Stream & s, float & c ) {
|
||||
nvStaticCheck(sizeof(float) == 4);
|
||||
s.byteOrderSerialize( &c, 4 );
|
||||
return s;
|
||||
return s.byteOrderSerialize( &c, 4 );
|
||||
}
|
||||
friend Stream & operator<<( Stream & s, double & c ) {
|
||||
nvStaticCheck(sizeof(double) == 8);
|
||||
s.byteOrderSerialize( &c, 8 );
|
||||
return s;
|
||||
return s.byteOrderSerialize( &c, 8 );
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
/** Serialize in the stream byte order. */
|
||||
/// Serialize in the stream byte order.
|
||||
Stream & byteOrderSerialize( void * v, int len ) {
|
||||
if( m_byteOrder == getSystemByteOrder() ) {
|
||||
serialize( v, len );
|
||||
|
@ -21,6 +21,8 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include <nvcore/Stream.h>
|
||||
|
||||
#include "ColorBlock.h"
|
||||
#include "BlockDXT.h"
|
||||
|
||||
@ -505,6 +507,37 @@ void Block3DC::flip2()
|
||||
|
||||
|
||||
|
||||
Stream & nv::operator<<(Stream & stream, BlockDXT1 & block)
|
||||
{
|
||||
return stream << block.col0.u << block.col1.u << block.indices;
|
||||
}
|
||||
|
||||
Stream & nv::operator<<(Stream & stream, AlphaBlockDXT3 & block)
|
||||
{
|
||||
stream.serialize(&block, sizeof(block));
|
||||
return stream;
|
||||
}
|
||||
|
||||
Stream & nv::operator<<(Stream & stream, BlockDXT3 & block)
|
||||
{
|
||||
return stream << block.alpha << block.color;
|
||||
}
|
||||
|
||||
Stream & nv::operator<<(Stream & stream, AlphaBlockDXT5 & block)
|
||||
{
|
||||
stream.serialize(&block, sizeof(block));
|
||||
return stream;
|
||||
}
|
||||
|
||||
Stream & nv::operator<<(Stream & stream, BlockDXT5 & block)
|
||||
{
|
||||
return stream << block.alpha << block.color;
|
||||
}
|
||||
|
||||
Stream & nv::operator<<(Stream & stream, Block3DC & block)
|
||||
{
|
||||
return stream << block.x << block.y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -26,9 +26,12 @@
|
||||
|
||||
#include <nvmath/Color.h>
|
||||
|
||||
#include <nvimage.h>
|
||||
|
||||
namespace nv
|
||||
{
|
||||
struct ColorBlock;
|
||||
class Stream;
|
||||
|
||||
/// DXT1 block.
|
||||
struct BlockDXT1
|
||||
@ -61,9 +64,7 @@ namespace nv
|
||||
return col0.u >= col1.u; // @@ > or >= ?
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// DXT3 alpha block with explicit alpha.
|
||||
struct AlphaBlockDXT3
|
||||
{
|
||||
@ -149,6 +150,7 @@ namespace nv
|
||||
void flip4();
|
||||
void flip2();
|
||||
};
|
||||
|
||||
|
||||
/// DXT5 block.
|
||||
struct BlockDXT5
|
||||
@ -161,6 +163,7 @@ namespace nv
|
||||
void flip4();
|
||||
void flip2();
|
||||
};
|
||||
|
||||
|
||||
/// 3DC block.
|
||||
struct Block3DC
|
||||
@ -174,6 +177,14 @@ namespace nv
|
||||
void flip2();
|
||||
};
|
||||
|
||||
// Serialization functions.
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, BlockDXT1 & block);
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, AlphaBlockDXT3 & block);
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, BlockDXT3 & block);
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, AlphaBlockDXT5 & block);
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, BlockDXT5 & block);
|
||||
NVIMAGE_API Stream & operator<<(Stream & stream, Block3DC & block);
|
||||
|
||||
} // nv namespace
|
||||
|
||||
#endif // NV_IMAGE_BLOCKDXT_H
|
||||
|
@ -76,10 +76,18 @@ namespace
|
||||
static const uint DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000U;
|
||||
static const uint DDSCAPS2_CUBEMAP_ALL_FACES = 0x0000FC00U;
|
||||
|
||||
static const uint DDPF_RGB = 0x00000040U;
|
||||
static const uint DDPF_FOURCC = 0x00000004U;
|
||||
static const uint DDPF_ALPHAPIXELS = 0x00000001U;
|
||||
static const uint DDPF_NORMAL = 0x80000000U; // @@ Custom flag.
|
||||
static const uint DDPF_ALPHA = 0x00000002U;
|
||||
static const uint DDPF_FOURCC = 0x00000004U;
|
||||
static const uint DDPF_RGB = 0x00000040U;
|
||||
static const uint DDPF_PALETTEINDEXED1 = 0x00000800U;
|
||||
static const uint DDPF_PALETTEINDEXED2 = 0x00001000U;
|
||||
static const uint DDPF_PALETTEINDEXED4 = 0x00000008U;
|
||||
static const uint DDPF_PALETTEINDEXED8 = 0x00000020U;
|
||||
|
||||
static const uint DDPF_ALPHAPREMULT = 0x00008000U;
|
||||
|
||||
static const uint DDPF_NORMAL = 0x80000000U; // @@ Custom nv flag.
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -523,7 +531,7 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba)
|
||||
nvDebugCheck(stream != NULL);
|
||||
nvDebugCheck(rgba != NULL);
|
||||
|
||||
/*if (header.pf.fourcc == FOURCC_DXT1)
|
||||
if (header.pf.fourcc == FOURCC_DXT1)
|
||||
{
|
||||
BlockDXT1 block;
|
||||
*stream << block;
|
||||
@ -565,7 +573,7 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba)
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
Color32 & c = rgba->color(i);
|
||||
c.r = c.a;
|
||||
c.r = c.g = c.b = c.a;
|
||||
c.a = 255;
|
||||
}
|
||||
}
|
||||
@ -588,10 +596,12 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba)
|
||||
{
|
||||
Color32 & c = rgba->color(i);
|
||||
c.g = c.a;
|
||||
c.b = 0;
|
||||
c.a = 255;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
// If normal map flag set, conver to normal.
|
||||
// @@ If normal map flag set, convert to normal.
|
||||
|
||||
}
|
||||
|
||||
@ -706,8 +716,14 @@ void DirectDrawSurface::printInfo() const
|
||||
if (header.pf.flags & DDPF_RGB) printf("\t\tDDPF_RGB\n");
|
||||
if (header.pf.flags & DDPF_FOURCC) printf("\t\tDDPF_FOURCC\n");
|
||||
if (header.pf.flags & DDPF_ALPHAPIXELS) printf("\t\tDDPF_ALPHAPIXELS\n");
|
||||
if (header.pf.flags & DDPF_ALPHA) printf("\t\tDDPF_ALPHA\n");
|
||||
if (header.pf.flags & DDPF_PALETTEINDEXED1) printf("\t\tDDPF_PALETTEINDEXED1\n");
|
||||
if (header.pf.flags & DDPF_PALETTEINDEXED2) printf("\t\tDDPF_PALETTEINDEXED2\n");
|
||||
if (header.pf.flags & DDPF_PALETTEINDEXED4) printf("\t\tDDPF_PALETTEINDEXED4\n");
|
||||
if (header.pf.flags & DDPF_PALETTEINDEXED8) printf("\t\tDDPF_PALETTEINDEXED8\n");
|
||||
if (header.pf.flags & DDPF_ALPHAPREMULT) printf("\t\tDDPF_ALPHAPREMULT\n");
|
||||
if (header.pf.flags & DDPF_NORMAL) printf("\t\tDDPF_NORMAL\n");
|
||||
|
||||
|
||||
printf("\tFourCC: '%c%c%c%c'\n", ((header.pf.fourcc >> 0) & 0xFF), ((header.pf.fourcc >> 8) & 0xFF), ((header.pf.fourcc >> 16) & 0xFF), ((header.pf.fourcc >> 24) & 0xFF));
|
||||
printf("\tBit count: %d\n", header.pf.bitcount);
|
||||
printf("\tRed mask: 0x%.8X\n", header.pf.rmask);
|
||||
|
@ -48,7 +48,11 @@ TARGET_LINK_LIBRARIES(nvcompress nvcore nvmath nvimage nvtt)
|
||||
|
||||
INSTALL(TARGETS nvcompress DESTINATION bin)
|
||||
|
||||
#ADD_EXECUTABLE(nvtextool nvdxt.cpp configdialog.cpp)
|
||||
ADD_EXECUTABLE(nvddsinfo tools/ddsinfo.cpp)
|
||||
TARGET_LINK_LIBRARIES(nvddsinfo nvcore nvmath nvimage)
|
||||
|
||||
INSTALL(TARGETS nvcompress nvddsinfo DESTINATION bin)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -356,8 +356,7 @@ void nv::compressBC4(const Image * image, const nvtt::OutputOptions & outputOpti
|
||||
// 128: 4.67 - 0.79
|
||||
// 256: 4.92 - 0.20
|
||||
// inf: 4.98 - 0.09
|
||||
|
||||
printf("Alpha error: %f\n", float(totalError) / (w*h));
|
||||
//printf("Alpha error: %f\n", float(totalError) / (w*h));
|
||||
}
|
||||
|
||||
|
||||
|
@ -274,8 +274,6 @@ int main(int argc, char *argv[])
|
||||
if (nv::strCaseCmp(input.extension(), ".dds") == 0)
|
||||
{
|
||||
// Load surface.
|
||||
printf("The file '%s' is not a supported image type.\n", input.str());
|
||||
|
||||
nv::DirectDrawSurface dds(input);
|
||||
if (!dds.isValid())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user