r600g/compute Improve debugging output
[mesa.git] / src / gallium / drivers / softpipe / sp_state_shader.c
index 40d32a4dfb07deb6b2877ed90e157a7da98b41f5..eb4b6b1458ce68c907ff620997d1bf68c5e62d3a 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;
 
@@ -343,6 +347,8 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
    unsigned size;
    const void *data;
 
+   assert(shader < PIPE_SHADER_TYPES);
+
    if (cb && cb->user_buffer) {
       constants = softpipe_user_buffer_create(pipe->screen,
                                               (void *) cb->user_buffer,
@@ -350,10 +356,10 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
                                               PIPE_BIND_CONSTANT_BUFFER);
    }
 
-   size = constants ? constants->width0 : 0;
-   data = constants ? softpipe_resource(constants)->data : NULL;
-
-   assert(shader < PIPE_SHADER_TYPES);
+   size = cb ? cb->buffer_size : 0;
+   data = constants ? softpipe_resource_data(constants) : NULL;
+   if (data)
+      data = (const char *) data + cb->buffer_offset;
 
    draw_flush(softpipe->draw);