[Mesa-dev] [PATCH] radeonsi: Use dummy pixel shader if compilation of the real shader failed
Michel Dänzer
michel at daenzer.net
Mon Oct 6 01:07:30 PDT 2014
From: Michel Dänzer <michel.daenzer at amd.com>
Instead of crashing.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79155#c5
Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
src/gallium/drivers/radeonsi/si_state.c | 18 +++++++++++-------
src/gallium/drivers/radeonsi/si_state.h | 1 +
src/gallium/drivers/radeonsi/si_state_draw.c | 8 ++++++++
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 57bfa59..0166798 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2373,6 +2373,16 @@ static void si_bind_gs_shader(struct pipe_context *ctx, void *state)
sctx->gs_shader = sel;
}
+void si_make_dummy_ps(struct si_context *sctx)
+{
+ if (!sctx->dummy_pixel_shader) {
+ sctx->dummy_pixel_shader =
+ util_make_fragment_cloneinput_shader(&sctx->b.b, 0,
+ TGSI_SEMANTIC_GENERIC,
+ TGSI_INTERPOLATE_CONSTANT);
+ }
+}
+
static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
{
struct si_context *sctx = (struct si_context *)ctx;
@@ -2384,13 +2394,7 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
/* use a dummy shader if binding a NULL shader */
if (!sel) {
- if (!sctx->dummy_pixel_shader) {
- sctx->dummy_pixel_shader =
- util_make_fragment_cloneinput_shader(&sctx->b.b, 0,
- TGSI_SEMANTIC_GENERIC,
- TGSI_INTERPOLATE_CONSTANT);
- }
-
+ si_make_dummy_ps(sctx);
sel = sctx->dummy_pixel_shader;
}
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index 7b6de6b..f70bddf 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -257,6 +257,7 @@ boolean si_is_format_supported(struct pipe_screen *screen,
unsigned usage);
int si_shader_select(struct pipe_context *ctx,
struct si_shader_selector *sel);
+void si_make_dummy_ps(struct si_context *sctx);
void si_init_state_functions(struct si_context *sctx);
void si_init_config(struct si_context *sctx);
unsigned cik_bank_wh(unsigned bankwh);
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c
index e8d84a9..e76c745 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -662,6 +662,14 @@ static void si_update_derived_state(struct si_context *sctx)
si_shader_select(ctx, sctx->ps_shader);
+ if (!sctx->ps_shader->current) {
+ /* use a dummy shader if compiling the shader (variant) failed */
+ si_make_dummy_ps(sctx);
+ si_shader_select(ctx, sctx->dummy_pixel_shader);
+ sctx->ps_shader->current =
+ ((struct si_shader_selector*)sctx->dummy_pixel_shader)->current;
+ }
+
if (!sctx->ps_shader->current->pm4)
si_shader_ps(ctx, sctx->ps_shader->current);
--
2.1.1
More information about the mesa-dev
mailing list