[PATCH vkd3d 2/2] vkd3d: Handle plane slice for texture views.
Henri Verbeet
hverbeet at gmail.com
Fri Jan 14 11:11:43 CST 2022
On Fri, 14 Jan 2022 at 05:57, Conor McCarthy <cmccarthy at codeweavers.com> wrote:
> +static VkImageAspectFlags vk_image_aspect_flags_from_d3d12_plane_slice(const struct vkd3d_format *format,
> + unsigned int plane_slice)
> +{
> + VkImageAspectFlags aspect_flags = format->vk_aspect_mask;
> + unsigned int i;
> +
> + /* For all formats we currently handle, the n-th aspect bit in Vulkan
> + * corresponds to the n-th plane in D3D12, so isolate the respective
> + * bit in the aspect flags. */
> + for (i = 0; i < plane_slice; i++)
> + aspect_flags &= aspect_flags - 1;
> +
So above we're clearing the least significant bit set.
> + if (!aspect_flags)
> + {
> + WARN("Invalid plane slice %u for format %#x.\n", plane_slice, format->vk_format);
> + aspect_flags = format->vk_aspect_mask;
> + }
> +
> + return aspect_flags & -aspect_flags;
And then here we return the least significant bit set.
> +}
> +
That works, but I wouldn't say it's the most obvious code I've ever
seen; some comments wouldn't be inappropriate.
More information about the wine-devel
mailing list