a.disp == b.disp);
}
+struct x86_reg aos_get_x86( struct aos_compilation *cp,
+ unsigned value )
+{
+ if (cp->ebp != value) {
+ unsigned offset;
+
+ switch (value) {
+ case X86_IMMEDIATES:
+ offset = Offset(struct aos_machine, immediates);
+ break;
+ case X86_CONSTANTS:
+ offset = Offset(struct aos_machine, constants);
+ break;
+ case X86_ATTRIBS:
+ offset = Offset(struct aos_machine, attrib);
+ break;
+ default:
+ assert(0);
+ offset = 0;
+ }
+
+ x86_mov(cp->func, cp->temp_EBP,
+ x86_make_disp(cp->machine_EDX, offset));
+ /* x86_deref(x86_make_disp(cp->machine_EDX, offset))); */
+
+ cp->ebp = value;
+ }
+
+ return cp->temp_EBP;
+}
+
static struct x86_reg get_reg_ptr(struct aos_compilation *cp,
unsigned file,
case TGSI_FILE_TEMPORARY:
return x86_make_disp(ptr, Offset(struct aos_machine, temp[idx]));
- case TGSI_FILE_IMMEDIATE:
- return x86_make_disp(ptr, Offset(struct aos_machine, immediate[idx]));
-
- case TGSI_FILE_CONSTANT:
- return x86_make_disp(ptr, Offset(struct aos_machine, constant[idx]));
-
case AOS_FILE_INTERNAL:
return x86_make_disp(ptr, Offset(struct aos_machine, internal[idx]));
+ case TGSI_FILE_IMMEDIATE:
+ return x86_make_disp(aos_get_x86(cp, X86_IMMEDIATES), idx * 4 * sizeof(float));
+
+ case TGSI_FILE_CONSTANT:
+ return x86_make_disp(aos_get_x86(cp, X86_CONSTANTS), idx * 4 * sizeof(float));
+
default:
ERROR(cp, "unknown reg file");
return x86_make_reg(0,0);
}
+#if 0
static boolean note_immediate( struct aos_compilation *cp,
struct tgsi_full_immediate *imm )
{
return TRUE;
}
+#endif
cp.outbuf_ECX = x86_make_reg(file_REG32, reg_CX);
cp.machine_EDX = x86_make_reg(file_REG32, reg_DX);
cp.count_ESI = x86_make_reg(file_REG32, reg_SI);
+ cp.temp_EBP = x86_make_reg(file_REG32, reg_BP);
x86_init_func(cp.func);
x86_push(cp.func, cp.idx_EBX);
x86_push(cp.func, cp.count_ESI);
+ x86_push(cp.func, cp.temp_EBP);
/* Load arguments into regs:
switch (parse.FullToken.Token.Type) {
case TGSI_TOKEN_TYPE_IMMEDIATE:
+#if 0
if (!note_immediate( &cp, &parse.FullToken.FullImmediate ))
goto fail;
+#endif
break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
if (cp.func->need_emms)
mmx_emms(cp.func);
+ x86_pop(cp.func, cp.temp_EBP);
x86_pop(cp.func, cp.count_ESI);
x86_pop(cp.func, cp.idx_EBX);
for (i = 0; i < vaos->base.key.nr_inputs; i++) {
if (vaos->base.key.element[i].in.buffer == buf) {
- vaos->machine->attrib[i].input_ptr = ((char *)ptr +
- vaos->base.key.element[i].in.offset);
- vaos->machine->attrib[i].input_stride = stride;
+ vaos->attrib[i].input_ptr = ((char *)ptr +
+ vaos->base.key.element[i].in.offset);
+ vaos->attrib[i].input_stride = stride;
}
}
}
-static void vaos_destroy( struct draw_vs_varient *varient )
-{
- struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
-
- if (vaos->machine)
- align_free( vaos->machine );
-
- x86_release_func( &vaos->func[0] );
- x86_release_func( &vaos->func[1] );
-
- FREE(vaos);
-}
static void PIPE_CDECL vaos_run_elts( struct draw_vs_varient *varient,
const unsigned *elts,
struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
vaos->machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
+ vaos->machine->constants = vaos->draw->pt.user.constants;
+ vaos->machine->immediates = vaos->base.vs->immediates;
+ vaos->machine->attrib = vaos->attrib;
+
vaos->gen_run_elts( varient,
elts,
count,
struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
vaos->machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
+ vaos->machine->constants = vaos->draw->pt.user.constants;
+ vaos->machine->immediates = vaos->base.vs->immediates;
+ vaos->machine->attrib = vaos->attrib;
+
vaos->gen_run_linear( varient,
start,
count,
{
struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
- memcpy(vaos->machine->constant,
- constants,
- (vaos->base.vs->info.file_max[TGSI_FILE_CONSTANT] + 1) * 4 * sizeof(float));
-
#if 0
unsigned i;
for (i =0; i < vaos->base.vs->info.file_max[TGSI_FILE_CONSTANT] + 1; i++)
memcpy(vaos->machine->translate, viewport->translate, 4 * sizeof(float));
}
+static void vaos_destroy( struct draw_vs_varient *varient )
+{
+ struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
+
+ if (vaos->machine)
+ align_free( vaos->machine );
+
+ FREE( vaos->attrib );
+
+ x86_release_func( &vaos->func[0] );
+ x86_release_func( &vaos->func[1] );
+
+ FREE(vaos);
+}
+
static struct draw_vs_varient *varient_aos_sse( struct draw_vertex_shader *vs,
vaos->base.run_elts = vaos_run_elts;
vaos->draw = vs->draw;
+
+ vaos->attrib = MALLOC( key->nr_inputs * sizeof(vaos->attrib[0]) );
+ if (!vaos->attrib)
+ goto fail;
+
vaos->machine = align_malloc( sizeof(struct aos_machine), 16 );
if (!vaos->machine)
goto fail;
return &vaos->base;
fail:
- if (vaos->machine)
+ if (vaos && vaos->attrib)
+ FREE(vaos->attrib);
+
+ if (vaos && vaos->machine)
align_free( vaos->machine );
if (vaos)
#define MAX_SHINE_TAB 4
#define MAX_LIT_INFO 16
+struct aos_attrib {
+ const void *input_ptr;
+ unsigned input_stride;
+};
+
+
+
+
/* This is the temporary storage used by all the aos_sse vs varients.
* Create one per context and reuse by passing a pointer in at
* vs_varient creation??
float input [MAX_INPUTS ][4];
float output [MAX_OUTPUTS ][4];
float temp [MAX_TEMPS ][4];
- float constant [MAX_CONSTANTS ][4]; /* fixme -- should just be a pointer */
- float immediate[MAX_IMMEDIATES][4]; /* fixme -- should just be a pointer */
float internal [MAX_INTERNALS ][4];
float scale[4]; /* viewport */
ushort fpu_restore;
ushort fpucntl; /* one of FPU_* above */
- struct {
- const void *input_ptr;
- unsigned input_stride;
+ const float (*immediates)[4]; /* points to shader data */
+ const float (*constants)[4]; /* points to draw data */
- unsigned output_offset;
- } attrib[PIPE_MAX_ATTRIBS];
+ const struct aos_attrib *attrib; /* points to ? */
};
unsigned last_used;
} xmm[8];
+ unsigned ebp; /* one of X86_* */
boolean input_fetched[PIPE_MAX_ATTRIBS];
unsigned output_last_write[PIPE_MAX_ATTRIBS];
struct x86_reg outbuf_ECX;
struct x86_reg machine_EDX;
struct x86_reg count_ESI; /* decrements to zero */
+ struct x86_reg temp_EBP;
};
struct x86_reg aos_get_xmm_reg( struct aos_compilation *cp );
} while (0)
+#define X86_NULL 0
+#define X86_IMMEDIATES 1
+#define X86_CONSTANTS 2
+#define X86_ATTRIBS 3
-
+struct x86_reg aos_get_x86( struct aos_compilation *cp,
+ unsigned value );
struct draw_vs_varient_aos_sse {
struct draw_vs_varient base;
struct draw_context *draw;
-#if 0
- struct {
- const void *ptr;
- unsigned stride;
- } attrib[PIPE_MAX_ATTRIBS];
-#endif
+ struct aos_attrib *attrib;
struct aos_machine *machine; /* XXX: temporarily unshared */
-static void get_src_ptr( struct x86_function *func,
+static void get_src_ptr( struct aos_compilation *cp,
struct x86_reg src,
- struct x86_reg machine,
struct x86_reg elt,
unsigned a )
{
- struct x86_reg input_ptr =
- x86_make_disp(machine,
- Offset(struct aos_machine, attrib[a].input_ptr));
+ struct x86_reg attrib = x86_make_disp(aos_get_x86( cp, X86_ATTRIBS ),
+ a * sizeof(struct aos_attrib));
- struct x86_reg input_stride =
- x86_make_disp(machine,
- Offset(struct aos_machine, attrib[a].input_stride));
+ struct x86_reg input_ptr = x86_make_disp(attrib,
+ Offset(struct aos_attrib, input_ptr));
+
+ struct x86_reg input_stride = x86_make_disp(attrib,
+ Offset(struct aos_attrib, input_stride));
/* Calculate pointer to current attrib:
*/
- x86_mov(func, src, input_stride);
- x86_imul(func, src, elt);
- x86_add(func, src, input_ptr);
+ x86_mov(cp->func, src, input_stride);
+ x86_imul(cp->func, src, elt);
+ x86_add(cp->func, src, input_ptr);
}
/* Figure out source pointer address:
*/
- get_src_ptr(cp->func,
+ get_src_ptr(cp,
src,
- cp->machine_EDX,
linear ? cp->idx_EBX : x86_deref(cp->idx_EBX),
idx);