1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 /* Authors: Keith Whitwell <keith@tungstengraphics.com>
38 #include "pipe/p_state.h"
39 #include "rtasm/rtasm_x86sse.h"
50 #define MAX_INPUTS PIPE_MAX_ATTRIBS
51 #define MAX_OUTPUTS PIPE_MAX_ATTRIBS
52 #define MAX_TEMPS PIPE_MAX_ATTRIBS /* say */
53 #define MAX_CONSTANTS PIPE_MAX_ATTRIBS /* say */
54 #define MAX_IMMEDIATES PIPE_MAX_ATTRIBS /* say */
55 #define MAX_INTERNALS 8
57 #define AOS_FILE_INTERNAL TGSI_FILE_COUNT
60 #define FPU_RND_NEAREST 2
63 typedef void PIPE_CDECL (*lit_func
)( struct aos_machine
*,
75 struct shine_tab
*shine_tab
;
78 #define MAX_SHINE_TAB 4
79 #define MAX_LIT_INFO 16
81 /* This is the temporary storage used by all the aos_sse vs varients.
82 * Create one per context and reuse by passing a pointer in at
83 * vs_varient creation??
86 float input
[MAX_INPUTS
][4];
87 float output
[MAX_OUTPUTS
][4];
88 float temp
[MAX_TEMPS
][4];
89 float constant
[MAX_CONSTANTS
][4]; /* fixme -- should just be a pointer */
90 float immediate
[MAX_IMMEDIATES
][4]; /* fixme -- should just be a pointer */
91 float internal
[MAX_INTERNALS
][4];
93 float scale
[4]; /* viewport */
94 float translate
[4]; /* viewport */
96 float tmp
[2][4]; /* scratch space for LIT */
98 struct shine_tab shine_tab
[MAX_SHINE_TAB
];
99 struct lit_info lit_info
[MAX_LIT_INFO
];
103 ushort fpu_rnd_nearest
;
104 ushort fpu_rnd_neg_inf
;
106 ushort fpucntl
; /* one of FPU_* above */
109 const void *input_ptr
;
110 unsigned input_stride
;
112 unsigned output_offset
;
113 } attrib
[PIPE_MAX_ATTRIBS
];
119 struct aos_compilation
{
120 struct x86_function
*func
;
121 struct draw_vs_varient_aos_sse
*vaos
;
123 unsigned insn_counter
;
124 unsigned num_immediates
;
136 boolean input_fetched
[PIPE_MAX_ATTRIBS
];
137 unsigned output_last_write
[PIPE_MAX_ATTRIBS
];
143 /* these are actually known values, but putting them in a struct
144 * like this is helpful to keep them in sync across the file.
146 struct x86_reg tmp_EAX
;
147 struct x86_reg idx_EBX
; /* either start+i or &elt[i] */
148 struct x86_reg outbuf_ECX
;
149 struct x86_reg machine_EDX
;
150 struct x86_reg count_ESI
; /* decrements to zero */
153 struct x86_reg
aos_get_xmm_reg( struct aos_compilation
*cp
);
154 void aos_release_xmm_reg( struct aos_compilation
*cp
, unsigned idx
);
156 void aos_adopt_xmm_reg( struct aos_compilation
*cp
,
162 struct x86_reg
aos_get_shader_reg( struct aos_compilation
*cp
,
166 boolean
aos_fetch_inputs( struct aos_compilation
*cp
,
169 boolean
aos_emit_outputs( struct aos_compilation
*cp
);
172 #define IMM_ONES 0 /* 1, 1,1,1 */
173 #define IMM_SWZ 1 /* 1,-1,0, 0xffffffff */
174 #define IMM_IDENTITY 2 /* 0, 0,0,1 */
175 #define IMM_INV_255 3 /* 1/255, 1/255, 1/255, 1/255 */
176 #define IMM_255 4 /* 255, 255, 255, 255 */
177 #define IMM_NEGS 5 /* -1,-1,-1,-1 */
178 #define IMM_RSQ 6 /* -.5,1.5,_,_ */
179 #define IMM_PSIZE 7 /* not really an immediate - updated each run */
181 struct x86_reg
aos_get_internal( struct aos_compilation
*cp
,
183 struct x86_reg
aos_get_internal_xmm( struct aos_compilation
*cp
,
187 #define ERROR(cp, msg) \
189 debug_printf("%s: x86 translation failed: %s\n", __FUNCTION__, msg); \
199 struct draw_vs_varient_aos_sse
{
200 struct draw_vs_varient base
;
201 struct draw_context
*draw
;
207 } attrib
[PIPE_MAX_ATTRIBS
];
210 struct aos_machine
*machine
; /* XXX: temporarily unshared */
212 vsv_run_linear_func gen_run_linear
;
213 vsv_run_elts_func gen_run_elts
;
216 struct x86_function func
[2];