1 #include "pipe/p_compiler.h"
2 #include "util/u_debug.h"
3 #include "util/u_math.h"
4 #include "u_format_etc.h"
6 /* define etc1_parse_block and etc. */
7 #define UINT8_TYPE uint8_t
9 #include "../../../mesa/main/texcompress_etc_tmp.h"
14 util_format_etc1_rgb8_unpack_rgba_8unorm(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
16 etc1_unpack_rgba8888(dst_row
, dst_stride
, src_row
, src_stride
, width
, height
);
20 util_format_etc1_rgb8_pack_rgba_8unorm(UNUSED
uint8_t *dst_row
, UNUSED
unsigned dst_stride
,
21 UNUSED
const uint8_t *src_row
, UNUSED
unsigned src_stride
,
22 UNUSED
unsigned width
, UNUSED
unsigned height
)
28 util_format_etc1_rgb8_unpack_rgba_float(float *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
30 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 4;
31 struct etc1_block block
;
34 for (y
= 0; y
< height
; y
+= bh
) {
35 const uint8_t *src
= src_row
;
37 for (x
= 0; x
< width
; x
+= bw
) {
38 etc1_parse_block(&block
, src
);
40 for (j
= 0; j
< bh
; j
++) {
41 float *dst
= dst_row
+ (y
+ j
) * dst_stride
/ sizeof(*dst_row
) + x
* comps
;
44 for (i
= 0; i
< bw
; i
++) {
45 etc1_fetch_texel(&block
, i
, j
, tmp
);
46 dst
[0] = ubyte_to_float(tmp
[0]);
47 dst
[1] = ubyte_to_float(tmp
[1]);
48 dst
[2] = ubyte_to_float(tmp
[2]);
57 src_row
+= src_stride
;
62 util_format_etc1_rgb8_pack_rgba_float(UNUSED
uint8_t *dst_row
, UNUSED
unsigned dst_stride
,
63 UNUSED
const float *src_row
, UNUSED
unsigned src_stride
,
64 UNUSED
unsigned width
, UNUSED
unsigned height
)
70 util_format_etc1_rgb8_fetch_rgba_float(float *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
72 struct etc1_block block
;
75 assert(i
< 4 && j
< 4); /* check i, j against 4x4 block size */
77 etc1_parse_block(&block
, src
);
78 etc1_fetch_texel(&block
, i
, j
, tmp
);
80 dst
[0] = ubyte_to_float(tmp
[0]);
81 dst
[1] = ubyte_to_float(tmp
[1]);
82 dst
[2] = ubyte_to_float(tmp
[2]);