mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 20:08:06 +02:00
intel: Fix crashes for importing drm buffer
image_aspect_to_binding() converts aspect to index by subrracting
VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT, however these enum values
are bitfields, not consecutive numbers, so comparing and subtracting
them won't work.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20269>
(cherry picked from commit 7642f3b99c)
This commit is contained in:
parent
0c7a3133ac
commit
3e3def9620
2 changed files with 12 additions and 5 deletions
|
|
@ -796,7 +796,7 @@
|
|||
"description": "intel: Fix crashes for importing drm buffer",
|
||||
"nominated": false,
|
||||
"nomination_type": null,
|
||||
"resolution": 4,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null
|
||||
},
|
||||
|
|
|
|||
|
|
@ -59,21 +59,28 @@ memory_range_end(struct anv_image_memory_range memory_range)
|
|||
static struct anv_image_binding *
|
||||
image_aspect_to_binding(struct anv_image *image, VkImageAspectFlags aspect)
|
||||
{
|
||||
uint32_t plane;
|
||||
uint32_t plane = 0;
|
||||
|
||||
assert(image->disjoint);
|
||||
|
||||
if (image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
|
||||
/* Spec requires special aspects for modifier images. */
|
||||
assert(aspect >= VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT &&
|
||||
aspect <= VK_IMAGE_ASPECT_MEMORY_PLANE_3_BIT_EXT);
|
||||
assert(aspect == VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT ||
|
||||
aspect == VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXT ||
|
||||
aspect == VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXT ||
|
||||
aspect == VK_IMAGE_ASPECT_MEMORY_PLANE_3_BIT_EXT);
|
||||
|
||||
/* We don't advertise DISJOINT for modifiers with aux, and therefore we
|
||||
* don't handle queries of the modifier's "aux plane" here.
|
||||
*/
|
||||
assert(!isl_drm_modifier_has_aux(image->vk.drm_format_mod));
|
||||
|
||||
plane = aspect - VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT;
|
||||
switch(aspect) {
|
||||
case VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT: plane = 0; break;
|
||||
case VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXT: plane = 1; break;
|
||||
case VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXT: plane = 2; break;
|
||||
case VK_IMAGE_ASPECT_MEMORY_PLANE_3_BIT_EXT: plane = 3; break;
|
||||
}
|
||||
} else {
|
||||
plane = anv_image_aspect_to_plane(image, aspect);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue