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
00030
00031 #ifndef DRAW_VS_AOS_H
00032 #define DRAW_VS_AOS_H
00033
00034 #include "pipe/p_config.h"
00035
00036 #ifdef PIPE_ARCH_X86
00037
00038 struct tgsi_token;
00039 struct x86_function;
00040
00041 #include "pipe/p_state.h"
00042 #include "rtasm/rtasm_x86sse.h"
00043
00044
00045
00046
00047
00048 #define X 0
00049 #define Y 1
00050 #define Z 2
00051 #define W 3
00052
00053 #define MAX_INPUTS PIPE_MAX_ATTRIBS
00054 #define MAX_OUTPUTS PIPE_MAX_SHADER_OUTPUTS
00055 #define MAX_TEMPS TGSI_EXEC_NUM_TEMPS
00056 #define MAX_CONSTANTS 1024
00057 #define MAX_IMMEDIATES 1024
00058 #define MAX_INTERNALS 8
00060 #define AOS_FILE_INTERNAL TGSI_FILE_COUNT
00061
00062 #define FPU_RND_NEG 1
00063 #define FPU_RND_NEAREST 2
00064
00065 struct aos_machine;
00066 typedef void (PIPE_CDECL *lit_func)( struct aos_machine *,
00067 float *result,
00068 const float *in,
00069 unsigned count );
00070
00071 void PIPE_CDECL aos_do_lit( struct aos_machine *machine,
00072 float *result,
00073 const float *in,
00074 unsigned count );
00075
00076 struct shine_tab {
00077 float exponent;
00078 float values[258];
00079 unsigned last_used;
00080 };
00081
00082 struct lit_info {
00083 lit_func func;
00084 struct shine_tab *shine_tab;
00085 };
00086
00087 #define MAX_SHINE_TAB 4
00088 #define MAX_LIT_INFO 16
00089
00090 struct aos_buffer {
00091 const void *base_ptr;
00092 unsigned stride;
00093 void *ptr;
00094 };
00095
00096
00097
00098
00099
00100
00101
00102
00103 struct aos_machine {
00104 float input [MAX_INPUTS ][4];
00105 float output [MAX_OUTPUTS ][4];
00106 float temp [MAX_TEMPS ][4];
00107 float internal [MAX_INTERNALS ][4];
00108
00109 float scale[4];
00110 float translate[4];
00111
00112 float tmp[2][4];
00113
00114 struct shine_tab shine_tab[MAX_SHINE_TAB];
00115 struct lit_info lit_info[MAX_LIT_INFO];
00116 unsigned now;
00117
00118
00119 ushort fpu_rnd_nearest;
00120 ushort fpu_rnd_neg_inf;
00121 ushort fpu_restore;
00122 ushort fpucntl;
00123
00124 const float (*immediates)[4];
00125 const float (*constants)[4];
00126
00127 const struct aos_buffer *buffer;
00128 };
00129
00130
00131
00132
00133 struct aos_compilation {
00134 struct x86_function *func;
00135 struct draw_vs_varient_aos_sse *vaos;
00136
00137 unsigned insn_counter;
00138 unsigned num_immediates;
00139 unsigned count;
00140 unsigned lit_count;
00141
00142 struct {
00143 unsigned idx:16;
00144 unsigned file:8;
00145 unsigned dirty:8;
00146 unsigned last_used;
00147 } xmm[8];
00148
00149 unsigned x86_reg[2];
00150
00151 boolean input_fetched[PIPE_MAX_ATTRIBS];
00152 unsigned output_last_write[PIPE_MAX_ATTRIBS];
00153
00154 boolean have_sse2;
00155 boolean error;
00156 short fpucntl;
00157
00158
00159
00160
00161 struct x86_reg tmp_EAX;
00162 struct x86_reg idx_EBX;
00163 struct x86_reg outbuf_ECX;
00164 struct x86_reg machine_EDX;
00165 struct x86_reg count_ESI;
00166 struct x86_reg temp_EBP;
00167 struct x86_reg stack_ESP;
00168 };
00169
00170 struct x86_reg aos_get_xmm_reg( struct aos_compilation *cp );
00171 void aos_release_xmm_reg( struct aos_compilation *cp, unsigned idx );
00172
00173 void aos_adopt_xmm_reg( struct aos_compilation *cp,
00174 struct x86_reg reg,
00175 unsigned file,
00176 unsigned idx,
00177 unsigned dirty );
00178
00179 void aos_spill_all( struct aos_compilation *cp );
00180
00181 struct x86_reg aos_get_shader_reg( struct aos_compilation *cp,
00182 unsigned file,
00183 unsigned idx );
00184
00185 boolean aos_init_inputs( struct aos_compilation *cp, boolean linear );
00186 boolean aos_fetch_inputs( struct aos_compilation *cp, boolean linear );
00187 boolean aos_incr_inputs( struct aos_compilation *cp, boolean linear );
00188
00189 boolean aos_emit_outputs( struct aos_compilation *cp );
00190
00191
00192 #define IMM_ONES 0
00193 #define IMM_SWZ 1
00194 #define IMM_IDENTITY 2
00195 #define IMM_INV_255 3
00196 #define IMM_255 4
00197 #define IMM_NEGS 5
00198 #define IMM_RSQ 6
00199 #define IMM_PSIZE 7
00200
00201 struct x86_reg aos_get_internal( struct aos_compilation *cp,
00202 unsigned imm );
00203 struct x86_reg aos_get_internal_xmm( struct aos_compilation *cp,
00204 unsigned imm );
00205
00206
00207 #define ERROR(cp, msg) \
00208 do { \
00209 if (0) debug_printf("%s: x86 translation failed: %s\n", __FUNCTION__, msg); \
00210 cp->error = 1; \
00211 } while (0)
00212
00213
00214 #define X86_NULL 0
00215 #define X86_IMMEDIATES 1
00216 #define X86_CONSTANTS 2
00217 #define X86_BUFFERS 3
00218
00219 struct x86_reg aos_get_x86( struct aos_compilation *cp,
00220 unsigned which_reg,
00221 unsigned value );
00222
00223
00224 typedef void (PIPE_CDECL *vaos_run_elts_func)( struct aos_machine *,
00225 const unsigned *elts,
00226 unsigned count,
00227 void *output_buffer);
00228
00229 typedef void (PIPE_CDECL *vaos_run_linear_func)( struct aos_machine *,
00230 unsigned start,
00231 unsigned count,
00232 void *output_buffer);
00233
00234
00235 struct draw_vs_varient_aos_sse {
00236 struct draw_vs_varient base;
00237 struct draw_context *draw;
00238
00239 struct aos_buffer *buffer;
00240 unsigned nr_vb;
00241
00242 vaos_run_linear_func gen_run_linear;
00243 vaos_run_elts_func gen_run_elts;
00244
00245
00246 struct x86_function func[2];
00247 };
00248
00249
00250 #endif
00251
00252 #endif
00253