radeonsi: Use dummy pixel shader if compilation of the real shader failed
authorMichel Dänzer <michel.daenzer@amd.com>
Mon, 6 Oct 2014 08:05:38 +0000 (17:05 +0900)
committerMichel Dänzer <michel@daenzer.net>
Tue, 7 Oct 2014 03:07:13 +0000 (12:07 +0900)
Instead of crashing.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79155#c5
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state.h
src/gallium/drivers/radeonsi/si_state_draw.c

index 57bfa591c56488935f10e72cc5fbae370c4f62a2..0166798c0e2b587359bbe48375b096720c1fbc18 100644 (file)
@@ -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;
        }
 
index 7b6de6b663b0d18072850246f83454cfe749ef53..f70bddfb8ec141d1fb84d9679dae7cd4992a8a9e 100644 (file)
@@ -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);
index e8d84a90d573ec9a9640db314db62b5a2922fec0..c9e4353c3a42ba0e75ca9e1ec38975271111aad3 100644 (file)
@@ -662,6 +662,16 @@ static void si_update_derived_state(struct si_context *sctx)
 
        si_shader_select(ctx, sctx->ps_shader);
 
+       if (!sctx->ps_shader->current) {
+               struct si_shader_selector *sel;
+
+               /* use a dummy shader if compiling the shader (variant) failed */
+               si_make_dummy_ps(sctx);
+               sel = sctx->dummy_pixel_shader;
+               si_shader_select(ctx, sel);
+               sctx->ps_shader->current = sel->current;
+       }
+
        if (!sctx->ps_shader->current->pm4)
                si_shader_ps(ctx, sctx->ps_shader->current);