anv/image: Do more work in anv_image_view_init

There was a bunch of common code in gen7/8_image_view_init that we really
should be sharing.
This commit is contained in:
Jason Ekstrand
2016-01-01 13:47:18 -08:00
parent 87dd59e578
commit a7cc12910d
4 changed files with 22 additions and 32 deletions
+16
View File
@@ -432,6 +432,22 @@ anv_image_view_init(struct anv_image_view *iview,
break;
}
struct anv_surface *surface =
anv_image_get_surface_for_aspect_mask(image, range->aspectMask);
iview->image = image;
iview->bo = image->bo;
iview->offset = image->offset + surface->offset;
iview->aspect_mask = pCreateInfo->subresourceRange.aspectMask;
iview->format = anv_format_for_vk_format(pCreateInfo->format);
iview->extent = (VkExtent3D) {
.width = anv_minify(image->extent.width, range->baseMipLevel),
.height = anv_minify(image->extent.height, range->baseMipLevel),
.depth = anv_minify(image->extent.depth, range->baseMipLevel),
};
switch (device->info.gen) {
case 7:
if (device->info.is_haswell)
+2
View File
@@ -1492,6 +1492,8 @@ struct anv_image_view {
const struct anv_format *format; /**< VkImageViewCreateInfo::format */
struct anv_bo *bo;
uint32_t offset; /**< Offset into bo. */
VkImageAspectFlags aspect_mask;
VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */
/** RENDER_SURFACE_STATE when using image as a color render target. */
+2 -16
View File
@@ -198,23 +198,9 @@ genX(image_view_init)(struct anv_image_view *iview,
struct anv_surface *surface =
anv_image_get_surface_for_aspect_mask(image, range->aspectMask);
const struct anv_format *format =
anv_format_for_vk_format(pCreateInfo->format);
if (pCreateInfo->viewType != VK_IMAGE_VIEW_TYPE_2D)
anv_finishme("non-2D image views");
iview->image = image;
iview->bo = image->bo;
iview->offset = image->offset + surface->offset;
iview->format = anv_format_for_vk_format(pCreateInfo->format);
iview->extent = (VkExtent3D) {
.width = anv_minify(image->extent.width, range->baseMipLevel),
.height = anv_minify(image->extent.height, range->baseMipLevel),
.depth = anv_minify(image->extent.depth, range->baseMipLevel),
};
uint32_t depth = 1;
if (range->layerCount > 1) {
depth = range->layerCount;
@@ -228,7 +214,7 @@ genX(image_view_init)(struct anv_image_view *iview,
struct GENX(RENDER_SURFACE_STATE) surface_state = {
.SurfaceType = anv_surftype(image, pCreateInfo->viewType, false),
.SurfaceArray = image->array_size > 1,
.SurfaceFormat = format->surface_format,
.SurfaceFormat = iview->format->surface_format,
.SurfaceVerticalAlignment = anv_valign[image_align_sa.height],
.SurfaceHorizontalAlignment = anv_halign[image_align_sa.width],
@@ -325,7 +311,7 @@ genX(image_view_init)(struct anv_image_view *iview,
surface_state.SurfaceFormat =
isl_lower_storage_image_format(&device->isl_dev,
format->surface_format);
iview->format->surface_format);
surface_state.SurfaceMinLOD = range->baseMipLevel;
surface_state.MIPCountLOD = MAX2(range->levelCount, 1) - 1;
+2 -16
View File
@@ -140,20 +140,6 @@ genX(image_view_init)(struct anv_image_view *iview,
uint32_t depth = 1; /* RENDER_SURFACE_STATE::Depth */
uint32_t rt_view_extent = 1; /* RENDER_SURFACE_STATE::RenderTargetViewExtent */
const struct anv_format *format_info =
anv_format_for_vk_format(pCreateInfo->format);
iview->image = image;
iview->bo = image->bo;
iview->offset = image->offset + surface->offset;
iview->format = format_info;
iview->extent = (VkExtent3D) {
.width = anv_minify(image->extent.width, range->baseMipLevel),
.height = anv_minify(image->extent.height, range->baseMipLevel),
.depth = anv_minify(image->extent.depth, range->baseMipLevel),
};
switch (image->type) {
case VK_IMAGE_TYPE_1D:
case VK_IMAGE_TYPE_2D:
@@ -208,7 +194,7 @@ genX(image_view_init)(struct anv_image_view *iview,
struct GENX(RENDER_SURFACE_STATE) surface_state = {
.SurfaceType = anv_surftype(image, pCreateInfo->viewType, false),
.SurfaceArray = image->array_size > 1,
.SurfaceFormat = format_info->surface_format,
.SurfaceFormat = iview->format->surface_format,
.SurfaceVerticalAlignment = valign,
.SurfaceHorizontalAlignment = halign,
.TileMode = isl_to_gen_tiling[surface->isl.tiling],
@@ -300,7 +286,7 @@ genX(image_view_init)(struct anv_image_view *iview,
surface_state.SurfaceFormat =
isl_lower_storage_image_format(&device->isl_dev,
format_info->surface_format);
iview->format->surface_format);
surface_state.SurfaceMinLOD = range->baseMipLevel;
surface_state.MIPCountLOD = MAX2(range->levelCount, 1) - 1;