aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTapani Pälli <[email protected]>2018-09-27 08:00:53 +0300
committerTapani Pälli <[email protected]>2018-12-19 09:38:41 +0200
commit8a469fd3350a4f9512ac479026d802a3d9180bcd (patch)
tree923e2c766a26f4af37f50a90865fcde5ff2e1771
parent2a98e5bbb9ea24241b89bc5a51be10f4385b1c8d (diff)
anv: refactor make_surface to use data from anv_image
Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
-rw-r--r--src/intel/vulkan/anv_image.c78
-rw-r--r--src/intel/vulkan/anv_private.h5
2 files changed, 46 insertions, 37 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 6aaeca9c83f..a9458a2185c 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -159,28 +159,26 @@ add_surface(struct anv_image *image, struct anv_surface *surf, uint32_t plane)
static bool
all_formats_ccs_e_compatible(const struct gen_device_info *devinfo,
- const struct VkImageCreateInfo *vk_info)
+ const VkImageFormatListCreateInfoKHR *fmt_list,
+ struct anv_image *image)
{
enum isl_format format =
- anv_get_isl_format(devinfo, vk_info->format,
- VK_IMAGE_ASPECT_COLOR_BIT, vk_info->tiling);
+ anv_get_isl_format(devinfo, image->vk_format,
+ VK_IMAGE_ASPECT_COLOR_BIT, image->tiling);
if (!isl_format_supports_ccs_e(devinfo, format))
return false;
- if (!(vk_info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT))
+ if (!(image->create_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT))
return true;
- const VkImageFormatListCreateInfoKHR *fmt_list =
- vk_find_struct_const(vk_info->pNext, IMAGE_FORMAT_LIST_CREATE_INFO_KHR);
-
if (!fmt_list || fmt_list->viewFormatCount == 0)
return false;
for (uint32_t i = 0; i < fmt_list->viewFormatCount; i++) {
enum isl_format view_format =
anv_get_isl_format(devinfo, fmt_list->pViewFormats[i],
- VK_IMAGE_ASPECT_COLOR_BIT, vk_info->tiling);
+ VK_IMAGE_ASPECT_COLOR_BIT, image->tiling);
if (!isl_formats_are_ccs_e_compatible(devinfo, format, view_format))
return false;
@@ -299,11 +297,11 @@ add_aux_state_tracking_buffer(struct anv_image *image,
static VkResult
make_surface(const struct anv_device *dev,
struct anv_image *image,
- const struct anv_image_create_info *anv_info,
+ uint32_t stride,
isl_tiling_flags_t tiling_flags,
+ isl_surf_usage_flags_t isl_extra_usage_flags,
VkImageAspectFlagBits aspect)
{
- const VkImageCreateInfo *vk_info = anv_info->vk_info;
bool ok;
static const enum isl_surf_dim vk_to_isl_surf_dim[] = {
@@ -312,8 +310,7 @@ make_surface(const struct anv_device *dev,
[VK_IMAGE_TYPE_3D] = ISL_SURF_DIM_3D,
};
- image->extent = anv_sanitize_image_extent(vk_info->imageType,
- vk_info->extent);
+ image->extent = anv_sanitize_image_extent(image->type, image->extent);
const unsigned plane = anv_image_aspect_to_plane(image->aspects, aspect);
const struct anv_format_plane plane_format =
@@ -321,8 +318,8 @@ make_surface(const struct anv_device *dev,
struct anv_surface *anv_surf = &image->planes[plane].surface;
const isl_surf_usage_flags_t usage =
- choose_isl_surf_usage(vk_info->flags, image->usage,
- anv_info->isl_extra_usage_flags, aspect);
+ choose_isl_surf_usage(image->create_flags, image->usage,
+ isl_extra_usage_flags, aspect);
/* If an image is created as BLOCK_TEXEL_VIEW_COMPATIBLE, then we need to
* fall back to linear on Broadwell and earlier because we aren't
@@ -332,24 +329,24 @@ make_surface(const struct anv_device *dev,
*/
bool needs_shadow = false;
if (dev->info.gen <= 8 &&
- (vk_info->flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) &&
- vk_info->tiling == VK_IMAGE_TILING_OPTIMAL) {
+ (image->create_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) &&
+ image->tiling == VK_IMAGE_TILING_OPTIMAL) {
assert(isl_format_is_compressed(plane_format.isl_format));
tiling_flags = ISL_TILING_LINEAR_BIT;
needs_shadow = true;
}
ok = isl_surf_init(&dev->isl_dev, &anv_surf->isl,
- .dim = vk_to_isl_surf_dim[vk_info->imageType],
+ .dim = vk_to_isl_surf_dim[image->type],
.format = plane_format.isl_format,
.width = image->extent.width / plane_format.denominator_scales[0],
.height = image->extent.height / plane_format.denominator_scales[1],
.depth = image->extent.depth,
- .levels = vk_info->mipLevels,
- .array_len = vk_info->arrayLayers,
- .samples = vk_info->samples,
+ .levels = image->levels,
+ .array_len = image->array_size,
+ .samples = image->samples,
.min_alignment_B = 0,
- .row_pitch_B = anv_info->stride,
+ .row_pitch_B = stride,
.usage = usage,
.tiling_flags = tiling_flags);
@@ -369,16 +366,16 @@ make_surface(const struct anv_device *dev,
assert(tiling_flags == ISL_TILING_LINEAR_BIT);
ok = isl_surf_init(&dev->isl_dev, &image->planes[plane].shadow_surface.isl,
- .dim = vk_to_isl_surf_dim[vk_info->imageType],
+ .dim = vk_to_isl_surf_dim[image->type],
.format = plane_format.isl_format,
.width = image->extent.width,
.height = image->extent.height,
.depth = image->extent.depth,
- .levels = vk_info->mipLevels,
- .array_len = vk_info->arrayLayers,
- .samples = vk_info->samples,
+ .levels = image->levels,
+ .array_len = image->array_size,
+ .samples = image->samples,
.min_alignment_B = 0,
- .row_pitch_B = anv_info->stride,
+ .row_pitch_B = stride,
.usage = usage,
.tiling_flags = ISL_TILING_ANY_MASK);
@@ -405,12 +402,12 @@ make_surface(const struct anv_device *dev,
/* It will never be used as an attachment, HiZ is pointless. */
} else if (dev->info.gen == 7) {
anv_perf_warn(dev->instance, image, "Implement gen7 HiZ");
- } else if (vk_info->mipLevels > 1) {
+ } else if (image->levels > 1) {
anv_perf_warn(dev->instance, image, "Enable multi-LOD HiZ");
- } else if (vk_info->arrayLayers > 1) {
+ } else if (image->array_size > 1) {
anv_perf_warn(dev->instance, image,
"Implement multi-arrayLayer HiZ clears and resolves");
- } else if (dev->info.gen == 8 && vk_info->samples > 1) {
+ } else if (dev->info.gen == 8 && image->samples > 1) {
anv_perf_warn(dev->instance, image, "Enable gen8 multisampled HiZ");
} else if (!unlikely(INTEL_DEBUG & DEBUG_NO_HIZ)) {
assert(image->planes[plane].aux_surface.isl.size_B == 0);
@@ -421,7 +418,7 @@ make_surface(const struct anv_device *dev,
add_surface(image, &image->planes[plane].aux_surface, plane);
image->planes[plane].aux_usage = ISL_AUX_USAGE_HIZ;
}
- } else if ((aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) && vk_info->samples == 1) {
+ } else if ((aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) && image->samples == 1) {
/* TODO: Disallow compression with :
*
* 1) non multiplanar images (We appear to hit a sampler bug with
@@ -435,7 +432,7 @@ make_surface(const struct anv_device *dev,
*/
const bool allow_compression =
image->n_planes == 1 &&
- (vk_info->flags & VK_IMAGE_CREATE_ALIAS_BIT) == 0 &&
+ (image->create_flags & VK_IMAGE_CREATE_ALIAS_BIT) == 0 &&
likely((INTEL_DEBUG & DEBUG_NO_RBC) == 0);
if (allow_compression) {
@@ -472,14 +469,14 @@ make_surface(const struct anv_device *dev,
* a render target. This means that it's safe to just leave
* compression on at all times for these formats.
*/
- if (!(vk_info->usage & VK_IMAGE_USAGE_STORAGE_BIT) &&
- all_formats_ccs_e_compatible(&dev->info, vk_info)) {
+ if (!(image->usage & VK_IMAGE_USAGE_STORAGE_BIT) &&
+ image->ccs_e_compatible) {
image->planes[plane].aux_usage = ISL_AUX_USAGE_CCS_E;
}
}
}
- } else if ((aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) && vk_info->samples > 1) {
- assert(!(vk_info->usage & VK_IMAGE_USAGE_STORAGE_BIT));
+ } else if ((aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) && image->samples > 1) {
+ assert(!(image->usage & VK_IMAGE_USAGE_STORAGE_BIT));
assert(image->planes[plane].aux_surface.isl.size_B == 0);
ok = isl_surf_get_mcs_surf(&dev->isl_dev,
&image->planes[plane].surface.isl,
@@ -606,10 +603,17 @@ anv_image_create(VkDevice _device,
image->n_planes = format->n_planes;
+ const VkImageFormatListCreateInfoKHR *fmt_list =
+ vk_find_struct_const(pCreateInfo->pNext,
+ IMAGE_FORMAT_LIST_CREATE_INFO_KHR);
+
+ image->ccs_e_compatible =
+ all_formats_ccs_e_compatible(&device->info, fmt_list, image);
+
uint32_t b;
for_each_bit(b, image->aspects) {
- r = make_surface(device, image, create_info, isl_tiling_flags,
- (1 << b));
+ r = make_surface(device, image, create_info->stride, isl_tiling_flags,
+ create_info->isl_extra_usage_flags, (1 << b));
if (r != VK_SUCCESS)
goto fail;
}
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index efc30c4ab68..0efb2fd0be2 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2689,6 +2689,11 @@ struct anv_image {
*/
bool disjoint;
+ /* All the formats that can be used when creating views of this image
+ * are CCS_E compatible.
+ */
+ bool ccs_e_compatible;
+
/**
* Image subsurfaces
*