zink: only mark resources as cube-compatible if supported

We need to check if the number of samples are valid for the image
first if we've going to set the cube-compatible bit.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10913>
This commit is contained in:
Erik Faye-Lund 2021-05-21 10:38:32 +02:00 committed by Marge Bot
parent b92c1a043a
commit 71494c4874

View file

@ -331,8 +331,6 @@ create_ici(struct zink_screen *screen, const struct pipe_resource *templ, unsign
case PIPE_TEXTURE_CUBE:
case PIPE_TEXTURE_CUBE_ARRAY:
ici.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
FALLTHROUGH;
case PIPE_TEXTURE_2D:
case PIPE_TEXTURE_2D_ARRAY:
case PIPE_TEXTURE_RECT:
@ -385,6 +383,19 @@ create_ici(struct zink_screen *screen, const struct pipe_resource *templ, unsign
if (!good)
debug_printf("ZINK: failed to validate image creation\n");
if (templ->target == PIPE_TEXTURE_CUBE ||
templ->target == PIPE_TEXTURE_CUBE_ARRAY) {
VkImageFormatProperties props;
if (vkGetPhysicalDeviceImageFormatProperties(screen->pdev, ici.format,
ici.imageType, ici.tiling,
ici.usage, ici.flags |
VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT,
&props) == VK_SUCCESS) {
if (props.sampleCounts & ici.samples)
ici.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
}
}
ici.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
ici.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
return ici;