radeonsi: If pixel shader compilation fails, use a dummy shader.

Otherwise we're likely to hang the GPU.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Michel Dänzer 2012-08-08 15:35:42 +02:00 committed by Michel Dänzer
parent be42a45e02
commit 82cd9c0fc2
4 changed files with 25 additions and 1 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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);

View file

@ -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);