anv: avoid requiring ordered memory planes for explicit import
The spec does not have such requirement, but anv requires it for validating the offset. However, for DRM_FORMAT_YVU420, chroma channels can be swapped upon import to match B/R channel order of VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM. This fixes some sw codec path in Instagram when interop with gpu. v2: fix image memory requirement for re-ordered explicit import Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Emma Anholt <emma@anholt.net> (v1) Reviewed-by: Matt Tuner <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23643>
This commit is contained in:
@@ -144,20 +144,13 @@ image_binding_grow(const struct anv_device *device,
|
||||
"VkImageDrmFormatModifierExplicitCreateInfoEXT::"
|
||||
"pPlaneLayouts[]::offset is misaligned");
|
||||
}
|
||||
|
||||
/* We require that surfaces be added in memory-order. This simplifies the
|
||||
* layout validation required by
|
||||
* VkImageDrmFormatModifierExplicitCreateInfoEXT,
|
||||
*/
|
||||
if (unlikely(offset < container->size)) {
|
||||
return vk_errorf(device,
|
||||
VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT,
|
||||
"VkImageDrmFormatModifierExplicitCreateInfoEXT::"
|
||||
"pPlaneLayouts[]::offset is too small");
|
||||
}
|
||||
}
|
||||
|
||||
if (__builtin_add_overflow(offset, size, &container->size)) {
|
||||
/* Surfaces can be added out of memory-order. Track the end of each memory
|
||||
* plane to update the binding size properly.
|
||||
*/
|
||||
uint64_t memory_range_end;
|
||||
if (__builtin_add_overflow(offset, size, &memory_range_end)) {
|
||||
if (has_implicit_offset) {
|
||||
assert(!"overflow");
|
||||
return vk_errorf(device, VK_ERROR_UNKNOWN,
|
||||
@@ -170,6 +163,7 @@ image_binding_grow(const struct anv_device *device,
|
||||
}
|
||||
}
|
||||
|
||||
container->size = MAX2(container->size, memory_range_end);
|
||||
container->alignment = MAX2(container->alignment, alignment);
|
||||
|
||||
*out_range = (struct anv_image_memory_range) {
|
||||
|
Reference in New Issue
Block a user