FacticiusVir / SharpVk

C# Bindings for the Vulkan API & SPIR-V
MIT License
147 stars 18 forks source link

Next field not set to 0 #30

Closed jcoder58 closed 7 years ago

jcoder58 commented 7 years ago

I got the following warning from Vulkan:

ParameterValidation: vkCreateGraphicsPipelines: value of pCreateInfos[0].pStages[1].pNext must be NULL. This warning is based on the Valid Usage documentation for version 30 of the Vulkan header. It is possible that you are using a struct from a private extension or an extension that was added to a later version of the Vulkan header, in which case your use of pCreateInfos[0].pStages[1].pNext is perfectly valid but is not guaranteed to work correctly with validation enabled

Looking through your code, I saw that you did not explicitly set the Next field when you marshaled the structures. I fixed the warning by adding

    pointer->Next = null;

to PipelineShaderStageCreateInfo.MarshalTo to fix the issue I was having.

FacticiusVir commented 7 years ago

Looks like fall-out from the marshalling rework done for Linux/Xamarin - struct memory was originally zeroed when allocated, but that was swapped for explicitly initialising all fields. Guess I missed some! Will update the generator to fix.

FacticiusVir commented 7 years ago

Huh, actually subtler than that; memory zeroing still happens for individual struct allocates, but not for arrays. Either way, the fix is the same, let me know if that resolves your validate error.

jcoder58 commented 7 years ago

That fixed it.