diff options
author | Iago Toral Quiroga <[email protected]> | 2019-10-09 11:13:00 +0200 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2019-12-16 08:42:37 +0100 |
commit | b636d4ebc72b9c2f99f5214ae428b6cdcb85aab3 (patch) | |
tree | 246a22df8cafd4022dd24ff8ddfccd663b721c9c /src/gallium/drivers/v3d | |
parent | e2f22634335ca3f2ab32d33f52adf617bf08cc96 (diff) |
v3d: don't try to render if shaders failed to compile
This is the same we do in the compute path to avoid crashes
at draw time.
Reviewed-by: Alejandro PiƱeiro <[email protected]>
Diffstat (limited to 'src/gallium/drivers/v3d')
-rw-r--r-- | src/gallium/drivers/v3d/v3dx_draw.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index a4cff4c86c6..d0f6f623e6c 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -1030,6 +1030,33 @@ v3d_hw_prim_type(enum pipe_prim_type prim_type) } } +static bool +v3d_check_compiled_shaders(struct v3d_context *v3d) +{ + static bool warned[5] = { 0 }; + + uint32_t failed_stage = MESA_SHADER_NONE; + if (!v3d->prog.vs->resource || !v3d->prog.cs->resource) { + failed_stage = MESA_SHADER_VERTEX; + } else if ((v3d->prog.gs_bin && !v3d->prog.gs_bin->resource) || + (v3d->prog.gs && !v3d->prog.gs->resource)) { + failed_stage = MESA_SHADER_GEOMETRY; + } else if (v3d->prog.fs && !v3d->prog.fs->resource) { + failed_stage = MESA_SHADER_FRAGMENT; + } + + if (likely(failed_stage == MESA_SHADER_NONE)) + return true; + + if (!warned[failed_stage]) { + fprintf(stderr, + "%s shader failed to compile. Expect corruption.\n", + _mesa_shader_stage_to_string(failed_stage)); + warned[failed_stage] = true; + } + return false; +} + static void v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) { @@ -1137,6 +1164,8 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) v3d_start_draw(v3d); v3d_update_compiled_shaders(v3d, info->mode); + if (!v3d_check_compiled_shaders(v3d)) + return; v3d_update_job_ez(v3d, job); /* If this job was writing to transform feedback buffers before this |