From: Michel Dänzer Date: Wed, 8 Aug 2012 13:35:42 +0000 (+0200) Subject: radeonsi: If pixel shader compilation fails, use a dummy shader. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=82cd9c0fc2838a153006a646b0d356ed54b8680e;p=mesa.git radeonsi: If pixel shader compilation fails, use a dummy shader. Otherwise we're likely to hang the GPU. Signed-off-by: Michel Dänzer Reviewed-by: Alex Deucher --- diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c b/src/gallium/drivers/radeonsi/radeonsi_pipe.c index 3c5eaf7d61c..9ee96a06200 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c +++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c @@ -37,6 +37,7 @@ #include "util/u_pack_color.h" #include "util/u_memory.h" #include "util/u_inlines.h" +#include "util/u_simple_shaders.h" #include "util/u_upload_mgr.h" #include "vl/vl_decoder.h" #include "vl/vl_video_buffer.h" @@ -171,6 +172,9 @@ static void r600_destroy_context(struct pipe_context *context) { struct r600_context *rctx = (struct r600_context *)context; + if (rctx->dummy_pixel_shader) { + rctx->context.delete_fs_state(&rctx->context, rctx->dummy_pixel_shader); + } rctx->context.delete_depth_stencil_alpha_state(&rctx->context, rctx->custom_dsa_flush); util_unreference_framebuffer_state(&rctx->framebuffer); @@ -251,6 +255,12 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void r600_get_backend_mask(rctx); /* this emits commands and must be last */ + rctx->dummy_pixel_shader = + util_make_fragment_cloneinput_shader(&rctx->context, 0, + TGSI_SEMANTIC_GENERIC, + TGSI_INTERPOLATE_CONSTANT); + rctx->context.bind_fs_state(&rctx->context, rctx->dummy_pixel_shader); + return &rctx->context; } diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h index bde468c64fe..3bba6d1a893 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h +++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h @@ -206,6 +206,10 @@ struct r600_context { struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; unsigned nr_vertex_buffers; + /* With rasterizer discard, there doesn't have to be a pixel shader. + * In that case, we bind this one: */ + struct si_pipe_shader *dummy_pixel_shader; + /* SI state handling */ union si_state queued; union si_state emitted; diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c index 5313e5e6532..a05061765ef 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_shader.c +++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c @@ -627,7 +627,10 @@ int si_pipe_shader_create( tgsi_dump(shader->tokens, 0); } - lp_build_tgsi_llvm(bld_base, shader->tokens); + if (!lp_build_tgsi_llvm(bld_base, shader->tokens)) { + fprintf(stderr, "Failed to translate shader from TGSI to LLVM\n"); + return -EINVAL; + } radeon_llvm_finalize_module(&si_shader_ctx.radeon_bld); diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index 0d9f0091895..7af1944f82c 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -373,6 +373,13 @@ static void si_update_derived_state(struct r600_context *rctx) if (!rctx->ps_shader->bo) { si_pipe_shader_ps(ctx, rctx->ps_shader); } + if (!rctx->ps_shader->bo) { + if (!rctx->dummy_pixel_shader->bo) + si_pipe_shader_ps(ctx, rctx->dummy_pixel_shader); + + if (rctx->dummy_pixel_shader->pm4) + si_pm4_bind_state(rctx, vs, rctx->dummy_pixel_shader->pm4); + } if (rctx->shader_dirty) { si_update_spi_map(rctx);