gallium: move the test for bypass_vs into the vs_XXX_run() functions

Also:
1. Added an identity_viewport flag to skip viewport transformation when it
has no effect.  Might also add an explicit bypass_viewport flag someday.
2. Separate the code for computing clip codes and doing the viewport transform.
Predicate them separately.
Note: even if bypass_vs is set, we still look at the shader to determine the
number of inputs and outputs.
This commit is contained in:
Brian 2008-03-31 14:14:30 -06:00
parent 9cbd840043
commit 594dab4769
6 changed files with 76 additions and 35 deletions

View File

@ -228,6 +228,14 @@ void draw_set_viewport_state( struct draw_context *draw,
{
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
draw->viewport = *viewport; /* struct copy */
draw->identity_viewport = (viewport->scale[0] == 1.0f &&
viewport->scale[1] == 1.0f &&
viewport->scale[2] == 1.0f &&
viewport->scale[3] == 1.0f &&
viewport->translate[0] == 0.0f &&
viewport->translate[1] == 0.0f &&
viewport->translate[2] == 0.0f &&
viewport->translate[3] == 0.0f);
}

View File

@ -593,8 +593,7 @@ draw_arrays(struct draw_context *draw, unsigned prim,
}
/* drawing done here: */
if (!draw->rasterizer->bypass_vs ||
!draw_pt_arrays(draw, prim, start, count)) {
if (!draw_pt_arrays(draw, prim, start, count)) {
/* we have to run the whole pipeline */
draw_prim(draw, prim, start, count);
}

View File

@ -232,6 +232,8 @@ struct draw_context
struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
struct draw_vertex_shader *vertex_shader;
boolean identity_viewport;
uint num_vs_outputs; /**< convenience, from vertex_shader */
/* user-space vertex data, buffers */

View File

@ -110,13 +110,20 @@ vs_exec_run( struct draw_vertex_shader *shader,
machine->Consts = (float (*)[4]) draw->user.constants;
machine->Inputs = ALIGN16_ASSIGN(inputs);
machine->Outputs = ALIGN16_ASSIGN(outputs);
if (draw->rasterizer->bypass_vs) {
/* outputs are just the inputs */
machine->Outputs = machine->Inputs;
}
else {
machine->Outputs = ALIGN16_ASSIGN(outputs);
}
draw->vertex_fetch.fetch_func( draw, machine, elts, count );
/* run interpreter */
tgsi_exec_machine_run( machine );
if (!draw->rasterizer->bypass_vs) {
/* run interpreter */
tgsi_exec_machine_run( machine );
}
/* store machine results */
for (j = 0; j < count; j++) {
@ -136,8 +143,13 @@ vs_exec_run( struct draw_vertex_shader *shader,
if (!draw->rasterizer->bypass_clipping) {
vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
vOut[j]->edgeflag = 1;
}
else {
vOut[j]->clipmask = 0;
}
vOut[j]->edgeflag = 1;
if (!draw->identity_viewport) {
/* divide by w */
w = 1.0f / w;
x *= w;
@ -151,8 +163,6 @@ vs_exec_run( struct draw_vertex_shader *shader,
vOut[j]->data[0][3] = w;
}
else {
vOut[j]->clipmask = 0;
vOut[j]->edgeflag = 1;
vOut[j]->data[0][0] = x;
vOut[j]->data[0][1] = y;
vOut[j]->data[0][2] = z;

View File

@ -121,31 +121,45 @@ vs_llvm_run( struct draw_vertex_shader *base,
machine->Consts = (float (*)[4]) draw->user.constants;
machine->Inputs = ALIGN16_ASSIGN(inputs);
machine->Outputs = ALIGN16_ASSIGN(outputs);
if (draw->rasterizer->bypass_vs) {
/* outputs are just the inputs */
machine->Outputs = machine->Inputs;
}
else {
machine->Outputs = ALIGN16_ASSIGN(outputs);
}
draw->vertex_fetch.fetch_func( draw, machine, elts, count );
/* run shader */
gallivm_cpu_vs_exec(shader->llvm_prog,
machine->Inputs,
machine->Outputs,
machine->Consts,
machine->Temps);
if (!draw->rasterizer->bypass_vs) {
/* run shader */
gallivm_cpu_vs_exec(shader->llvm_prog,
machine->Inputs,
machine->Outputs,
machine->Consts,
machine->Temps);
}
/* store machine results */
for (j = 0; j < count; j++) {
unsigned slot;
float x, y, z, w;
if (!draw->rasterizer->bypass_clipping) {
x = vOut[j]->clip[0] = machine->Outputs[0].xyzw[0].f[j];
y = vOut[j]->clip[1] = machine->Outputs[0].xyzw[1].f[j];
z = vOut[j]->clip[2] = machine->Outputs[0].xyzw[2].f[j];
w = vOut[j]->clip[3] = machine->Outputs[0].xyzw[3].f[j];
x = vOut[j]->clip[0] = machine->Outputs[0].xyzw[0].f[j];
y = vOut[j]->clip[1] = machine->Outputs[0].xyzw[1].f[j];
z = vOut[j]->clip[2] = machine->Outputs[0].xyzw[2].f[j];
w = vOut[j]->clip[3] = machine->Outputs[0].xyzw[3].f[j];
if (!draw->rasterizer->bypass_clipping) {
vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
vOut[j]->edgeflag = 1;
}
else {
vOut[j]->clipmask = 0;
}
vOut[j]->edgeflag = 1;
if (!draw->identity_viewport) {
/* divide by w */
w = 1.0f / w;
x *= w;
@ -159,8 +173,6 @@ vs_llvm_run( struct draw_vertex_shader *base,
vOut[j]->data[0][3] = w;
}
else {
vOut[j]->clipmask = 0;
vOut[j]->edgeflag = 1;
vOut[j]->data[0][0] = x;
vOut[j]->data[0][1] = y;
vOut[j]->data[0][2] = z;

View File

@ -126,7 +126,13 @@ vs_sse_run( struct draw_vertex_shader *base,
/* Consts does not require 16 byte alignment. */
machine->Consts = (float (*)[4]) draw->user.constants;
machine->Inputs = ALIGN16_ASSIGN(inputs);
machine->Outputs = ALIGN16_ASSIGN(outputs);
if (draw->rasterizer->bypass_vs) {
/* outputs are just the inputs */
machine->Outputs = machine->Inputs;
}
else {
machine->Outputs = ALIGN16_ASSIGN(outputs);
}
/* Fetch vertices. This may at some point be integrated into the
@ -137,13 +143,14 @@ vs_sse_run( struct draw_vertex_shader *base,
draw->vertex_fetch.fetch_func( draw, machine, elts, count );
/* run compiled shader
*/
shader->func(
machine->Inputs,
machine->Outputs,
machine->Consts,
machine->Temps );
if (!draw->rasterizer->bypass_vs) {
/* run compiled shader
*/
shader->func(machine->Inputs,
machine->Outputs,
machine->Consts,
machine->Temps );
}
/* XXX: Computing the clipmask and emitting results should be done
@ -161,8 +168,13 @@ vs_sse_run( struct draw_vertex_shader *base,
if (!draw->rasterizer->bypass_clipping) {
vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
vOut[j]->edgeflag = 1;
}
else {
vOut[j]->clipmask = 0;
}
vOut[j]->edgeflag = 1;
if (!draw->identity_viewport) {
/* divide by w */
w = 1.0f / w;
x *= w;
@ -176,8 +188,6 @@ vs_sse_run( struct draw_vertex_shader *base,
vOut[j]->data[0][3] = w;
}
else {
vOut[j]->clipmask = 0;
vOut[j]->edgeflag = 1;
vOut[j]->data[0][0] = x;
vOut[j]->data[0][1] = y;
vOut[j]->data[0][2] = z;