i965/fs: Allow constant propagation into logical send sources.
[mesa.git] / src / gallium / drivers / llvmpipe / lp_state_gs.c
index 55da0f16a8de55f8b50ef7d745c81858bfb7ce12..405a415624e2bd794f2b9058441bbed5e4cf54e5 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  * 
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007 VMware, Inc.
  * All Rights Reserved.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -28,6 +28,7 @@
 #include "lp_context.h"
 #include "lp_state.h"
 #include "lp_texture.h"
+#include "lp_debug.h"
 
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
@@ -46,34 +47,31 @@ llvmpipe_create_gs_state(struct pipe_context *pipe,
    struct lp_geometry_shader *state;
 
    state = CALLOC_STRUCT(lp_geometry_shader);
-   if (state == NULL )
-      goto fail;
+   if (!state)
+      goto no_state;
 
    /* debug */
-   if (0)
+   if (LP_DEBUG & DEBUG_TGSI) {
+      debug_printf("llvmpipe: Create geometry shader %p:\n", (void *)state);
       tgsi_dump(templ->tokens, 0);
+   }
 
    /* copy stream output info */
-   state->shader = *templ;
+   state->no_tokens = !templ->tokens;
+   memcpy(&state->stream_output, &templ->stream_output, sizeof state->stream_output);
+
    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;
+      state->dgs = draw_create_geometry_shader(llvmpipe->draw, templ);
+      if (state->dgs == NULL) {
+         goto no_dgs;
+      }
    }
 
    return state;
 
-fail:
-   if (state) {
-      FREE( (void *)state->shader.tokens );
-      FREE( state->draw_data );
-      FREE( state );
-   }
+no_dgs:
+   FREE( state );
+no_state:
    return NULL;
 }
 
@@ -86,7 +84,7 @@ llvmpipe_bind_gs_state(struct pipe_context *pipe, void *gs)
    llvmpipe->gs = (struct lp_geometry_shader *)gs;
 
    draw_bind_geometry_shader(llvmpipe->draw,
-                             (llvmpipe->gs ? llvmpipe->gs->draw_data : NULL));
+                             (llvmpipe->gs ? llvmpipe->gs->dgs : NULL));
 
    llvmpipe->dirty |= LP_NEW_GS;
 }
@@ -104,8 +102,7 @@ llvmpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
       return;
    }
 
-   draw_delete_geometry_shader(llvmpipe->draw, state->draw_data);
-   FREE( (void *)state->shader.tokens );
+   draw_delete_geometry_shader(llvmpipe->draw, state->dgs);
    FREE(state);
 }