summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c25
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aapoint.c12
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_clip.c16
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_cull.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_offset.c7
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_stipple.c5
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_vbuf.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_line.c9
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_point.c9
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h2
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_post_vs.c38
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.c11
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.h1
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_varient.c4
15 files changed, 97 insertions, 60 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 634bf067f1..ecdebca5f1 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -78,6 +78,8 @@ struct aaline_stage
/** 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;
@@ -520,9 +522,10 @@ aaline_line(struct draw_stage *stage, struct prim_header *header)
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;
@@ -549,35 +552,35 @@ aaline_line(struct draw_stage *stage, struct prim_header *header)
*/
/* 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);
@@ -653,7 +656,7 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
/* 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;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index 96dcdb43d5..87fd303649 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -85,6 +85,7 @@ struct aapoint_stage
/** this is the vertex attrib slot for the new texcoords */
uint tex_slot;
+ uint pos_slot;
/*
* Currently bound state
@@ -570,6 +571,7 @@ aapoint_point(struct draw_stage *stage, struct prim_header *header)
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;
@@ -619,19 +621,19 @@ aapoint_point(struct draw_stage *stage, struct prim_header *header)
}
/* 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;
@@ -683,6 +685,8 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
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;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index 77ccddac4a..fa10f8efca 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -113,6 +113,7 @@ static void interp( const struct clipper *clip,
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.
@@ -138,18 +139,17 @@ static void interp( const struct clipper *clip,
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]);
}
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c
index 87aaf1f85b..d0d22a38e0 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_cull.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c
@@ -55,10 +55,12 @@ static INLINE struct cull_stage *cull_stage( struct draw_stage *stage )
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];
diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c
index ea6de8c571..8f1650e55c 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_offset.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c
@@ -62,14 +62,15 @@ static INLINE struct offset_stage *offset_stage( struct draw_stage *stage )
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];
diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
index 9522b79582..bf0db18a68 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
@@ -119,8 +119,9 @@ stipple_line(struct draw_stage *stage, struct prim_header *header)
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;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
index 9e5597c32c..10a1f7df79 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
@@ -136,6 +136,8 @@ emit_vertex( struct vbuf_stage *vbuf,
* 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);
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
index 878c9c7169..29649f5787 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
@@ -58,6 +58,7 @@ static void wideline_line( struct draw_stage *stage,
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;
@@ -67,10 +68,10 @@ static void wideline_line( struct draw_stage *stage,
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]);
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
index df92e3f2d0..d40a07f4ae 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
@@ -96,6 +96,7 @@ static void widepoint_point( struct draw_stage *stage,
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;
@@ -108,10 +109,10 @@ static void widepoint_point( struct draw_stage *stage,
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) {
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 1865601cc0..7bd1e670b4 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -177,7 +177,7 @@ struct draw_context
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;
diff --git a/src/gallium/auxiliary/draw/draw_pt_post_vs.c b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
index c4a67c8289..af6306b1c6 100644
--- a/src/gallium/auxiliary/draw/draw_pt_post_vs.c
+++ b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
@@ -100,16 +100,19 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
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,
@@ -120,19 +123,19 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
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
}
@@ -154,15 +157,18 @@ static boolean post_vs_viewport( struct pt_post_vs *pvs,
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);
}
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index 979f9864fd..978954e91c 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -85,6 +85,16 @@ draw_create_vertex_shader(struct draw_context *draw,
}
}
+ 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;
}
@@ -100,6 +110,7 @@ draw_bind_vertex_shader(struct draw_context *draw,
{
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 {
diff --git a/src/gallium/auxiliary/draw/draw_vs.h b/src/gallium/auxiliary/draw/draw_vs.h
index 08c6de8ba8..45992d1986 100644
--- a/src/gallium/auxiliary/draw/draw_vs.h
+++ b/src/gallium/auxiliary/draw/draw_vs.h
@@ -106,6 +106,7 @@ struct draw_vertex_shader {
struct pipe_shader_state state;
struct tgsi_shader_info info;
+ unsigned position_output;
/* Extracted from shader:
*/
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.c b/src/gallium/auxiliary/draw/draw_vs_aos.c
index c47647ea72..5d4a8b38c8 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos.c
@@ -1686,7 +1686,7 @@ static boolean emit_viewport( struct aos_compilation *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));
@@ -1700,7 +1700,7 @@ static boolean emit_viewport( struct aos_compilation *cp )
aos_adopt_xmm_reg( cp,
pos,
TGSI_FILE_OUTPUT,
- 0,
+ cp->vaos->draw->vs.position_output,
TRUE );
return TRUE;
}
@@ -1715,7 +1715,7 @@ static boolean emit_rhw_viewport( struct aos_compilation *cp )
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));
@@ -1740,7 +1740,7 @@ static boolean emit_rhw_viewport( struct aos_compilation *cp )
aos_adopt_xmm_reg( cp,
pos,
TGSI_FILE_OUTPUT,
- 0,
+ cp->vaos->draw->vs.position_output,
TRUE );
return TRUE;
}
diff --git a/src/gallium/auxiliary/draw/draw_vs_varient.c b/src/gallium/auxiliary/draw/draw_vs_varient.c
index abe8c5ec2d..ad0b829afa 100644
--- a/src/gallium/auxiliary/draw/draw_vs_varient.c
+++ b/src/gallium/auxiliary/draw/draw_vs_varient.c
@@ -89,6 +89,8 @@ static void do_rhw_viewport( struct draw_vs_varient_generic *vsvg,
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];
@@ -110,6 +112,8 @@ static void do_viewport( struct draw_vs_varient_generic *vsvg,
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;