vulkan icon indicating copy to clipboard operation
vulkan copied to clipboard

example program fails with various validation errors

Open TylerGubala opened this issue 6 years ago • 13 comments

Thank you for creating the Python Vulkan Bindings.

I am just now trying to become more familiar with Vulkan on Python. For some reason I am having an issue running the example.

I installed SDL2 and PYSDL2 on my computer and placed the binary in my venv's site-packages directory, prepending the following line above import sdl2:

os.environ["PYSDL2_DLL_PATH"] = "C:\\Users\\TGubs\\Code\\Python\\vulkan_py_playground\\venv\\Lib\\site-packages"

I then tried running the example using the latest SDL2.dll I could find and the most recent Windows build of Vulkan. Here are my results:

(venv) PS C:\Users\TGubs\Code\Python\vulkan_py_playground> python vulkan/example/example_sdl2.py
availables extensions: ['VK_KHR_device_group_creation', 'VK_KHR_external_fence_capabilities', 'VK_KHR_external_memory_capabilities', 'VK_KHR_external_semaphore_capabilities', 'VK_KHR_get_physical_device_properties2', 'VK_KHR_get_surface_capabilities2', 'VK_KHR_surface', 'VK_KHR_surface_protected_capabilities', 'VK_KHR_win32_surface', 'VK_EXT_debug_report', 'VK_EXT_debug_utils', 'VK_EXT_swapchain_colorspace', 'VK_NV_external_memory_capabilities']

availables layers: ['VK_LAYER_NV_optimus', 'VK_LAYER_NV_nsight', 'VK_LAYER_VALVE_steam_overlay', 'VK_LAYER_VALVE_steam_fossilize', 'VK_LAYER_LUNARG_api_dump', 'VK_LAYER_LUNARG_assistant_layer', 'VK_LAYER_LUNARG_core_validation', 'VK_LAYER_LUNARG_device_simulation', 'VK_LAYER_KHRONOS_validation', 'VK_LAYER_LUNARG_monitor', 'VK_LAYER_LUNARG_object_tracker', 'VK_LAYER_LUNARG_screenshot', 'VK_LAYER_LUNARG_standard_validation', 'VK_LAYER_LUNARG_parameter_validation', 'VK_LAYER_GOOGLE_threading', 'VK_LAYER_GOOGLE_unique_objects', 'VK_LAYER_LUNARG_vktrace']

Create windows surface
availables devices: ['GeForce GTX 1080 Ti']
selected device: GeForce GTX 1080 Ti

3 available queue family
DEBUG: Validation  [ VUID-vkGetPhysicalDeviceSurfaceSupportKHR-surface-parameter ] Object: 0x7d4bd4000000002 (Type = 26) | Invalid VkSurfaceKHR Object 0x7d4bd4000000002. The Vulkan spec states: surface must be a valid VkSurfaceKHR handle (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkGetPhysicalDeviceSurfaceSupportKHR-surface-parameter)
DEBUG: Validation  [ UNASSIGNED-Threading-Info ] Object: 0x7d4bd4000000002 (Type = 0) | Couldn't find VkNonDispatchableHandle Object 0x7d4bd4000000002. This should not happen and may indicate a bug in the application.

I am on Windows10, Python 3.7-32. Wondering if there is something wrong with my configuration.

Thanks in advance!

TylerGubala avatar Sep 24 '19 22:09 TylerGubala

I am also experiencing this on my Surface Book. I will get more logs once I get to my computer.

spencerelliott avatar Nov 07 '19 11:11 spencerelliott

Hello, I never see this error, I will take a look. Thanks for the report.

realitix avatar Nov 07 '19 13:11 realitix

The error we see comes from here, the surface pointer is bad. So it means that the problem comes from the surface creation for Windows here.

The problem may comes from the function GetWindowLongA which is not compatible with 64 bits Windows.

Can you try to change here:

return _lib.GetWindowLongA(_ffi.cast('void*', hWnd), -6)

by

return _lib.GetWindowLongPtrA(_ffi.cast('void*', hWnd), -6)

I wait for your answer. I don't have a Windows so I can't test it myself.

realitix avatar Nov 07 '19 13:11 realitix

I'm getting this stack trace:

Traceback (most recent call last):
  File "c:/Users/spenc/Documents/Python/vulkan/example/example_sdl2.py", line 145, in <module>
    surface = surface_mapping[wm_info.subsystem]()
  File "c:/Users/spenc/Documents/Python/vulkan/example/example_sdl2.py", line 134, in surface_win32
    hinstance=get_instance(wm_info.info.win.window),
  File "c:/Users/spenc/Documents/Python/vulkan/example/example_sdl2.py", line 128, in get_instance
    return _lib.GetWindowLongPtrA(_ffi.cast('void*', hWnd), -6)
  File "C:\Users\spenc\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cffi\api.py", line 908, in __getattr__
    make_accessor(name)
  File "C:\Users\spenc\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cffi\api.py", line 903, in make_accessor
    raise AttributeError(name)
AttributeError: GetWindowLongPtrA

I'll see if I can research this a bit more, too.

spencerelliott avatar Nov 09 '19 19:11 spencerelliott

Indeed you must change the function name on line https://github.com/realitix/vulkan/blob/master/example/example_sdl2.py#L126 too

realitix avatar Nov 09 '19 20:11 realitix

Ah, that's my bad. I'll try out again soon. Thank you.

spencerelliott avatar Nov 09 '19 20:11 spencerelliott

It seems like the method cannot be found in user32.dll. I'm not sure why since Microsoft even suggests using the method you described.

  File "c:/Users/spenc/Documents/Python/vulkan/example/example_sdl2.py", line 145, in <module>
    surface = surface_mapping[wm_info.subsystem]()
  File "c:/Users/spenc/Documents/Python/vulkan/example/example_sdl2.py", line 134, in surface_win32
    hinstance=get_instance(wm_info.info.win.window),
  File "c:/Users/spenc/Documents/Python/vulkan/example/example_sdl2.py", line 128, in get_instance
    return _lib.GetWindowLongPtr(_ffi.cast('void*', hWnd), -6)
  File "C:\Users\spenc\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cffi\api.py", line 908, in __getattr__
    make_accessor(name)
  File "C:\Users\spenc\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cffi\api.py", line 904, in make_accessor
    accessors[name](name)
  File "C:\Users\spenc\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cffi\api.py", line 834, in accessor_function
    value = backendlib.load_function(BType, name)
AttributeError: function/symbol 'GetWindowLongPtr' not found in library 'User32.dll': error 0x7f

I tried both GetWindowLongPtr and GetWindowLongPtrA.

spencerelliott avatar Nov 11 '19 17:11 spencerelliott

Strange, I have to try but I need to boot a Windows machine. I can't do it soon.

realitix avatar Nov 11 '19 18:11 realitix

@realitix Any way we can help? I know machine availibility woes. Have you done Gitcoin before? I'd be willing to bet some folks want to learn this as badly as I.

TylerGubala avatar Dec 11 '19 20:12 TylerGubala

OK @TylerGubala, I will try to take some time next week to install a Windows machine.

realitix avatar Dec 11 '19 21:12 realitix

Sorry I didn't take time earlier. I just installed a new windows vm, I will work on it tomorrow.

realitix avatar Feb 14 '20 18:02 realitix

Sadly I can't test in a VM, I need a real computer to test Vulkan on Windows... So we'll see.

realitix avatar Jan 18 '24 13:01 realitix

Sadly I can't test in a VM, I need a real computer to test Vulkan on Windows... So we'll see.

If you can passthrough a GPU directly into the VM, you should be able to use that, depends if you have a spare Vulkan Compatible GPU you can plug in to passthrough it to the VM.

barkermn01 avatar Feb 08 '24 12:02 barkermn01