summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorChristoph Bumiller <[email protected]>2010-09-16 00:51:32 +0200
committerChristoph Bumiller <[email protected]>2010-09-16 14:49:20 +0200
commite0aa7e043803b10f503440ed088d89b67f5fd66f (patch)
treeed0bda4d639313609d17ac3f43f6e78f7f7a50b7 /src/gallium
parent8fbe968a62f845da2a1491c398acf0b2140d2372 (diff)
nv50: don't segfault on shaders with 0 instructions
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/nv50/nv50_pc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gallium/drivers/nv50/nv50_pc.c b/src/gallium/drivers/nv50/nv50_pc.c
index bb464ec4c9f..676540538e5 100644
--- a/src/gallium/drivers/nv50/nv50_pc.c
+++ b/src/gallium/drivers/nv50/nv50_pc.c
@@ -459,7 +459,8 @@ nv50_emit_program(struct nv_pc *pc)
assert(pc->emit == &code[pc->bin_size / 4]);
/* XXX: we can do better than this ... */
- if (!(pc->emit[-2] & 1) || (pc->emit[-2] & 2) || (pc->emit[-1] & 3)) {
+ if (!pc->bin_size ||
+ !(pc->emit[-2] & 1) || (pc->emit[-2] & 2) || (pc->emit[-1] & 3)) {
pc->emit[0] = 0xf0000001;
pc->emit[1] = 0xe0000000;
pc->bin_size += 8;
@@ -523,6 +524,7 @@ nv50_generate_code(struct nv50_translation_info *ti)
ret = nv_pc_exec_pass2(pc);
if (ret)
goto out;
+ assert(!(pc->bin_size % 8));
pc->emit = CALLOC(pc->bin_size / 4 + 2, 4);
if (!pc->emit) {