Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DevIL/include/IL/devil_internal_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ extern "C" {
#define IL_MAX(a,b) (((a) > (b)) ? (a) : (b))
#define IL_MIN(a,b) (((a) < (b)) ? (a) : (b))

#define IL_SWAP(T,a,b) {T t = a; a = b; b = t;}


//! Basic Palette struct
typedef struct ILpal
Expand Down Expand Up @@ -86,6 +88,7 @@ typedef struct ILimage
ILuint OffY; //!< y-offset of the image
ILubyte* DxtcData; //!< compressed data
ILenum DxtcFormat; //!< compressed data format
ILenum DxgiFormat; //!< compressed data format
ILuint DxtcSize; //!< compressed data size
} ILimage;

Expand Down
122 changes: 122 additions & 0 deletions DevIL/include/IL/il.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,133 @@ typedef long long unsigned int ILuint64;
#define IL_DXT5 0x070A
#define IL_DXT_NO_COMP 0x070B
#define IL_KEEP_DXTC_DATA 0x070C
#define IL_SKIP_DXTC_DECOMPRESS 0x070D
#define IL_DXTC_DATA_FORMAT 0x070D
#define IL_3DC 0x070E
#define IL_RXGB 0x070F
#define IL_ATI1N 0x0710
#define IL_DXT1A 0x0711 // Normally the same as IL_DXT1, except for nVidia Texture Tools.

// DXGI definitions
#define IL_DXGI_UNKNOWN 0
#define IL_DXGI_R32G32B32A32_TYPELESS 1
#define IL_DXGI_R32G32B32A32_FLOAT 2
#define IL_DXGI_R32G32B32A32_UINT 3
#define IL_DXGI_R32G32B32A32_SINT 4
#define IL_DXGI_R32G32B32_TYPELESS 5
#define IL_DXGI_R32G32B32_FLOAT 6
#define IL_DXGI_R32G32B32_UINT 7
#define IL_DXGI_R32G32B32_SINT 8
#define IL_DXGI_R16G16B16A16_TYPELESS 9
#define IL_DXGI_R16G16B16A16_FLOAT 10
#define IL_DXGI_R16G16B16A16_UNORM 11
#define IL_DXGI_R16G16B16A16_UINT 12
#define IL_DXGI_R16G16B16A16_SNORM 13
#define IL_DXGI_R16G16B16A16_SINT 14
#define IL_DXGI_R32G32_TYPELESS 15
#define IL_DXGI_R32G32_FLOAT 16
#define IL_DXGI_R32G32_UINT 17
#define IL_DXGI_R32G32_SINT 18
#define IL_DXGI_R32G8X24_TYPELESS 19
#define IL_DXGI_D32_FLOAT_S8X24_UINT 20
#define IL_DXGI_R32_FLOAT_X8X24_TYPELESS 21
#define IL_DXGI_X32_TYPELESS_G8X24_UINT 22
#define IL_DXGI_R10G10B10A2_TYPELESS 23
#define IL_DXGI_R10G10B10A2_UNORM 24
#define IL_DXGI_R10G10B10A2_UINT 25
#define IL_DXGI_R11G11B10_FLOAT 26
#define IL_DXGI_R8G8B8A8_TYPELESS 27
#define IL_DXGI_R8G8B8A8_UNORM 28
#define IL_DXGI_R8G8B8A8_UNORM_SRGB 29
#define IL_DXGI_R8G8B8A8_UINT 30
#define IL_DXGI_R8G8B8A8_SNORM 31
#define IL_DXGI_R8G8B8A8_SINT 32
#define IL_DXGI_R16G16_TYPELESS 33
#define IL_DXGI_R16G16_FLOAT 34
#define IL_DXGI_R16G16_UNORM 35
#define IL_DXGI_R16G16_UINT 36
#define IL_DXGI_R16G16_SNORM 37
#define IL_DXGI_R16G16_SINT 38
#define IL_DXGI_R32_TYPELESS 39
#define IL_DXGI_D32_FLOAT 40
#define IL_DXGI_R32_FLOAT 41
#define IL_DXGI_R32_UINT 42
#define IL_DXGI_R32_SINT 43
#define IL_DXGI_R24G8_TYPELESS 44
#define IL_DXGI_D24_UNORM_S8_UINT 45
#define IL_DXGI_R24_UNORM_X8_TYPELESS 46
#define IL_DXGI_X24_TYPELESS_G8_UINT 47
#define IL_DXGI_R8G8_TYPELESS 48
#define IL_DXGI_R8G8_UNORM 49
#define IL_DXGI_R8G8_UINT 50
#define IL_DXGI_R8G8_SNORM 51
#define IL_DXGI_R8G8_SINT 52
#define IL_DXGI_R16_TYPELESS 53
#define IL_DXGI_D16_UNORM 55
#define IL_DXGI_R16_UNORM 56
#define IL_DXGI_R16_UINT 57
#define IL_DXGI_R16_SNORM 58
#define IL_DXGI_R16_SINT 59
#define IL_DXGI_R8_TYPELESS 60
#define IL_DXGI_R8_UNORM 61
#define IL_DXGI_R8_UINT 62
#define IL_DXGI_R8_SNORM 63
#define IL_DXGI_R8_SINT 64
#define IL_DXGI_A8_UNORM 65
#define IL_DXGI_R1_UNORM 66
#define IL_DXGI_R9G9B9E5_SHAREDEXP 67
#define IL_DXGI_R8G8_B8G8_UNORM 68
#define IL_DXGI_G8R8_G8B8_UNORM 69
#define IL_DXGI_BC1_TYPELESS 70
#define IL_DXGI_BC1_UNORM 71
#define IL_DXGI_BC1_UNORM_SRGB 72
#define IL_DXGI_BC2_TYPELESS 73
#define IL_DXGI_BC2_UNORM 74
#define IL_DXGI_BC2_UNORM_SRGB 75
#define IL_DXGI_BC3_TYPELESS 76
#define IL_DXGI_BC3_UNORM 77
#define IL_DXGI_BC3_UNORM_SRGB 78
#define IL_DXGI_BC4_TYPELESS 79
#define IL_DXGI_BC4_UNORM 80
#define IL_DXGI_BC4_SNORM 81
#define IL_DXGI_BC5_TYPELESS 82
#define IL_DXGI_BC5_UNORM 83
#define IL_DXGI_BC5_SNORM 84
#define IL_DXGI_B5G6R5_UNORM 85
#define IL_DXGI_B5G5R5A1_UNORM 86
#define IL_DXGI_B8G8R8A8_UNORM 87
#define IL_DXGI_B8G8R8X8_UNORM 88
#define IL_DXGI_R10G10B10_XR_BIAS_A2_UNORM 89
#define IL_DXGI_B8G8R8A8_TYPELESS 90
#define IL_DXGI_B8G8R8A8_UNORM_SRGB 91
#define IL_DXGI_B8G8R8X8_TYPELESS 92
#define IL_DXGI_B8G8R8X8_UNORM_SRGB 93
#define IL_DXGI_BC6H_TYPELESS 94
#define IL_DXGI_BC6H_UF16 95
#define IL_DXGI_BC6H_SF16 96
#define IL_DXGI_BC7_TYPELESS 97
#define IL_DXGI_BC7_UNORM 98
#define IL_DXGI_BC7_UNORM_SRGB 99
#define IL_DXGI_AYUV 100
#define IL_DXGI_Y410 101
#define IL_DXGI_Y416 102
#define IL_DXGI_NV12 103
#define IL_DXGI_P010 104
#define IL_DXGI_P016 105
#define IL_DXGI_420_OPAQUE 106
#define IL_DXGI_YUY2 107
#define IL_DXGI_Y210 108
#define IL_DXGI_Y216 109
#define IL_DXGI_NV11 110
#define IL_DXGI_AI44 111
#define IL_DXGI_IA44 112
#define IL_DXGI_P8 113
#define IL_DXGI_A8P8 114
#define IL_DXGI_B4G4R4A4_UNORM 115
#define IL_DXGI_P208 130
#define IL_DXGI_V208 131
#define IL_DXGI_V408 132

// Environment map definitions
#define IL_CUBEMAP_POSITIVEX 0x00000400
#define IL_CUBEMAP_NEGATIVEX 0x00000800
Expand Down Expand Up @@ -566,6 +687,7 @@ ILAPI ILboolean ILAPIENTRY ilGetBoolean(ILenum Mode);
ILAPI void ILAPIENTRY ilGetBooleanv(ILenum Mode, ILboolean *Param);
ILAPI ILubyte* ILAPIENTRY ilGetData(void);
ILAPI ILuint ILAPIENTRY ilGetDXTCData(void *Buffer, ILuint BufferSize, ILenum DXTCFormat);
ILAPI void ILAPIENTRY ilGetKeptDXTCData(ILubyte** DXTCData, ILuint* DXTCMipMapCount, ILuint* DXTCSize, ILenum* DXTCFormat, ILenum* DXGIFormat);
ILAPI ILenum ILAPIENTRY ilGetError(void);
ILAPI ILint ILAPIENTRY ilGetInteger(ILenum Mode);
ILAPI void ILAPIENTRY ilGetIntegerv(ILenum Mode, ILint *Param);
Expand Down
177 changes: 177 additions & 0 deletions DevIL/src-IL/include/bc7decomp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#pragma once

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4201) // nonstandard extension used: nameless struct/union
#endif

#include "il_internal.h"

#include <stdint.h>

namespace bc7decomp
{

enum eNoClamp { cNoClamp };

template <typename S> inline S clamp(S value, S low, S high) { return (value < low) ? low : ((value > high) ? high : value); }

class color_rgba
{
public:
union
{
uint8_t m_comps[4];

struct
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
};
};

inline color_rgba()
{
static_assert(sizeof(*this) == 4, "sizeof(*this) != 4");
}

inline color_rgba(int y)
{
set(y);
}

inline color_rgba(int y, int na)
{
set(y, na);
}

inline color_rgba(int sr, int sg, int sb, int sa)
{
set(sr, sg, sb, sa);
}

inline color_rgba(eNoClamp, int sr, int sg, int sb, int sa)
{
set_noclamp_rgba((uint8_t)sr, (uint8_t)sg, (uint8_t)sb, (uint8_t)sa);
}

inline color_rgba& set_noclamp_y(int y)
{
m_comps[0] = (uint8_t)y;
m_comps[1] = (uint8_t)y;
m_comps[2] = (uint8_t)y;
m_comps[3] = (uint8_t)255;
return *this;
}

inline color_rgba &set_noclamp_rgba(int sr, int sg, int sb, int sa)
{
m_comps[0] = (uint8_t)sr;
m_comps[1] = (uint8_t)sg;
m_comps[2] = (uint8_t)sb;
m_comps[3] = (uint8_t)sa;
return *this;
}

inline color_rgba &set(int y)
{
m_comps[0] = static_cast<uint8_t>(clamp<int>(y, 0, 255));
m_comps[1] = m_comps[0];
m_comps[2] = m_comps[0];
m_comps[3] = 255;
return *this;
}

inline color_rgba &set(int y, int na)
{
m_comps[0] = static_cast<uint8_t>(clamp<int>(y, 0, 255));
m_comps[1] = m_comps[0];
m_comps[2] = m_comps[0];
m_comps[3] = static_cast<uint8_t>(clamp<int>(na, 0, 255));
return *this;
}

inline color_rgba &set(int sr, int sg, int sb, int sa)
{
m_comps[0] = static_cast<uint8_t>(clamp<int>(sr, 0, 255));
m_comps[1] = static_cast<uint8_t>(clamp<int>(sg, 0, 255));
m_comps[2] = static_cast<uint8_t>(clamp<int>(sb, 0, 255));
m_comps[3] = static_cast<uint8_t>(clamp<int>(sa, 0, 255));
return *this;
}

inline color_rgba &set_rgb(int sr, int sg, int sb)
{
m_comps[0] = static_cast<uint8_t>(clamp<int>(sr, 0, 255));
m_comps[1] = static_cast<uint8_t>(clamp<int>(sg, 0, 255));
m_comps[2] = static_cast<uint8_t>(clamp<int>(sb, 0, 255));
return *this;
}

inline color_rgba &set_rgb(const color_rgba &other)
{
r = other.r;
g = other.g;
b = other.b;
return *this;
}

inline const uint8_t &operator[] (uint32_t index) const { assert(index < 4); return m_comps[index]; }
inline uint8_t &operator[] (uint32_t index) { assert(index < 4); return m_comps[index]; }

inline void clear()
{
m_comps[0] = 0;
m_comps[1] = 0;
m_comps[2] = 0;
m_comps[3] = 0;
}

inline bool operator== (const color_rgba &rhs) const
{
if (m_comps[0] != rhs.m_comps[0]) return false;
if (m_comps[1] != rhs.m_comps[1]) return false;
if (m_comps[2] != rhs.m_comps[2]) return false;
if (m_comps[3] != rhs.m_comps[3]) return false;
return true;
}

inline bool operator!= (const color_rgba &rhs) const
{
return !(*this == rhs);
}

inline bool operator<(const color_rgba &rhs) const
{
for (int i = 0; i < 4; i++)
{
if (m_comps[i] < rhs.m_comps[i])
return true;
else if (m_comps[i] != rhs.m_comps[i])
return false;
}
return false;
}

inline int get_601_luma() const { return (19595U * m_comps[0] + 38470U * m_comps[1] + 7471U * m_comps[2] + 32768U) >> 16U; }
inline int get_709_luma() const { return (13938U * m_comps[0] + 46869U * m_comps[1] + 4729U * m_comps[2] + 32768U) >> 16U; }
inline int get_luma(bool luma_601) const { return luma_601 ? get_601_luma() : get_709_luma(); }

static color_rgba comp_min(const color_rgba& a, const color_rgba& b) { return color_rgba(IL_MIN(a[0], b[0]), IL_MIN(a[1], b[1]), IL_MIN(a[2], b[2]), IL_MIN(a[3], b[3])); }
static color_rgba comp_max(const color_rgba& a, const color_rgba& b) { return color_rgba(IL_MAX(a[0], b[0]), IL_MAX(a[1], b[1]), IL_MAX(a[2], b[2]), IL_MAX(a[3], b[3])); }
};

bool unpack_bc7(const void *pBlock, color_rgba *pPixels);

} // namespace bc7decomp

namespace bc7decomp_ref
{
bool unpack_bc7(const void* pBlock, bc7decomp::color_rgba* pPixels);
} // namespace bc7decomp_ref

#ifdef _MSC_VER
#pragma warning(pop)
#endif
2 changes: 2 additions & 0 deletions DevIL/src-IL/include/il_dds.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ ILboolean AllocImage(ILuint CompFormat, ILboolean IsDXT10);
ILboolean DdsDecompress(ILuint CompFormat, ILboolean IsDXT10);
ILboolean ReadMipmaps(ILuint CompFormat, ILboolean IsDXT10);
ILuint DecodePixelFormat(ILuint *CompFormat);
ILuint GetDX10BlockSize();
void DxtcReadColor(ILushort Data, Color8888* Out);
void DxtcReadColors(const ILubyte* Data, Color8888* Out);
ILboolean DecompressARGB(ILuint CompFormat);
Expand All @@ -342,6 +343,7 @@ ILboolean DecompressDXT2(ILimage *lImage, ILubyte *lCompData);
ILboolean DecompressDXT3(ILimage *lImage, ILubyte *lCompData);
ILboolean DecompressDXT4(ILimage *lImage, ILubyte *lCompData);
ILboolean DecompressDXT5(ILimage *lImage, ILubyte *lCompData);
ILboolean DecompressBC7UNORM(ILimage* lImage, ILubyte* lCompData);
ILboolean Decompress3Dc();
ILboolean DecompressAti1n();
ILboolean DecompressRXGB();
Expand Down
1 change: 1 addition & 0 deletions DevIL/src-IL/include/il_states.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef struct IL_STATES
ILuint ilQuantMaxIndexs;
// DXTC states
ILboolean ilKeepDxtcData;
ILboolean ilSkipDxtcDecompress;
ILboolean ilUseNVidiaDXT;
ILboolean ilUseSquishDXT;

Expand Down
Loading