Mesa (arb_geometry_shader4): gs: start on fixing fetching of geometry shader inputs
Zack Rusin
zack at kemper.freedesktop.org
Fri Jul 17 00:37:06 UTC 2009
Module: Mesa
Branch: arb_geometry_shader4
Commit: adf1d0cffcbababa0e4e968b5a916b27199b6dbb
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=adf1d0cffcbababa0e4e968b5a916b27199b6dbb
Author: Zack Rusin <zackr at vmware.com>
Date: Thu Jul 16 20:39:46 2009 -0400
gs: start on fixing fetching of geometry shader inputs
it's a little wonky, because for geometry shaders some inputs match
vertex shader outputs and some are auto-generated (e.g. gl_VerticesIn or
gl_PrimitiveId) so we need to add those auto-generated ones to the
output stream of the vertex shader.
---
src/gallium/auxiliary/draw/draw_gs.c | 75 ++++++++++++++++++++--------------
1 files changed, 44 insertions(+), 31 deletions(-)
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index bdef375..a09bd2b 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -140,6 +140,48 @@ static INLINE int num_vertices_for_prim(int prim)
}
}
+static void draw_fetch_geometry_input(struct draw_geometry_shader *shader,
+ int start_primitive,
+ int num_primitives,
+ const float (*input)[4],
+ unsigned input_stride)
+{
+ struct tgsi_exec_machine *machine = shader->machine;
+ unsigned slot, k, j;
+ unsigned num_vertices = num_vertices_for_prim(shader->state.input_type);
+
+ for (k = 0; k < num_primitives; ++k) {
+ for (j = 0; j < num_vertices; j++) {
+ int idx = ((start_primitive + k) * num_vertices + j) * shader->info.num_inputs;
+#if 1
+ debug_printf("%d) Prim, %d) Input vert:\n", start_primitive, idx);
+ for (slot = 0; slot < shader->info.num_inputs; slot++) {
+ debug_printf("\t%d: %f %f %f %f\n", slot,
+ input[idx + slot][0],
+ input[idx + slot][1],
+ input[idx + slot][2],
+ input[idx + slot][3]);
+ }
+#endif
+
+ for (slot = 0; slot < shader->info.num_inputs; slot++) {
+#if 0
+ assert(!util_is_inf_or_nan(input[idx + slot][0]));
+ assert(!util_is_inf_or_nan(input[idx + slot][1]));
+ assert(!util_is_inf_or_nan(input[idx + slot][2]));
+ assert(!util_is_inf_or_nan(input[idx + slot][3]));
+#endif
+ machine->Inputs[idx + slot].xyzw[0].f[j] = input[idx + slot][0];
+ machine->Inputs[idx + slot].xyzw[1].f[j] = input[idx + slot][1];
+ machine->Inputs[idx + slot].xyzw[2].f[j] = input[idx + slot][2];
+ machine->Inputs[idx + slot].xyzw[3].f[j] = input[idx + slot][3];
+ }
+
+ input = (const float (*)[4])((const char *)input + input_stride);
+ }
+ }
+}
+
void draw_geometry_shader_run(struct draw_geometry_shader *shader,
const float (*input)[4],
float (*output)[4],
@@ -149,7 +191,7 @@ void draw_geometry_shader_run(struct draw_geometry_shader *shader,
unsigned output_stride)
{
struct tgsi_exec_machine *machine = shader->machine;
- unsigned int i, j, k;
+ unsigned int i, j;
unsigned slot;
unsigned num_vertices = num_vertices_for_prim(shader->state.input_type);
unsigned num_primitives = count/num_vertices;
@@ -159,36 +201,7 @@ void draw_geometry_shader_run(struct draw_geometry_shader *shader,
for (i = 0; i < num_primitives; i += MAX_TGSI_PRIMITIVES) {
unsigned int max_primitives = MIN2(MAX_TGSI_PRIMITIVES, num_primitives - i);
- for (k = 0; k < max_primitives; ++k) {
- for (j = 0; j < num_vertices; j++) {
- int idx = ((i + k) * num_vertices + j) * shader->info.num_inputs;
-#if 1
- debug_printf("%d) Prim, %d) Input vert:\n", i, idx);
- for (slot = 0; slot < shader->info.num_inputs; slot++) {
- debug_printf("\t%d: %f %f %f %f\n", slot,
- input[idx + slot][0],
- input[idx + slot][1],
- input[idx + slot][2],
- input[idx + slot][3]);
- }
-#endif
-
- for (slot = 0; slot < shader->info.num_inputs; slot++) {
-#if 0
- assert(!util_is_inf_or_nan(input[idx + slot][0]));
- assert(!util_is_inf_or_nan(input[idx + slot][1]));
- assert(!util_is_inf_or_nan(input[idx + slot][2]));
- assert(!util_is_inf_or_nan(input[idx + slot][3]));
-#endif
- machine->Inputs[idx + slot].xyzw[0].f[j] = input[idx + slot][0];
- machine->Inputs[idx + slot].xyzw[1].f[j] = input[idx + slot][1];
- machine->Inputs[idx + slot].xyzw[2].f[j] = input[idx + slot][2];
- machine->Inputs[idx + slot].xyzw[3].f[j] = input[idx + slot][3];
- }
-
- input = (const float (*)[4])((const char *)input + input_stride);
- }
- }
+ draw_fetch_geometry_input(shader, i, max_primitives, input, input_stride);
tgsi_set_exec_mask(machine,
1,
More information about the mesa-commit
mailing list