db.SurfaceFormat = isl_surf_get_depth_format(dev, info->depth_surf);
db.Width = info->depth_surf->logical_level0_px.width - 1;
db.Height = info->depth_surf->logical_level0_px.height - 1;
+ if (db.SurfaceType == SURFTYPE_3D)
+ db.Depth = info->depth_surf->logical_level0_px.depth - 1;
} else if (info->stencil_surf) {
db.SurfaceType = isl_to_gen_ds_surftype[info->stencil_surf->dim];
db.SurfaceFormat = D32_FLOAT;
db.Width = info->stencil_surf->logical_level0_px.width - 1;
db.Height = info->stencil_surf->logical_level0_px.height - 1;
+ if (db.SurfaceType == SURFTYPE_3D)
+ db.Depth = info->stencil_surf->logical_level0_px.depth - 1;
} else {
db.SurfaceType = SURFTYPE_NULL;
db.SurfaceFormat = D32_FLOAT;
if (info->depth_surf || info->stencil_surf) {
/* These are based entirely on the view */
- db.Depth = db.RenderTargetViewExtent = info->view->array_len - 1;
+ db.RenderTargetViewExtent = info->view->array_len - 1;
db.LOD = info->view->base_level;
db.MinimumArrayElement = info->view->base_array_layer;
+
+ /* From the Haswell PRM docs for 3DSTATE_DEPTH_BUFFER::Depth
+ *
+ * "This field specifies the total number of levels for a volume
+ * texture or the number of array elements allowed to be accessed
+ * starting at the Minimum Array Element for arrayed surfaces. If the
+ * volume texture is MIP-mapped, this field specifies the depth of
+ * the base MIP level."
+ *
+ * For 3D surfaces, we set it to the correct depth above. For non-3D
+ * surfaces, this is the same as RenderTargetViewExtent.
+ */
+ if (db.SurfaceType != SURFTYPE_3D)
+ db.Depth = db.RenderTargetViewExtent;
}
if (info->depth_surf) {