Zack Rusin | 7d69090 | 2008-02-04 10:07:02 -0500 | [diff] [blame] | 1 | #ifndef GALLIVM_P_H |
| 2 | #define GALLIVM_P_H |
| 3 | |
| 4 | #ifdef MESA_LLVM |
| 5 | |
Zack Rusin | 3c3c1ff | 2008-02-12 23:08:42 -0500 | [diff] [blame] | 6 | #include "gallivm.h" |
| 7 | #include "pipe/p_shader_tokens.h" |
| 8 | #include "pipe/p_compiler.h" |
| 9 | |
Zack Rusin | 7d69090 | 2008-02-04 10:07:02 -0500 | [diff] [blame] | 10 | namespace llvm { |
| 11 | class Module; |
| 12 | } |
| 13 | |
| 14 | #if defined __cplusplus |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
| 18 | enum gallivm_shader_type; |
| 19 | enum gallivm_vector_layout; |
| 20 | |
| 21 | struct gallivm_interpolate { |
| 22 | int attrib; |
| 23 | int chan; |
| 24 | int type; |
| 25 | }; |
| 26 | |
| 27 | struct gallivm_ir { |
| 28 | llvm::Module *module; |
| 29 | int id; |
| 30 | enum gallivm_shader_type type; |
| 31 | enum gallivm_vector_layout layout; |
| 32 | int num_components; |
| 33 | int num_consts; |
| 34 | |
José Fonseca | 9a8a5d7 | 2008-02-27 16:42:15 +0900 | [diff] [blame] | 35 | /* FIXME: this might not be enough for some shaders */ |
Zack Rusin | 7d69090 | 2008-02-04 10:07:02 -0500 | [diff] [blame] | 36 | struct gallivm_interpolate interpolators[32*4]; |
| 37 | int num_interp; |
| 38 | }; |
| 39 | |
| 40 | struct gallivm_prog { |
| 41 | llvm::Module *module; |
| 42 | void *function; |
| 43 | |
| 44 | int id; |
| 45 | enum gallivm_shader_type type; |
| 46 | |
| 47 | int num_consts; |
| 48 | |
José Fonseca | 9a8a5d7 | 2008-02-27 16:42:15 +0900 | [diff] [blame] | 49 | /* FIXME: this might not be enough for some shaders */ |
Zack Rusin | 7d69090 | 2008-02-04 10:07:02 -0500 | [diff] [blame] | 50 | struct gallivm_interpolate interpolators[32*4]; |
| 51 | int num_interp; |
| 52 | }; |
| 53 | |
Zack Rusin | 3c3c1ff | 2008-02-12 23:08:42 -0500 | [diff] [blame] | 54 | static INLINE void gallivm_swizzle_components(int swizzle, |
| 55 | int *xc, int *yc, |
| 56 | int *zc, int *wc) |
| 57 | { |
| 58 | int x = swizzle / 1000; swizzle -= x * 1000; |
| 59 | int y = swizzle / 100; swizzle -= y * 100; |
| 60 | int z = swizzle / 10; swizzle -= z * 10; |
| 61 | int w = swizzle; |
| 62 | |
| 63 | if (xc) *xc = x; |
| 64 | if (yc) *yc = y; |
| 65 | if (zc) *zc = z; |
| 66 | if (wc) *wc = w; |
| 67 | } |
| 68 | |
| 69 | static INLINE boolean gallivm_is_swizzle(int swizzle) |
| 70 | { |
| 71 | const int NO_SWIZZLE = TGSI_SWIZZLE_X * 1000 + TGSI_SWIZZLE_Y * 100 + |
| 72 | TGSI_SWIZZLE_Z * 10 + TGSI_SWIZZLE_W; |
| 73 | return swizzle != NO_SWIZZLE; |
| 74 | } |
| 75 | |
| 76 | static INLINE int gallivm_x_swizzle(int swizzle) |
| 77 | { |
| 78 | int x; |
| 79 | gallivm_swizzle_components(swizzle, &x, 0, 0, 0); |
| 80 | return x; |
| 81 | } |
| 82 | |
| 83 | static INLINE int gallivm_y_swizzle(int swizzle) |
| 84 | { |
| 85 | int y; |
| 86 | gallivm_swizzle_components(swizzle, 0, &y, 0, 0); |
| 87 | return y; |
| 88 | } |
| 89 | |
| 90 | static INLINE int gallivm_z_swizzle(int swizzle) |
| 91 | { |
| 92 | int z; |
| 93 | gallivm_swizzle_components(swizzle, 0, 0, &z, 0); |
| 94 | return z; |
| 95 | } |
| 96 | |
| 97 | static INLINE int gallivm_w_swizzle(int swizzle) |
| 98 | { |
| 99 | int w; |
| 100 | gallivm_swizzle_components(swizzle, 0, 0, 0, &w); |
| 101 | return w; |
| 102 | } |
| 103 | |
Zack Rusin | 7d69090 | 2008-02-04 10:07:02 -0500 | [diff] [blame] | 104 | #if defined __cplusplus |
José Fonseca | 9a8a5d7 | 2008-02-27 16:42:15 +0900 | [diff] [blame] | 105 | } |
Zack Rusin | 7d69090 | 2008-02-04 10:07:02 -0500 | [diff] [blame] | 106 | #endif |
| 107 | |
Stephane Marchesin | 7b0e0e1 | 2008-11-16 20:32:05 +0100 | [diff] [blame] | 108 | #endif /* MESA_LLVM */ |
| 109 | |
Zack Rusin | 7d69090 | 2008-02-04 10:07:02 -0500 | [diff] [blame] | 110 | #endif |