softpipe: fix streamout with an emptry geometry shader
authorZack Rusin <zackr@vmware.com>
Fri, 19 Apr 2013 19:51:07 +0000 (12:51 -0700)
committerZack Rusin <zackr@vmware.com>
Tue, 23 Apr 2013 00:36:07 +0000 (20:36 -0400)
Same approach as in the llvmpipe, if the geometry shader is
null and we have stream output then attach it to the vertex
shader right before executing the draw pipeline.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/drivers/softpipe/sp_draw_arrays.c
src/gallium/drivers/softpipe/sp_state_shader.c

index 4378312bc3622ca0138a5415ae6b4192efb979c4..0eb9c5024dfd886eff5cf982b460d3c6e9c96b94 100644 (file)
@@ -105,6 +105,13 @@ softpipe_draw_vbo(struct pipe_context *pipe,
    draw_set_mapped_so_targets(draw, sp->num_so_targets,
                               sp->so_targets);
 
+   if (sp->gs && !sp->gs->shader.tokens) {
+      /* we have an empty geometry shader with stream output, so
+         attach the stream output info to the current vertex shader */
+      if (sp->vs) {
+         draw_vs_attach_so(sp->vs->draw_data, &sp->gs->shader.stream_output);
+      }
+   }
    draw_collect_pipeline_statistics(draw,
                                     sp->active_statistics_queries > 0);
 
index 40d32a4dfb07deb6b2877ed90e157a7da98b41f5..79bd597ebcb89dffee8d5da64e2172833959cda1 100644 (file)
@@ -275,21 +275,25 @@ softpipe_create_gs_state(struct pipe_context *pipe,
    if (state == NULL )
       goto fail;
 
-   /* debug */
-   if (softpipe->dump_gs)
-      tgsi_dump(templ->tokens, 0);
+   state->shader = *templ;
 
-   /* copy shader tokens, the ones passed in will go away.
-    */
-   state->shader.tokens = tgsi_dup_tokens(templ->tokens);
-   if (state->shader.tokens == NULL)
-      goto fail;
+   if (templ->tokens) {
+      /* debug */
+      if (softpipe->dump_gs)
+         tgsi_dump(templ->tokens, 0);
 
-   state->draw_data = draw_create_geometry_shader(softpipe->draw, templ);
-   if (state->draw_data == NULL)
-      goto fail;
+      /* copy shader tokens, the ones passed in will go away.
+       */
+      state->shader.tokens = tgsi_dup_tokens(templ->tokens);
+      if (state->shader.tokens == NULL)
+         goto fail;
 
-   state->max_sampler = state->draw_data->info.file_max[TGSI_FILE_SAMPLER];
+      state->draw_data = draw_create_geometry_shader(softpipe->draw, templ);
+      if (state->draw_data == NULL)
+         goto fail;
+
+      state->max_sampler = state->draw_data->info.file_max[TGSI_FILE_SAMPLER];
+   }
 
    return state;