An attempt at encoding/decoding lines/uint16. It sucks, but it's a starting point.
[babel] / babel.cl
1 #include "babel_cl.h"
2
3
4 __kernel
5 void
6 decodelines(
7         __global char* restrict page,
8         __global const line_t * restrict line,
9         uint numpages, uint numlines)
10 {
11         /* line index */
12         size_t lix = get_global_id(0);
13
14         /* column */
15         size_t col = get_global_id(1);
16
17         if (lix >= numpages*CHARS_PER_PAGE || col >= CHARS_PER_LINE)
18                 return;
19
20         /* global index in the page */
21         size_t gix = lix*CHARS_PER_LINE + col;
22
23         /* TODO get a character with a specific algorithm */
24         line_t l = line[lix % numlines];
25
26         size_t cix = get_symbol_index(&l, col);
27
28 #if 1 /* check, shouldn't happen */
29         if (cix > SYMBOLS)
30                 page[gix] = '?';
31         else
32 #endif
33
34         page[gix] = alphabet[cix];
35
36 }