freedreno/ir3: fix crash in compile fail case
authorRob Clark <robdclark@gmail.com>
Mon, 18 Feb 2019 18:54:26 +0000 (13:54 -0500)
committerRob Clark <robdclark@gmail.com>
Wed, 20 Feb 2019 23:50:08 +0000 (18:50 -0500)
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 <robdclark@gmail.com>
src/freedreno/ir3/ir3_shader.c
src/gallium/drivers/freedreno/a6xx/fd6_draw.c
src/gallium/drivers/freedreno/ir3/ir3_cache.c

index 51c7b75ea3873b2185b6d5eddf25d94325aeff6e..3dcc3945ffe47de0e6d84e348f62d5faeffe92e3 100644 (file)
@@ -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;
index adbdef24a4d678f08154fc6dec7a3077651e5300..9ed79cbcb7fce3ce9291bea3db0b8d9ff4dab1ae 100644 (file)
@@ -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);
 
index 2de23e49873c207588821bbff012dd3bddb4a753..8e7070a727d6d37f32cbc2fdc1eda892949fbd7e 100644 (file)
@@ -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;