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);
/**
* 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;
assert(aview->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL);
- return (const struct anv_depth_stencil_view *) aview;
+ return aview;
}
}
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 *
}
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");
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;
}
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);
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 {
},
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,
(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 });
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,
src_image, &src_iview,
pRegions[r].srcOffset,
pRegions[r].extent,
- dest_image, &dest_cview,
+ dest_image, &dest_aview,
dest_offset,
pRegions[r].extent);
}
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,
src_image, &src_iview,
pRegions[r].srcOffset,
pRegions[r].srcExtent,
- dest_image, &dest_cview,
+ dest_image, &dest_aview,
dest_offset,
pRegions[r].destExtent);
}
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),
(VkOffset3D) { 0, 0, 0 },
pRegions[r].imageExtent,
dest_image,
- &dest_cview,
+ &dest_aview,
dest_offset,
pRegions[r].imageExtent);
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,
pRegions[r].imageOffset,
pRegions[r].imageExtent,
anv_image_from_handle(destImage),
- &dest_cview,
+ &dest_aview,
(VkOffset3D) { 0, 0, 0 },
pRegions[r].imageExtent);
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,
},
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),
.attachmentCount = 1,
.pAttachments = (VkAttachmentBindInfo[]) {
{
- .view = anv_attachment_view_to_handle(aview),
+ .view = anv_attachment_view_to_handle(&aview),
.layout = VK_IMAGE_LAYOUT_GENERAL
}
},
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);
};
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;
};
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;
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);
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,
}
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);
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 */
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,
}
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 =