nv50/ir/ra: Fix traversal before the beginning of the active list in buildRIG.
[mesa.git] / src / gallium / drivers / nv50 / nv50_program.c
index 9c5a080f6d60f1d19d1143a4ae6edd3d10a341fb..10810bf3e07ef049c7007663d029e550a0533034 100644 (file)
@@ -343,13 +343,13 @@ nv50_program_translate(struct nv50_program *prog, uint16_t chipset)
       NOUVEAU_ERR("shader translation failed: %i\n", ret);
       goto out;
    }
-   if (info->bin.syms) /* we don't need them yet */
-      FREE(info->bin.syms);
+   FREE(info->bin.syms);
 
    prog->code = info->bin.code;
    prog->code_size = info->bin.codeSize;
    prog->fixups = info->bin.relocData;
    prog->max_gpr = MAX2(4, (info->bin.maxGPR >> 1) + 1);
+   prog->tls_space = info->bin.tlsSpace;
 
    if (prog->type == PIPE_SHADER_FRAGMENT) {
       if (info->prop.fp.writesDepth) {
@@ -396,9 +396,20 @@ 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;
 
+   ret = nv50_tls_realloc(nv50->screen, prog->tls_space);
+   if (ret < 0)
+      return FALSE;
+   if (ret > 0)
+      nv50->state.new_tls_space = TRUE;
+
    if (prog->fixups)
       nv50_ir_relocate_code(prog->fixups, prog->code, prog->code_base, 0, 0);
 
@@ -421,14 +432,11 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p)
    if (p->mem)
       nouveau_heap_free(&p->mem);
 
-   if (p->code)
-      FREE(p->code);
+   FREE(p->code);
 
-   if (p->fixups)
-      FREE(p->fixups);
+   FREE(p->fixups);
 
-   if (p->so)
-      FREE(p->so);
+   FREE(p->so);
 
    memset(p, 0, sizeof(*p));