Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vkEnumerateInstanceVersion is not available. #44

Closed
sunbearc22 opened this issue Jul 26, 2018 · 9 comments
Closed

vkEnumerateInstanceVersion is not available. #44

sunbearc22 opened this issue Jul 26, 2018 · 9 comments

Comments

@sunbearc22
Copy link

sunbearc22 commented Jul 26, 2018

Hi realitix. I think we need the vkEnumerateInstanceVersion function in _vulkan.py for Vulkan versions 1.1.70.0 and upwards.

According to Spec, this function is obtained using

vkGetInstanceProcAddr( instance=Null, pName=vkEnumerateInstanceVersion )

After reading _vulkan.py, I noticed that vkEnumerateInstanceExtensionProperties, vkEnumerateInstanceLayerProperties and vkCreateInstance were explicitly declared python functions. Meaning functions provided by vkGetInstanceProcAddr when instance=Null are to be explicitly declared python functions. Thus _vulkan.py should have vkEnumerateInstanceVersion as an explicitly declared python function.

I did try something like:

vkEnumerateInstanceVersion = vkGetInstanceProcAddr(None, vkEnumerateInstanceVersion)

but got

UnboundLocalError: local variable 'vkEnumerateInstanceVersion' referenced before assignment

Suggestion. Will the following function be appropriate for _vulkan.py?

def vkEnumerateInstanceVersion(pApiVersion):
   ''Supply pApiVersion in str format, e.g. `1.1.77.0` '''

    pApiVersion = pApiVersion.split('.')
    major = int(pApiVersion[0])
    minor = int(pApiVersion[1])
    patch = int(pApiVersion[2])
    pApiVersion = VK_MAKE_VERSION(major, minor, patch)

    result = _callApi(lib.vkEnumerateInstanceVersion, pApiVersion)
    if result != VK_SUCCESS:
        raise exception_codes[result]

    return result
@sunbearc22
Copy link
Author

Hi realitix, I have adapted the example by LunarG and applied it on vulkan 1.1.71.2 app. Below is the function to test for vkEnumerateInstanceVersion.

    def checkApiVersion(self):
        try:
            vkEnumerateInstanceVersion = vkGetInstanceProcAddr(
                VK_NULL_HANDLE, "vkEnumerateInstanceVersion")
            logging.info('"vkEnumerateInstanceVersion" exist.')
        except ExtensionNotSupportedError:
            logging.info('No "vkEnumerateInstanceVersion": treat as Vulkan 1.0 only.')

Presently, vulkan 1.1.71.2 is returning ExtensionNotSupportedError when this function is executed.

vulkan.cdef.h lines 3874 & 3903 do define vkEnumerateInstanceVersion.

@sunbearc22
Copy link
Author

I tried appending the following vkEnumerateInstanceVersion function at line 3728 of _vulkan.py to fake its presence but my above function still met the exception ExtensionNotSupportedError.

def vkEnumerateInstanceVersion():

    pApiVersion = ffi.NULL

    result = _callApi(lib.vkEnumerateInstanceVersion, pApiVersion)
    if result != VK_SUCCESS:
        raise exception_codes[result]

    return result

@realitix
Copy link
Owner

Hello @sunbearc22,
Thanks for the report, I will look at it.

@sunbearc22
Copy link
Author

sunbearc22 commented Jul 28, 2018

@realitix. Thanks. I have corrected the above function to use pApiVersion = ffi.new('uint32_t*') but still did not work.

BTW, is macro VK_DEFINE_HANDLE missing also? I could not find it in _vulkan.py or vulkan.cdef.h.

I have also reviewed the definition of lib. in _vulkan.py. According to line 97 & 100, for Linux users lib refers to $VULKAN_SDK/lib/libvulkan.so.1 which is a link to $VULKAN_SDK/lib/libvulkan.so.1.1.77 in my case. So I have checked that lib. is accessing the correct version of the Vulkan library I want to test.

@sunbearc22
Copy link
Author

@realitix. According to definition of vkGetInstanceProcAddr line 6857, the object in _instance_ext_funcs needs vkEnumerateInstanceVersion but is missing. After adding the definition, the ExtensionNotSupportedError was avoided. Question: Is vkEnumerateInstanceVersion an instance extension function given that its parameter instance = VK_NULL_HANDLE ?

def vkGetInstanceProcAddr(instance, pName):
    fn = _callApi(lib.vkGetInstanceProcAddr, instance, pName)
    if fn == ffi.NULL:
        raise ProcedureNotFoundError()
    if not pName in _instance_ext_funcs:
        raise ExtensionNotSupportedError()
    fn = ffi.cast('PFN_' + pName, fn)
    return _instance_ext_funcs[pName](fn)

@realitix
Copy link
Owner

Hello @sunbearc22,
It should be fixed when the new_version will be ready

@realitix
Copy link
Owner

realitix commented Feb 8, 2019

Hello @sunbearc22,
Can you try again, I just updated to the 1.1.99 SDK

@sunbearc22
Copy link
Author

Hi realitx, apologies for my late reply. May I know which LunarG Vulkan SDK does vulkan 1.1.99.0 uses? I could find these closes SDKs (1.1.97.0, 1.1.101.0, and 1.1.106.0).

@realitix
Copy link
Owner

Hello @sunbearc22.
It should work now.
I will push a new version soon on pypi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants