From: Chia-I Wu Date: Tue, 11 Nov 2014 02:25:20 +0000 (+0800) Subject: ilo: add variants of 3DSTATE_WM X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8ebb86325b567ae6dacdefdcc79d30bf93927c79;p=mesa.git ilo: add variants of 3DSTATE_WM Add gen6_hiz_3DSTATE_WM() and gen7_hiz_3DSTATE_WM() for HiZ ops without dispatching. Signed-off-by: Chia-I Wu --- diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h index 3207843cbcd..15921855b0f 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h @@ -282,41 +282,20 @@ static inline void gen6_3DSTATE_WM(struct ilo_builder *builder, const struct ilo_shader_state *fs, const struct ilo_rasterizer_state *rasterizer, - bool dual_blend, bool cc_may_kill, - uint32_t hiz_op) + bool dual_blend, bool cc_may_kill) { const uint8_t cmd_len = 9; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2); const int num_samples = 1; - const struct ilo_shader_cso *fs_cso; + const struct ilo_shader_cso *cso; uint32_t dw2, dw4, dw5, dw6, *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); - if (!fs) { - /* see brwCreateContext() */ - const int max_threads = (builder->dev->gt == 2) ? 80 : 40; - - ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; - dw[1] = 0; - dw[2] = 0; - dw[3] = 0; - dw[4] = hiz_op; - /* honor the valid range even if dispatching is disabled */ - dw[5] = (max_threads - 1) << GEN6_WM_DW5_MAX_THREADS__SHIFT; - dw[6] = 0; - dw[7] = 0; - dw[8] = 0; - - return; - } - - fs_cso = ilo_shader_get_kernel_cso(fs); - dw2 = fs_cso->payload[0]; - dw4 = fs_cso->payload[1]; - dw5 = fs_cso->payload[2]; - dw6 = fs_cso->payload[3]; + cso = ilo_shader_get_kernel_cso(fs); + dw2 = cso->payload[0]; + dw4 = cso->payload[1]; + dw5 = cso->payload[2]; + dw6 = cso->payload[3]; /* * From the Sandy Bridge PRM, volume 2 part 1, page 248: @@ -325,7 +304,6 @@ gen6_3DSTATE_WM(struct ilo_builder *builder, * bits is set: Depth Buffer Clear , Hierarchical Depth Buffer Resolve * Enable or Depth Buffer Resolve Enable." */ - assert(!hiz_op); dw4 |= GEN6_WM_DW4_STATISTICS; if (cc_may_kill) @@ -344,7 +322,8 @@ gen6_3DSTATE_WM(struct ilo_builder *builder, } ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2); dw[1] = ilo_shader_get_kernel_offset(fs); dw[2] = dw2; dw[3] = 0; /* scratch */ @@ -355,37 +334,51 @@ gen6_3DSTATE_WM(struct ilo_builder *builder, dw[8] = 0; /* kernel 2 */ } +static inline void +gen6_hiz_3DSTATE_WM(struct ilo_builder *builder, uint32_t hiz_op) +{ + const uint8_t cmd_len = 9; + const int max_threads = (builder->dev->gt == 2) ? 80 : 40; + uint32_t *dw; + + ILO_DEV_ASSERT(builder->dev, 6, 6); + + ilo_builder_batch_pointer(builder, cmd_len, &dw); + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2); + dw[1] = 0; + dw[2] = 0; + dw[3] = 0; + dw[4] = hiz_op; + /* honor the valid range even if dispatching is disabled */ + dw[5] = (max_threads - 1) << GEN6_WM_DW5_MAX_THREADS__SHIFT; + dw[6] = 0; + dw[7] = 0; + dw[8] = 0; +} + static inline void gen7_3DSTATE_WM(struct ilo_builder *builder, const struct ilo_shader_state *fs, const struct ilo_rasterizer_state *rasterizer, - bool cc_may_kill, uint32_t hiz_op) + bool cc_may_kill) { const uint8_t cmd_len = 3; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2); const int num_samples = 1; + const struct ilo_shader_cso *cso; uint32_t dw1, dw2, *dw; ILO_DEV_ASSERT(builder->dev, 7, 7.5); - /* see ilo_gpe_init_rasterizer_wm() */ - if (rasterizer) { - dw1 = rasterizer->wm.payload[0]; - dw2 = rasterizer->wm.payload[1]; + /* see rasterizer_init_wm_gen7() */ + dw1 = rasterizer->wm.payload[0]; + dw2 = rasterizer->wm.payload[1]; - assert(!hiz_op); - dw1 |= GEN7_WM_DW1_STATISTICS; - } - else { - dw1 = hiz_op; - dw2 = 0; - } - - if (fs) { - const struct ilo_shader_cso *fs_cso = ilo_shader_get_kernel_cso(fs); + /* see fs_init_cso_gen7() */ + cso = ilo_shader_get_kernel_cso(fs); + dw1 |= cso->payload[3]; - dw1 |= fs_cso->payload[3]; - } + dw1 |= GEN7_WM_DW1_STATISTICS; if (cc_may_kill) dw1 |= GEN7_WM_DW1_PS_ENABLE | GEN7_WM_DW1_PS_KILL; @@ -396,11 +389,26 @@ gen7_3DSTATE_WM(struct ilo_builder *builder, } ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2); dw[1] = dw1; dw[2] = dw2; } +static inline void +gen7_hiz_3DSTATE_WM(struct ilo_builder *builder, uint32_t hiz_op) +{ + const uint8_t cmd_len = 3; + uint32_t *dw; + + ILO_DEV_ASSERT(builder->dev, 7, 7.5); + + ilo_builder_batch_pointer(builder, cmd_len, &dw); + dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2); + dw[1] = hiz_op; + dw[2] = 0; +} + static inline void gen7_3DSTATE_PS(struct ilo_builder *builder, const struct ilo_shader_state *fs, diff --git a/src/gallium/drivers/ilo/ilo_render_gen6.c b/src/gallium/drivers/ilo/ilo_render_gen6.c index 70a7400d5dd..4e3bd18b309 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen6.c +++ b/src/gallium/drivers/ilo/ilo_render_gen6.c @@ -698,7 +698,7 @@ gen6_draw_wm(struct ilo_render *r, gen6_wa_pre_3dstate_wm_max_threads(r); gen6_3DSTATE_WM(r->builder, vec->fs, - vec->rasterizer, dual_blend, cc_may_kill, 0); + vec->rasterizer, dual_blend, cc_may_kill); } } @@ -879,7 +879,7 @@ gen6_rectlist_wm(struct ilo_render *r, gen6_3DSTATE_CONSTANT_PS(r->builder, NULL, NULL, 0); gen6_wa_pre_3dstate_wm_max_threads(r); - gen6_3DSTATE_WM(r->builder, NULL, NULL, false, false, hiz_op); + gen6_hiz_3DSTATE_WM(r->builder, hiz_op); } static void diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c index 79d147a7a25..ab27a3d0b62 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen7.c +++ b/src/gallium/drivers/ilo/ilo_render_gen7.c @@ -512,8 +512,7 @@ gen7_draw_wm(struct ilo_render *r, const bool cc_may_kill = (vec->dsa->dw_alpha || vec->blend->alpha_to_coverage); - gen7_3DSTATE_WM(r->builder, vec->fs, - vec->rasterizer, cc_may_kill, 0); + gen7_3DSTATE_WM(r->builder, vec->fs, vec->rasterizer, cc_may_kill); } /* 3DSTATE_BINDING_TABLE_POINTERS_PS */ @@ -766,7 +765,7 @@ gen7_rectlist_wm(struct ilo_render *r, break; } - gen7_3DSTATE_WM(r->builder, NULL, NULL, false, hiz_op); + gen7_hiz_3DSTATE_WM(r->builder, hiz_op); gen7_3DSTATE_CONSTANT_PS(r->builder, NULL, NULL, 0);