To replace the hacky zs_align_surface().
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
#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"
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);
}
}
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) :
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];
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);
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) {
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);
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) {
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;
}
}
-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,
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:
(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;
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;