radeonsi: Rename r600->si for structs in si_resource.h.
[mesa.git] / src / gallium / drivers / radeonsi / si_state.c
index ede8827fe4753184f2e017d82448ad084771d2cf..46fc36ee14efb214343274193c31414b3699d9fd 100644 (file)
 #include "util/u_format_s3tc.h"
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_scan.h"
-#include "radeonsi_pipe.h"
-#include "radeonsi_shader.h"
+#include "si_pipe.h"
+#include "si_shader.h"
 #include "si_state.h"
 #include "../radeon/r600_cs.h"
 #include "sid.h"
 
-static uint32_t cik_num_banks(uint32_t nbanks)
+static uint32_t cik_num_banks(struct si_screen *rscreen, unsigned bpe, unsigned tile_split)
 {
-       switch (nbanks) {
+       if (rscreen->b.info.cik_macrotile_mode_array_valid) {
+               unsigned index, tileb;
+
+               tileb = 8 * 8 * bpe;
+               tileb = MIN2(tile_split, tileb);
+
+               for (index = 0; tileb > 64; index++) {
+                       tileb >>= 1;
+               }
+
+               assert(index < 16);
+
+               return (rscreen->b.info.cik_macrotile_mode_array[index] >> 6) & 0x3;
+       }
+
+       /* The old way. */
+       switch (rscreen->b.tiling_info.num_banks) {
        case 2:
                return V_02803C_ADDR_SURF_2_BANK;
        case 4:
@@ -55,7 +71,6 @@ static uint32_t cik_num_banks(uint32_t nbanks)
        }
 }
 
-
 static unsigned cik_tile_split(unsigned tile_split)
 {
        switch (tile_split) {
@@ -125,33 +140,36 @@ static unsigned cik_bank_wh(unsigned bankwh)
        return bankwh;
 }
 
-static unsigned cik_db_pipe_config(unsigned tile_pipes,
-                                  unsigned num_rbs)
+static unsigned cik_db_pipe_config(struct si_screen *rscreen, unsigned tile_mode)
 {
-       unsigned pipe_config;
+       if (rscreen->b.info.si_tile_mode_array_valid) {
+               uint32_t gb_tile_mode = rscreen->b.info.si_tile_mode_array[tile_mode];
+
+               return G_009910_PIPE_CONFIG(gb_tile_mode);
+       }
 
-       switch (tile_pipes) {
+       /* This is probably broken for a lot of chips, but it's only used
+        * if the kernel cannot return the tile mode array for CIK. */
+       switch (rscreen->b.info.r600_num_tile_pipes) {
+       case 16:
+               return V_02803C_X_ADDR_SURF_P16_32X32_16X16;
        case 8:
-               pipe_config = V_02803C_X_ADDR_SURF_P8_32X32_16X16;
-               break;
+               return V_02803C_X_ADDR_SURF_P8_32X32_16X16;
        case 4:
        default:
-               if (num_rbs == 4)
-                       pipe_config = V_02803C_X_ADDR_SURF_P4_16X16;
+               if (rscreen->b.info.r600_num_backends == 4)
+                       return V_02803C_X_ADDR_SURF_P4_16X16;
                else
-                       pipe_config = V_02803C_X_ADDR_SURF_P4_8X16;
-               break;
+                       return V_02803C_X_ADDR_SURF_P4_8X16;
        case 2:
-                       pipe_config = V_02803C_ADDR_SURF_P2;
-               break;
+               return V_02803C_ADDR_SURF_P2;
        }
-       return pipe_config;
 }
 
 /*
  * inferred framebuffer and blender state
  */
-static void si_update_fb_blend_state(struct r600_context *rctx)
+static void si_update_fb_blend_state(struct si_context *rctx)
 {
        struct si_pm4_state *pm4;
        struct si_state_blend *blend = rctx->queued.named.blend;
@@ -252,20 +270,18 @@ static void *si_create_blend_state_mode(struct pipe_context *ctx,
        struct si_state_blend *blend = CALLOC_STRUCT(si_state_blend);
        struct si_pm4_state *pm4 = &blend->pm4;
 
-       uint32_t color_control;
+       uint32_t color_control = 0;
 
        if (blend == NULL)
                return NULL;
 
        blend->alpha_to_one = state->alpha_to_one;
 
-       color_control = S_028808_MODE(mode);
        if (state->logicop_enable) {
                color_control |= S_028808_ROP3(state->logicop_func | (state->logicop_func << 4));
        } else {
                color_control |= S_028808_ROP3(0xcc);
        }
-       si_pm4_set_reg(pm4, R_028808_CB_COLOR_CONTROL, color_control);
 
        si_pm4_set_reg(pm4, R_028B70_DB_ALPHA_TO_MASK,
                       S_028B70_ALPHA_TO_MASK_ENABLE(state->alpha_to_coverage) |
@@ -310,6 +326,13 @@ static void *si_create_blend_state_mode(struct pipe_context *ctx,
                si_pm4_set_reg(pm4, R_028780_CB_BLEND0_CONTROL + i * 4, blend_cntl);
        }
 
+       if (blend->cb_target_mask) {
+               color_control |= S_028808_MODE(mode);
+       } else {
+               color_control |= S_028808_MODE(V_028808_CB_DISABLE);
+       }
+       si_pm4_set_reg(pm4, R_028808_CB_COLOR_CONTROL, color_control);
+
        return blend;
 }
 
@@ -321,21 +344,21 @@ static void *si_create_blend_state(struct pipe_context *ctx,
 
 static void si_bind_blend_state(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        si_pm4_bind_state(rctx, blend, (struct si_state_blend *)state);
        si_update_fb_blend_state(rctx);
 }
 
 static void si_delete_blend_state(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        si_pm4_delete_state(rctx, blend, (struct si_state_blend *)state);
 }
 
 static void si_set_blend_color(struct pipe_context *ctx,
                               const struct pipe_blend_color *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pm4_state *pm4 = si_pm4_alloc_state(rctx);
 
         if (pm4 == NULL)
@@ -356,7 +379,7 @@ static void si_set_blend_color(struct pipe_context *ctx,
 static void si_set_clip_state(struct pipe_context *ctx,
                              const struct pipe_clip_state *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pm4_state *pm4 = si_pm4_alloc_state(rctx);
        struct pipe_constant_buffer cb;
 
@@ -389,7 +412,7 @@ static void si_set_scissor_states(struct pipe_context *ctx,
                                   unsigned num_scissors,
                                   const struct pipe_scissor_state *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pm4_state *pm4 = si_pm4_alloc_state(rctx);
        uint32_t tl, br;
 
@@ -415,7 +438,7 @@ static void si_set_viewport_states(struct pipe_context *ctx,
                                    unsigned num_viewports,
                                    const struct pipe_viewport_state *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_state_viewport *viewport = CALLOC_STRUCT(si_state_viewport);
        struct si_pm4_state *pm4 = &viewport->pm4;
 
@@ -436,7 +459,7 @@ static void si_set_viewport_states(struct pipe_context *ctx,
 /*
  * inferred state between framebuffer and rasterizer
  */
-static void si_update_fb_rs_state(struct r600_context *rctx)
+static void si_update_fb_rs_state(struct si_context *rctx)
 {
        struct si_state_rasterizer *rs = rctx->queued.named.rasterizer;
        struct si_pm4_state *pm4;
@@ -608,7 +631,7 @@ static void *si_create_rs_state(struct pipe_context *ctx,
 
 static void si_bind_rs_state(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_state_rasterizer *rs = (struct si_state_rasterizer *)state;
 
        if (state == NULL)
@@ -625,14 +648,14 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state)
 
 static void si_delete_rs_state(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        si_pm4_delete_state(rctx, rasterizer, (struct si_state_rasterizer *)state);
 }
 
 /*
  * infeered state between dsa and stencil ref
  */
-static void si_update_dsa_stencil_ref(struct r600_context *rctx)
+static void si_update_dsa_stencil_ref(struct si_context *rctx)
 {
        struct si_pm4_state *pm4 = si_pm4_alloc_state(rctx);
        struct pipe_stencil_ref *ref = &rctx->stencil_ref;
@@ -658,7 +681,7 @@ static void si_update_dsa_stencil_ref(struct r600_context *rctx)
 static void si_set_pipe_stencil_ref(struct pipe_context *ctx,
                                    const struct pipe_stencil_ref *state)
 {
-        struct r600_context *rctx = (struct r600_context *)ctx;
+        struct si_context *rctx = (struct si_context *)ctx;
         rctx->stencil_ref = *state;
        si_update_dsa_stencil_ref(rctx);
 }
@@ -756,7 +779,7 @@ static void *si_create_dsa_state(struct pipe_context *ctx,
 
 static void si_bind_dsa_state(struct pipe_context *ctx, void *state)
 {
-        struct r600_context *rctx = (struct r600_context *)ctx;
+        struct si_context *rctx = (struct si_context *)ctx;
         struct si_state_dsa *dsa = state;
 
         if (state == NULL)
@@ -768,11 +791,11 @@ static void si_bind_dsa_state(struct pipe_context *ctx, void *state)
 
 static void si_delete_dsa_state(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        si_pm4_delete_state(rctx, dsa, (struct si_state_dsa *)state);
 }
 
-static void *si_create_db_flush_dsa(struct r600_context *rctx, bool copy_depth,
+static void *si_create_db_flush_dsa(struct si_context *rctx, bool copy_depth,
                                    bool copy_stencil, int sample)
 {
        struct pipe_depth_stencil_alpha_state dsa;
@@ -791,11 +814,6 @@ static void *si_create_db_flush_dsa(struct r600_context *rctx, bool copy_depth,
                si_pm4_set_reg(&state->pm4, R_028000_DB_RENDER_CONTROL,
                               S_028000_DEPTH_COMPRESS_DISABLE(1) |
                               S_028000_STENCIL_COMPRESS_DISABLE(1));
-               si_pm4_set_reg(&state->pm4, R_02800C_DB_RENDER_OVERRIDE,
-                              S_02800C_FORCE_HIZ_ENABLE(V_02800C_FORCE_DISABLE) |
-                              S_02800C_FORCE_HIS_ENABLE0(V_02800C_FORCE_DISABLE) |
-                              S_02800C_FORCE_HIS_ENABLE1(V_02800C_FORCE_DISABLE) |
-                              S_02800C_DISABLE_TILE_RATE_TILES(1));
        }
 
         return state;
@@ -1044,7 +1062,7 @@ static uint32_t si_translate_texformat(struct pipe_screen *screen,
                                       const struct util_format_description *desc,
                                       int first_non_void)
 {
-       struct r600_screen *rscreen = (struct r600_screen*)screen;
+       struct si_screen *rscreen = (struct si_screen*)screen;
        bool enable_s3tc = rscreen->b.info.drm_minor >= 31;
        boolean uniform = TRUE;
        int i;
@@ -1458,7 +1476,7 @@ boolean si_is_format_supported(struct pipe_screen *screen,
                                unsigned sample_count,
                                unsigned usage)
 {
-       struct r600_screen *rscreen = (struct r600_screen *)screen;
+       struct si_screen *rscreen = (struct si_screen *)screen;
        unsigned retval = 0;
 
        if (target >= PIPE_MAX_TEXTURE_TYPES) {
@@ -1543,11 +1561,11 @@ static unsigned si_tile_mode_index(struct r600_texture *rtex, unsigned level, bo
  * framebuffer handling
  */
 
-static void si_cb(struct r600_context *rctx, struct si_pm4_state *pm4,
+static void si_cb(struct si_context *rctx, struct si_pm4_state *pm4,
                  const struct pipe_framebuffer_state *state, int cb)
 {
        struct r600_texture *rtex;
-       struct r600_surface *surf;
+       struct si_surface *surf;
        unsigned level = state->cbufs[cb]->u.tex.level;
        unsigned pitch, slice;
        unsigned color_info, color_attrib, color_pitch, color_view;
@@ -1559,7 +1577,7 @@ static void si_cb(struct r600_context *rctx, struct si_pm4_state *pm4,
        unsigned blend_clamp = 0, blend_bypass = 0;
        unsigned max_comp_size;
 
-       surf = (struct r600_surface *)state->cbufs[cb];
+       surf = (struct si_surface *)state->cbufs[cb];
        rtex = (struct r600_texture*)state->cbufs[cb]->texture;
 
        offset = rtex->surface.level[level].offset;
@@ -1721,53 +1739,12 @@ static void si_cb(struct r600_context *rctx, struct si_pm4_state *pm4,
        }
 }
 
-/* Update register(s) containing depth buffer and draw state. */
-void si_update_db_draw_state(struct r600_context *rctx, struct r600_surface *zsbuf)
-{
-       struct si_pm4_state *pm4;
-       uint32_t db_render_override;
-       boolean hiz_enable = false;
-
-       pm4 = si_pm4_alloc_state(rctx);
-       if (pm4 == NULL) {
-               return;
-       }
-
-       /* db */
-
-       /* TODO HiS aka stencil buffer htile goes here */
-       db_render_override = S_02800C_FORCE_HIS_ENABLE0(V_02800C_FORCE_DISABLE) |
-                            S_02800C_FORCE_HIS_ENABLE1(V_02800C_FORCE_DISABLE);
-
-       /* HiZ aka depth buffer htile */
-       if (zsbuf && zsbuf->base.texture) {
-               struct r600_texture *rtex = (struct r600_texture*)zsbuf->base.texture;
-               uint level = zsbuf->base.u.tex.level;
-               /* use htile only for first level */
-               hiz_enable = rtex->htile_buffer && !level;
-       }
-       if (hiz_enable) {
-               db_render_override |= S_02800C_FORCE_HIZ_ENABLE(V_02800C_FORCE_OFF);
-       } else {
-               db_render_override |= S_02800C_FORCE_HIZ_ENABLE(V_02800C_FORCE_DISABLE);
-       }
-
-       /* draw */
-
-       if (rctx->num_cs_dw_nontimer_queries_suspend) {
-               db_render_override |= S_02800C_NOOP_CULL_DISABLE(1);
-       }
-
-       si_pm4_set_reg(pm4, R_02800C_DB_RENDER_OVERRIDE, db_render_override);
-       si_pm4_set_state(rctx, db_draw, pm4);
-}
-
-static void si_db(struct r600_context *rctx, struct si_pm4_state *pm4,
+static void si_db(struct si_context *rctx, struct si_pm4_state *pm4,
                  const struct pipe_framebuffer_state *state)
 {
-       struct r600_screen *rscreen = rctx->screen;
+       struct si_screen *rscreen = rctx->screen;
        struct r600_texture *rtex;
-       struct r600_surface *surf;
+       struct si_surface *surf;
        unsigned level, pitch, slice, format, tile_mode_index, array_mode;
        unsigned macro_aspect, tile_split, stile_split, bankh, bankw, nbanks, pipe_config;
        uint32_t z_info, s_info, db_depth_info;
@@ -1780,7 +1757,7 @@ static void si_db(struct r600_context *rctx, struct si_pm4_state *pm4,
                return;
        }
 
-       surf = (struct r600_surface *)state->zsbuf;
+       surf = (struct si_surface *)state->zsbuf;
        level = surf->base.u.tex.level;
        rtex = (struct r600_texture*)surf->base.texture;
 
@@ -1838,9 +1815,9 @@ static void si_db(struct r600_context *rctx, struct si_pm4_state *pm4,
                macro_aspect = cik_macro_tile_aspect(macro_aspect);
                bankw = cik_bank_wh(bankw);
                bankh = cik_bank_wh(bankh);
-               nbanks = cik_num_banks(rscreen->b.tiling_info.num_banks);
-               pipe_config = cik_db_pipe_config(rscreen->b.info.r600_num_tile_pipes,
-                                                rscreen->b.info.r600_num_backends);
+               nbanks = cik_num_banks(rscreen, rtex->surface.bpe, rtex->surface.tile_split);
+               tile_mode_index = si_tile_mode_index(rtex, level, false);
+               pipe_config = cik_db_pipe_config(rscreen, tile_mode_index);
 
                db_depth_info |= S_02803C_ARRAY_MODE(array_mode) |
                        S_02803C_PIPE_CONFIG(pipe_config) |
@@ -1860,11 +1837,27 @@ static void si_db(struct r600_context *rctx, struct si_pm4_state *pm4,
        /* HiZ aka depth buffer htile */
        /* use htile only for first level */
        if (rtex->htile_buffer && !level) {
+               const struct util_format_description *fmt_desc;
+
                z_info |= S_028040_TILE_SURFACE_ENABLE(1);
-               /* Force off means no force, DB_SHADER_CONTROL decides */
+
+               /* This is optimal for the clear value of 1.0 and using
+                * the LESS and LEQUAL test functions. Set this to 0
+                * for the opposite case. This can only be changed when
+                * clearing. */
+               z_info |= S_028040_ZRANGE_PRECISION(1);
+
+               fmt_desc = util_format_description(rtex->resource.b.b.format);
+               if (!util_format_has_stencil(fmt_desc)) {
+                       /* Use all of the htile_buffer for depth */
+                       s_info |= S_028044_TILE_STENCIL_DISABLE(1);
+               }
+
                uint64_t va = r600_resource_va(&rctx->screen->b.b, &rtex->htile_buffer->b.b);
                db_htile_data_base = va >> 8;
                db_htile_surface = S_028ABC_FULL_CACHE(1);
+
+               si_pm4_add_bo(pm4, rtex->htile_buffer, RADEON_USAGE_READWRITE);
        } else {
                db_htile_data_base = 0;
                db_htile_surface = 0;
@@ -1995,7 +1988,7 @@ static void si_get_sample_position(struct pipe_context *ctx,
        }
 }
 
-static void si_set_msaa_state(struct r600_context *rctx, struct si_pm4_state *pm4, int nr_samples)
+static void si_set_msaa_state(struct si_context *rctx, struct si_pm4_state *pm4, int nr_samples)
 {
        unsigned max_dist = 0;
 
@@ -2086,7 +2079,7 @@ static void si_set_msaa_state(struct r600_context *rctx, struct si_pm4_state *pm
 static void si_set_framebuffer_state(struct pipe_context *ctx,
                                     const struct pipe_framebuffer_state *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pm4_state *pm4 = si_pm4_alloc_state(rctx);
        uint32_t tl, br;
        int tl_x, tl_y, br_x, br_y, nr_samples, i;
@@ -2109,8 +2102,15 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
        rctx->export_16bpc = 0;
        rctx->fb_compressed_cb_mask = 0;
        for (i = 0; i < state->nr_cbufs; i++) {
-               struct r600_texture *rtex =
-                       (struct r600_texture*)state->cbufs[i]->texture;
+               struct r600_texture *rtex;
+
+               if (!state->cbufs[i]) {
+                       si_pm4_set_reg(pm4, R_028C70_CB_COLOR0_INFO + i * 0x3C,
+                                      S_028C70_FORMAT(V_028C70_COLOR_INVALID));
+                       continue;
+               }
+
+               rtex = (struct r600_texture*)state->cbufs[i]->texture;
 
                si_cb(rctx, pm4, state, i);
 
@@ -2143,22 +2143,16 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
        si_pm4_set_reg(pm4, R_028204_PA_SC_WINDOW_SCISSOR_TL, tl);
        si_pm4_set_reg(pm4, R_028208_PA_SC_WINDOW_SCISSOR_BR, br);
 
-       if (state->nr_cbufs)
-               nr_samples = state->cbufs[0]->texture->nr_samples;
-       else if (state->zsbuf)
-               nr_samples = state->zsbuf->texture->nr_samples;
-       else
-               nr_samples = 0;
+       nr_samples = util_framebuffer_get_num_samples(state);
 
        si_set_msaa_state(rctx, pm4, nr_samples);
        rctx->fb_log_samples = util_logbase2(nr_samples);
-       rctx->fb_cb0_is_integer = state->nr_cbufs &&
+       rctx->fb_cb0_is_integer = state->nr_cbufs && state->cbufs[0] &&
                                  util_format_is_pure_integer(state->cbufs[0]->format);
 
        si_pm4_set_state(rctx, framebuffer, pm4);
        si_update_fb_rs_state(rctx);
        si_update_fb_blend_state(rctx);
-       si_update_db_draw_state(rctx, (struct r600_surface *)state->zsbuf);
 }
 
 /*
@@ -2170,7 +2164,7 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx,
                                          struct si_pipe_shader_selector *sel,
                                          union si_shader_key *key)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        memset(key, 0, sizeof(*key));
 
        if (sel->type == PIPE_SHADER_VERTEX) {
@@ -2280,14 +2274,17 @@ static void *si_create_shader_state(struct pipe_context *ctx,
 {
        struct si_pipe_shader_selector *sel = CALLOC_STRUCT(si_pipe_shader_selector);
        int r;
-       struct tgsi_shader_info info;
-
-       tgsi_scan_shader(state->tokens, &info);
 
        sel->type = pipe_shader_type;
        sel->tokens = tgsi_dup_tokens(state->tokens);
        sel->so = state->stream_output;
-       sel->fs_write_all = info.color0_writes_all_cbufs;
+
+       if (pipe_shader_type == PIPE_SHADER_FRAGMENT) {
+               struct tgsi_shader_info info;
+
+               tgsi_scan_shader(state->tokens, &info);
+               sel->fs_write_all = info.color0_writes_all_cbufs;
+       }
 
        r = si_shader_select(ctx, sel, NULL);
        if (r) {
@@ -2312,7 +2309,7 @@ static void *si_create_vs_state(struct pipe_context *ctx,
 
 static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pipe_shader_selector *sel = state;
 
        if (rctx->vs_shader == sel)
@@ -2329,7 +2326,7 @@ static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
 
 static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pipe_shader_selector *sel = state;
 
        if (rctx->ps_shader == sel)
@@ -2346,7 +2343,7 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
 static void si_delete_shader_selector(struct pipe_context *ctx,
                                      struct si_pipe_shader_selector *sel)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pipe_shader *p = sel->current, *c;
 
        while (p) {
@@ -2363,7 +2360,7 @@ static void si_delete_shader_selector(struct pipe_context *ctx,
 
 static void si_delete_vs_shader(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pipe_shader_selector *sel = (struct si_pipe_shader_selector *)state;
 
        if (rctx->vs_shader == sel) {
@@ -2375,7 +2372,7 @@ static void si_delete_vs_shader(struct pipe_context *ctx, void *state)
 
 static void si_delete_ps_shader(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pipe_shader_selector *sel = (struct si_pipe_shader_selector *)state;
 
        if (rctx->ps_shader == sel) {
@@ -2712,8 +2709,8 @@ static void si_set_sampler_views(struct pipe_context *ctx,
                                  unsigned count,
                                 struct pipe_sampler_view **views)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
-       struct r600_textures_info *samplers = &rctx->samplers[shader];
+       struct si_context *rctx = (struct si_context *)ctx;
+       struct si_textures_info *samplers = &rctx->samplers[shader];
        struct si_pipe_sampler_view **rviews = (struct si_pipe_sampler_view **)views;
        int i;
 
@@ -2770,9 +2767,9 @@ static void si_set_sampler_views(struct pipe_context *ctx,
        rctx->b.flags |= R600_CONTEXT_INV_TEX_CACHE;
 }
 
-static struct si_pm4_state *si_set_sampler_states(struct r600_context *rctx, unsigned count,
+static struct si_pm4_state *si_set_sampler_states(struct si_context *rctx, unsigned count,
                                                   void **states,
-                                                  struct r600_textures_info *samplers,
+                                                  struct si_textures_info *samplers,
                                                   unsigned user_data_reg)
 {
        struct si_pipe_sampler_state **rstates = (struct si_pipe_sampler_state **)states;
@@ -2846,7 +2843,7 @@ out:
 
 static void si_bind_vs_sampler_states(struct pipe_context *ctx, unsigned count, void **states)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pm4_state *pm4;
 
        pm4 = si_set_sampler_states(rctx, count, states, &rctx->samplers[PIPE_SHADER_VERTEX],
@@ -2856,7 +2853,7 @@ static void si_bind_vs_sampler_states(struct pipe_context *ctx, unsigned count,
 
 static void si_bind_ps_sampler_states(struct pipe_context *ctx, unsigned count, void **states)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pm4_state *pm4;
 
        pm4 = si_set_sampler_states(rctx, count, states, &rctx->samplers[PIPE_SHADER_FRAGMENT],
@@ -2887,7 +2884,7 @@ static void si_bind_sampler_states(struct pipe_context *ctx, unsigned shader,
 
 static void si_set_sample_mask(struct pipe_context *ctx, unsigned sample_mask)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_pm4_state *pm4 = si_pm4_alloc_state(rctx);
        uint16_t mask = sample_mask;
 
@@ -2945,7 +2942,7 @@ static void *si_create_vertex_elements(struct pipe_context *ctx,
 
 static void si_bind_vertex_elements(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
        struct si_vertex_element *v = (struct si_vertex_element*)state;
 
        rctx->vertex_elements = v;
@@ -2953,7 +2950,7 @@ static void si_bind_vertex_elements(struct pipe_context *ctx, void *state)
 
 static void si_delete_vertex_element(struct pipe_context *ctx, void *state)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
 
        if (rctx->vertex_elements == state)
                rctx->vertex_elements = NULL;
@@ -2963,7 +2960,7 @@ static void si_delete_vertex_element(struct pipe_context *ctx, void *state)
 static void si_set_vertex_buffers(struct pipe_context *ctx, unsigned start_slot, unsigned count,
                                  const struct pipe_vertex_buffer *buffers)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
 
        util_set_vertex_buffers_count(rctx->vertex_buffer, &rctx->nr_vertex_buffers, buffers, start_slot, count);
 }
@@ -2971,7 +2968,7 @@ static void si_set_vertex_buffers(struct pipe_context *ctx, unsigned start_slot,
 static void si_set_index_buffer(struct pipe_context *ctx,
                                const struct pipe_index_buffer *ib)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
 
        if (ib) {
                pipe_resource_reference(&rctx->index_buffer.buffer, ib->buffer);
@@ -2991,13 +2988,13 @@ static void si_set_polygon_stipple(struct pipe_context *ctx,
 
 static void si_texture_barrier(struct pipe_context *ctx)
 {
-       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_context *rctx = (struct si_context *)ctx;
 
        rctx->b.flags |= R600_CONTEXT_INV_TEX_CACHE |
                         R600_CONTEXT_FLUSH_AND_INV_CB;
 }
 
-static void *si_create_blend_custom(struct r600_context *rctx, unsigned mode)
+static void *si_create_blend_custom(struct si_context *rctx, unsigned mode)
 {
        struct pipe_blend_state blend;
 
@@ -3012,7 +3009,7 @@ static struct pipe_surface *r600_create_surface(struct pipe_context *pipe,
                                                const struct pipe_surface *surf_tmpl)
 {
        struct r600_texture *rtex = (struct r600_texture*)texture;
-       struct r600_surface *surface = CALLOC_STRUCT(r600_surface);
+       struct si_surface *surface = CALLOC_STRUCT(si_surface);
        unsigned level = surf_tmpl->u.tex.level;
 
        if (surface == NULL)
@@ -3054,7 +3051,7 @@ static boolean si_dma_copy(struct pipe_context *ctx,
        return FALSE;
 }
 
-void si_init_state_functions(struct r600_context *rctx)
+void si_init_state_functions(struct si_context *rctx)
 {
        int i;
 
@@ -3120,7 +3117,7 @@ void si_init_state_functions(struct r600_context *rctx)
        rctx->b.b.draw_vbo = si_draw_vbo;
 }
 
-void si_init_config(struct r600_context *rctx)
+void si_init_config(struct si_context *rctx)
 {
        struct si_pm4_state *pm4 = si_pm4_alloc_state(rctx);
 
@@ -3224,6 +3221,9 @@ void si_init_config(struct r600_context *rctx)
        si_pm4_set_reg(pm4, R_028AC0_DB_SRESULTS_COMPARE_STATE0, 0x0);
        si_pm4_set_reg(pm4, R_028AC4_DB_SRESULTS_COMPARE_STATE1, 0x0);
        si_pm4_set_reg(pm4, R_028AC8_DB_PRELOAD_CONTROL, 0x0);
+       si_pm4_set_reg(pm4, R_02800C_DB_RENDER_OVERRIDE,
+                      S_02800C_FORCE_HIS_ENABLE0(V_02800C_FORCE_DISABLE) |
+                      S_02800C_FORCE_HIS_ENABLE1(V_02800C_FORCE_DISABLE));
        si_pm4_set_reg(pm4, R_028400_VGT_MAX_VTX_INDX, ~0);
        si_pm4_set_reg(pm4, R_028404_VGT_MIN_VTX_INDX, 0);