radeonsi: add checks for a NULL pixel shader
authorMarek Olšák <marek.olsak@amd.com>
Thu, 22 Oct 2015 20:17:28 +0000 (22:17 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 23 Oct 2015 22:01:20 +0000 (00:01 +0200)
This will allow removing the dummy PS.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index a71ff4926ab51cb3e54941578671d047948e3a06..e91b6c7c6657b8f6a97ef0e88af5069c55a4888f 100644 (file)
@@ -266,6 +266,7 @@ static void si_emit_cb_target_mask(struct si_context *sctx, struct r600_atom *at
         * Reproducible with Unigine Heaven 4.0 and drirc missing.
         */
        if (blend->dual_src_blend &&
+           sctx->ps_shader.cso &&
            (sctx->ps_shader.cso->ps_colors_written & 0x3) != 0x3)
                mask = 0;
 
index eea00e0fafcf5fce4c6151df52ca1af655bc8996..ce8d1cca212be40474f27a649afbdb330b09b254 100644 (file)
@@ -956,13 +956,15 @@ static void si_emit_spi_map(struct si_context *sctx, struct r600_atom *atom)
        struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs;
        struct si_shader *ps = sctx->ps_shader.current;
        struct si_shader *vs = si_get_vs_state(sctx);
-       struct tgsi_shader_info *psinfo = &ps->selector->info;
+       struct tgsi_shader_info *psinfo;
        struct tgsi_shader_info *vsinfo = &vs->selector->info;
        unsigned i, j, tmp, num_written = 0;
 
-       if (!ps->nparam)
+       if (!ps || !ps->nparam)
                return;
 
+       psinfo = &ps->selector->info;
+
        radeon_set_context_reg_seq(cs, R_028644_SPI_PS_INPUT_CNTL_0, ps->nparam);
 
        for (i = 0; i < psinfo->num_inputs; i++) {
@@ -1025,7 +1027,12 @@ static void si_emit_spi_ps_input(struct si_context *sctx, struct r600_atom *atom
 {
        struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs;
        struct si_shader *ps = sctx->ps_shader.current;
-       unsigned input_ena = ps->spi_ps_input_ena;
+       unsigned input_ena;
+
+       if (!ps)
+               return;
+
+       input_ena = ps->spi_ps_input_ena;
 
        /* we need to enable at least one of them, otherwise we hang the GPU */
        assert(G_0286CC_PERSP_SAMPLE_ENA(input_ena) ||
@@ -1531,23 +1538,38 @@ bool si_update_shaders(struct si_context *sctx)
 
        si_update_vgt_shader_config(sctx);
 
-       r = si_shader_select(ctx, &sctx->ps_shader);
-       if (r)
-               return false;
-       si_pm4_bind_state(sctx, ps, sctx->ps_shader.current->pm4);
-
-       if (si_pm4_state_changed(sctx, ps) || si_pm4_state_changed(sctx, vs) ||
-           sctx->sprite_coord_enable != rs->sprite_coord_enable ||
-           sctx->flatshade != rs->flatshade) {
-               sctx->sprite_coord_enable = rs->sprite_coord_enable;
-               sctx->flatshade = rs->flatshade;
-               si_mark_atom_dirty(sctx, &sctx->spi_map);
-       }
+       if (sctx->ps_shader.cso) {
+               r = si_shader_select(ctx, &sctx->ps_shader);
+               if (r)
+                       return false;
+               si_pm4_bind_state(sctx, ps, sctx->ps_shader.current->pm4);
+
+               if (si_pm4_state_changed(sctx, ps) || si_pm4_state_changed(sctx, vs) ||
+                   sctx->sprite_coord_enable != rs->sprite_coord_enable ||
+                   sctx->flatshade != rs->flatshade) {
+                       sctx->sprite_coord_enable = rs->sprite_coord_enable;
+                       sctx->flatshade = rs->flatshade;
+                       si_mark_atom_dirty(sctx, &sctx->spi_map);
+               }
+
+               if (si_pm4_state_changed(sctx, ps) ||
+                   sctx->force_persample_interp != rs->force_persample_interp) {
+                       sctx->force_persample_interp = rs->force_persample_interp;
+                       si_mark_atom_dirty(sctx, &sctx->spi_ps_input);
+               }
 
-       if (si_pm4_state_changed(sctx, ps) ||
-           sctx->force_persample_interp != rs->force_persample_interp) {
-               sctx->force_persample_interp = rs->force_persample_interp;
-               si_mark_atom_dirty(sctx, &sctx->spi_ps_input);
+               if (sctx->ps_db_shader_control != sctx->ps_shader.current->db_shader_control) {
+                       sctx->ps_db_shader_control = sctx->ps_shader.current->db_shader_control;
+                       si_mark_atom_dirty(sctx, &sctx->db_render_state);
+               }
+
+               if (sctx->smoothing_enabled != sctx->ps_shader.current->key.ps.poly_line_smoothing) {
+                       sctx->smoothing_enabled = sctx->ps_shader.current->key.ps.poly_line_smoothing;
+                       si_mark_atom_dirty(sctx, &sctx->msaa_config);
+
+                       if (sctx->b.chip_class == SI)
+                               si_mark_atom_dirty(sctx, &sctx->db_render_state);
+               }
        }
 
        if (si_pm4_state_changed(sctx, ls) ||
@@ -1559,19 +1581,6 @@ bool si_update_shaders(struct si_context *sctx)
                if (!si_update_spi_tmpring_size(sctx))
                        return false;
        }
-
-       if (sctx->ps_db_shader_control != sctx->ps_shader.current->db_shader_control) {
-               sctx->ps_db_shader_control = sctx->ps_shader.current->db_shader_control;
-               si_mark_atom_dirty(sctx, &sctx->db_render_state);
-       }
-
-       if (sctx->smoothing_enabled != sctx->ps_shader.current->key.ps.poly_line_smoothing) {
-               sctx->smoothing_enabled = sctx->ps_shader.current->key.ps.poly_line_smoothing;
-               si_mark_atom_dirty(sctx, &sctx->msaa_config);
-
-               if (sctx->b.chip_class == SI)
-                       si_mark_atom_dirty(sctx, &sctx->db_render_state);
-       }
        return true;
 }