/** For AA lines, this is the vertex attrib slot for the new texcoords */
uint tex_slot;
+ /** position, not necessarily output zero */
+ uint pos_slot;
void *sampler_cso;
struct pipe_texture *texture;
struct prim_header tri;
struct vertex_header *v[8];
uint texPos = aaline->tex_slot;
+ uint posPos = aaline->pos_slot;
float *pos, *tex;
- float dx = header->v[1]->data[0][0] - header->v[0]->data[0][0];
- float dy = header->v[1]->data[0][1] - header->v[0]->data[0][1];
+ float dx = header->v[1]->data[posPos][0] - header->v[0]->data[posPos][0];
+ float dy = header->v[1]->data[posPos][1] - header->v[0]->data[posPos][1];
double a = atan2(dy, dx);
float c_a = (float) cos(a), s_a = (float) sin(a);
uint i;
*/
/* new verts */
- pos = v[0]->data[0];
+ pos = v[0]->data[posPos];
pos[0] += (-dx * c_a - dy * s_a);
pos[1] += (-dx * s_a + dy * c_a);
- pos = v[1]->data[0];
+ pos = v[1]->data[posPos];
pos[0] += (-dx * c_a - -dy * s_a);
pos[1] += (-dx * s_a + -dy * c_a);
- pos = v[2]->data[0];
+ pos = v[2]->data[posPos];
pos[0] += ( dx * c_a - dy * s_a);
pos[1] += ( dx * s_a + dy * c_a);
- pos = v[3]->data[0];
+ pos = v[3]->data[posPos];
pos[0] += ( dx * c_a - -dy * s_a);
pos[1] += ( dx * s_a + -dy * c_a);
- pos = v[4]->data[0];
+ pos = v[4]->data[posPos];
pos[0] += (-dx * c_a - dy * s_a);
pos[1] += (-dx * s_a + dy * c_a);
- pos = v[5]->data[0];
+ pos = v[5]->data[posPos];
pos[0] += (-dx * c_a - -dy * s_a);
pos[1] += (-dx * s_a + -dy * c_a);
- pos = v[6]->data[0];
+ pos = v[6]->data[posPos];
pos[0] += ( dx * c_a - dy * s_a);
pos[1] += ( dx * s_a + dy * c_a);
- pos = v[7]->data[0];
+ pos = v[7]->data[posPos];
pos[0] += ( dx * c_a - -dy * s_a);
pos[1] += ( dx * s_a + -dy * c_a);
/* update vertex attrib info */
aaline->tex_slot = draw->vs.num_vs_outputs;
- assert(aaline->tex_slot > 0); /* output[0] is vertex pos */
+ aaline->pos_slot = draw->vs.position_output;
/* advertise the extra post-transformed vertex attribute */
draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
/** this is the vertex attrib slot for the new texcoords */
uint tex_slot;
+ uint pos_slot;
/*
* Currently bound state
struct prim_header tri;
struct vertex_header *v[4];
uint texPos = aapoint->tex_slot;
+ uint pos_slot = aapoint->pos_slot;
float radius, *pos, *tex;
uint i;
float k;
}
/* new verts */
- pos = v[0]->data[0];
+ pos = v[0]->data[pos_slot];
pos[0] -= radius;
pos[1] -= radius;
- pos = v[1]->data[0];
+ pos = v[1]->data[pos_slot];
pos[0] += radius;
pos[1] -= radius;
- pos = v[2]->data[0];
+ pos = v[2]->data[pos_slot];
pos[0] += radius;
pos[1] += radius;
- pos = v[3]->data[0];
+ pos = v[3]->data[pos_slot];
pos[0] -= radius;
pos[1] += radius;
aapoint->tex_slot = draw->vs.num_vs_outputs;
assert(aapoint->tex_slot > 0); /* output[0] is vertex pos */
+ aapoint->pos_slot = draw->vs.position_output;
+
draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
draw->extra_vp_outputs.semantic_index = aapoint->fs->generic_attrib;
draw->extra_vp_outputs.slot = aapoint->tex_slot;
const struct vertex_header *in )
{
const unsigned nr_attrs = clip->stage.draw->vs.num_vs_outputs;
+ const unsigned pos_attr = clip->stage.draw->vs.position_output;
unsigned j;
/* Vertex header.
const float *trans = clip->stage.draw->viewport.translate;
const float oow = 1.0f / pos[3];
- dst->data[0][0] = pos[0] * oow * scale[0] + trans[0];
- dst->data[0][1] = pos[1] * oow * scale[1] + trans[1];
- dst->data[0][2] = pos[2] * oow * scale[2] + trans[2];
- dst->data[0][3] = oow;
+ dst->data[pos_attr][0] = pos[0] * oow * scale[0] + trans[0];
+ dst->data[pos_attr][1] = pos[1] * oow * scale[1] + trans[1];
+ dst->data[pos_attr][2] = pos[2] * oow * scale[2] + trans[2];
+ dst->data[pos_attr][3] = oow;
}
/* Other attributes
- * Note: start at 1 to skip winpos (data[0]) since we just computed
- * it above.
*/
- for (j = 1; j < nr_attrs; j++) {
- interp_attr(dst->data[j], t, in->data[j], out->data[j]);
+ for (j = 0; j < nr_attrs; j++) {
+ if (j != pos_attr)
+ interp_attr(dst->data[j], t, in->data[j], out->data[j]);
}
}
static void cull_tri( struct draw_stage *stage,
struct prim_header *header )
{
+ const unsigned pos = stage->draw->vs.position_output;
+
/* Window coords: */
- const float *v0 = header->v[0]->data[0];
- const float *v1 = header->v[1]->data[0];
- const float *v2 = header->v[2]->data[0];
+ const float *v0 = header->v[0]->data[pos];
+ const float *v1 = header->v[1]->data[pos];
+ const float *v2 = header->v[2]->data[pos];
/* edge vectors e = v0 - v2, f = v1 - v2 */
const float ex = v0[0] - v2[0];
static void do_offset_tri( struct draw_stage *stage,
struct prim_header *header )
{
+ const unsigned pos = stage->draw->vs.position_output;
struct offset_stage *offset = offset_stage(stage);
float inv_det = 1.0f / header->det;
/* Window coords:
*/
- float *v0 = header->v[0]->data[0];
- float *v1 = header->v[1]->data[0];
- float *v2 = header->v[2]->data[0];
+ float *v0 = header->v[0]->data[pos];
+ float *v1 = header->v[1]->data[pos];
+ float *v2 = header->v[2]->data[pos];
/* edge vectors e = v0 - v2, f = v1 - v2 */
float ex = v0[0] - v2[0];
struct stipple_stage *stipple = stipple_stage(stage);
struct vertex_header *v0 = header->v[0];
struct vertex_header *v1 = header->v[1];
- const float *pos0 = v0->data[0];
- const float *pos1 = v1->data[0];
+ const unsigned pos = stage->draw->vs.position_output;
+ const float *pos0 = v0->data[pos];
+ const float *pos1 = v1->data[pos];
float start = 0;
int state = 0;
* set_buffer is efficient. Consider a special one-shot mode for
* translate.
*/
+ /* Note: we really do want data[0] here, not data[pos]:
+ */
vbuf->translate->set_buffer(vbuf->translate, 0, vertex->data[0], 0);
vbuf->translate->run(vbuf->translate, 0, 1, vbuf->vertex_ptr);
struct prim_header *header )
{
/*const struct wideline_stage *wide = wideline_stage(stage);*/
+ const unsigned pos = stage->draw->vs.position_output;
const float half_width = 0.5f * stage->draw->rasterizer->line_width;
struct prim_header tri;
struct vertex_header *v2 = dup_vert(stage, header->v[1], 2);
struct vertex_header *v3 = dup_vert(stage, header->v[1], 3);
- float *pos0 = v0->data[0];
- float *pos1 = v1->data[0];
- float *pos2 = v2->data[0];
- float *pos3 = v3->data[0];
+ float *pos0 = v0->data[pos];
+ float *pos1 = v1->data[pos];
+ float *pos2 = v2->data[pos];
+ float *pos3 = v3->data[pos];
const float dx = FABSF(pos0[0] - pos2[0]);
const float dy = FABSF(pos0[1] - pos2[1]);
struct prim_header *header )
{
const struct widepoint_stage *wide = widepoint_stage(stage);
+ const unsigned pos = stage->draw->vs.position_output;
const boolean sprite = (boolean) stage->draw->rasterizer->point_sprite;
float half_size;
float left_adj, right_adj, bot_adj, top_adj;
struct vertex_header *v2 = dup_vert(stage, header->v[0], 2);
struct vertex_header *v3 = dup_vert(stage, header->v[0], 3);
- float *pos0 = v0->data[0];
- float *pos1 = v1->data[0];
- float *pos2 = v2->data[0];
- float *pos3 = v3->data[0];
+ float *pos0 = v0->data[pos];
+ float *pos1 = v1->data[pos];
+ float *pos2 = v2->data[pos];
+ float *pos3 = v3->data[pos];
/* point size is either per-vertex or fixed size */
if (wide->psize_slot >= 0) {
struct {
struct draw_vertex_shader *vertex_shader;
uint num_vs_outputs; /**< convenience, from vertex_shader */
-
+ uint position_output;
/** TGSI program interpreter runtime state */
struct tgsi_exec_machine machine;
struct vertex_header *out = vertices;
const float *scale = pvs->draw->viewport.scale;
const float *trans = pvs->draw->viewport.translate;
+ const unsigned pos = pvs->draw->vs.position_output;
unsigned clipped = 0;
unsigned j;
if (0) debug_printf("%s\n");
for (j = 0; j < count; j++) {
- out->clip[0] = out->data[0][0];
- out->clip[1] = out->data[0][1];
- out->clip[2] = out->data[0][2];
- out->clip[3] = out->data[0][3];
+ float *position = out->data[pos];
+
+ out->clip[0] = position[0];
+ out->clip[1] = position[1];
+ out->clip[2] = position[2];
+ out->clip[3] = position[3];
out->vertex_id = 0xffff;
out->clipmask = compute_clipmask_gl(out->clip,
if (out->clipmask == 0)
{
/* divide by w */
- float w = 1.0f / out->data[0][3];
+ float w = 1.0f / position[3];
/* Viewport mapping */
- out->data[0][0] = out->data[0][0] * w * scale[0] + trans[0];
- out->data[0][1] = out->data[0][1] * w * scale[1] + trans[1];
- out->data[0][2] = out->data[0][2] * w * scale[2] + trans[2];
- out->data[0][3] = w;
+ position[0] = position[0] * w * scale[0] + trans[0];
+ position[1] = position[1] * w * scale[1] + trans[1];
+ position[2] = position[2] * w * scale[2] + trans[2];
+ position[3] = w;
#if 0
debug_printf("post viewport: %f %f %f %f\n",
- out->data[0][0],
- out->data[0][1],
- out->data[0][2],
- out->data[0][3]);
+ position[0],
+ position[1],
+ position[2],
+ position[3]);
#endif
}
struct vertex_header *out = vertices;
const float *scale = pvs->draw->viewport.scale;
const float *trans = pvs->draw->viewport.translate;
+ const unsigned pos = pvs->draw->vs.position_output;
unsigned j;
if (0) debug_printf("%s\n", __FUNCTION__);
for (j = 0; j < count; j++) {
+ float *position = out->data[pos];
+
/* Viewport mapping only, no cliptest/rhw divide
*/
- out->data[0][0] = out->data[0][0] * scale[0] + trans[0];
- out->data[0][1] = out->data[0][1] * scale[1] + trans[1];
- out->data[0][2] = out->data[0][2] * scale[2] + trans[2];
+ position[0] = position[0] * scale[0] + trans[0];
+ position[1] = position[1] * scale[1] + trans[1];
+ position[2] = position[2] * scale[2] + trans[2];
out = (struct vertex_header *)((char *)out + stride);
}
}
}
+ if (vs)
+ {
+ uint i;
+ for (i = 0; i < vs->info.num_outputs; i++) {
+ if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
+ vs->info.output_semantic_index[i] == 0)
+ vs->position_output = i;
+ }
+ }
+
assert(vs);
return vs;
}
{
draw->vs.vertex_shader = dvs;
draw->vs.num_vs_outputs = dvs->info.num_outputs;
+ draw->vs.position_output = dvs->position_output;
dvs->prepare( dvs, draw );
}
else {
struct pipe_shader_state state;
struct tgsi_shader_info info;
+ unsigned position_output;
/* Extracted from shader:
*/
{
struct x86_reg pos = aos_get_shader_reg_xmm(cp,
TGSI_FILE_OUTPUT,
- 0);
+ cp->vaos->draw->vs.position_output );
struct x86_reg scale = x86_make_disp(cp->machine_EDX,
Offset(struct aos_machine, scale));
aos_adopt_xmm_reg( cp,
pos,
TGSI_FILE_OUTPUT,
- 0,
+ cp->vaos->draw->vs.position_output,
TRUE );
return TRUE;
}
struct x86_reg tmp = aos_get_xmm_reg(cp);
struct x86_reg pos = aos_get_shader_reg_xmm(cp,
TGSI_FILE_OUTPUT,
- 0);
+ cp->vaos->draw->vs.position_output);
struct x86_reg scale = x86_make_disp(cp->machine_EDX,
Offset(struct aos_machine, scale));
aos_adopt_xmm_reg( cp,
pos,
TGSI_FILE_OUTPUT,
- 0,
+ cp->vaos->draw->vs.position_output,
TRUE );
return TRUE;
}
unsigned stride = vsvg->temp_vertex_stride;
unsigned j;
+ ptr += vsvg->base.vs->position_output * 4 * sizeof(float);
+
for (j = 0; j < count; j++, ptr += stride) {
float *data = (float *)ptr;
float w = 1.0f / data[3];
unsigned stride = vsvg->temp_vertex_stride;
unsigned j;
+ ptr += vsvg->base.vs->position_output * 4 * sizeof(float);
+
for (j = 0; j < count; j++, ptr += stride) {
float *data = (float *)ptr;