+ fse->key.output_stride = vinfo->size * 4;
fse->key.nr_elements = MAX2(num_vs_outputs, /* outputs - translate to hw format */
num_vs_inputs); /* inputs - fetch from api format */
- fse->key.output_stride = vinfo->size * 4;
+ fse->key.viewport = 1;
+ fse->key.clip = 0;
+ fse->key.pad = 0;
+
memset(fse->key.element, 0,
fse->key.nr_elements * sizeof(fse->key.element[0]));
fse->active->set_constants( fse->active,
(const float (*)[4])draw->pt.user.constants );
+ fse->active->set_viewport( fse->active,
+ &draw->viewport );
+
//return TRUE;
}
struct draw_vs_varient_key {
unsigned output_stride;
- unsigned nr_elements;
+ unsigned nr_elements:16;
+ unsigned viewport:1;
+ unsigned clip:1;
+ unsigned pad:14;
struct draw_vs_element element[PIPE_MAX_ATTRIBS];
};
void (*set_constants)( struct draw_vs_varient *,
const float (*constants)[4] );
+ void (*set_viewport)( struct draw_vs_varient *,
+ const struct pipe_viewport_state * );
+
void (PIPE_CDECL *run_linear)( struct draw_vs_varient *shader,
unsigned start,
unsigned count,
}
}
+
+static boolean emit_viewport( struct aos_compilation *cp )
+{
+ struct x86_reg pos = aos_get_shader_reg(cp,
+ TGSI_FILE_OUTPUT,
+ 0);
+
+ struct x86_reg scale = x86_make_disp(cp->machine_EDX,
+ Offset(struct aos_machine, scale));
+
+ struct x86_reg translate = x86_make_disp(cp->machine_EDX,
+ Offset(struct aos_machine, translate));
+
+ if (pos.file != file_XMM) {
+ struct x86_reg dst = aos_get_xmm_reg(cp);
+ sse_movups(cp->func, dst, pos);
+ pos = dst;
+ }
+
+ sse_mulps(cp->func, pos, scale);
+ sse_addps(cp->func, pos, translate);
+
+ aos_adopt_xmm_reg( cp,
+ pos,
+ TGSI_FILE_OUTPUT,
+ 0,
+ TRUE );
+ return TRUE;
+}
+
+
static boolean note_immediate( struct aos_compilation *cp,
struct tgsi_full_immediate *imm )
{
if (cp.error)
goto fail;
+ if (cp.vaos->base.key.viewport) {
+ emit_viewport(&cp);
+ }
+
/* Emit output... TODO: do this eagerly after the last write to a
* given output.
*/
}
+static void vaos_set_viewport( struct draw_vs_varient *varient,
+ const struct pipe_viewport_state *viewport )
+{
+ struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
+
+ memcpy(vaos->machine->scale, viewport->scale, 4 * sizeof(float));
+ memcpy(vaos->machine->translate, viewport->translate, 4 * sizeof(float));
+}
+
+
+
static struct draw_vs_varient *varient_aos_sse( struct draw_vertex_shader *vs,
const struct draw_vs_varient_key *key )
{
struct draw_vs_varient_aos_sse *vaos = CALLOC_STRUCT(draw_vs_varient_aos_sse);
+ if (key->clip)
+ return NULL;
+
if (!vaos)
goto fail;
vaos->base.vs = vs;
vaos->base.set_input = vaos_set_buffer;
vaos->base.set_constants = vaos_set_constants;
+ vaos->base.set_viewport = vaos_set_viewport;
vaos->base.destroy = vaos_destroy;
vaos->base.run_linear = vaos_run_linear;
vaos->base.run_elts = vaos_run_elts;
float immediate[MAX_IMMEDIATES][4]; /* fixme -- should just be a pointer */
float internal [MAX_INTERNALS ][4];
- unsigned fpu_round_nearest;
- unsigned fpu_round_neg_inf;
+ float scale[4]; /* viewport */
+ float translate[4]; /* viewport */
+
+ ushort fpu_round_nearest;
+ ushort fpu_round_neg_inf;
+ ushort fpu_restore;
+ ushort fpucntl; /* one of FPU_* above */
struct {
const void *input_ptr;
tgsi_scan_shader(templ->tokens, &vs->base.info);
vs->base.draw = draw;
- vs->base.create_varient = draw_vs_varient_generic;
-// vs->base.create_varient = draw_vs_varient_aos_sse;
+ vs->base.create_varient = draw_vs_varient_aos_sse;
+// vs->base.create_varient = draw_vs_varient_generic;
vs->base.prepare = vs_sse_prepare;
vs->base.run_linear = vs_sse_run_linear;
vs->base.delete = vs_sse_delete;
+
+static void vsvg_set_viewport( struct draw_vs_varient *varient,
+ const struct pipe_viewport_state *viewport )
+{
+}
+
static void vsvg_destroy( struct draw_vs_varient *varient )
{
FREE(varient);
unsigned i;
struct translate_key fetch, emit;
+ if (key->viewport || key->clip)
+ return NULL;
+
struct draw_vs_varient_generic *vsvg = CALLOC_STRUCT( draw_vs_varient_generic );
if (vsvg == NULL)
return NULL;
vsvg->base.vs = vs;
vsvg->base.set_input = vsvg_set_input;
vsvg->base.set_constants = vsvg_set_constants;
+ vsvg->base.set_viewport = vsvg_set_viewport;
vsvg->base.run_elts = vsvg_run_elts;
vsvg->base.run_linear = vsvg_run_linear;
vsvg->base.destroy = vsvg_destroy;