From: Jason Ekstrand Date: Fri, 1 Jan 2016 21:47:18 +0000 (-0800) Subject: anv/image: Do more work in anv_image_view_init X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a7cc12910d1963d21fda8165ce790c4cb4241fba;p=mesa.git 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. --- diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 5a9f826ec43..5bee5a236e8 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -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) diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index d915f694347..76c47de594a 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -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. */ diff --git a/src/vulkan/gen7_state.c b/src/vulkan/gen7_state.c index c5c4cdaaf85..fe2967c7ef4 100644 --- a/src/vulkan/gen7_state.c +++ b/src/vulkan/gen7_state.c @@ -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; diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index c7cc585c5e1..5562a252a21 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -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;