• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright (C) 2011 Red Hat Inc.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included
13  * in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21  * OTHER DEALINGS IN THE SOFTWARE.
22  *
23  **************************************************************************/
24 
25 #include <stdio.h>
26 #include "util/format/u_format.h"
27 #include "util/format/u_format_rgtc.h"
28 #include "util/u_math.h"
29 #include "util/rgtc.h"
30 
31 void
util_format_rgtc1_unorm_fetch_rgba_8unorm(uint8_t * dst,const uint8_t * src,unsigned i,unsigned j)32 util_format_rgtc1_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
33 {
34    util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
35    dst[1] = 0;
36    dst[2] = 0;
37    dst[3] = 255;
38 }
39 
40 void
util_format_rgtc1_unorm_unpack_rgba_8unorm(uint8_t * dst_row,unsigned dst_stride,const uint8_t * src_row,unsigned src_stride,unsigned width,unsigned height)41 util_format_rgtc1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
42 {
43    const unsigned bw = 4, bh = 4, comps = 4;
44    unsigned x, y, i, j;
45    unsigned block_size = 8;
46 
47    for(y = 0; y < height; y += bh) {
48       const uint8_t *src = src_row;
49       for(x = 0; x < width; x += bw) {
50          for(j = 0; j < bh; ++j) {
51             for(i = 0; i < bw; ++i) {
52                uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
53 	       util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 1);
54 	       dst[1] = 0;
55 	       dst[2] = 0;
56 	       dst[3] = 255;
57 	    }
58 	 }
59 	 src += block_size;
60       }
61       src_row += src_stride;
62    }
63 }
64 
65 void
util_format_rgtc1_unorm_pack_rgba_8unorm(uint8_t * dst_row,unsigned dst_stride,const uint8_t * src_row,unsigned src_stride,unsigned width,unsigned height)66 util_format_rgtc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row,
67 					 unsigned src_stride, unsigned width, unsigned height)
68 {
69    const unsigned bw = 4, bh = 4, bytes_per_block = 8;
70    unsigned x, y, i, j;
71 
72    for(y = 0; y < height; y += bh) {
73       uint8_t *dst = dst_row;
74       for(x = 0; x < width; x += bw) {
75          uint8_t tmp[4][4];  /* [bh][bw][comps] */
76          for(j = 0; j < bh; ++j) {
77             for(i = 0; i < bw; ++i) {
78 	       tmp[j][i] = src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4];
79             }
80          }
81          util_format_unsigned_encode_rgtc_ubyte(dst, tmp, 4, 4);
82          dst += bytes_per_block;
83       }
84       dst_row += dst_stride / sizeof(*dst_row);
85    }
86 }
87 
88 void
util_format_rgtc1_unorm_unpack_rgba_float(void * dst_row,unsigned dst_stride,const uint8_t * src_row,unsigned src_stride,unsigned width,unsigned height)89 util_format_rgtc1_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
90 {
91    unsigned x, y, i, j;
92    int block_size = 8;
93    for(y = 0; y < height; y += 4) {
94       const uint8_t *src = src_row;
95       for(x = 0; x < width; x += 4) {
96          for(j = 0; j < 4; ++j) {
97             for(i = 0; i < 4; ++i) {
98                float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16);
99                uint8_t tmp_r;
100                util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
101                dst[0] = ubyte_to_float(tmp_r);
102                dst[1] = 0.0;
103                dst[2] = 0.0;
104                dst[3] = 1.0;
105             }
106          }
107          src += block_size;
108       }
109       src_row += src_stride;
110    }
111 }
112 
113 void
util_format_rgtc1_unorm_pack_rgba_float(uint8_t * dst_row,unsigned dst_stride,const float * src_row,unsigned src_stride,unsigned width,unsigned height)114 util_format_rgtc1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
115 {
116    const unsigned bw = 4, bh = 4, bytes_per_block = 8;
117    unsigned x, y, i, j;
118 
119    for(y = 0; y < height; y += bh) {
120       uint8_t *dst = dst_row;
121       for(x = 0; x < width; x += bw) {
122          uint8_t tmp[4][4];  /* [bh][bw][comps] */
123          for(j = 0; j < bh; ++j) {
124             for(i = 0; i < bw; ++i) {
125 	       tmp[j][i] = float_to_ubyte(src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4]);
126             }
127          }
128          util_format_unsigned_encode_rgtc_ubyte(dst, tmp, 4, 4);
129          dst += bytes_per_block;
130       }
131       dst_row += dst_stride / sizeof(*dst_row);
132    }
133 }
134 
135 void
util_format_rgtc1_unorm_fetch_rgba(void * in_dst,const uint8_t * src,unsigned i,unsigned j)136 util_format_rgtc1_unorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
137 {
138    float *dst = in_dst;
139    uint8_t tmp_r;
140    util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
141    dst[0] = ubyte_to_float(tmp_r);
142    dst[1] = 0.0;
143    dst[2] = 0.0;
144    dst[3] = 1.0;
145 }
146 
147 void
util_format_rgtc1_snorm_fetch_rgba_8unorm(UNUSED uint8_t * dst,UNUSED const uint8_t * src,UNUSED unsigned i,UNUSED unsigned j)148 util_format_rgtc1_snorm_fetch_rgba_8unorm(UNUSED uint8_t *dst, UNUSED const uint8_t *src,
149                                           UNUSED unsigned i, UNUSED unsigned j)
150 {
151    fprintf(stderr,"%s\n", __func__);
152 }
153 
154 void
util_format_rgtc1_snorm_unpack_rgba_8unorm(UNUSED uint8_t * dst_row,UNUSED unsigned dst_stride,UNUSED const uint8_t * src_row,UNUSED unsigned src_stride,UNUSED unsigned width,UNUSED unsigned height)155 util_format_rgtc1_snorm_unpack_rgba_8unorm(UNUSED uint8_t *dst_row, UNUSED unsigned dst_stride,
156                                            UNUSED const uint8_t *src_row, UNUSED unsigned src_stride,
157                                            UNUSED unsigned width, UNUSED unsigned height)
158 {
159    fprintf(stderr,"%s\n", __func__);
160 }
161 
162 void
util_format_rgtc1_snorm_pack_rgba_8unorm(UNUSED uint8_t * dst_row,UNUSED unsigned dst_stride,UNUSED const uint8_t * src_row,UNUSED unsigned src_stride,UNUSED unsigned width,UNUSED unsigned height)163 util_format_rgtc1_snorm_pack_rgba_8unorm(UNUSED uint8_t *dst_row, UNUSED unsigned dst_stride,
164                                          UNUSED const uint8_t *src_row, UNUSED unsigned src_stride,
165                                          UNUSED unsigned width, UNUSED unsigned height)
166 {
167    fprintf(stderr,"%s\n", __func__);
168 }
169 
170 void
util_format_rgtc1_snorm_pack_rgba_float(uint8_t * dst_row,unsigned dst_stride,const float * src_row,unsigned src_stride,unsigned width,unsigned height)171 util_format_rgtc1_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
172 {
173    const unsigned bw = 4, bh = 4, bytes_per_block = 8;
174    unsigned x, y, i, j;
175 
176    for(y = 0; y < height; y += bh) {
177       int8_t *dst = (int8_t *)dst_row;
178       for(x = 0; x < width; x += bw) {
179          int8_t tmp[4][4];  /* [bh][bw][comps] */
180          for(j = 0; j < bh; ++j) {
181             for(i = 0; i < bw; ++i) {
182 	       tmp[j][i] = float_to_byte_tex(src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4]);
183             }
184          }
185          util_format_signed_encode_rgtc_ubyte(dst, tmp, 4, 4);
186          dst += bytes_per_block;
187       }
188       dst_row += dst_stride / sizeof(*dst_row);
189    }
190 }
191 
192 void
util_format_rgtc1_snorm_unpack_rgba_float(void * dst_row,unsigned dst_stride,const uint8_t * src_row,unsigned src_stride,unsigned width,unsigned height)193 util_format_rgtc1_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
194 {
195    unsigned x, y, i, j;
196    int block_size = 8;
197    for(y = 0; y < height; y += 4) {
198       const int8_t *src = (int8_t *)src_row;
199       for(x = 0; x < width; x += 4) {
200          for(j = 0; j < 4; ++j) {
201             for(i = 0; i < 4; ++i) {
202                float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16);
203                int8_t tmp_r;
204                util_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 1);
205                dst[0] = byte_to_float_tex(tmp_r);
206                dst[1] = 0.0;
207                dst[2] = 0.0;
208                dst[3] = 1.0;
209             }
210          }
211          src += block_size;
212       }
213       src_row += src_stride;
214    }
215 }
216 
217 void
util_format_rgtc1_snorm_fetch_rgba(void * in_dst,const uint8_t * src,unsigned i,unsigned j)218 util_format_rgtc1_snorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
219 {
220    float *dst = in_dst;
221    int8_t tmp_r;
222    util_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 1);
223    dst[0] = byte_to_float_tex(tmp_r);
224    dst[1] = 0.0;
225    dst[2] = 0.0;
226    dst[3] = 1.0;
227 }
228 
229 
230 void
util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t * dst,const uint8_t * src,unsigned i,unsigned j)231 util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
232 {
233    util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
234    util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 1, 2);
235    dst[2] = 0;
236    dst[3] = 255;
237 }
238 
239 void
util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t * dst_row,unsigned dst_stride,const uint8_t * src_row,unsigned src_stride,unsigned width,unsigned height)240 util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
241 {
242    const unsigned bw = 4, bh = 4, comps = 4;
243    unsigned x, y, i, j;
244    unsigned block_size = 16;
245 
246    for(y = 0; y < height; y += bh) {
247       const uint8_t *src = src_row;
248       for(x = 0; x < width; x += bw) {
249          for(j = 0; j < bh; ++j) {
250             for(i = 0; i < bw; ++i) {
251                uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps;
252 	       util_format_unsigned_fetch_texel_rgtc(0, src, i, j, dst, 2);
253 	       util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, dst + 1, 2);
254 	       dst[2] = 0;
255 	       dst[3] = 255;
256 	    }
257 	 }
258 	 src += block_size;
259       }
260       src_row += src_stride;
261    }
262 }
263 
264 void
util_format_rgtc2_unorm_pack_rgba_8unorm(uint8_t * dst_row,unsigned dst_stride,const uint8_t * src_row,unsigned src_stride,unsigned width,unsigned height)265 util_format_rgtc2_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
266 {
267    const unsigned bw = 4, bh = 4, bytes_per_block = 16;
268    unsigned x, y, i, j;
269 
270    for(y = 0; y < height; y += bh) {
271       uint8_t *dst = dst_row;
272       for(x = 0; x < width; x += bw) {
273          uint8_t tmp_r[4][4];  /* [bh][bw] */
274          uint8_t tmp_g[4][4];  /* [bh][bw] */
275          for(j = 0; j < bh; ++j) {
276             for(i = 0; i < bw; ++i) {
277 	       tmp_r[j][i] = src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4];
278 	       tmp_g[j][i] = src_row[((y + j)*src_stride/sizeof(*src_row) + (x + i)*4) + 1];
279             }
280          }
281          util_format_unsigned_encode_rgtc_ubyte(dst, tmp_r, 4, 4);
282          util_format_unsigned_encode_rgtc_ubyte(dst + 8, tmp_g, 4, 4);
283          dst += bytes_per_block;
284       }
285       dst_row += dst_stride / sizeof(*dst_row);
286    }
287 }
288 
289 void
util_format_rxtc2_unorm_pack_rgba_float(uint8_t * dst_row,unsigned dst_stride,const float * src_row,unsigned src_stride,unsigned width,unsigned height,unsigned chan2off)290 util_format_rxtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off)
291 {
292    const unsigned bw = 4, bh = 4, bytes_per_block = 16;
293    unsigned x, y, i, j;
294 
295    for(y = 0; y < height; y += bh) {
296       uint8_t *dst = dst_row;
297       for(x = 0; x < width; x += bw) {
298          uint8_t tmp_r[4][4];  /* [bh][bw][comps] */
299          uint8_t tmp_g[4][4];  /* [bh][bw][comps] */
300          for(j = 0; j < bh; ++j) {
301             for(i = 0; i < bw; ++i) {
302 	       tmp_r[j][i] = float_to_ubyte(src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4]);
303                tmp_g[j][i] = float_to_ubyte(src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4 + chan2off]);
304             }
305          }
306          util_format_unsigned_encode_rgtc_ubyte(dst, tmp_r, 4, 4);
307          util_format_unsigned_encode_rgtc_ubyte(dst + 8, tmp_g, 4, 4);
308          dst += bytes_per_block;
309       }
310       dst_row += dst_stride / sizeof(*dst_row);
311    }
312 }
313 
314 void
util_format_rgtc2_unorm_pack_rgba_float(uint8_t * dst_row,unsigned dst_stride,const float * src_row,unsigned src_stride,unsigned width,unsigned height)315 util_format_rgtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
316 {
317    util_format_rxtc2_unorm_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height, 1);
318 }
319 
320 void
util_format_rgtc2_unorm_unpack_rgba_float(void * dst_row,unsigned dst_stride,const uint8_t * src_row,unsigned src_stride,unsigned width,unsigned height)321 util_format_rgtc2_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
322 {
323    unsigned x, y, i, j;
324    int block_size = 16;
325    for(y = 0; y < height; y += 4) {
326       const uint8_t *src = src_row;
327       for(x = 0; x < width; x += 4) {
328          for(j = 0; j < 4; ++j) {
329             for(i = 0; i < 4; ++i) {
330                float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16);
331                uint8_t tmp_r, tmp_g;
332                util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
333                util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
334                dst[0] = ubyte_to_float(tmp_r);
335                dst[1] = ubyte_to_float(tmp_g);
336                dst[2] = 0.0;
337                dst[3] = 1.0;
338             }
339          }
340          src += block_size;
341       }
342       src_row += src_stride;
343    }
344 }
345 
346 void
util_format_rgtc2_unorm_fetch_rgba(void * in_dst,const uint8_t * src,unsigned i,unsigned j)347 util_format_rgtc2_unorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
348 {
349    float *dst = in_dst;
350    uint8_t tmp_r, tmp_g;
351    util_format_unsigned_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
352    util_format_unsigned_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
353    dst[0] = ubyte_to_float(tmp_r);
354    dst[1] = ubyte_to_float(tmp_g);
355    dst[2] = 0.0;
356    dst[3] = 1.0;
357 }
358 
359 
360 void
util_format_rgtc2_snorm_fetch_rgba_8unorm(UNUSED uint8_t * dst,UNUSED const uint8_t * src,UNUSED unsigned i,UNUSED unsigned j)361 util_format_rgtc2_snorm_fetch_rgba_8unorm(UNUSED uint8_t *dst, UNUSED const uint8_t *src,
362                                           UNUSED unsigned i, UNUSED unsigned j)
363 {
364    fprintf(stderr,"%s\n", __func__);
365 }
366 
367 void
util_format_rgtc2_snorm_unpack_rgba_8unorm(UNUSED uint8_t * dst_row,UNUSED unsigned dst_stride,UNUSED const uint8_t * src_row,UNUSED unsigned src_stride,UNUSED unsigned width,UNUSED unsigned height)368 util_format_rgtc2_snorm_unpack_rgba_8unorm(UNUSED uint8_t *dst_row, UNUSED unsigned dst_stride,
369                                            UNUSED const uint8_t *src_row, UNUSED unsigned src_stride,
370                                            UNUSED unsigned width, UNUSED unsigned height)
371 {
372    fprintf(stderr,"%s\n", __func__);
373 }
374 
375 void
util_format_rgtc2_snorm_pack_rgba_8unorm(UNUSED uint8_t * dst_row,UNUSED unsigned dst_stride,UNUSED const uint8_t * src_row,UNUSED unsigned src_stride,UNUSED unsigned width,UNUSED unsigned height)376 util_format_rgtc2_snorm_pack_rgba_8unorm(UNUSED uint8_t *dst_row, UNUSED unsigned dst_stride,
377                                          UNUSED const uint8_t *src_row, UNUSED unsigned src_stride,
378                                          UNUSED unsigned width, UNUSED unsigned height)
379 {
380    fprintf(stderr,"%s\n", __func__);
381 }
382 
383 void
util_format_rgtc2_snorm_unpack_rgba_float(void * dst_row,unsigned dst_stride,const uint8_t * src_row,unsigned src_stride,unsigned width,unsigned height)384 util_format_rgtc2_snorm_unpack_rgba_float(void *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
385 {
386    unsigned x, y, i, j;
387    int block_size = 16;
388    for(y = 0; y < height; y += 4) {
389       const int8_t *src = (int8_t *)src_row;
390       for(x = 0; x < width; x += 4) {
391          for(j = 0; j < 4; ++j) {
392             for(i = 0; i < 4; ++i) {
393                float *dst = (float *)((uint8_t *)dst_row + (y + j)*dst_stride + (x + i)*16);
394                int8_t tmp_r, tmp_g;
395                util_format_signed_fetch_texel_rgtc(0, src, i, j, &tmp_r, 2);
396                util_format_signed_fetch_texel_rgtc(0, src + 8, i, j, &tmp_g, 2);
397                dst[0] = byte_to_float_tex(tmp_r);
398                dst[1] = byte_to_float_tex(tmp_g);
399                dst[2] = 0.0;
400                dst[3] = 1.0;
401             }
402          }
403          src += block_size;
404       }
405       src_row += src_stride;
406    }
407 }
408 
409 void
util_format_rxtc2_snorm_pack_rgba_float(uint8_t * dst_row,unsigned dst_stride,const float * src_row,unsigned src_stride,unsigned width,unsigned height,unsigned chan2off)410 util_format_rxtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off)
411 {
412    const unsigned bw = 4, bh = 4, bytes_per_block = 16;
413    unsigned x, y, i, j;
414 
415    for(y = 0; y < height; y += bh) {
416       int8_t *dst = (int8_t *)dst_row;
417       for(x = 0; x < width; x += bw) {
418          int8_t tmp_r[4][4];  /* [bh][bw][comps] */
419          int8_t tmp_g[4][4];  /* [bh][bw][comps] */
420          for(j = 0; j < bh; ++j) {
421             for(i = 0; i < bw; ++i) {
422 	       tmp_r[j][i] = float_to_byte_tex(src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4]);
423                tmp_g[j][i] = float_to_byte_tex(src_row[(y + j)*src_stride/sizeof(*src_row) + (x + i)*4 + chan2off]);
424             }
425          }
426          util_format_signed_encode_rgtc_ubyte(dst, tmp_r, 4, 4);
427          util_format_signed_encode_rgtc_ubyte(dst + 8, tmp_g, 4, 4);
428          dst += bytes_per_block;
429       }
430       dst_row += dst_stride / sizeof(*dst_row);
431    }
432 }
433 
434 void
util_format_rgtc2_snorm_pack_rgba_float(uint8_t * dst_row,unsigned dst_stride,const float * src_row,unsigned src_stride,unsigned width,unsigned height)435 util_format_rgtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
436 {
437    util_format_rxtc2_snorm_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height, 1);
438 }
439 
440 void
util_format_rgtc2_snorm_fetch_rgba(void * in_dst,const uint8_t * src,unsigned i,unsigned j)441 util_format_rgtc2_snorm_fetch_rgba(void *in_dst, const uint8_t *src, unsigned i, unsigned j)
442 {
443    float *dst = in_dst;
444    int8_t tmp_r, tmp_g;
445    util_format_signed_fetch_texel_rgtc(0, (int8_t *)src, i, j, &tmp_r, 2);
446    util_format_signed_fetch_texel_rgtc(0, (int8_t *)src + 8, i, j, &tmp_g, 2);
447    dst[0] = byte_to_float_tex(tmp_r);
448    dst[1] = byte_to_float_tex(tmp_g);
449    dst[2] = 0.0;
450    dst[3] = 1.0;
451 }
452 
453