vk: Don't duplicate anv_depth_stencil_view's surface data

In anv_depth_stencil_view, replace the members
    bo
    depth_offset
    depth_stride
    depth_format
    depth_qpitch
    stencil_offset
    stencil_stride
    stencil_qpitch
with the single member
    const struct anv_image *image

The removed members duplicated data in anv_image::depth_surface and
anv_image::stencil_surface.
This commit is contained in:
Chad Versace 2015-08-28 07:52:19 -07:00
parent 35b0262a2d
commit c6f19b4248
4 changed files with 28 additions and 44 deletions

View file

@ -468,35 +468,15 @@ anv_depth_stencil_view_init(struct anv_depth_stencil_view *view,
view->base.attachment_type = ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL;
/* XXX: We don't handle any of these */
assert(anv_format_is_depth_or_stencil(image->format));
anv_assert(pCreateInfo->mipLevel == 0);
anv_assert(pCreateInfo->baseArraySlice == 0);
anv_assert(pCreateInfo->arraySize == 1);
view->bo = image->bo;
view->image = image;
view->format = anv_format_for_vk_format(pCreateInfo->format);
assert(anv_format_is_depth_or_stencil(image->format));
assert(anv_format_is_depth_or_stencil(view->format));
if (view->format->depth_format) {
view->depth_stride = image->depth_surface.stride;
view->depth_offset = image->offset + image->depth_surface.offset;
view->depth_qpitch = 0; /* FINISHME: QPitch */
} else {
view->depth_stride = 0;
view->depth_offset = 0;
view->depth_qpitch = 0;
}
if (view->format->has_stencil) {
view->stencil_stride = image->stencil_surface.stride;
view->stencil_offset = image->offset + image->stencil_surface.offset;
view->stencil_qpitch = 0; /* FINISHME: QPitch */
} else {
view->stencil_stride = 0;
view->stencil_offset = 0;
view->stencil_qpitch = 0;
}
}
struct anv_surface *

View file

@ -1119,18 +1119,8 @@ struct anv_color_attachment_view {
struct anv_depth_stencil_view {
struct anv_attachment_view base;
const struct anv_image *image; /**< VkAttachmentViewCreateInfo::image */
const struct anv_format *format; /**< VkAttachmentViewCreateInfo::format */
struct anv_bo *bo;
uint32_t depth_offset; /**< Offset into bo. */
uint32_t depth_stride; /**< 3DSTATE_DEPTH_BUFFER.SurfacePitch */
uint32_t depth_format; /**< 3DSTATE_DEPTH_BUFFER.SurfaceFormat */
uint16_t depth_qpitch; /**< 3DSTATE_DEPTH_BUFFER.SurfaceQPitch */
uint32_t stencil_offset; /**< Offset into bo. */
uint32_t stencil_stride; /**< 3DSTATE_STENCIL_BUFFER.SurfacePitch */
uint16_t stencil_qpitch; /**< 3DSTATE_STENCIL_BUFFER.SurfaceQPitch */
};
struct anv_image_create_info {

View file

@ -539,6 +539,7 @@ gen7_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
view = (const struct anv_depth_stencil_view *)aview;
}
const struct anv_image *image = view ? view->image : NULL;
const bool has_depth = view && view->format->depth_format;
const bool has_stencil = view && view->format->has_stencil;
@ -550,8 +551,11 @@ gen7_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
.StencilWriteEnable = has_stencil,
.HierarchicalDepthBufferEnable = false,
.SurfaceFormat = view->format->depth_format,
.SurfacePitch = view->depth_stride - 1,
.SurfaceBaseAddress = { view->bo, view->depth_offset },
.SurfacePitch = image->depth_surface.stride - 1,
.SurfaceBaseAddress = {
.bo = image->bo,
.offset = image->depth_surface.offset,
},
.Height = fb->height - 1,
.Width = fb->width - 1,
.LOD = 0,
@ -589,8 +593,11 @@ gen7_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
if (has_stencil) {
anv_batch_emit(&cmd_buffer->batch, GEN7_3DSTATE_STENCIL_BUFFER,
.StencilBufferObjectControlState = GEN7_MOCS,
.SurfacePitch = view->stencil_stride - 1,
.SurfaceBaseAddress = { view->bo, view->stencil_offset });
.SurfacePitch = image->stencil_surface.stride - 1,
.SurfaceBaseAddress = {
.bo = image->bo,
.offset = image->offset + image->stencil_surface.offset,
});
} else {
anv_batch_emit(&cmd_buffer->batch, GEN7_3DSTATE_STENCIL_BUFFER);
}

View file

@ -469,6 +469,7 @@ gen8_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
view = (const struct anv_depth_stencil_view *)aview;
}
const struct anv_image *image = view ? view->image : NULL;
const bool has_depth = view && view->format->depth_format;
const bool has_stencil = view && view->format->has_stencil;
@ -483,8 +484,11 @@ gen8_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
.StencilWriteEnable = has_stencil,
.HierarchicalDepthBufferEnable = false,
.SurfaceFormat = view->format->depth_format,
.SurfacePitch = view->depth_stride - 1,
.SurfaceBaseAddress = { view->bo, view->depth_offset },
.SurfacePitch = image->depth_surface.stride - 1,
.SurfaceBaseAddress = {
.bo = image->bo,
.offset = image->depth_surface.offset,
},
.Height = fb->height - 1,
.Width = fb->width - 1,
.LOD = 0,
@ -492,7 +496,7 @@ gen8_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
.MinimumArrayElement = 0,
.DepthBufferObjectControlState = GEN8_MOCS,
.RenderTargetViewExtent = 1 - 1,
.SurfaceQPitch = view->depth_qpitch >> 2);
.SurfaceQPitch = image->depth_surface.qpitch >> 2);
} else {
/* Even when no depth buffer is present, the hardware requires that
* 3DSTATE_DEPTH_BUFFER be programmed correctly. The Broadwell PRM says:
@ -524,9 +528,12 @@ gen8_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_STENCIL_BUFFER,
.StencilBufferEnable = true,
.StencilBufferObjectControlState = GEN8_MOCS,
.SurfacePitch = view->stencil_stride - 1,
.SurfaceBaseAddress = { view->bo, view->stencil_offset },
.SurfaceQPitch = view->stencil_qpitch >> 2);
.SurfacePitch = image->stencil_surface.stride - 1,
.SurfaceBaseAddress = {
.bo = image->bo,
.offset = image->offset + image->stencil_surface.offset,
},
.SurfaceQPitch = image->stencil_surface.stride >> 2);
} else {
anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_STENCIL_BUFFER);
}