chakmeshma
chakmeshma

Reputation: 284

vkCreateImage returns VK_ERROR_INITIALIZATION_FAILED although supported

My Vulkan implementation returns VK_ERROR_INITIALIZATION_FAILED whenever i call vkCreateImage. I checked output of vkGetPhysicalDeviceImageFormatProperties as well as output of vkGetPhysicalDeviceFormatProperties and made sure that format of the image i'm creating (with regard to it's creation parameters) is supported. I've successfully initialized a Vulkan instance and a logical device, so the problem must lie somewhere else.

The Vulkan Spec mentions no VK_ERROR_INITIALIZATION_FAILED as a possible return value from vkCreateImage, which makes it more hard to uproot the problem.

The VkImageCreateInfo structure i push to vkCreateImage is as follows:

imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
imageCreateInfo.pNext = nullptr;
imageCreateInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
imageCreateInfo.format = VK_FORMAT_R8G8B8A8_UNORM;
imageCreateInfo.extent.width = 1024;
imageCreateInfo.extent.height = 1024;
imageCreateInfo.extent.depth = 1;
imageCreateInfo.arrayLayers = 1;
imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
imageCreateInfo.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
imageCreateInfo.mipLevels = 0;
imageCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
imageCreateInfo.queueFamilyIndexCount = 0;
imageCreateInfo.pQueueFamilyIndices = nullptr;

Upvotes: 0

Views: 886

Answers (1)

Ekzuzy
Ekzuzy

Reputation: 3457

As described in the specification:

mipLevels must be greater than 0

So judging by Your code, providing 0 value for number of mip levels may be the reason (or one of the reasons) of failure.

Upvotes: 2

Related Questions