diff options
author | Chia-I Wu <[email protected]> | 2014-09-30 15:18:09 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-09-30 16:41:31 +0800 |
commit | 2b4c8ffc30c097cb89b2e76e64a764eb258d5491 (patch) | |
tree | 8d9c72417ab5482de53b6875f1aa16da23ff6317 /src/gallium/drivers/ilo | |
parent | 343b014b57ecc5431477e090100e6a26edbda540 (diff) |
ilo: precalculate aligned depth buffer size
To replace the hacky zs_align_surface().
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/gallium/drivers/ilo')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_blitter_rectlist.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_builder_3d_bottom.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render_gen6.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_render_gen7.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state_gen.h | 35 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state_gen6.c | 35 |
7 files changed, 43 insertions, 48 deletions
diff --git a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c index 699a7decbef..579c9c7eca3 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c +++ b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c @@ -31,7 +31,7 @@ #include "ilo_builder_3d_top.h" /* for ve_init_cso_with_components() */ #include "ilo_draw.h" #include "ilo_state.h" -#include "ilo_state_gen.h" /* for zs_align_surface() */ +#include "ilo_state_gen.h" #include "ilo_blit.h" #include "ilo_blitter.h" @@ -254,10 +254,6 @@ hiz_align_fb(struct ilo_blitter *blitter) if (blitter->fb.width % align_w || blitter->fb.height % align_h) { blitter->fb.width = align(blitter->fb.width, align_w); blitter->fb.height = align(blitter->fb.height, align_h); - - assert(!blitter->fb.dst.is_rt); - zs_align_surface(blitter->ilo->dev, align_w, align_h, - &blitter->fb.dst.u.zs); } } diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h index 83b266e0329..73b5fae47ae 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h @@ -747,7 +747,8 @@ gen6_3DSTATE_AA_LINE_PARAMETERS(struct ilo_builder *builder) static inline void gen6_3DSTATE_DEPTH_BUFFER(struct ilo_builder *builder, - const struct ilo_zs_surface *zs) + const struct ilo_zs_surface *zs, + bool aligned_8x4) { const uint32_t cmd = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? GEN7_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER) : @@ -762,7 +763,7 @@ gen6_3DSTATE_DEPTH_BUFFER(struct ilo_builder *builder, dw[0] = cmd | (cmd_len - 2); dw[1] = zs->payload[0]; - dw[3] = zs->payload[2]; + dw[3] = (aligned_8x4) ? zs->dw_aligned_8x4 : zs->payload[2]; dw[4] = zs->payload[3]; dw[5] = zs->payload[4]; dw[6] = zs->payload[5]; diff --git a/src/gallium/drivers/ilo/ilo_render_gen6.c b/src/gallium/drivers/ilo/ilo_render_gen6.c index 9369f6326d5..2c66b973baa 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen6.c +++ b/src/gallium/drivers/ilo/ilo_render_gen6.c @@ -788,7 +788,7 @@ gen6_draw_wm_depth(struct ilo_render *r, gen6_wa_pre_depth(r); } - gen6_3DSTATE_DEPTH_BUFFER(r->builder, zs); + gen6_3DSTATE_DEPTH_BUFFER(r->builder, zs, false); gen6_3DSTATE_HIER_DEPTH_BUFFER(r->builder, zs); gen6_3DSTATE_STENCIL_BUFFER(r->builder, zs); gen6_3DSTATE_CLEAR_PARAMS(r->builder, clear_params); @@ -919,7 +919,7 @@ gen6_rectlist_wm_depth(struct ilo_render *r, if (blitter->uses & (ILO_BLITTER_USE_FB_DEPTH | ILO_BLITTER_USE_FB_STENCIL)) { gen6_3DSTATE_DEPTH_BUFFER(r->builder, - &blitter->fb.dst.u.zs); + &blitter->fb.dst.u.zs, true); } if (blitter->uses & ILO_BLITTER_USE_FB_DEPTH) { diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c index a39944e67b2..373f800e071 100644 --- a/src/gallium/drivers/ilo/ilo_render_gen7.c +++ b/src/gallium/drivers/ilo/ilo_render_gen7.c @@ -602,7 +602,7 @@ gen7_draw_wm(struct ilo_render *r, clear_params = 0; } - gen6_3DSTATE_DEPTH_BUFFER(r->builder, zs); + gen6_3DSTATE_DEPTH_BUFFER(r->builder, zs, false); gen6_3DSTATE_HIER_DEPTH_BUFFER(r->builder, zs); gen6_3DSTATE_STENCIL_BUFFER(r->builder, zs); gen7_3DSTATE_CLEAR_PARAMS(r->builder, clear_params); @@ -789,7 +789,7 @@ gen7_rectlist_wm_depth(struct ilo_render *r, if (blitter->uses & (ILO_BLITTER_USE_FB_DEPTH | ILO_BLITTER_USE_FB_STENCIL)) { gen6_3DSTATE_DEPTH_BUFFER(r->builder, - &blitter->fb.dst.u.zs); + &blitter->fb.dst.u.zs, true); } if (blitter->uses & ILO_BLITTER_USE_FB_DEPTH) { diff --git a/src/gallium/drivers/ilo/ilo_state.h b/src/gallium/drivers/ilo/ilo_state.h index d62c00a2790..7f68118d4b6 100644 --- a/src/gallium/drivers/ilo/ilo_state.h +++ b/src/gallium/drivers/ilo/ilo_state.h @@ -335,6 +335,8 @@ struct ilo_surface_cso { struct ilo_view_surface rt; struct ilo_zs_surface { uint32_t payload[10]; + uint32_t dw_aligned_8x4; + struct intel_bo *bo; struct intel_bo *hiz_bo; struct intel_bo *separate_s8_bo; diff --git a/src/gallium/drivers/ilo/ilo_state_gen.h b/src/gallium/drivers/ilo/ilo_state_gen.h index 9e4f0ebaafd..a4faad5134b 100644 --- a/src/gallium/drivers/ilo/ilo_state_gen.h +++ b/src/gallium/drivers/ilo/ilo_state_gen.h @@ -80,41 +80,6 @@ ilo_gpe_gen6_translate_texture(enum pipe_texture_target target) } } -static inline void -zs_align_surface(const struct ilo_dev_info *dev, - unsigned align_w, unsigned align_h, - struct ilo_zs_surface *zs) -{ - unsigned mask, shift_w, shift_h; - unsigned width, height; - uint32_t dw3; - - ILO_DEV_ASSERT(dev, 6, 7.5); - - if (ilo_dev_gen(dev) >= ILO_GEN(7)) { - shift_w = 4; - shift_h = 18; - mask = 0x3fff; - } - else { - shift_w = 6; - shift_h = 19; - mask = 0x1fff; - } - - dw3 = zs->payload[2]; - - /* aligned width and height */ - width = align(((dw3 >> shift_w) & mask) + 1, align_w); - height = align(((dw3 >> shift_h) & mask) + 1, align_h); - - dw3 = (dw3 & ~((mask << shift_w) | (mask << shift_h))) | - (width - 1) << shift_w | - (height - 1) << shift_h; - - zs->payload[2] = dw3; -} - void ilo_gpe_init_ve(const struct ilo_dev_info *dev, unsigned num_states, diff --git a/src/gallium/drivers/ilo/ilo_state_gen6.c b/src/gallium/drivers/ilo/ilo_state_gen6.c index 0fb226dc1c4..6950f275908 100644 --- a/src/gallium/drivers/ilo/ilo_state_gen6.c +++ b/src/gallium/drivers/ilo/ilo_state_gen6.c @@ -1140,13 +1140,35 @@ ilo_gpe_init_zs_surface(const struct ilo_dev_info *dev, const int max_array_size = (ilo_dev_gen(dev) >= ILO_GEN(7)) ? 2048 : 512; struct ilo_zs_surface_info info; uint32_t dw1, dw2, dw3, dw4, dw5, dw6; + int align_w = 8, align_h = 4; ILO_DEV_ASSERT(dev, 6, 7.5); - if (tex) + if (tex) { zs_init_info(dev, tex, format, level, first_layer, num_layers, &info); - else + + switch (tex->base.nr_samples) { + case 2: + align_w /= 2; + break; + case 4: + align_w /= 2; + align_h /= 2; + break; + case 8: + align_w /= 4; + align_h /= 2; + break; + case 16: + align_w /= 4; + align_h /= 4; + break; + default: + break; + } + } else { zs_init_info_null(dev, &info); + } switch (info.surface_type) { case GEN6_SURFTYPE_NULL: @@ -1209,6 +1231,10 @@ ilo_gpe_init_zs_surface(const struct ilo_dev_info *dev, (info.width - 1) << 4 | info.lod; + zs->dw_aligned_8x4 = (align(info.height, align_h) - 1) << 18 | + (align(info.width, align_w) - 1) << 4 | + info.lod; + dw4 = (info.depth - 1) << 21 | info.first_layer << 10; @@ -1231,6 +1257,11 @@ ilo_gpe_init_zs_surface(const struct ilo_dev_info *dev, info.lod << 2 | GEN6_DEPTH_DW3_MIPLAYOUT_BELOW; + zs->dw_aligned_8x4 = (align(info.height, align_h) - 1) << 19 | + (align(info.width, align_w) - 1) << 6 | + info.lod << 2 | + GEN6_DEPTH_DW3_MIPLAYOUT_BELOW; + dw4 = (info.depth - 1) << 21 | info.first_layer << 10 | (info.num_layers - 1) << 1; |