summaryrefslogtreecommitdiffstats
path: root/src/vulkan
diff options
context:
space:
mode:
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/anv_image.c26
-rw-r--r--src/vulkan/anv_private.h12
-rw-r--r--src/vulkan/gen7_cmd_buffer.c15
-rw-r--r--src/vulkan/gen8_cmd_buffer.c19
4 files changed, 28 insertions, 44 deletions
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c
index 6ab541e5bce..242de52f639 100644
--- a/src/vulkan/anv_image.c
+++ b/src/vulkan/anv_image.c
@@ -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(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 *
diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h
index 594b4fedc6c..5cbc67b7c2c 100644
--- a/src/vulkan/anv_private.h
+++ b/src/vulkan/anv_private.h
@@ -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 {
diff --git a/src/vulkan/gen7_cmd_buffer.c b/src/vulkan/gen7_cmd_buffer.c
index c157155cd99..84b733ca458 100644
--- a/src/vulkan/gen7_cmd_buffer.c
+++ b/src/vulkan/gen7_cmd_buffer.c
@@ -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);
}
diff --git a/src/vulkan/gen8_cmd_buffer.c b/src/vulkan/gen8_cmd_buffer.c
index 0ec0f666ae0..5aa78528f5c 100644
--- a/src/vulkan/gen8_cmd_buffer.c
+++ b/src/vulkan/gen8_cmd_buffer.c
@@ -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);
}