From: Rob Clark Date: Mon, 18 Feb 2019 18:54:26 +0000 (-0500) Subject: freedreno/ir3: fix crash in compile fail case X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=97479df8aaf6f00ebc70da452ea43e04f829ef2f;p=mesa.git freedreno/ir3: fix crash in compile fail case The variant will be NULL if RA failed. Which isn't ideal, but at least lets not segfault and bring down the rest of the dEQP run with us. Signed-off-by: Rob Clark --- diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index 51c7b75ea38..3dcc3945ffe 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -228,7 +228,7 @@ ir3_shader_get_variant(struct ir3_shader *shader, struct ir3_shader_key *key, struct ir3_shader_variant *v = shader_variant(shader, key, created); - if (binning_pass) { + if (v && binning_pass) { if (!v->binning) v->binning = create_variant(shader, key, true); return v->binning; diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c index adbdef24a4d..9ed79cbcb7f 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c @@ -186,6 +186,10 @@ fd6_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info, fd6_ctx->prog = fd6_emit_get_prog(&emit); } + /* bail if compile failed: */ + if (!fd6_ctx->prog) + return NULL; + emit.dirty = ctx->dirty; /* *after* fixup_shader_state() */ emit.bs = fd6_emit_get_prog(&emit)->bs; emit.vs = fd6_emit_get_prog(&emit)->vs; @@ -194,11 +198,6 @@ fd6_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info, const struct ir3_shader_variant *vp = emit.vs; const struct ir3_shader_variant *fp = emit.fs; - /* do regular pass first, since that is more likely to fail compiling: */ - - if (!vp || !fp) - return false; - ctx->stats.vs_regs += ir3_shader_halfregs(vp); ctx->stats.fs_regs += ir3_shader_halfregs(fp); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cache.c b/src/gallium/drivers/freedreno/ir3/ir3_cache.c index 2de23e49873..8e7070a727d 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cache.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cache.c @@ -97,6 +97,10 @@ ir3_cache_lookup(struct ir3_cache *cache, const struct ir3_cache_key *key, struct ir3_shader_variant *vs = ir3_shader_variant(key->vs, key->key, false, debug); struct ir3_shader_variant *fs = ir3_shader_variant(key->fs, key->key, false, debug); + if (!bs || !vs || !fs) { + return NULL; + } + struct ir3_program_state *state = cache->funcs->create_state(cache->data, bs, vs, fs, &key->key); state->key = *key;