summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-05-27 12:26:23 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2008-05-27 12:26:23 +0100
commita08c574bfcf72c7f7ffbeb35c10347b491ef87fb (patch)
treed461dd17249bcabd02627f5393f2145336fdfb03 /src/gallium/auxiliary/draw
parent50c1d329b95ad78e03ca4d537daee4d11f308c7a (diff)
draw: hook up viewport / rhw emit to varient key state
Diffstat (limited to 'src/gallium/auxiliary/draw')
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos.c16
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_varient.c52
3 files changed, 53 insertions, 19 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
index 7fefd391a6..2f2e7195b3 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
@@ -94,8 +94,8 @@ static void fse_prepare( struct draw_pt_middle_end *middle,
fse->key.nr_elements = MAX2(num_vs_outputs, /* outputs - translate to hw format */
num_vs_inputs); /* inputs - fetch from api format */
- fse->key.viewport = 1;
- fse->key.clip = 0;
+ fse->key.viewport = !draw->identity_viewport;
+ fse->key.clip = !draw->bypass_clipping;
fse->key.pad = 0;
memset(fse->key.element, 0,
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.c b/src/gallium/auxiliary/draw/draw_vs_aos.c
index d3989fe107..c63553216c 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos.c
@@ -2021,11 +2021,14 @@ static boolean build_vertex_program( struct draw_vs_varient_aos_sse *varient,
if (cp.error)
goto fail;
- if (cp.vaos->base.key.viewport) {
- if (0)
- emit_viewport(&cp);
- else
- emit_rhw_viewport(&cp);
+ if (cp.vaos->base.key.clip) {
+ /* not really handling clipping, just do the rhw so we can
+ * see the results...
+ */
+ emit_rhw_viewport(&cp);
+ }
+ else if (cp.vaos->base.key.viewport) {
+ emit_viewport(&cp);
}
/* Emit output... TODO: do this eagerly after the last write to a
@@ -2188,9 +2191,6 @@ static struct draw_vs_varient *varient_aos_sse( struct draw_vertex_shader *vs,
{
struct draw_vs_varient_aos_sse *vaos = CALLOC_STRUCT(draw_vs_varient_aos_sse);
- if (key->clip)
- return NULL;
-
if (!vaos)
goto fail;
diff --git a/src/gallium/auxiliary/draw/draw_vs_varient.c b/src/gallium/auxiliary/draw/draw_vs_varient.c
index c15c648527..d4deabfff3 100644
--- a/src/gallium/auxiliary/draw/draw_vs_varient.c
+++ b/src/gallium/auxiliary/draw/draw_vs_varient.c
@@ -89,9 +89,9 @@ static void vsvg_set_input( struct draw_vs_varient *varient,
/* Mainly for debug at this stage:
*/
-static void do_viewport( struct draw_vs_varient_generic *vsvg,
- unsigned count,
- void *output_buffer )
+static void do_rhw_viewport( struct draw_vs_varient_generic *vsvg,
+ unsigned count,
+ void *output_buffer )
{
char *ptr = (char *)output_buffer;
const float *scale = vsvg->viewport.scale;
@@ -109,6 +109,25 @@ static void do_viewport( struct draw_vs_varient_generic *vsvg,
data[3] = w;
}
}
+
+static void do_viewport( struct draw_vs_varient_generic *vsvg,
+ unsigned count,
+ void *output_buffer )
+{
+ char *ptr = (char *)output_buffer;
+ const float *scale = vsvg->viewport.scale;
+ const float *trans = vsvg->viewport.translate;
+ unsigned stride = vsvg->base.key.output_stride;
+ unsigned j;
+
+ for (j = 0; j < count; j++, ptr += stride) {
+ float *data = (float *)ptr;
+
+ data[0] = data[0] * scale[0] + trans[0];
+ data[1] = data[1] * scale[1] + trans[1];
+ data[2] = data[2] * scale[2] + trans[2];
+ }
+}
static void vsvg_run_elts( struct draw_vs_varient *varient,
@@ -136,10 +155,20 @@ static void vsvg_run_elts( struct draw_vs_varient *varient,
vsvg->base.key.output_stride,
vsvg->base.key.output_stride);
- if (vsvg->base.key.viewport)
+
+ if (vsvg->base.key.clip) {
+ /* not really handling clipping, just do the rhw so we can
+ * see the results...
+ */
+ do_rhw_viewport( vsvg,
+ count,
+ output_buffer );
+ }
+ else if (vsvg->base.key.viewport) {
do_viewport( vsvg,
count,
output_buffer );
+ }
//if (!vsvg->already_in_emit_format)
@@ -182,11 +211,19 @@ static void vsvg_run_linear( struct draw_vs_varient *varient,
vsvg->base.key.output_stride,
vsvg->base.key.output_stride);
- if (vsvg->base.key.viewport)
+ if (vsvg->base.key.clip) {
+ /* not really handling clipping, just do the rhw so we can
+ * see the results...
+ */
+ do_rhw_viewport( vsvg,
+ count,
+ output_buffer );
+ }
+ else if (vsvg->base.key.viewport) {
do_viewport( vsvg,
count,
output_buffer );
-
+ }
//if (!vsvg->already_in_emit_format)
vsvg->emit->set_buffer( vsvg->emit,
@@ -224,9 +261,6 @@ struct draw_vs_varient *draw_vs_varient_generic( struct draw_vertex_shader *vs,
unsigned i;
struct translate_key fetch, emit;
- if (key->clip)
- return NULL;
-
struct draw_vs_varient_generic *vsvg = CALLOC_STRUCT( draw_vs_varient_generic );
if (vsvg == NULL)
return NULL;