}
static isl_tiling_flags_t
-choose_isl_tiling_flags(const struct anv_image_create_info *anv_info,
+choose_isl_tiling_flags(const struct gen_device_info *devinfo,
+ const struct anv_image_create_info *anv_info,
const struct isl_drm_modifier_info *isl_mod_info,
bool legacy_scanout)
{
if (anv_info->isl_tiling_flags)
flags &= anv_info->isl_tiling_flags;
- if (legacy_scanout)
- flags &= ISL_TILING_LINEAR_BIT | ISL_TILING_X_BIT;
+ if (legacy_scanout) {
+ isl_tiling_flags_t legacy_mask = ISL_TILING_LINEAR_BIT;
+ if (devinfo->has_tiling_uapi)
+ legacy_mask |= ISL_TILING_X_BIT;
+ flags &= legacy_mask;
+ }
assert(flags);
&image->planes[plane].surface.isl,
&image->planes[plane].aux_surface.isl);
assert(ok);
- image->planes[plane].aux_usage = ISL_AUX_USAGE_HIZ;
+ if (!isl_surf_supports_ccs(&device->isl_dev,
+ &image->planes[plane].surface.isl)) {
+ image->planes[plane].aux_usage = ISL_AUX_USAGE_HIZ;
+ } else if (image->usage & (VK_IMAGE_USAGE_SAMPLED_BIT |
+ VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) &&
+ image->samples == 1) {
+ /* If it's used as an input attachment or a texture and it's
+ * single-sampled (this is a requirement for HiZ+CCS write-through
+ * mode), use write-through mode so that we don't need to resolve
+ * before texturing. This will make depth testing a bit slower but
+ * texturing faster.
+ *
+ * TODO: This is a heuristic trade-off; we haven't tuned it at all.
+ */
+ assert(device->info.gen >= 12);
+ image->planes[plane].aux_usage = ISL_AUX_USAGE_HIZ_CCS_WT;
+ } else {
+ assert(device->info.gen >= 12);
+ image->planes[plane].aux_usage = ISL_AUX_USAGE_HIZ_CCS;
+ }
add_surface(image, &image->planes[plane].aux_surface, plane);
} else if ((aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) && image->samples == 1) {
if (image->n_planes != 1) {
anv_assert(pCreateInfo->extent.height > 0);
anv_assert(pCreateInfo->extent.depth > 0);
- image = vk_zalloc2(&device->alloc, alloc, sizeof(*image), 8,
+ image = vk_zalloc2(&device->vk.alloc, alloc, sizeof(*image), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!image)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ vk_object_base_init(&device->vk, &image->base, VK_OBJECT_TYPE_IMAGE);
image->type = pCreateInfo->imageType;
image->extent = pCreateInfo->extent;
image->vk_format = pCreateInfo->format;
assert(format != NULL);
const isl_tiling_flags_t isl_tiling_flags =
- choose_isl_tiling_flags(create_info, isl_mod_info,
+ choose_isl_tiling_flags(&device->info, create_info, isl_mod_info,
image->needs_set_tiling);
image->n_planes = format->n_planes;
fail:
if (image)
- vk_free2(&device->alloc, alloc, image);
+ vk_free2(&device->vk.alloc, alloc, image);
return r;
}
}
}
- vk_free2(&device->alloc, pAllocator, image);
+ vk_object_base_finish(&image->base);
+ vk_free2(&device->vk.alloc, pAllocator, image);
}
static void anv_image_bind_memory_plane(struct anv_device *device,
assert(aspect == VK_IMAGE_ASPECT_COLOR_BIT);
return VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT;
- case VK_IMAGE_LAYOUT_RANGE_SIZE:
case VK_IMAGE_LAYOUT_MAX_ENUM:
unreachable("Invalid image layout.");
}
case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL:
return aspect == VK_IMAGE_ASPECT_STENCIL_BIT;
- case VK_IMAGE_LAYOUT_RANGE_SIZE:
case VK_IMAGE_LAYOUT_MAX_ENUM:
unreachable("Invalid image layout.");
}
/* Handle a few special cases */
switch (layout) {
/* Invalid layouts */
- case VK_IMAGE_LAYOUT_RANGE_SIZE:
case VK_IMAGE_LAYOUT_MAX_ENUM:
unreachable("Invalid image layout.");
aux_supported = false;
break;
+ case ISL_AUX_USAGE_HIZ_CCS:
+ aux_supported = false;
+ break;
+
+ case ISL_AUX_USAGE_HIZ_CCS_WT:
+ break;
+
case ISL_AUX_USAGE_CCS_D:
aux_supported = false;
break;
switch (aux_usage) {
case ISL_AUX_USAGE_HIZ:
+ case ISL_AUX_USAGE_HIZ_CCS:
+ case ISL_AUX_USAGE_HIZ_CCS_WT:
if (aux_supported) {
return ISL_AUX_STATE_COMPRESSED_CLEAR;
} else if (read_only) {
* depth/stencil attachment, we should enable HiZ so that we can get
* faster depth testing.
*/
- return ISL_AUX_USAGE_HIZ;
+ return image->planes[plane].aux_usage;
} else {
return ISL_AUX_USAGE_NONE;
}
return ANV_FAST_CLEAR_ANY;
} else if (image->planes[plane].aux_usage == ISL_AUX_USAGE_MCS ||
image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E) {
- /* If the image has MCS or CCS_E enabled all the time then we can use
- * fast-clear as long as the clear color is the default value of zero
- * since this is the default value we program into every surface
- * state used for texturing.
- */
- return ANV_FAST_CLEAR_DEFAULT_VALUE;
+ if (devinfo->gen >= 11) {
+ /* On ICL and later, the sampler hardware uses a copy of the clear
+ * value that is encoded as a pixel value. Therefore, we can use
+ * any clear color we like for sampling.
+ */
+ return ANV_FAST_CLEAR_ANY;
+ } else {
+ /* If the image has MCS or CCS_E enabled all the time then we can
+ * use fast-clear as long as the clear color is the default value
+ * of zero since this is the default value we program into every
+ * surface state used for texturing.
+ */
+ return ANV_FAST_CLEAR_DEFAULT_VALUE;
+ }
} else {
return ANV_FAST_CLEAR_NONE;
}
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
struct anv_image_view *iview;
- iview = vk_zalloc2(&device->alloc, pAllocator, sizeof(*iview), 8,
+ iview = vk_zalloc2(&device->vk.alloc, pAllocator, sizeof(*iview), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (iview == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ vk_object_base_init(&device->vk, &iview->base, VK_OBJECT_TYPE_IMAGE_VIEW);
+
const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
assert(range->layerCount > 0);
}
}
- vk_free2(&device->alloc, pAllocator, iview);
+ vk_object_base_finish(&iview->base);
+ vk_free2(&device->vk.alloc, pAllocator, iview);
}
ANV_FROM_HANDLE(anv_buffer, buffer, pCreateInfo->buffer);
struct anv_buffer_view *view;
- view = vk_alloc2(&device->alloc, pAllocator, sizeof(*view), 8,
+ view = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*view), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!view)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
/* TODO: Handle the format swizzle? */
+ vk_object_base_init(&device->vk, &view->base, VK_OBJECT_TYPE_BUFFER_VIEW);
view->format = anv_get_isl_format(&device->info, pCreateInfo->format,
VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_TILING_LINEAR);
anv_state_pool_free(&device->surface_state_pool,
view->writeonly_storage_surface_state);
- vk_free2(&device->alloc, pAllocator, view);
+ vk_object_base_finish(&view->base);
+ vk_free2(&device->vk.alloc, pAllocator, view);
}