maierfelix/nvk

Polymorphic arguments for struct aliases

Reon90 opened this issue · 13 comments

I don't understand why memoryRequirements in VkMemoryRequirements2 object is NULL, on the other hand c++ realization is correct.

nvk - JS
annotation 2019-01-30 114435

C++
annotation 2019-01-30 114352

I can approve that this is not working as expected, I found the following reason:

vkGetAccelerationStructureMemoryRequirementsNV takes VkMemoryRequirements2KHR which is an alias for VkMemoryRequirements2. VkMemoryRequirements2KHR doesn't contain any members, so the JS->Type reflection here is not performed at all.

The following line in the 1.1.97 XML specification indicates, that:

<type category="struct" name="VkMemoryRequirements2KHR" alias="VkMemoryRequirements2"/>

Note the alias attribute. This could be solved by interpreting VkMemoryRequirements2KHR as VkMemoryRequirements2 in the parsing process and in the code-generation part as well. I'm not a 100% sure though if this is a general fix.

@maierfelix are you planning to implement it?

Yes I'm investigating, trying to fix this as soon as possible!:)

@maierfelix Hello, as I see you have done a lot of commits, was there fixed this bug?

I had to finish completing the online documentation and fixing some type inconsistency. I didn't cover this issue yet, but I have a fix ready in mind.

Edit: Do you have an repository of your RT project somewhere?

@maierfelix no sorry I don't have, as you know I can't build basic example with RT.
any news about it?

@Reon90 Latest master now contains the changes to fix this issue, please validate that it's working now.
I also added parameter type validation for vulkan function calls, they should now be more safe to use.

I guess that you use vkGetAccelerationStructureMemoryRequirementsNV to gather the memoryRequirements - Please note that the specification currently states to use VkMemoryRequirements2KHR for pMemoryRequirements and not VkMemoryRequirements2.

VkMemoryRequirements2KHR is just a typedef for VkMemoryRequirements2, so please use this one as described in the documentation here

Thanks and sorry for the delay!

@maierfelix thank you very much, I got correct results.

I will close this issue as soon as this is fully resolved (e.g. both VkMemoryRequirements2 and VkMemoryRequirements2KHR are allowed as pMemoryRequirements)

@maierfelix

const descriptorIndexing = new VkPhysicalDeviceDescriptorIndexingFeaturesEXT();
const deviceFeatures = new VkPhysicalDeviceFeatures2();
deviceFeatures.pNext = descriptorIndexing;
vkGetPhysicalDeviceFeatures2(physicalDevice, deviceFeatures);

TypeError: 'VkPhysicalDeviceFeatures2.pNext' must be 'null'

It was broken few days ago.

I can approve that this isn't working, I'm investigating

Closing this as this is not an too important issue? If someone is actually in the need to get this implemented, I'm open to make the changes