00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef I915_FPC_H
00030 #define I915_FPC_H
00031
00032
00033 #include "i915_context.h"
00034 #include "i915_reg.h"
00035
00036
00037
00038 #define I915_PROGRAM_SIZE 192
00039
00040
00041
00045 struct i915_fp_compile {
00046 struct i915_fragment_shader *shader;
00047
00048 boolean used_constants[I915_MAX_CONSTANT];
00049
00051 uint num_immediates;
00052 uint immediates_map[I915_MAX_CONSTANT];
00053 float immediates[I915_MAX_CONSTANT][4];
00054
00055 boolean first_instruction;
00056
00057 uint declarations[I915_PROGRAM_SIZE];
00058 uint program[I915_PROGRAM_SIZE];
00059
00060 uint *csr;
00062 uint *decl;
00064 uint decl_s;
00065 uint decl_t;
00067 uint temp_flag;
00068 uint utemp_flag;
00070 uint nr_tex_indirect;
00071 uint nr_tex_insn;
00072 uint nr_alu_insn;
00073 uint nr_decl_insn;
00074
00075 boolean error;
00076 uint wpos_tex;
00077 uint NumNativeInstructions;
00078 uint NumNativeAluInstructions;
00079 uint NumNativeTexInstructions;
00080 uint NumNativeTexIndirections;
00081 };
00082
00083
00084
00085
00086
00087 #define UREG_TYPE_SHIFT 29
00088 #define UREG_NR_SHIFT 24
00089 #define UREG_CHANNEL_X_NEGATE_SHIFT 23
00090 #define UREG_CHANNEL_X_SHIFT 20
00091 #define UREG_CHANNEL_Y_NEGATE_SHIFT 19
00092 #define UREG_CHANNEL_Y_SHIFT 16
00093 #define UREG_CHANNEL_Z_NEGATE_SHIFT 15
00094 #define UREG_CHANNEL_Z_SHIFT 12
00095 #define UREG_CHANNEL_W_NEGATE_SHIFT 11
00096 #define UREG_CHANNEL_W_SHIFT 8
00097 #define UREG_CHANNEL_ZERO_NEGATE_MBZ 5
00098 #define UREG_CHANNEL_ZERO_SHIFT 4
00099 #define UREG_CHANNEL_ONE_NEGATE_MBZ 1
00100 #define UREG_CHANNEL_ONE_SHIFT 0
00101
00102 #define UREG_BAD 0xffffffff
00103
00104 #define X SRC_X
00105 #define Y SRC_Y
00106 #define Z SRC_Z
00107 #define W SRC_W
00108 #define ZERO SRC_ZERO
00109 #define ONE SRC_ONE
00110
00111
00112
00113 #define UREG( type, nr ) (((type)<< UREG_TYPE_SHIFT) | \
00114 ((nr) << UREG_NR_SHIFT) | \
00115 (X << UREG_CHANNEL_X_SHIFT) | \
00116 (Y << UREG_CHANNEL_Y_SHIFT) | \
00117 (Z << UREG_CHANNEL_Z_SHIFT) | \
00118 (W << UREG_CHANNEL_W_SHIFT) | \
00119 (ZERO << UREG_CHANNEL_ZERO_SHIFT) | \
00120 (ONE << UREG_CHANNEL_ONE_SHIFT))
00121
00122 #define GET_CHANNEL_SRC( reg, channel ) ((reg<<(channel*4)) & (0xf<<20))
00123 #define CHANNEL_SRC( src, channel ) (src>>(channel*4))
00124
00125 #define GET_UREG_TYPE(reg) (((reg)>>UREG_TYPE_SHIFT)®_TYPE_MASK)
00126 #define GET_UREG_NR(reg) (((reg)>>UREG_NR_SHIFT)®_NR_MASK)
00127
00128
00129
00130 #define UREG_XYZW_CHANNEL_MASK 0x00ffff00
00131
00132
00133
00134 static INLINE int
00135 swizzle(int reg, uint x, uint y, uint z, uint w)
00136 {
00137 assert(x <= SRC_ONE);
00138 assert(y <= SRC_ONE);
00139 assert(z <= SRC_ONE);
00140 assert(w <= SRC_ONE);
00141 return ((reg & ~UREG_XYZW_CHANNEL_MASK) |
00142 CHANNEL_SRC(GET_CHANNEL_SRC(reg, x), 0) |
00143 CHANNEL_SRC(GET_CHANNEL_SRC(reg, y), 1) |
00144 CHANNEL_SRC(GET_CHANNEL_SRC(reg, z), 2) |
00145 CHANNEL_SRC(GET_CHANNEL_SRC(reg, w), 3));
00146 }
00147
00148
00149
00150
00151
00152
00153 extern void
00154 i915_translate_fragment_program( struct i915_context *i915,
00155 struct i915_fragment_shader *fs);
00156
00157
00158
00159 extern uint i915_get_temp(struct i915_fp_compile *p);
00160 extern uint i915_get_utemp(struct i915_fp_compile *p);
00161 extern void i915_release_utemps(struct i915_fp_compile *p);
00162
00163
00164 extern uint i915_emit_texld(struct i915_fp_compile *p,
00165 uint dest,
00166 uint destmask,
00167 uint sampler, uint coord, uint op);
00168
00169 extern uint i915_emit_arith(struct i915_fp_compile *p,
00170 uint op,
00171 uint dest,
00172 uint mask,
00173 uint saturate,
00174 uint src0, uint src1, uint src2);
00175
00176 extern uint i915_emit_decl(struct i915_fp_compile *p,
00177 uint type, uint nr, uint d0_flags);
00178
00179
00180 extern uint i915_emit_const1f(struct i915_fp_compile *p, float c0);
00181
00182 extern uint i915_emit_const2f(struct i915_fp_compile *p,
00183 float c0, float c1);
00184
00185 extern uint i915_emit_const4fv(struct i915_fp_compile *p,
00186 const float * c);
00187
00188 extern uint i915_emit_const4f(struct i915_fp_compile *p,
00189 float c0, float c1,
00190 float c2, float c3);
00191
00192
00193
00194
00195
00196 extern void i915_disassemble_program(const uint * program, uint sz);
00197
00198
00199
00200
00201
00202
00203 extern void
00204 i915_program_error(struct i915_fp_compile *p, const char *msg, ...);
00205
00206
00207 #endif