svga: Silence debug printf.
[mesa.git] / src / gallium / drivers / svga / svga_state_tss.c
index c08ec7c2e8cf92f52b8d64257da0ed8911c9bcc2..f8b269a101efd2df77ca47eb93ea2282cd4d81f4 100644 (file)
@@ -27,7 +27,7 @@
 #include "pipe/p_defines.h"
 #include "util/u_math.h"
 
-#include "svga_screen_texture.h"
+#include "svga_sampler_view.h"
 #include "svga_winsys.h"
 #include "svga_context.h"
 #include "svga_state.h"
@@ -45,7 +45,7 @@ void svga_cleanup_tss_binding(struct svga_context *svga)
 
       svga_sampler_view_reference(&view->v, NULL);
       pipe_sampler_view_reference( &svga->curr.sampler_views[i], NULL );
-      pipe_texture_reference( &view->texture, NULL );
+      pipe_resource_reference( &view->texture, NULL );
 
       view->dirty = 1;
    }
@@ -56,6 +56,7 @@ static int
 update_tss_binding(struct svga_context *svga, 
                    unsigned dirty )
 {
+   boolean reemit = !!(dirty & SVGA_NEW_COMMAND_BUFFER);
    unsigned i;
    unsigned count = MAX2( svga->curr.num_sampler_views,
                           svga->state.hw_draw.num_views );
@@ -77,7 +78,7 @@ update_tss_binding(struct svga_context *svga,
    for (i = 0; i < count; i++) {
       const struct svga_sampler_state *s = svga->curr.sampler[i];
       struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
-      struct pipe_texture *texture = NULL;
+      struct pipe_resource *texture = NULL;
 
       /* get min max lod */
       if (svga->curr.sampler_views[i]) {
@@ -94,7 +95,7 @@ update_tss_binding(struct svga_context *svga,
           view->max_lod != max_lod) {
 
          svga_sampler_view_reference(&view->v, NULL);
-         pipe_texture_reference( &view->texture, texture );
+         pipe_resource_reference( &view->texture, texture );
 
          view->dirty = TRUE;
          view->min_lod = min_lod;
@@ -107,12 +108,18 @@ update_tss_binding(struct svga_context *svga,
                                                 max_lod);
       }
 
-      if (view->dirty) {
+      /*
+       * We need to reemit non-null texture bindings, even when they are not
+       * dirty, to ensure that the resources are paged in.
+       */
+
+      if (view->dirty ||
+          (reemit && view->v)) {
          queue.bind[queue.bind_count].unit = i;
          queue.bind[queue.bind_count].view = view;
          queue.bind_count++;
       } 
-      else if (view->v) {
+      if (!view->dirty && view->v) {
          svga_validate_sampler_view(svga, view->v);
       }
    }
@@ -128,18 +135,21 @@ update_tss_binding(struct svga_context *svga,
          goto fail;
 
       for (i = 0; i < queue.bind_count; i++) {
+         struct svga_winsys_surface *handle;
+
          ts[i].stage = queue.bind[i].unit;
          ts[i].name = SVGA3D_TS_BIND_TEXTURE;
 
          if (queue.bind[i].view->v) {
-            svga->swc->surface_relocation(svga->swc,
-                                          &ts[i].value,
-                                          queue.bind[i].view->v->handle,
-                                          PIPE_BUFFER_USAGE_GPU_READ);
+            handle = queue.bind[i].view->v->handle;
          }
          else {
-            ts[i].value = SVGA3D_INVALID_ID;
+            handle = NULL;
          }
+         svga->swc->surface_relocation(svga->swc,
+                                       &ts[i].value,
+                                       handle,
+                                       SVGA_RELOC_READ);
          
          queue.bind[i].view->dirty = FALSE;
       }
@@ -157,7 +167,8 @@ fail:
 struct svga_tracked_state svga_hw_tss_binding = {
    "texture binding emit",
    SVGA_NEW_TEXTURE_BINDING |
-   SVGA_NEW_SAMPLER,
+   SVGA_NEW_SAMPLER |
+   SVGA_NEW_COMMAND_BUFFER,
    update_tss_binding
 };
 
@@ -227,7 +238,6 @@ update_tss(struct svga_context *svga,
          // TEXCOORDINDEX -- hopefully not needed
 
          if (svga->curr.tex_flags.flag_1d & (1 << i)) {
-            debug_printf("wrap 1d tex %d\n", i);
             EMIT_TS(svga, i, SVGA3D_TEX_ADDRESS_WRAP, ADDRESSV, fail);
          }
          else