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(uint8_t *dst_row
, unsigned dst_stride
, const uint8_t *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
26 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
)
28 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 4;
29 struct etc1_block block
;
32 for (y
= 0; y
< height
; y
+= bh
) {
33 const uint8_t *src
= src_row
;
35 for (x
= 0; x
< width
; x
+= bw
) {
36 etc1_parse_block(&block
, src
);
38 for (j
= 0; j
< bh
; j
++) {
39 float *dst
= dst_row
+ (y
+ j
) * dst_stride
/ sizeof(*dst_row
) + x
* comps
;
42 for (i
= 0; i
< bw
; i
++) {
43 etc1_fetch_texel(&block
, i
, j
, tmp
);
44 dst
[0] = ubyte_to_float(tmp
[0]);
45 dst
[1] = ubyte_to_float(tmp
[1]);
46 dst
[2] = ubyte_to_float(tmp
[2]);
55 src_row
+= src_stride
;
60 util_format_etc1_rgb8_pack_rgba_float(uint8_t *dst_row
, unsigned dst_stride
, const float *src_row
, unsigned src_stride
, unsigned width
, unsigned height
)
66 util_format_etc1_rgb8_fetch_rgba_float(float *dst
, const uint8_t *src
, unsigned i
, unsigned j
)
68 const unsigned bw
= 4, bh
= 4;
69 struct etc1_block block
;
72 assert(i
< bw
&& j
< bh
);
74 etc1_parse_block(&block
, src
);
75 etc1_fetch_texel(&block
, i
, j
, tmp
);
77 dst
[0] = ubyte_to_float(tmp
[0]);
78 dst
[1] = ubyte_to_float(tmp
[1]);
79 dst
[2] = ubyte_to_float(tmp
[2]);