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(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;
- }
+ assert(anv_format_is_depth_or_stencil(image->format));
+ assert(anv_format_is_depth_or_stencil(view->format));
}
struct anv_surface *
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 = (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;
.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,
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 = (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;
.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,
.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:
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);
}