Merge commit 'origin/master' into gallium-0.2
[mesa.git] / src / gallium / drivers / softpipe / sp_state_fs.c
index 4eefd1d61f524c1da4e155e83ed913cc23fc128d..e5b609cf6c98b83231207e31b353ec36beab12a1 100644 (file)
 #include "sp_fs.h"
 
 #include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
 #include "pipe/p_inlines.h"
 #include "pipe/p_winsys.h"
 #include "pipe/p_shader_tokens.h"
 #include "draw/draw_context.h"
-#include "tgsi/util/tgsi_dump.h"
-#include "tgsi/util/tgsi_scan.h"
+#include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_scan.h"
 
 
 void *
@@ -83,6 +83,8 @@ void
 softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct sp_fragment_shader *state = fs;
+
+   assert(fs != softpipe_context(pipe)->fs);
    
    state->delete( state );
 }
@@ -100,10 +102,7 @@ softpipe_create_vs_state(struct pipe_context *pipe,
       return NULL;
    }
 
-   state->shader = *templ;
-
-   state->draw_data = draw_create_vertex_shader(softpipe->draw,
-                                                &state->shader);
+   state->draw_data = draw_create_vertex_shader(softpipe->draw, templ);
    if (state->draw_data == NULL) {
       FREE( state );
       return NULL;
@@ -153,10 +152,10 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
    assert(index == 0);
 
    /* note: reference counting */
-   pipe_buffer_reference(ws,
+   winsys_buffer_reference(ws,
                         &softpipe->constants[shader].buffer,
-                        buf->buffer);
-   softpipe->constants[shader].size = buf->size;
+                        buf ? buf->buffer : NULL);
+   softpipe->constants[shader].size = buf ? buf->size : 0;
 
    softpipe->dirty |= SP_NEW_CONSTANTS;
 }