radeonsi: assume that rasterizer state is non-NULL in draw_vbo
authorMarek Olšák <marek.olsak@amd.com>
Thu, 31 May 2018 03:21:28 +0000 (23:21 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 14 Jun 2018 02:00:36 +0000 (22:00 -0400)
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state_draw.c
src/gallium/drivers/radeonsi/si_state_shaders.c
src/gallium/drivers/radeonsi/si_state_viewport.c

index 69a53f7a10bcdd81db7b67518e3e6f72045bf378..fb4649771fc0d17bb40a5d5af8e046186d1f9318 100644 (file)
@@ -1418,7 +1418,7 @@ static void si_emit_db_render_state(struct si_context *sctx)
        }
 
        /* Disable the gl_SampleMask fragment shader output if MSAA is disabled. */
-       if (!rs || !rs->multisample_enable)
+       if (!rs->multisample_enable)
                db_shader_control &= C_02880C_MASK_EXPORT_ENABLE;
 
        if (sctx->screen->has_rbplus &&
@@ -3251,7 +3251,7 @@ static void si_emit_msaa_sample_locs(struct si_context *sctx)
                 */
                if (has_msaa_sample_loc_bug &&
                    sctx->framebuffer.nr_samples > 1 &&
-                   rs && !rs->multisample_enable)
+                   !rs->multisample_enable)
                        small_prim_filter_cntl &= C_028830_SMALL_PRIM_FILTER_ENABLE;
 
                radeon_opt_set_context_reg(sctx,
index 5370587d747920c4bb7317bfbb0bae7f3eea7985..942cb3c79940c8c0ef6c3810389bfa8081c69362 100644 (file)
@@ -1229,15 +1229,10 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
                        return;
        }
 
-       if (unlikely(!sctx->vs_shader.cso)) {
-               assert(0);
-               return;
-       }
-       if (unlikely(!sctx->ps_shader.cso && (!rs || !rs->rasterizer_discard))) {
-               assert(0);
-               return;
-       }
-       if (unlikely(!!sctx->tes_shader.cso != (info->mode == PIPE_PRIM_PATCHES))) {
+       if (unlikely(!sctx->vs_shader.cso ||
+                    !rs ||
+                    (!sctx->ps_shader.cso && !rs->rasterizer_discard) ||
+                    (!!sctx->tes_shader.cso != (info->mode == PIPE_PRIM_PATCHES)))) {
                assert(0);
                return;
        }
index aa270ebcb4d0425ad4fb74ee5c72c2985cf935aa..e7610af2fa7d315d83f47bf1a65c15cff7b2e288 100644 (file)
@@ -1418,65 +1418,63 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
                        key->part.ps.epilog.color_is_int10 &= sel->info.colors_written;
                }
 
-               if (rs) {
-                       bool is_poly = !util_prim_is_points_or_lines(sctx->current_rast_prim);
-                       bool is_line = util_prim_is_lines(sctx->current_rast_prim);
+               bool is_poly = !util_prim_is_points_or_lines(sctx->current_rast_prim);
+               bool is_line = util_prim_is_lines(sctx->current_rast_prim);
 
-                       key->part.ps.prolog.color_two_side = rs->two_side && sel->info.colors_read;
-                       key->part.ps.prolog.flatshade_colors = rs->flatshade && sel->info.colors_read;
+               key->part.ps.prolog.color_two_side = rs->two_side && sel->info.colors_read;
+               key->part.ps.prolog.flatshade_colors = rs->flatshade && sel->info.colors_read;
 
-                       if (sctx->queued.named.blend) {
-                               key->part.ps.epilog.alpha_to_one = sctx->queued.named.blend->alpha_to_one &&
-                                                             rs->multisample_enable;
-                       }
+               if (sctx->queued.named.blend) {
+                       key->part.ps.epilog.alpha_to_one = sctx->queued.named.blend->alpha_to_one &&
+                                                          rs->multisample_enable;
+               }
 
-                       key->part.ps.prolog.poly_stipple = rs->poly_stipple_enable && is_poly;
-                       key->part.ps.epilog.poly_line_smoothing = ((is_poly && rs->poly_smooth) ||
-                                                             (is_line && rs->line_smooth)) &&
-                                                            sctx->framebuffer.nr_samples <= 1;
-                       key->part.ps.epilog.clamp_color = rs->clamp_fragment_color;
+               key->part.ps.prolog.poly_stipple = rs->poly_stipple_enable && is_poly;
+               key->part.ps.epilog.poly_line_smoothing = ((is_poly && rs->poly_smooth) ||
+                                                          (is_line && rs->line_smooth)) &&
+                                                         sctx->framebuffer.nr_samples <= 1;
+               key->part.ps.epilog.clamp_color = rs->clamp_fragment_color;
 
-                       if (sctx->ps_iter_samples > 1 &&
-                           sel->info.reads_samplemask) {
-                               key->part.ps.prolog.samplemask_log_ps_iter =
-                                       util_logbase2(sctx->ps_iter_samples);
-                       }
+               if (sctx->ps_iter_samples > 1 &&
+                   sel->info.reads_samplemask) {
+                       key->part.ps.prolog.samplemask_log_ps_iter =
+                               util_logbase2(sctx->ps_iter_samples);
+               }
 
-                       if (rs->force_persample_interp &&
-                           rs->multisample_enable &&
-                           sctx->framebuffer.nr_samples > 1 &&
-                           sctx->ps_iter_samples > 1) {
-                               key->part.ps.prolog.force_persp_sample_interp =
-                                       sel->info.uses_persp_center ||
-                                       sel->info.uses_persp_centroid;
-
-                               key->part.ps.prolog.force_linear_sample_interp =
-                                       sel->info.uses_linear_center ||
-                                       sel->info.uses_linear_centroid;
-                       } else if (rs->multisample_enable &&
-                                  sctx->framebuffer.nr_samples > 1) {
-                               key->part.ps.prolog.bc_optimize_for_persp =
-                                       sel->info.uses_persp_center &&
-                                       sel->info.uses_persp_centroid;
-                               key->part.ps.prolog.bc_optimize_for_linear =
-                                       sel->info.uses_linear_center &&
-                                       sel->info.uses_linear_centroid;
-                       } else {
-                               /* Make sure SPI doesn't compute more than 1 pair
-                                * of (i,j), which is the optimization here. */
-                               key->part.ps.prolog.force_persp_center_interp =
-                                       sel->info.uses_persp_center +
-                                       sel->info.uses_persp_centroid +
-                                       sel->info.uses_persp_sample > 1;
-
-                               key->part.ps.prolog.force_linear_center_interp =
-                                       sel->info.uses_linear_center +
-                                       sel->info.uses_linear_centroid +
-                                       sel->info.uses_linear_sample > 1;
-
-                               if (sel->info.opcode_count[TGSI_OPCODE_INTERP_SAMPLE])
-                                       key->mono.u.ps.interpolate_at_sample_force_center = 1;
-                       }
+               if (rs->force_persample_interp &&
+                   rs->multisample_enable &&
+                   sctx->framebuffer.nr_samples > 1 &&
+                   sctx->ps_iter_samples > 1) {
+                       key->part.ps.prolog.force_persp_sample_interp =
+                               sel->info.uses_persp_center ||
+                               sel->info.uses_persp_centroid;
+
+                       key->part.ps.prolog.force_linear_sample_interp =
+                               sel->info.uses_linear_center ||
+                               sel->info.uses_linear_centroid;
+               } else if (rs->multisample_enable &&
+                          sctx->framebuffer.nr_samples > 1) {
+                       key->part.ps.prolog.bc_optimize_for_persp =
+                               sel->info.uses_persp_center &&
+                               sel->info.uses_persp_centroid;
+                       key->part.ps.prolog.bc_optimize_for_linear =
+                               sel->info.uses_linear_center &&
+                               sel->info.uses_linear_centroid;
+               } else {
+                       /* Make sure SPI doesn't compute more than 1 pair
+                        * of (i,j), which is the optimization here. */
+                       key->part.ps.prolog.force_persp_center_interp =
+                               sel->info.uses_persp_center +
+                               sel->info.uses_persp_centroid +
+                               sel->info.uses_persp_sample > 1;
+
+                       key->part.ps.prolog.force_linear_center_interp =
+                               sel->info.uses_linear_center +
+                               sel->info.uses_linear_centroid +
+                               sel->info.uses_linear_sample > 1;
+
+                       if (sel->info.opcode_count[TGSI_OPCODE_INTERP_SAMPLE])
+                               key->mono.u.ps.interpolate_at_sample_force_center = 1;
                }
 
                key->part.ps.epilog.alpha_func = si_get_alpha_test_func(sctx);
index d16c3e7e41bb87ed30f69693f505f2aa01e6782e..d0287d5ad754e86d5052964c782f8b2f2993f426 100644 (file)
@@ -193,8 +193,7 @@ static void si_emit_guardband(struct si_context *ctx)
        discard_x = 1.0;
        discard_y = 1.0;
 
-       if (unlikely(util_prim_is_points_or_lines(ctx->current_rast_prim)) &&
-           ctx->queued.named.rasterizer) {
+       if (unlikely(util_prim_is_points_or_lines(ctx->current_rast_prim))) {
                /* When rendering wide points or lines, we need to be more
                 * conservative about when to discard them entirely. */
                const struct si_state_rasterizer *rs = ctx->queued.named.rasterizer;
@@ -229,10 +228,7 @@ static void si_emit_scissors(struct si_context *ctx)
        struct radeon_winsys_cs *cs = ctx->gfx_cs;
        struct pipe_scissor_state *states = ctx->scissors.states;
        unsigned mask = ctx->scissors.dirty_mask;
-       bool scissor_enabled = false;
-
-       if (ctx->queued.named.rasterizer)
-               scissor_enabled = ctx->queued.named.rasterizer->scissor_enable;
+       bool scissor_enabled = ctx->queued.named.rasterizer->scissor_enable;
 
        /* The simple case: Only 1 viewport is active. */
        if (!ctx->vs_writes_viewport_index) {
@@ -348,13 +344,10 @@ static void si_emit_depth_ranges(struct si_context *ctx)
        struct radeon_winsys_cs *cs = ctx->gfx_cs;
        struct pipe_viewport_state *states = ctx->viewports.states;
        unsigned mask = ctx->viewports.depth_range_dirty_mask;
-       bool clip_halfz = false;
+       bool clip_halfz = ctx->queued.named.rasterizer->clip_halfz;
        bool window_space = ctx->vs_disables_clipping_viewport;
        float zmin, zmax;
 
-       if (ctx->queued.named.rasterizer)
-               clip_halfz = ctx->queued.named.rasterizer->clip_halfz;
-
        /* The simple case: Only 1 viewport is active. */
        if (!ctx->vs_writes_viewport_index) {
                if (!(mask & 1))