radeonsi: add an initial dump_debug_state implementation dumping shaders
[mesa.git] / src / gallium / drivers / svga / svga_state_tss.c
index 3015a446fe299fbbd75e5c1882d79bf9fe5b5bd4..41334bd7cb9f1871341ed8704fb7af85c6f52ab1 100644 (file)
@@ -37,7 +37,7 @@
 
 void svga_cleanup_tss_binding(struct svga_context *svga)
 {
-   int i;
+   unsigned i;
    unsigned count = MAX2( svga->curr.num_sampler_views,
                           svga->state.hw_draw.num_views );
 
@@ -45,7 +45,7 @@ void svga_cleanup_tss_binding(struct svga_context *svga)
       struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
 
       svga_sampler_view_reference(&view->v, NULL);
-      pipe_sampler_view_reference( &svga->curr.sampler_views[i], NULL );
+      pipe_sampler_view_release(&svga->pipe, &svga->curr.sampler_views[i]);
       pipe_resource_reference( &view->texture, NULL );
 
       view->dirty = 1;
@@ -82,12 +82,14 @@ update_tss_binding(struct svga_context *svga,
       const struct svga_sampler_state *s = svga->curr.sampler[i];
       struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
       struct pipe_resource *texture = NULL;
+      struct pipe_sampler_view *sv = svga->curr.sampler_views[i];
 
       /* get min max lod */
-      if (svga->curr.sampler_views[i]) {
-         min_lod = MAX2(s->view_min_lod, 0);
-         max_lod = MIN2(s->view_max_lod, svga->curr.sampler_views[i]->texture->last_level);
-         texture = svga->curr.sampler_views[i]->texture;
+      if (sv && s) {
+         min_lod = MAX2(0, (s->view_min_lod + sv->u.tex.first_level));
+         max_lod = MIN2(s->view_max_lod + sv->u.tex.first_level,
+                        sv->texture->last_level);
+         texture = sv->texture;
       } else {
          min_lod = 0;
          max_lod = 0;
@@ -151,6 +153,7 @@ update_tss_binding(struct svga_context *svga,
          }
          svga->swc->surface_relocation(svga->swc,
                                        &ts[i].value,
+                                       NULL,
                                        handle,
                                        SVGA_RELOC_READ);
          
@@ -162,7 +165,7 @@ update_tss_binding(struct svga_context *svga,
 
    svga->rebind.texture_samplers = FALSE;
 
-   return 0;
+   return PIPE_OK;
 
 fail:
    return PIPE_ERROR_OUT_OF_MEMORY;
@@ -218,6 +221,7 @@ svga_reemit_tss_bindings(struct svga_context *svga)
          handle = queue.bind[i].view->v->handle;
          svga->swc->surface_relocation(svga->swc,
                                        &ts[i].value,
+                                       NULL,
                                        handle,
                                        SVGA_RELOC_READ);
       }
@@ -270,7 +274,7 @@ do {                                                                    \
 } while (0)
 
 
-static INLINE void 
+static inline void 
 svga_queue_tss( struct ts_queue *q,
                 unsigned unit,
                 unsigned tss,