Mesa (master): anv/image: Simplify assertions in anv_image_from_swapchain()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 8 14:38:25 UTC 2021
Module: Mesa
Branch: master
Commit: de870cc4b240c09cc34b236ee8e434ba1bb6787c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=de870cc4b240c09cc34b236ee8e434ba1bb6787c
Author: Chad Versace <chad at kiwitree.net>
Date: Mon Mar 22 11:17:08 2021 -0700
anv/image: Simplify assertions in anv_image_from_swapchain()
No intended change in behavior.
Conceptual diff:
|- assert(swapchain_image->apples == (pCreateInfo->apples + MORE));
| local_create_info->apples = pCreateInfo->apples + MORE;
|+ assert(swapchain_image->apples == local_create_info->apples);
And, where appropriate:
|- local_create_info->orange = X;
|+ /* See spec anchor #swapchain-wsi-image-create-info . */
|+ assert(local_create_info->orange == X);
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1466>
---
src/intel/vulkan/anv_image.c | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index dd53520dfc6..7ba3eee1e6c 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -1031,32 +1031,37 @@ anv_image_from_swapchain(VkDevice device,
struct anv_image *swapchain_image = anv_swapchain_get_image(swapchain_info->swapchain, 0);
assert(swapchain_image);
- assert(swapchain_image->type == pCreateInfo->imageType);
- assert(swapchain_image->vk_format == pCreateInfo->format);
- assert(swapchain_image->extent.width == pCreateInfo->extent.width);
- assert(swapchain_image->extent.height == pCreateInfo->extent.height);
- assert(swapchain_image->extent.depth == pCreateInfo->extent.depth);
- assert(swapchain_image->array_size == pCreateInfo->arrayLayers);
- /* Color attachment is added by the wsi code. */
- assert(swapchain_image->usage == (pCreateInfo->usage | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT));
-
- VkImageCreateInfo local_create_info;
- local_create_info = *pCreateInfo;
+ VkImageCreateInfo local_create_info = *pCreateInfo;
local_create_info.pNext = NULL;
- /* The following parameters are implictly selected by the wsi code. */
- local_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
- local_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
+
+ /* Added by wsi code. */
local_create_info.usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
- /* If the image has a particular modifier, specify that modifier. */
+ /* The spec requires TILING_OPTIMAL as input, but the swapchain image may
+ * privately use a different tiling. See spec anchor
+ * #swapchain-wsi-image-create-info .
+ */
+ assert(local_create_info.tiling == VK_IMAGE_TILING_OPTIMAL);
+
VkImageDrmFormatModifierListCreateInfoEXT local_modifier_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT,
.drmFormatModifierCount = 1,
.pDrmFormatModifiers = &swapchain_image->drm_format_mod,
};
+
if (swapchain_image->drm_format_mod != DRM_FORMAT_MOD_INVALID)
__vk_append_struct(&local_create_info, &local_modifier_info);
+ assert(swapchain_image->type == local_create_info.imageType);
+ assert(swapchain_image->vk_format == local_create_info.format);
+ assert(swapchain_image->extent.width == local_create_info.extent.width);
+ assert(swapchain_image->extent.height == local_create_info.extent.height);
+ assert(swapchain_image->extent.depth == local_create_info.extent.depth);
+ assert(swapchain_image->array_size == local_create_info.arrayLayers);
+ assert(swapchain_image->samples == local_create_info.samples);
+ assert(swapchain_image->tiling == local_create_info.tiling);
+ assert(swapchain_image->usage == local_create_info.usage);
+
return anv_image_create(device,
&(struct anv_image_create_info) {
.vk_info = &local_create_info,
More information about the mesa-commit
mailing list