realitix/vulkan

Generating for latest version (1.2.162.1)

Closed this issue · 4 comments

The raytracing functions were added officially in 1.2.162.0 and I'd love to have a play with them, so I've set myself the task of generating the files for the latest version.

I'm running Win10 x64 with Python 3.8.5 x64

Firstly, confirm I have the right idea:

  • git clone this repo somewhere
  • install the vulkan sdk of the right version
  • copy vk.xml from VulkanSDK//share/vulkan/registry to /generator/
  • copy all of the files from VulkanSDK//Include/vulkan to /generator/vulkan_include
  • run the 'generate.py' file to create the _vulkan.py and vulkan.cdef.h file in /vulkan/
  • run setup.py as normal to install or create a dist or whatever you want

Assuming that is the correct procedure, I've done the above and come across two blocking errors thrown by generator.py:

  • It's two "enum" KeyErrors raised when dealing with extension macros (generator.py@217-231)
  • They are caused by vk.xml(1.2.162.1)@13530-13535 as the 'VK_KHR_device_group' and 'VK_VERSION_1_1'
  • The ext requirements just don't have enums which generator.py can't handle.

I don't know enough about this system yet to know if it's the right fix or what repercussions it will have, but for now I've just put a check into generator.py@220 before the enum for loop so that it only runs if there are enums available.

With my 'fix' for those two KeyErrors, generate.py runs successfully

Two syntax errors are present in the generated _vulkan.py file:

  • _vulkan.py@6506-6507, the VK_UUID_SIZE name is 'contaminated' because in the vk.xml@4823 file is: <member len="2*ename:VK_UUID_SIZE" altlen="2*VK_UUID_SIZE">const <type>uint8_t</type>* <name>pVersionData</name></member>
  • _vulkan.py@7863 and 8029 both contain "pAllocateInfo->commandBufferCount" which (as I'm sure you know) isn't valid python, I'm guessing it's pulled incorrectly from one of the header files though I've not traced that down yet.

I assume both of these are just odd cases that generate.py doesn't yet handle? For now I've just manually modified them in the _vulkan.py file by removing the 2*ename: strings and replacing the -> with .

python setup.py install now works without errors

Now when I import vulkan I get name 'VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES' is not defined, which it isn't. VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES is also undefined when it should be.

It was at this point I thought I'd ask for your input..

Am I heading in the right direction? Are these bugs that need fixing or am I doing something wrong? Has any of this work been done already?

I'm not very experienced with CFFI or Vulkan yet but I'm pretty damn good with openGL, python, C, C++, I've even written a few python modules with SWIG which isn't miles away from this. Happy to help if I can.

Hello @tcdtech,

Sorry for the late reply, I didn't see the issue.
Indeed when updating vulkan version, often errors appear because the vk.xml format can change... And the script works with the current vk.xml format.

Yes you are clearly in the good direction, it's the way to do it. If you can continue to work on it, I will be glad to update the script with your modification. You can send a pull request and I will review it.

Thanks

Hello @tcdtech, did you manage to upgrade the version ?

Possible upgrade PR77
#77

It's updated for last version