VkBufferCreateInfo-sharingMode-parameter issue


#1

Can anyone help me out with this runtime error:

14757395258967641292VUID-VkBufferCreateInfo-sharingMode-parameter(ERROR / SPEC): msgNum: 0 - vkCreateBuffer: value of pCreateInfo->sharingMode (-858993460) does not fall within the begin..end range of the core VkSharingMode enumeration tokens and is not an extension added token. The Vulkan spec states: sharingMode must be a valid VkSharingMode value 
Objects: 1
[0] 0, type: 0, name: NULL

i am not unable to fix this !!

My VkBufferCreateInfo looks like this:

VkBufferCreateInfo bufferCreateInfo;
bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bufferCreateInfo.pNext = nullptr;
bufferCreateInfo.flags = 0;
bufferCreateInfo.size = sizeof(Vertex) * vertices.size();
bufferCreateInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
bufferCreateInfo.sharingMode - VK_SHARING_MODE_EXCLUSIVE;
bufferCreateInfo.queueFamilyIndexCount = 0;
bufferCreateInfo.pQueueFamilyIndices = nullptr;

VkResult result = vkCreateBuffer(device, &bufferCreateInfo, nullptr, &vertexBuffer);

#2

I think you need to turn on warnings from your compiler. Many will warn for this kind of error.
See your line above which sets sharingMode. What’s the character after the field name? It should be an ‘=’, but it’s not. It’s a ‘-’.

The error says that the value sharingMode that you’re providing is -858993460. That’s not the value that you think you’re populating this field with (0), which should make you take a closer look at the line that sets it and see the error.

Convert that to hex, and that’s 0xCCCCCCCC. If you’re using Windows/MSVC and this is a Debug build, then this magic number implies that this field is still set to the value for “uninitialised stack memory”. Realizing this would also prompt you to double-check that line where you are trying to assign sharingMode a value.


#3

Thank you so much :slight_smile: