Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Mein <mein@cs.umn.edu>2007-12-27 00:46:30 +0300
committerKent Mein <mein@cs.umn.edu>2007-12-27 00:46:30 +0300
commitae976e087a7110c6b25a0fee4f663185b5e4319d (patch)
tree836c8b93de2b6f726ce5ea64914e3945cd60a4ae /source/blender/imbuf/intern/dds/BlockDXT.h
parent8e84f64c3daa5cd2cafc7fd14d7d0fad472298cf (diff)
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent Notes From the author: The attached patch syncs the DDS code in Blender with the latest revision (324) of the nvidia texture tools. This fixes a few minor issues and adds support for a more types of DDS textures, in particular uncompressed textures that don't have the standard 16, 24, or 32 bits per pixel. Note: I have started using the nvidia texture tools convention for naming integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it much easier to merge patches from upstream. Since the code is compiled separately from the rest of Blender, this likely does not pose a problem. However, if there turns out to be a good reason for avoiding those nvidia type names from upstream, I'd be happy to fix it. Regards, Amorilia
Diffstat (limited to 'source/blender/imbuf/intern/dds/BlockDXT.h')
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.h79
1 files changed, 50 insertions, 29 deletions
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.h b/source/blender/imbuf/intern/dds/BlockDXT.h
index 1f710360c3c..5c232201f0c 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.h
+++ b/source/blender/imbuf/intern/dds/BlockDXT.h
@@ -58,6 +58,7 @@
#ifndef _DDS_BLOCKDXT_H
#define _DDS_BLOCKDXT_H
+#include <Common.h>
#include <Color.h>
#include <ColorBlock.h>
#include <Stream.h>
@@ -68,14 +69,14 @@ struct BlockDXT1
Color16 col0;
Color16 col1;
union {
- unsigned char row[4];
- unsigned int indices;
+ uint8 row[4];
+ uint indices;
};
bool isFourColorMode() const;
- unsigned int evaluatePalette(Color32 color_array[4]) const;
- unsigned int evaluatePaletteFast(Color32 color_array[4]) const;
+ uint evaluatePalette(Color32 color_array[4]) const;
+ uint evaluatePaletteFast(Color32 color_array[4]) const;
void evaluatePalette3(Color32 color_array[4]) const;
void evaluatePalette4(Color32 color_array[4]) const;
@@ -90,7 +91,7 @@ struct BlockDXT1
/// Return true if the block uses four color mode, false otherwise.
inline bool BlockDXT1::isFourColorMode() const
{
- return col0.u >= col1.u; // @@ > or >= ?
+ return col0.u > col1.u;
}
@@ -99,24 +100,24 @@ struct AlphaBlockDXT3
{
union {
struct {
- unsigned int alpha0 : 4;
- unsigned int alpha1 : 4;
- unsigned int alpha2 : 4;
- unsigned int alpha3 : 4;
- unsigned int alpha4 : 4;
- unsigned int alpha5 : 4;
- unsigned int alpha6 : 4;
- unsigned int alpha7 : 4;
- unsigned int alpha8 : 4;
- unsigned int alpha9 : 4;
- unsigned int alphaA : 4;
- unsigned int alphaB : 4;
- unsigned int alphaC : 4;
- unsigned int alphaD : 4;
- unsigned int alphaE : 4;
- unsigned int alphaF : 4;
+ uint alpha0 : 4;
+ uint alpha1 : 4;
+ uint alpha2 : 4;
+ uint alpha3 : 4;
+ uint alpha4 : 4;
+ uint alpha5 : 4;
+ uint alpha6 : 4;
+ uint alpha7 : 4;
+ uint alpha8 : 4;
+ uint alpha9 : 4;
+ uint alphaA : 4;
+ uint alphaB : 4;
+ uint alphaC : 4;
+ uint alphaD : 4;
+ uint alphaE : 4;
+ uint alphaF : 4;
};
- unsigned short row[4];
+ uint16 row[4];
};
void decodeBlock(ColorBlock * block) const;
@@ -163,16 +164,16 @@ struct AlphaBlockDXT5
unsigned int bitsE : 3; // 45 - 61
unsigned int bitsF : 3; // 48 - 64
};
- unsigned long long u;
+ uint64 u;
};
- void evaluatePalette(unsigned char alpha[8]) const;
- void evaluatePalette8(unsigned char alpha[8]) const;
- void evaluatePalette6(unsigned char alpha[8]) const;
- void indices(unsigned char index_array[16]) const;
+ void evaluatePalette(uint8 alpha[8]) const;
+ void evaluatePalette8(uint8 alpha[8]) const;
+ void evaluatePalette6(uint8 alpha[8]) const;
+ void indices(uint8 index_array[16]) const;
- unsigned int index(unsigned int index) const;
- void setIndex(unsigned int index, unsigned int value);
+ uint index(uint index) const;
+ void setIndex(uint index, uint value);
void decodeBlock(ColorBlock * block) const;
@@ -216,6 +217,25 @@ struct BlockATI2
void flip2();
};
+/// CTX1 block.
+struct BlockCTX1
+{
+ uint8 col0[2];
+ uint8 col1[2];
+ union {
+ uint8 row[4];
+ uint indices;
+ };
+
+ void evaluatePalette(Color32 color_array[4]) const;
+ void setIndices(int * idx);
+
+ void decodeBlock(ColorBlock * block) const;
+
+ void flip4();
+ void flip2();
+};
+
void mem_read(Stream & mem, BlockDXT1 & block);
void mem_read(Stream & mem, AlphaBlockDXT3 & block);
void mem_read(Stream & mem, BlockDXT3 & block);
@@ -223,5 +243,6 @@ void mem_read(Stream & mem, AlphaBlockDXT5 & block);
void mem_read(Stream & mem, BlockDXT5 & block);
void mem_read(Stream & mem, BlockATI1 & block);
void mem_read(Stream & mem, BlockATI2 & block);
+void mem_read(Stream & mem, BlockCTX1 & block);
#endif // _DDS_BLOCKDXT_H