Squashed commit of the following:
[mesa.git] / src / gallium / drivers / softpipe / sp_context.c
index b1cfe59bc1847e1b9a3b7e0e846a5d635c4a1579..d0c2978c246dc7d7288fa39033c834db056a2ce9 100644 (file)
@@ -44,7 +44,7 @@
 #include "sp_surface.h"
 #include "sp_tile_cache.h"
 #include "sp_tex_tile_cache.h"
-#include "sp_winsys.h"
+#include "sp_texture.h"
 #include "sp_query.h"
 
 
@@ -104,12 +104,12 @@ softpipe_destroy( struct pipe_context *pipe )
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
       sp_destroy_tex_tile_cache(softpipe->tex_cache[i]);
-      pipe_texture_reference(&softpipe->texture[i], NULL);
+      pipe_sampler_view_reference(&softpipe->sampler_views[i], NULL);
    }
 
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
       sp_destroy_tex_tile_cache(softpipe->vertex_tex_cache[i]);
-      pipe_texture_reference(&softpipe->vertex_textures[i], NULL);
+      pipe_sampler_view_reference(&softpipe->vertex_sampler_views[i], NULL);
    }
 
    for (i = 0; i < PIPE_SHADER_TYPES; i++) {
@@ -117,7 +117,7 @@ softpipe_destroy( struct pipe_context *pipe )
 
       for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++) {
          if (softpipe->constants[i][j]) {
-            pipe_buffer_reference(&softpipe->constants[i][j], NULL);
+            pipe_resource_reference(&softpipe->constants[i][j], NULL);
          }
       }
    }
@@ -135,13 +135,16 @@ softpipe_destroy( struct pipe_context *pipe )
  *    return PIPE_UNREFERENCED
  */
 static unsigned int
-softpipe_is_texture_referenced( struct pipe_context *pipe,
-                               struct pipe_texture *texture,
+softpipe_is_resource_referenced( struct pipe_context *pipe,
+                               struct pipe_resource *texture,
                                unsigned face, unsigned level)
 {
    struct softpipe_context *softpipe = softpipe_context( pipe );
    unsigned i;
 
+   if (texture->target == PIPE_BUFFER)
+      return PIPE_UNREFERENCED;
+   
    /* check if any of the bound drawing surfaces are this texture */
    if (softpipe->dirty_render_cache) {
       for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
@@ -172,12 +175,6 @@ softpipe_is_texture_referenced( struct pipe_context *pipe,
 }
 
 
-static unsigned int
-softpipe_is_buffer_referenced( struct pipe_context *pipe,
-                              struct pipe_buffer *buf)
-{
-   return PIPE_UNREFERENCED;
-}
 
 
 static void
@@ -194,7 +191,8 @@ softpipe_render_condition( struct pipe_context *pipe,
 
 
 struct pipe_context *
-softpipe_create( struct pipe_screen *screen )
+softpipe_create_context( struct pipe_screen *screen,
+                        void *priv )
 {
    struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
    uint i;
@@ -210,9 +208,10 @@ softpipe_create( struct pipe_screen *screen )
    softpipe->dump_fs = debug_get_bool_option( "GALLIUM_DUMP_FS", FALSE );
    softpipe->dump_gs = debug_get_bool_option( "SOFTPIPE_DUMP_GS", FALSE );
 
-   softpipe->pipe.winsys = screen->winsys;
+   softpipe->pipe.winsys = NULL;
    softpipe->pipe.screen = screen;
    softpipe->pipe.destroy = softpipe_destroy;
+   softpipe->pipe.priv = priv;
 
    /* state setters */
    softpipe->pipe.create_blend_state = softpipe_create_blend_state;
@@ -244,18 +243,24 @@ softpipe_create( struct pipe_screen *screen )
    softpipe->pipe.bind_gs_state   = softpipe_bind_gs_state;
    softpipe->pipe.delete_gs_state = softpipe_delete_gs_state;
 
+   softpipe->pipe.create_vertex_elements_state = softpipe_create_vertex_elements_state;
+   softpipe->pipe.bind_vertex_elements_state = softpipe_bind_vertex_elements_state;
+   softpipe->pipe.delete_vertex_elements_state = softpipe_delete_vertex_elements_state;
+
    softpipe->pipe.set_blend_color = softpipe_set_blend_color;
+   softpipe->pipe.set_stencil_ref = softpipe_set_stencil_ref;
    softpipe->pipe.set_clip_state = softpipe_set_clip_state;
    softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
    softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
    softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
    softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
-   softpipe->pipe.set_fragment_sampler_textures = softpipe_set_sampler_textures;
-   softpipe->pipe.set_vertex_sampler_textures = softpipe_set_vertex_sampler_textures;
+   softpipe->pipe.set_fragment_sampler_views = softpipe_set_sampler_views;
+   softpipe->pipe.set_vertex_sampler_views = softpipe_set_vertex_sampler_views;
+   softpipe->pipe.create_sampler_view = softpipe_create_sampler_view;
+   softpipe->pipe.sampler_view_destroy = softpipe_sampler_view_destroy;
    softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
 
    softpipe->pipe.set_vertex_buffers = softpipe_set_vertex_buffers;
-   softpipe->pipe.set_vertex_elements = softpipe_set_vertex_elements;
 
    softpipe->pipe.draw_arrays = softpipe_draw_arrays;
    softpipe->pipe.draw_elements = softpipe_draw_elements;
@@ -266,10 +271,10 @@ softpipe_create( struct pipe_screen *screen )
    softpipe->pipe.clear = softpipe_clear;
    softpipe->pipe.flush = softpipe_flush;
 
-   softpipe->pipe.is_texture_referenced = softpipe_is_texture_referenced;
-   softpipe->pipe.is_buffer_referenced = softpipe_is_buffer_referenced;
+   softpipe->pipe.is_resource_referenced = softpipe_is_resource_referenced;
 
    softpipe_init_query_funcs( softpipe );
+   softpipe_init_texture_funcs( &softpipe->pipe );
 
    softpipe->pipe.render_condition = softpipe_render_condition;
 
@@ -278,13 +283,13 @@ softpipe_create( struct pipe_screen *screen )
     * Must be before quad stage setup!
     */
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
-      softpipe->cbuf_cache[i] = sp_create_tile_cache( screen );
-   softpipe->zsbuf_cache = sp_create_tile_cache( screen );
+      softpipe->cbuf_cache[i] = sp_create_tile_cache( &softpipe->pipe );
+   softpipe->zsbuf_cache = sp_create_tile_cache( &softpipe->pipe );
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
-      softpipe->tex_cache[i] = sp_create_tex_tile_cache( screen );
+      softpipe->tex_cache[i] = sp_create_tex_tile_cache( &softpipe->pipe );
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
-      softpipe->vertex_tex_cache[i] = sp_create_tex_tile_cache(screen);
+      softpipe->vertex_tex_cache[i] = sp_create_tex_tile_cache( &softpipe->pipe );
    }
 
    /* setup quad rendering stages */