summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Rusin <zackr@vmware.com>2010-06-15 16:37:32 -0400
committerZack Rusin <zackr@vmware.com>2010-06-15 16:37:32 -0400
commit3560652ccf0d88bcc23c326ea99bbc7091b45f39 (patch)
treea718f08ab026ce939681d55f36c939762cffc31b
parent215e10ac2615359065cc264c68f08f39533bafd4 (diff)
gs: make sure we end primitives when finishing executing shaders
-rw-r--r--src/gallium/auxiliary/draw/draw_gs.c28
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h5
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c16
3 files changed, 23 insertions, 26 deletions
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index 505622d138b..c2c08fd4420 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -416,11 +416,18 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader,
output_prims->linear = TRUE;
output_prims->elts = NULL;
output_prims->start = 0;
+ output_prims->count = shader->emitted_vertices;
output_prims->prim = shader->output_primitive;
output_prims->primitive_lengths = shader->primitive_lengths;
output_prims->primitive_count = shader->emitted_primitives;
output_verts->count = shader->emitted_vertices;
+#if 0
+ debug_printf("GS finished, prims = %d, verts = %d\n",
+ output_prims->primitive_count,
+ output_verts->count);
+#endif
+
return shader->emitted_vertices;
}
@@ -440,24 +447,3 @@ void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
draw->gs.samplers);
}
}
-
-int draw_max_output_vertices(struct draw_context *draw,
- unsigned pipe_prim,
- unsigned count)
-{
- unsigned alloc_count = align( count, 4 );
-
- if (draw->gs.geometry_shader) {
- unsigned input_primitives = u_gs_prims_for_vertices(pipe_prim,
- count);
- /* max GS output is number of input primitives * max output
- * vertices per each invocation */
- unsigned gs_max_verts = input_primitives *
- draw->gs.geometry_shader->max_output_vertices;
- if (gs_max_verts > count)
- alloc_count = align(gs_max_verts, 4);
- }
- /*debug_printf("------- alloc count = %d (input = %d)\n",
- alloc_count, count);*/
- return alloc_count;
-}
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index e9c940248e6..4584033bc2b 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -403,9 +403,4 @@ draw_get_rasterizer_no_cull( struct draw_context *draw,
boolean flatshade );
-int draw_max_output_vertices(struct draw_context *draw,
- unsigned pipe_prim,
- unsigned count);
-
-
#endif /* DRAW_PRIVATE_H */
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index f66f72d257a..2b0809b6eba 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -1541,6 +1541,19 @@ emit_primitive(struct tgsi_exec_machine *mach)
}
}
+static void
+conditional_emit_primitive(struct tgsi_exec_machine *mach)
+{
+ if (TGSI_PROCESSOR_GEOMETRY == mach->Processor) {
+ int emitted_verts =
+ mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]];
+ if (emitted_verts) {
+ emit_primitive(mach);
+ }
+ }
+}
+
+
/*
* Fetch four texture samples using STR texture coordinates.
*/
@@ -3190,6 +3203,9 @@ exec_instruction(
break;
case TGSI_OPCODE_END:
+ /* make sure we end primitives which haven't
+ * been explicitly emitted */
+ conditional_emit_primitive(mach);
/* halt execution */
*pc = -1;
break;