gallium: make p_winsys internal
[mesa.git] / src / gallium / drivers / softpipe / sp_state_fs.c
index eb641ed321df964bedc555b93de8c153451cdbc6..4d01a9dbe15fa7ff66a4cb88c74ac9c8d06e1708 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/internal/p_winsys_screen.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;
@@ -120,7 +119,8 @@ softpipe_bind_vs_state(struct pipe_context *pipe, void *vs)
 
    softpipe->vs = (const struct sp_vertex_shader *)vs;
 
-   draw_bind_vertex_shader(softpipe->draw, softpipe->vs->draw_data);
+   draw_bind_vertex_shader(softpipe->draw,
+                           (softpipe->vs ? softpipe->vs->draw_data : NULL));
 
    softpipe->dirty |= SP_NEW_VS;
 }
@@ -146,16 +146,15 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
                              const struct pipe_constant_buffer *buf)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
-   struct pipe_winsys *ws = pipe->winsys;
+   struct pipe_screen *screen = pipe->screen;
 
    assert(shader < PIPE_SHADER_TYPES);
    assert(index == 0);
 
    /* note: reference counting */
-   pipe_buffer_reference(ws,
+   pipe_buffer_reference(screen,
                         &softpipe->constants[shader].buffer,
-                        buf->buffer);
-   softpipe->constants[shader].size = buf->size;
+                        buf ? buf->buffer : NULL);
 
    softpipe->dirty |= SP_NEW_CONSTANTS;
 }