nv50,nvc0: fix shader eviction
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 7 Dec 2012 21:43:10 +0000 (22:43 +0100)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 7 Dec 2012 21:48:54 +0000 (22:48 +0100)
src/gallium/drivers/nv50/nv50_program.c
src/gallium/drivers/nvc0/nvc0_program.c

index 0d292f7ab891cbebcba6daeea05122198acdb418..10810bf3e07ef049c7007663d029e550a0533034 100644 (file)
@@ -396,6 +396,11 @@ nv50_program_upload_code(struct nv50_context *nv50, struct nv50_program *prog)
             nouveau_heap_free(&evict->mem);
       }
       debug_printf("WARNING: out of code space, evicting all shaders.\n");
+      ret = nouveau_heap_alloc(heap, size, prog, &prog->mem);
+      if (ret) {
+         NOUVEAU_ERR("shader too large (0x%x) to fit in code space ?\n", size);
+         return FALSE;
+      }
    }
    prog->code_base = prog->mem->start;
 
index 9655e18de52d1441aa2bf80b395de887298b6cba..8bcb2066f1797f5b79c0cbc598735aeb3e3e55db 100644 (file)
@@ -670,8 +670,20 @@ nvc0_program_upload_code(struct nvc0_context *nvc0, struct nvc0_program *prog)
 
    ret = nouveau_heap_alloc(screen->text_heap, size, prog, &prog->mem);
    if (ret) {
-      NOUVEAU_ERR("out of code space\n");
-      return FALSE;
+      struct nouveau_heap *heap = screen->text_heap;
+      struct nouveau_heap *iter;
+      for (iter = heap; iter && iter->next != heap; iter = iter->next) {
+         struct nvc0_program *evict = iter->priv;
+         if (evict)
+            nouveau_heap_free(&evict->mem);
+      }
+      debug_printf("WARNING: out of code space, evicting all shaders.\n");
+      ret = nouveau_heap_alloc(heap, size, prog, &prog->mem);
+      if (ret) {
+         NOUVEAU_ERR("shader too large (0x%x) to fit in code space ?\n", size);
+         return FALSE;
+      }
+      IMMED_NVC0(nvc0->base.pushbuf, NVC0_3D(SERIALIZE), 0);
    }
    prog->code_base = prog->mem->start;
    prog->immd_base = align(prog->mem->start + prog->immd_base, 0x100);