GPUOpen-Archive / Anvil

Anvil is a cross-platform framework for Vulkan
MIT License
594 stars 62 forks source link

Creating a buffer with device local memory and client data causes validation error #100

Closed Silverlan closed 6 years ago

Silverlan commented 6 years ago

Anvil Version: 18-09-03 (straight from github) Vulkan SDK: 1.1.82.1

Code:

std::array<uint8_t,1> data = {5};
auto bufferCreateInfo = Anvil::BufferCreateInfo::create_nonsparse_alloc(
    &GetDevice(),static_cast<VkDeviceSize>(data.size() *sizeof(data.front())),Anvil::QueueFamily::QUEUE_FAMILY_GRAPHICS_BIT,
    static_cast<VkSharingMode>(vk::SharingMode::eExclusive),static_cast<VkBufferUsageFlags>(vk::BufferUsageFlagBits::eUniformBuffer),
    Anvil::MemoryFeatureFlagBits::MEMORY_FEATURE_FLAG_DEVICE_LOCAL
);
bufferCreateInfo->set_client_data(data.data());
auto buf = Anvil::Buffer::create(
    std::move(bufferCreateInfo)
);

Validation error message:

[VK] [ VUID-VkBufferCreateInfo-sharingMode-00914 ] Object: VK_NULL_HANDLE (Type = 0) | vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, pCreateInfo->queueFamilyIndexCount must be greater than 1. The spec valid usage text states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkBufferCreateInfo-sharingMode-00914)

As far as I can tell the error only occurs with device local memory, and if client data is specified. I believe it has something to do with the temporary buffer created in Anvil::Buffer::write, which is created with the _VK_SHARING_MODECONCURRENT flag.

Silverlan commented 6 years ago

After some additional testing, I can't seem to replicate this bug anymore. Not sure what the cause was, but it seems to have disappeared.