summaryrefslogtreecommitdiffstats
path: root/src/vulkan
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2015-10-05 17:27:38 -0700
committerChad Versace <[email protected]>2015-10-05 17:46:04 -0700
commit935706234855e19e17402ee3b3cc19bc032b4932 (patch)
tree72f63a6df805576fdf5ef0fbc32a725fcbc3a266 /src/vulkan
parentae30535602d8b2f10a31feb133331c0c985b8b41 (diff)
vk: Merge anv_*_attachment_view into anv_attachment_view
Remove anv_color_attachment_view and anv_depth_stencil_view, merging them into anv_attachment_view. This prepares for merging VkAttachmentView into VkImageView.
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/anv_cmd_buffer.c10
-rw-r--r--src/vulkan/anv_image.c50
-rw-r--r--src/vulkan/anv_meta.c44
-rw-r--r--src/vulkan/anv_private.h21
-rw-r--r--src/vulkan/gen7_cmd_buffer.c13
-rw-r--r--src/vulkan/gen7_state.c5
-rw-r--r--src/vulkan/gen8_cmd_buffer.c13
-rw-r--r--src/vulkan/gen8_state.c5
8 files changed, 67 insertions, 94 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c
index 008eeed40d6..cab916c1383 100644
--- a/src/vulkan/anv_cmd_buffer.c
+++ b/src/vulkan/anv_cmd_buffer.c
@@ -434,14 +434,10 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
for (uint32_t a = 0; a < attachments; a++) {
const struct anv_attachment_view *aview =
fb->attachments[subpass->color_attachments[a]];
+ const struct anv_image_view *iview = &aview->image_view;
assert(aview->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_COLOR);
- const struct anv_color_attachment_view *cview =
- (const struct anv_color_attachment_view *) aview;
-
- const struct anv_image_view *iview = &cview->image_view;
-
bt_map[a] = iview->surface_state.offset + state_offset;
add_surface_state_reloc(cmd_buffer, iview->surface_state,
iview->bo, iview->offset);
@@ -821,7 +817,7 @@ VkResult anv_ResetCommandPool(
/**
* Return NULL if the current subpass has no depthstencil attachment.
*/
-const struct anv_depth_stencil_view *
+const struct anv_attachment_view *
anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer)
{
const struct anv_subpass *subpass = cmd_buffer->state.subpass;
@@ -835,5 +831,5 @@ anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer)
assert(aview->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL);
- return (const struct anv_depth_stencil_view *) aview;
+ return aview;
}
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c
index 75233d1fe61..f926cc2b1c0 100644
--- a/src/vulkan/anv_image.c
+++ b/src/vulkan/anv_image.c
@@ -512,24 +512,23 @@ anv_DestroyImageView(VkDevice _device, VkImageView _iview)
}
static void
-anv_depth_stencil_view_init(struct anv_depth_stencil_view *ds_view,
+anv_depth_stencil_view_init(struct anv_attachment_view *aview,
const VkAttachmentViewCreateInfo *pCreateInfo)
{
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
- ds_view->attachment_view.attachment_type =
- ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL;
+ aview->attachment_type = ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL;
/* XXX: We don't handle any of these */
anv_assert(pCreateInfo->mipLevel == 0);
anv_assert(pCreateInfo->baseArraySlice == 0);
anv_assert(pCreateInfo->arraySize == 1);
- ds_view->image = image;
- ds_view->format = anv_format_for_vk_format(pCreateInfo->format);
+ aview->image_view.image = image;
+ aview->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(ds_view->format));
+ assert(anv_format_is_depth_or_stencil(aview->image_view.format));
}
struct anv_surface *
@@ -579,17 +578,17 @@ anv_image_get_surface_for_color_attachment(struct anv_image *image)
}
void
-anv_color_attachment_view_init(struct anv_color_attachment_view *cview,
+anv_color_attachment_view_init(struct anv_attachment_view *aview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer)
{
switch (device->info.gen) {
case 7:
- gen7_color_attachment_view_init(cview, device, pCreateInfo, cmd_buffer);
+ gen7_color_attachment_view_init(aview, device, pCreateInfo, cmd_buffer);
break;
case 8:
- gen8_color_attachment_view_init(cview, device, pCreateInfo, cmd_buffer);
+ gen8_color_attachment_view_init(aview, device, pCreateInfo, cmd_buffer);
break;
default:
unreachable("unsupported gen\n");
@@ -602,34 +601,26 @@ anv_CreateAttachmentView(VkDevice _device,
VkAttachmentView *pView)
{
ANV_FROM_HANDLE(anv_device, device, _device);
+ struct anv_attachment_view *aview;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO);
+ aview = anv_device_alloc(device, sizeof(*aview), 8,
+ VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ if (aview == NULL)
+ return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+
const struct anv_format *format =
anv_format_for_vk_format(pCreateInfo->format);
if (anv_format_is_depth_or_stencil(format)) {
- struct anv_depth_stencil_view *ds_view =
- anv_device_alloc(device, sizeof(*ds_view), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
- if (ds_view == NULL)
- return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
-
- anv_depth_stencil_view_init(ds_view, pCreateInfo);
-
- *pView = anv_attachment_view_to_handle(&ds_view->attachment_view);
+ anv_depth_stencil_view_init(aview, pCreateInfo);
} else {
- struct anv_color_attachment_view *cview =
- anv_device_alloc(device, sizeof(*cview), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
- if (cview == NULL)
- return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
-
- anv_color_attachment_view_init(cview, device, pCreateInfo, NULL);
-
- *pView = anv_attachment_view_to_handle(&cview->attachment_view);
+ anv_color_attachment_view_init(aview, device, pCreateInfo, NULL);
}
+ *pView = anv_attachment_view_to_handle(aview);
+
return VK_SUCCESS;
}
@@ -640,10 +631,7 @@ anv_DestroyAttachmentView(VkDevice _device, VkAttachmentView _aview)
ANV_FROM_HANDLE(anv_attachment_view, aview, _aview);
if (aview->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_COLOR) {
- struct anv_color_attachment_view *cview =
- (struct anv_color_attachment_view *) aview;
-
- anv_image_view_fini(device, &cview->image_view);
+ anv_image_view_fini(device, &aview->image_view);
}
anv_device_free(device, aview);
diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c
index 085acc7a318..f6134338fdd 100644
--- a/src/vulkan/anv_meta.c
+++ b/src/vulkan/anv_meta.c
@@ -733,13 +733,12 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
VkOffset3D src_offset,
VkExtent3D src_extent,
struct anv_image *dest_image,
- struct anv_color_attachment_view *dest_cview,
+ struct anv_attachment_view *dest_aview,
VkOffset3D dest_offset,
VkExtent3D dest_extent)
{
struct anv_device *device = cmd_buffer->device;
- struct anv_attachment_view *dest_aview = &dest_cview->attachment_view;
- struct anv_image_view *dest_iview = &dest_cview->image_view;
+ struct anv_image_view *dest_iview = &dest_aview->image_view;
VkDescriptorPool dummy_desc_pool = { .handle = 1 };
struct blit_vb_data {
@@ -1023,8 +1022,8 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
},
cmd_buffer);
- struct anv_color_attachment_view dest_cview;
- anv_color_attachment_view_init(&dest_cview, cmd_buffer->device,
+ struct anv_attachment_view dest_aview;
+ anv_color_attachment_view_init(&dest_aview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = dest_image,
@@ -1041,7 +1040,7 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
(VkOffset3D) { 0, 0, 0 },
(VkExtent3D) { width, height, 1 },
anv_image_from_handle(dest_image),
- &dest_cview,
+ &dest_aview,
(VkOffset3D) { 0, 0, 0 },
(VkExtent3D) { width, height, 1 });
@@ -1185,8 +1184,8 @@ void anv_CmdCopyImage(
if (pRegions[r].extent.depth > 1)
anv_finishme("FINISHME: copy multiple depth layers");
- struct anv_color_attachment_view dest_cview;
- anv_color_attachment_view_init(&dest_cview, cmd_buffer->device,
+ struct anv_attachment_view dest_aview;
+ anv_color_attachment_view_init(&dest_aview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = destImage,
@@ -1201,7 +1200,7 @@ void anv_CmdCopyImage(
src_image, &src_iview,
pRegions[r].srcOffset,
pRegions[r].extent,
- dest_image, &dest_cview,
+ dest_image, &dest_aview,
dest_offset,
pRegions[r].extent);
}
@@ -1271,8 +1270,8 @@ void anv_CmdBlitImage(
if (pRegions[r].destExtent.depth > 1)
anv_finishme("FINISHME: copy multiple depth layers");
- struct anv_color_attachment_view dest_cview;
- anv_color_attachment_view_init(&dest_cview, cmd_buffer->device,
+ struct anv_attachment_view dest_aview;
+ anv_color_attachment_view_init(&dest_aview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = destImage,
@@ -1287,7 +1286,7 @@ void anv_CmdBlitImage(
src_image, &src_iview,
pRegions[r].srcOffset,
pRegions[r].srcExtent,
- dest_image, &dest_cview,
+ dest_image, &dest_aview,
dest_offset,
pRegions[r].destExtent);
}
@@ -1401,8 +1400,8 @@ void anv_CmdCopyBufferToImage(
if (pRegions[r].imageExtent.depth > 1)
anv_finishme("FINISHME: copy multiple depth layers");
- struct anv_color_attachment_view dest_cview;
- anv_color_attachment_view_init(&dest_cview, cmd_buffer->device,
+ struct anv_attachment_view dest_aview;
+ anv_color_attachment_view_init(&dest_aview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = anv_image_to_handle(dest_image),
@@ -1419,7 +1418,7 @@ void anv_CmdCopyBufferToImage(
(VkOffset3D) { 0, 0, 0 },
pRegions[r].imageExtent,
dest_image,
- &dest_cview,
+ &dest_aview,
dest_offset,
pRegions[r].imageExtent);
@@ -1483,8 +1482,8 @@ void anv_CmdCopyImageToBuffer(
dest_format,
&pRegions[r]);
- struct anv_color_attachment_view dest_cview;
- anv_color_attachment_view_init(&dest_cview, cmd_buffer->device,
+ struct anv_attachment_view dest_aview;
+ anv_color_attachment_view_init(&dest_aview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = destImage,
@@ -1501,7 +1500,7 @@ void anv_CmdCopyImageToBuffer(
pRegions[r].imageOffset,
pRegions[r].imageExtent,
anv_image_from_handle(destImage),
- &dest_cview,
+ &dest_aview,
(VkOffset3D) { 0, 0, 0 },
pRegions[r].imageExtent);
@@ -1548,8 +1547,8 @@ void anv_CmdClearColorImage(
for (uint32_t r = 0; r < rangeCount; r++) {
for (uint32_t l = 0; l < pRanges[r].mipLevels; l++) {
for (uint32_t s = 0; s < pRanges[r].arraySize; s++) {
- struct anv_color_attachment_view cview;
- anv_color_attachment_view_init(&cview, cmd_buffer->device,
+ struct anv_attachment_view aview;
+ anv_color_attachment_view_init(&aview, cmd_buffer->device,
&(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = _image,
@@ -1560,8 +1559,7 @@ void anv_CmdClearColorImage(
},
cmd_buffer);
- struct anv_attachment_view *aview = &cview.attachment_view;
- struct anv_image_view *iview = &cview.image_view;
+ struct anv_image_view *iview = &aview.image_view;
VkFramebuffer fb;
anv_CreateFramebuffer(anv_device_to_handle(cmd_buffer->device),
@@ -1570,7 +1568,7 @@ void anv_CmdClearColorImage(
.attachmentCount = 1,
.pAttachments = (VkAttachmentBindInfo[]) {
{
- .view = anv_attachment_view_to_handle(aview),
+ .view = anv_attachment_view_to_handle(&aview),
.layout = VK_IMAGE_LAYOUT_GENERAL
}
},
diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h
index b290fcc75b7..a0d4f8c2867 100644
--- a/src/vulkan/anv_private.h
+++ b/src/vulkan/anv_private.h
@@ -994,7 +994,7 @@ anv_cmd_buffer_push_constants(struct anv_cmd_buffer *cmd_buffer,
void anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
struct anv_render_pass *pass,
const VkClearValue *clear_values);
-const struct anv_depth_stencil_view *
+const struct anv_attachment_view *
anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer);
void anv_cmd_buffer_dump(struct anv_cmd_buffer *cmd_buffer);
@@ -1244,10 +1244,11 @@ struct anv_buffer_view {
};
struct anv_image_view {
+ const struct anv_image *image; /**< VkAttachmentViewCreateInfo::image */
+ const struct anv_format *format; /**< VkAttachmentViewCreateInfo::format */
struct anv_state surface_state; /**< RENDER_SURFACE_STATE */
struct anv_bo *bo;
uint32_t offset; /**< Offset into bo. */
- const struct anv_format *format; /**< VkImageViewCreateInfo::format */
VkExtent3D extent;
};
@@ -1258,19 +1259,9 @@ enum anv_attachment_view_type {
struct anv_attachment_view {
enum anv_attachment_view_type attachment_type;
-};
-
-struct anv_color_attachment_view {
- struct anv_attachment_view attachment_view;
struct anv_image_view image_view;
};
-struct anv_depth_stencil_view {
- struct anv_attachment_view attachment_view;
- const struct anv_image *image; /**< VkAttachmentViewCreateInfo::image */
- const struct anv_format *format; /**< VkAttachmentViewCreateInfo::format */
-};
-
struct anv_image_create_info {
const VkImageCreateInfo *vk_info;
bool force_tile_mode;
@@ -1306,17 +1297,17 @@ gen8_image_view_init(struct anv_image_view *iview,
const VkImageViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer);
-void anv_color_attachment_view_init(struct anv_color_attachment_view *cview,
+void anv_color_attachment_view_init(struct anv_attachment_view *aview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer);
-void gen7_color_attachment_view_init(struct anv_color_attachment_view *cview,
+void gen7_color_attachment_view_init(struct anv_attachment_view *aview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer);
-void gen8_color_attachment_view_init(struct anv_color_attachment_view *cview,
+void gen8_color_attachment_view_init(struct anv_attachment_view *aview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer);
diff --git a/src/vulkan/gen7_cmd_buffer.c b/src/vulkan/gen7_cmd_buffer.c
index b264013d62e..5803569502f 100644
--- a/src/vulkan/gen7_cmd_buffer.c
+++ b/src/vulkan/gen7_cmd_buffer.c
@@ -529,20 +529,21 @@ static void
gen7_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
{
const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
- const struct anv_depth_stencil_view *ds_view =
+ const struct anv_attachment_view *aview =
anv_cmd_buffer_get_depth_stencil_view(cmd_buffer);
- const struct anv_image *image = ds_view ? ds_view->image : NULL;
- const bool has_depth = ds_view && ds_view->format->depth_format;
- const bool has_stencil = ds_view && ds_view->format->has_stencil;
+ const struct anv_image_view *iview = aview ? &aview->image_view : NULL;
+ const struct anv_image *image = iview ? iview->image : NULL;
+ const bool has_depth = iview && iview->format->depth_format;
+ const bool has_stencil = iview && iview->format->has_stencil;
/* Emit 3DSTATE_DEPTH_BUFFER */
if (has_depth) {
anv_batch_emit(&cmd_buffer->batch, GEN7_3DSTATE_DEPTH_BUFFER,
.SurfaceType = SURFTYPE_2D,
- .DepthWriteEnable = ds_view->format->depth_format,
+ .DepthWriteEnable = iview->format->depth_format,
.StencilWriteEnable = has_stencil,
.HierarchicalDepthBufferEnable = false,
- .SurfaceFormat = ds_view->format->depth_format,
+ .SurfaceFormat = iview->format->depth_format,
.SurfacePitch = image->depth_surface.stride - 1,
.SurfaceBaseAddress = {
.bo = image->bo,
diff --git a/src/vulkan/gen7_state.c b/src/vulkan/gen7_state.c
index d65c1a373f0..778c9096461 100644
--- a/src/vulkan/gen7_state.c
+++ b/src/vulkan/gen7_state.c
@@ -360,14 +360,13 @@ gen7_image_view_init(struct anv_image_view *iview,
}
void
-gen7_color_attachment_view_init(struct anv_color_attachment_view *cview,
+gen7_color_attachment_view_init(struct anv_attachment_view *aview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer)
{
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
- struct anv_attachment_view *aview = &cview->attachment_view;
- struct anv_image_view *iview = &cview->image_view;
+ struct anv_image_view *iview = &aview->image_view;
struct anv_surface *surface =
anv_image_get_surface_for_color_attachment(image);
diff --git a/src/vulkan/gen8_cmd_buffer.c b/src/vulkan/gen8_cmd_buffer.c
index 30573639986..3ed32e8de3d 100644
--- a/src/vulkan/gen8_cmd_buffer.c
+++ b/src/vulkan/gen8_cmd_buffer.c
@@ -458,11 +458,12 @@ static void
gen8_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
{
const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
- const struct anv_depth_stencil_view *ds_view =
+ const struct anv_attachment_view *aview =
anv_cmd_buffer_get_depth_stencil_view(cmd_buffer);
- const struct anv_image *image = ds_view ? ds_view->image : NULL;
- const bool has_depth = ds_view && ds_view->format->depth_format;
- const bool has_stencil = ds_view && ds_view->format->has_stencil;
+ const struct anv_image_view *iview = aview ? &aview->image_view : NULL;
+ const struct anv_image *image = iview ? iview->image : NULL;
+ const bool has_depth = iview && iview->format->depth_format;
+ const bool has_stencil = iview && iview->format->has_stencil;
/* FIXME: Implement the PMA stall W/A */
/* FIXME: Width and Height are wrong */
@@ -471,10 +472,10 @@ gen8_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
if (has_depth) {
anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_DEPTH_BUFFER,
.SurfaceType = SURFTYPE_2D,
- .DepthWriteEnable = ds_view->format->depth_format,
+ .DepthWriteEnable = iview->format->depth_format,
.StencilWriteEnable = has_stencil,
.HierarchicalDepthBufferEnable = false,
- .SurfaceFormat = ds_view->format->depth_format,
+ .SurfaceFormat = iview->format->depth_format,
.SurfacePitch = image->depth_surface.stride - 1,
.SurfaceBaseAddress = {
.bo = image->bo,
diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c
index 8e9b43cab05..450bc52b579 100644
--- a/src/vulkan/gen8_state.c
+++ b/src/vulkan/gen8_state.c
@@ -281,14 +281,13 @@ gen8_image_view_init(struct anv_image_view *iview,
}
void
-gen8_color_attachment_view_init(struct anv_color_attachment_view *cview,
+gen8_color_attachment_view_init(struct anv_attachment_view *aview,
struct anv_device *device,
const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer)
{
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
- struct anv_attachment_view *aview = &cview->attachment_view;
- struct anv_image_view *iview = &cview->image_view;
+ struct anv_image_view *iview = &aview->image_view;
struct anv_surface *surface =
anv_image_get_surface_for_color_attachment(image);
const struct anv_format *format_info =