amd,radeonsi: rename radeon_winsys_cs -> radeon_cmdbuf
[mesa.git] / src / gallium / drivers / radeonsi / si_state.c
index a41ace11623516fc57d8adaa5b572172aa5018d5..92a1d151262214e509d215590f1e459d10baf33b 100644 (file)
@@ -66,7 +66,7 @@ static unsigned si_pack_float_12p4(float x)
  */
 static void si_emit_cb_render_state(struct si_context *sctx)
 {
-       struct radeon_winsys_cs *cs = sctx->gfx_cs;
+       struct radeon_cmdbuf *cs = sctx->gfx_cs;
        struct si_state_blend *blend = sctx->queued.named.blend;
        /* CB_COLORn_INFO.FORMAT=INVALID should disable unbound colorbuffers,
         * but you never know. */
@@ -703,7 +703,7 @@ static void si_set_blend_color(struct pipe_context *ctx,
 
 static void si_emit_blend_color(struct si_context *sctx)
 {
-       struct radeon_winsys_cs *cs = sctx->gfx_cs;
+       struct radeon_cmdbuf *cs = sctx->gfx_cs;
 
        radeon_set_context_reg_seq(cs, R_028414_CB_BLEND_RED, 4);
        radeon_emit_array(cs, (uint32_t*)sctx->blend_color.state.color, 4);
@@ -737,7 +737,7 @@ static void si_set_clip_state(struct pipe_context *ctx,
 
 static void si_emit_clip_state(struct si_context *sctx)
 {
-       struct radeon_winsys_cs *cs = sctx->gfx_cs;
+       struct radeon_cmdbuf *cs = sctx->gfx_cs;
 
        radeon_set_context_reg_seq(cs, R_0285BC_PA_CL_UCP_0_X, 6*4);
        radeon_emit_array(cs, (uint32_t*)sctx->clip_state.state.ucp, 6*4);
@@ -745,7 +745,6 @@ static void si_emit_clip_state(struct si_context *sctx)
 
 static void si_emit_clip_regs(struct si_context *sctx)
 {
-       struct radeon_winsys_cs *cs = sctx->gfx_cs;
        struct si_shader *vs = si_get_vs_state(sctx);
        struct si_shader_selector *vs_sel = vs->selector;
        struct tgsi_shader_info *info = &vs_sel->info;
@@ -773,12 +772,14 @@ static void si_emit_clip_regs(struct si_context *sctx)
        clipdist_mask &= rs->clip_plane_enable;
        culldist_mask |= clipdist_mask;
 
-       radeon_set_context_reg(cs, R_02881C_PA_CL_VS_OUT_CNTL,
+       radeon_opt_set_context_reg(sctx, R_02881C_PA_CL_VS_OUT_CNTL,
+               SI_TRACKED_PA_CL_VS_OUT_CNTL,
                vs_sel->pa_cl_vs_out_cntl |
                S_02881C_VS_OUT_CCDIST0_VEC_ENA((total_mask & 0x0F) != 0) |
                S_02881C_VS_OUT_CCDIST1_VEC_ENA((total_mask & 0xF0) != 0) |
                clipdist_mask | (culldist_mask << 8));
-       radeon_set_context_reg(cs, R_028810_PA_CL_CLIP_CNTL,
+       radeon_opt_set_context_reg(sctx, R_028810_PA_CL_CLIP_CNTL,
+               SI_TRACKED_PA_CL_CLIP_CNTL,
                rs->pa_cl_clip_cntl |
                ucp_mask |
                S_028810_CLIP_DISABLE(window_space));
@@ -1006,13 +1007,16 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state)
        si_update_poly_offset_state(sctx);
 
        if (!old_rs ||
-           (old_rs->scissor_enable != rs->scissor_enable ||
-            old_rs->line_width != rs->line_width ||
-            old_rs->max_point_size != rs->max_point_size)) {
+           old_rs->scissor_enable != rs->scissor_enable) {
                sctx->scissors.dirty_mask = (1 << SI_MAX_VIEWPORTS) - 1;
                si_mark_atom_dirty(sctx, &sctx->atoms.s.scissors);
        }
 
+       if (!old_rs ||
+           old_rs->line_width != rs->line_width ||
+           old_rs->max_point_size != rs->max_point_size)
+               si_mark_atom_dirty(sctx, &sctx->atoms.s.guardband);
+
        if (!old_rs ||
            old_rs->clip_halfz != rs->clip_halfz) {
                sctx->viewports.depth_range_dirty_mask = (1 << SI_MAX_VIEWPORTS) - 1;
@@ -1059,7 +1063,7 @@ static void si_delete_rs_state(struct pipe_context *ctx, void *state)
  */
 static void si_emit_stencil_ref(struct si_context *sctx)
 {
-       struct radeon_winsys_cs *cs = sctx->gfx_cs;
+       struct radeon_cmdbuf *cs = sctx->gfx_cs;
        struct pipe_stencil_ref *ref = &sctx->stencil_ref.state;
        struct si_dsa_stencil_ref_part *dsa = &sctx->stencil_ref.dsa_part;
 
@@ -1414,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 &&
@@ -2956,7 +2960,7 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
 
 static void si_emit_framebuffer_state(struct si_context *sctx)
 {
-       struct radeon_winsys_cs *cs = sctx->gfx_cs;
+       struct radeon_cmdbuf *cs = sctx->gfx_cs;
        struct pipe_framebuffer_state *state = &sctx->framebuffer.state;
        unsigned i, nr_cbufs = state->nr_cbufs;
        struct r600_texture *tex = NULL;
@@ -3213,7 +3217,7 @@ static void si_emit_framebuffer_state(struct si_context *sctx)
 
 static void si_emit_msaa_sample_locs(struct si_context *sctx)
 {
-       struct radeon_winsys_cs *cs = sctx->gfx_cs;
+       struct radeon_cmdbuf *cs = sctx->gfx_cs;
        unsigned nr_samples = sctx->framebuffer.nr_samples;
        bool has_msaa_sample_loc_bug = sctx->screen->has_msaa_sample_loc_bug;
 
@@ -3247,11 +3251,13 @@ 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_set_context_reg(cs, R_028830_PA_SU_SMALL_PRIM_FILTER_CNTL,
-                                      small_prim_filter_cntl);
+               radeon_opt_set_context_reg(sctx,
+                                          R_028830_PA_SU_SMALL_PRIM_FILTER_CNTL,
+                                          SI_TRACKED_PA_SU_SMALL_PRIM_FILTER_CNTL,
+                                          small_prim_filter_cntl);
        }
 }
 
@@ -3324,7 +3330,7 @@ static bool si_out_of_order_rasterization(struct si_context *sctx)
 
 static void si_emit_msaa_config(struct si_context *sctx)
 {
-       struct radeon_winsys_cs *cs = sctx->gfx_cs;
+       struct radeon_cmdbuf *cs = sctx->gfx_cs;
        unsigned num_tile_pipes = sctx->screen->info.num_tile_pipes;
        /* 33% faster rendering to linear color buffers */
        bool dst_is_linear = sctx->framebuffer.any_dst_linear;
@@ -3413,6 +3419,7 @@ static void si_emit_msaa_config(struct si_context *sctx)
         *       endcaps.
         */
        unsigned sc_line_cntl = S_028BDC_DX10_DIAMOND_TEST_ENA(1);
+       unsigned sc_aa_config = 0;
 
        if (coverage_samples > 1) {
                /* distance from the pixel center, indexed by log2(nr_samples) */
@@ -3428,40 +3435,33 @@ static void si_emit_msaa_config(struct si_context *sctx)
                unsigned ps_iter_samples = si_get_ps_iter_samples(sctx);
                unsigned log_ps_iter_samples = util_logbase2(ps_iter_samples);
 
-               radeon_set_context_reg_seq(cs, R_028BDC_PA_SC_LINE_CNTL, 2);
-               radeon_emit(cs, sc_line_cntl |
-                           S_028BDC_EXPAND_LINE_WIDTH(1)); /* R_028BDC_PA_SC_LINE_CNTL */
-               radeon_emit(cs, S_028BE0_MSAA_NUM_SAMPLES(log_samples) |
-                           S_028BE0_MAX_SAMPLE_DIST(max_dist[log_samples]) |
-                           S_028BE0_MSAA_EXPOSED_SAMPLES(log_samples)); /* R_028BE0_PA_SC_AA_CONFIG */
+               sc_line_cntl |= S_028BDC_EXPAND_LINE_WIDTH(1);
+               sc_aa_config = S_028BE0_MSAA_NUM_SAMPLES(log_samples) |
+                              S_028BE0_MAX_SAMPLE_DIST(max_dist[log_samples]) |
+                              S_028BE0_MSAA_EXPOSED_SAMPLES(log_samples);
 
                if (sctx->framebuffer.nr_samples > 1) {
-                       radeon_set_context_reg(cs, R_028804_DB_EQAA,
-                                              db_eqaa |
-                                              S_028804_MAX_ANCHOR_SAMPLES(log_z_samples) |
-                                              S_028804_PS_ITER_SAMPLES(log_ps_iter_samples) |
-                                              S_028804_MASK_EXPORT_NUM_SAMPLES(log_samples) |
-                                              S_028804_ALPHA_TO_MASK_NUM_SAMPLES(log_samples));
-                       radeon_set_context_reg(cs, R_028A4C_PA_SC_MODE_CNTL_1,
-                                              S_028A4C_PS_ITER_SAMPLE(ps_iter_samples > 1) |
-                                              sc_mode_cntl_1);
+                       db_eqaa |= S_028804_MAX_ANCHOR_SAMPLES(log_z_samples) |
+                                  S_028804_PS_ITER_SAMPLES(log_ps_iter_samples) |
+                                  S_028804_MASK_EXPORT_NUM_SAMPLES(log_samples) |
+                                  S_028804_ALPHA_TO_MASK_NUM_SAMPLES(log_samples);
+                       sc_mode_cntl_1 |= S_028A4C_PS_ITER_SAMPLE(ps_iter_samples > 1);
                } else if (sctx->smoothing_enabled) {
-                       radeon_set_context_reg(cs, R_028804_DB_EQAA,
-                                              db_eqaa |
-                                              S_028804_OVERRASTERIZATION_AMOUNT(log_samples));
-                       radeon_set_context_reg(cs, R_028A4C_PA_SC_MODE_CNTL_1,
-                                              sc_mode_cntl_1);
+                       db_eqaa |= S_028804_OVERRASTERIZATION_AMOUNT(log_samples);
                }
-       } else {
-               radeon_set_context_reg_seq(cs, R_028BDC_PA_SC_LINE_CNTL, 2);
-               radeon_emit(cs, sc_line_cntl); /* R_028BDC_PA_SC_LINE_CNTL */
-               radeon_emit(cs, 0); /* R_028BE0_PA_SC_AA_CONFIG */
-
-               radeon_set_context_reg(cs, R_028804_DB_EQAA, db_eqaa);
-               radeon_set_context_reg(cs, R_028A4C_PA_SC_MODE_CNTL_1,
-                                      sc_mode_cntl_1);
        }
 
+       /* R_028BDC_PA_SC_LINE_CNTL, R_028BE0_PA_SC_AA_CONFIG */
+       radeon_opt_set_context_reg2(sctx, R_028BDC_PA_SC_LINE_CNTL,
+                                   SI_TRACKED_PA_SC_LINE_CNTL, sc_line_cntl,
+                                   sc_aa_config);
+       /* R_028804_DB_EQAA */
+       radeon_opt_set_context_reg(sctx, R_028804_DB_EQAA, SI_TRACKED_DB_EQAA,
+                                  db_eqaa);
+       /* R_028A4C_PA_SC_MODE_CNTL_1 */
+       radeon_opt_set_context_reg(sctx, R_028A4C_PA_SC_MODE_CNTL_1,
+                                  SI_TRACKED_PA_SC_MODE_CNTL_1, sc_mode_cntl_1);
+
        /* GFX9: Flush DFSM when the AA mode changes. */
        if (sctx->screen->dfsm_allowed) {
                radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0));
@@ -4302,7 +4302,7 @@ static void si_set_sample_mask(struct pipe_context *ctx, unsigned sample_mask)
 
 static void si_emit_sample_mask(struct si_context *sctx)
 {
-       struct radeon_winsys_cs *cs = sctx->gfx_cs;
+       struct radeon_cmdbuf *cs = sctx->gfx_cs;
        unsigned mask = sctx->sample_mask;
 
        /* Needed for line and polygon smoothing as well as for the Polaris