Skip to content

Commit 0118759

Browse files
committed
Reference code support for BC7/BPTC
1 parent 9116d72 commit 0118759

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

source/hap.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,28 @@
4646
#define kHapFormatRGBADXT5 0xE
4747
#define kHapFormatYCoCgDXT5 0xF
4848
#define kHapFormatARGTC1 0x1
49+
#define kHapFormatRGBABPTC 0xC
4950

5051
/*
5152
Packed byte values for Hap
5253
5354
Format Compressor Byte Code
5455
----------------------------------------
55-
RGB_DXT1 None 0xAB
56-
RGB_DXT1 Snappy 0xBB
57-
RGB_DXT1 Complex 0xCB
58-
RGBA_DXT5 None 0xAE
59-
RGBA_DXT5 Snappy 0xBE
60-
RGBA_DXT5 Complex 0xCE
61-
YCoCg_DXT5 None 0xAF
62-
YCoCg_DXT5 Snappy 0xBF
63-
YCoCg_DXT5 Complex 0xCF
64-
A_RGTC1 None 0xA1
65-
A_RGTC1 Snappy 0xB1
66-
A_RGTC1 Complex 0xC1
56+
RGB_DXT1 None 0xAB
57+
RGB_DXT1 Snappy 0xBB
58+
RGB_DXT1 Complex 0xCB
59+
RGBA_DXT5 None 0xAE
60+
RGBA_DXT5 Snappy 0xBE
61+
RGBA_DXT5 Complex 0xCE
62+
YCoCg_DXT5 None 0xAF
63+
YCoCg_DXT5 Snappy 0xBF
64+
YCoCg_DXT5 Complex 0xCF
65+
A_RGTC1 None 0xA1
66+
A_RGTC1 Snappy 0xB1
67+
A_RGTC1 Complex 0xC1
68+
RGBA_BPTC_UNORM None 0xAC
69+
RGBA_BPTC_UNORM Snappy 0xBC
70+
RGBA_BPTC_UNORM Complex 0xCC
6771
*/
6872

6973
/*
@@ -212,6 +216,8 @@ static unsigned int hap_texture_format_constant_for_format_identifier(unsigned i
212216
return HapTextureFormat_YCoCg_DXT5;
213217
case kHapFormatARGTC1:
214218
return HapTextureFormat_A_RGTC1;
219+
case kHapFormatRGBABPTC:
220+
return HapTextureFormat_RGBA_BPTC_UNORM;
215221
default:
216222
return 0;
217223

@@ -231,6 +237,8 @@ static unsigned int hap_texture_format_identifier_for_format_constant(unsigned i
231237
return kHapFormatYCoCgDXT5;
232238
case HapTextureFormat_A_RGTC1:
233239
return kHapFormatARGTC1;
240+
case HapTextureFormat_RGBA_BPTC_UNORM:
241+
return kHapFormatRGBABPTC;
234242
default:
235243
return 0;
236244
}
@@ -346,6 +354,7 @@ static unsigned int hap_encode_texture(const void *inputBuffer, unsigned long in
346354
&& textureFormat != HapTextureFormat_RGBA_DXT5
347355
&& textureFormat != HapTextureFormat_YCoCg_DXT5
348356
&& textureFormat != HapTextureFormat_A_RGTC1
357+
&& textureFormat != HapTextureFormat_RGBA_BPTC_UNORM
349358
)
350359
|| (compressor != HapCompressorNone
351360
&& compressor != HapCompressorSnappy

source/hap.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ extern "C" {
3333
#endif
3434

3535
/*
36-
These match the constants defined by GL_EXT_texture_compression_s3tc and
37-
GL_ARB_texture_compression_rgtc
36+
These match the constants defined by GL_EXT_texture_compression_s3tc,
37+
GL_ARB_texture_compression_rgtc and GL_ARB_texture_compression_bptc
3838
*/
3939

4040
enum HapTextureFormat {
4141
HapTextureFormat_RGB_DXT1 = 0x83F0,
4242
HapTextureFormat_RGBA_DXT5 = 0x83F3,
4343
HapTextureFormat_YCoCg_DXT5 = 0x01,
44-
HapTextureFormat_A_RGTC1 = 0x8DBB
44+
HapTextureFormat_A_RGTC1 = 0x8DBB,
45+
HapTextureFormat_RGBA_BPTC_UNORM = 0x8E8C
4546
};
4647

4748
enum HapCompressor {

0 commit comments

Comments
 (0)