gallivm_p.h

Go to the documentation of this file.
00001 #ifndef GALLIVM_P_H
00002 #define GALLIVM_P_H
00003 
00004 #ifdef MESA_LLVM
00005 
00006 #include "gallivm.h"
00007 #include "pipe/p_shader_tokens.h"
00008 #include "pipe/p_compiler.h"
00009 
00010 namespace llvm {
00011    class Module;
00012 }
00013 
00014 #if defined __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 enum gallivm_shader_type;
00019 enum gallivm_vector_layout;
00020 
00021 struct gallivm_interpolate {
00022    int attrib;
00023    int chan;
00024    int type;
00025 };
00026 
00027 struct gallivm_ir {
00028    llvm::Module *module;
00029    int id;
00030    enum gallivm_shader_type type;
00031    enum gallivm_vector_layout layout;
00032    int num_components;
00033    int   num_consts;
00034 
00035    /* FIXME: this might not be enough for some shaders */
00036    struct gallivm_interpolate interpolators[32*4];
00037    int   num_interp;
00038 };
00039 
00040 struct gallivm_prog {
00041    llvm::Module *module;
00042    void *function;
00043 
00044    int   id;
00045    enum gallivm_shader_type type;
00046 
00047    int   num_consts;
00048 
00049    /* FIXME: this might not be enough for some shaders */
00050    struct gallivm_interpolate interpolators[32*4];
00051    int   num_interp;
00052 };
00053 
00054 static INLINE void gallivm_swizzle_components(int swizzle,
00055                                               int *xc, int *yc,
00056                                               int *zc, int *wc)
00057 {
00058    int x = swizzle / 1000; swizzle -= x * 1000;
00059    int y = swizzle / 100;  swizzle -= y * 100;
00060    int z = swizzle / 10;   swizzle -= z * 10;
00061    int w = swizzle;
00062 
00063    if (xc) *xc = x;
00064    if (yc) *yc = y;
00065    if (zc) *zc = z;
00066    if (wc) *wc = w;
00067 }
00068 
00069 static INLINE boolean gallivm_is_swizzle(int swizzle)
00070 {
00071    const int NO_SWIZZLE = TGSI_SWIZZLE_X * 1000 + TGSI_SWIZZLE_Y * 100 +
00072                           TGSI_SWIZZLE_Z * 10 + TGSI_SWIZZLE_W;
00073    return swizzle != NO_SWIZZLE;
00074 }
00075 
00076 static INLINE int gallivm_x_swizzle(int swizzle)
00077 {
00078    int x;
00079    gallivm_swizzle_components(swizzle, &x, 0, 0, 0);
00080    return x;
00081 }
00082 
00083 static INLINE int gallivm_y_swizzle(int swizzle)
00084 {
00085    int y;
00086    gallivm_swizzle_components(swizzle, 0, &y, 0, 0);
00087    return y;
00088 }
00089 
00090 static INLINE int gallivm_z_swizzle(int swizzle)
00091 {
00092    int z;
00093    gallivm_swizzle_components(swizzle, 0, 0, &z, 0);
00094    return z;
00095 }
00096 
00097 static INLINE int gallivm_w_swizzle(int swizzle)
00098 {
00099    int w;
00100    gallivm_swizzle_components(swizzle, 0, 0, 0, &w);
00101    return w;
00102 }
00103 
00104 #endif /* MESA_LLVM */
00105 
00106 #if defined __cplusplus
00107 }
00108 #endif
00109 
00110 #endif

Generated on Tue Sep 29 06:25:14 2009 for Gallium3D by  doxygen 1.5.4