llvmpipe: fix blending with half-float formats
[mesa.git] / src / gallium / drivers / llvmpipe / lp_state_gs.c
index 1ba6f10821e8ffaf9fc89c0b456966945939c789..55da0f16a8de55f8b50ef7d745c81858bfb7ce12 100644 (file)
@@ -53,15 +53,18 @@ llvmpipe_create_gs_state(struct pipe_context *pipe,
    if (0)
       tgsi_dump(templ->tokens, 0);
 
-   /* 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->draw_data = draw_create_geometry_shader(llvmpipe->draw, templ);
-   if (state->draw_data == NULL)
-      goto fail;
+   /* copy stream output info */
+   state->shader = *templ;
+   if (templ->tokens) {
+      /* 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->draw_data = draw_create_geometry_shader(llvmpipe->draw, templ);
+      if (state->draw_data == NULL)
+         goto fail;
+   }
 
    return state;
 
@@ -97,8 +100,12 @@ llvmpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
    struct lp_geometry_shader *state =
       (struct lp_geometry_shader *)gs;
 
-   draw_delete_geometry_shader(llvmpipe->draw,
-                               (state) ? state->draw_data : 0);
+   if (!state) {
+      return;
+   }
+
+   draw_delete_geometry_shader(llvmpipe->draw, state->draw_data);
+   FREE( (void *)state->shader.tokens );
    FREE(state);
 }