Squashed commit of the following:
[mesa.git] / src / gallium / drivers / softpipe / sp_context.c
index e8f2318e488ee585da3c0f2e861db4db57ca7d91..d0c2978c246dc7d7288fa39033c834db056a2ce9 100644 (file)
@@ -44,6 +44,7 @@
 #include "sp_surface.h"
 #include "sp_tile_cache.h"
 #include "sp_tex_tile_cache.h"
+#include "sp_texture.h"
 #include "sp_query.h"
 
 
@@ -103,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++) {
@@ -116,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);
          }
       }
    }
@@ -134,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++) {
@@ -171,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
@@ -210,7 +208,7 @@ softpipe_create_context( 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;
@@ -256,8 +254,10 @@ softpipe_create_context( struct pipe_screen *screen,
    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;
@@ -271,10 +271,10 @@ softpipe_create_context( 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;
 
@@ -283,13 +283,13 @@ softpipe_create_context( 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 */