BeRo1985 / pasvulkan

Vulkan header generator, OOP-style API wrapper, framework and prospective Vulkan-based game engine for Object Pascal
zlib License
185 stars 28 forks source link

GetPhysicalDeviceFeatures2KHR failing in TpvVulkanPhysicalDevice.Create #25

Closed johnhutch111 closed 2 years ago

johnhutch111 commented 2 years ago

if not assigned(vkGetPhysicalDeviceProperties2KHR) then begin @vkGetPhysicalDeviceProperties2KHR:=vkVoidFunctionToPointer(vkGetProcAddress(LibVulkan,'vkGetPhysicalDeviceProperties2KHR')); @vk.fCommands.GetPhysicalDeviceProperties2KHR:=addr(vkGetPhysicalDeviceProperties2KHR); end;

vkGetPhysicalDeviceProperties2KHR returns nil in LoadVulkanGlobalCommands

if (fInstance.APIVersion and VK_API_VERSION_WITHOUT_PATCH_MASK)=VK_API_VERSION_1_0 then begin fInstance.Commands.GetPhysicalDeviceFeatures2KHR(Handle,@fFeatures2KHR); end else begin fInstance.Commands.GetPhysicalDeviceFeatures2(Handle,@fFeatures2KHR); end;

Fails when fInstance.APIVersion = VK_API_VERSION_1_0 OK when GetPhysicalDeviceFeatures2 is called

VK_KHR_get_physical_device_properties2 extension NOT available on my NVIDIA RTX 3080 or Intel UHD hardware.

Vulkan API version 1.2.162. Any Suggestions??

johnhutch111 commented 2 years ago

It seems ALL the procedures with ...2KHR are returning NIL during the LoadVulcanGlobalCommands

BeRo1985 commented 2 years ago

Hm, I'm currently working with a NVIDIA Geforce RTX3070 Mobile on PasVulkan. Which NVIDIA driver version you have? I've 512.59. But I'll double check by enforcing a Vulkan 1.2 context later.

BeRo1985 commented 2 years ago

Hm, are you working with a Vulkan 1.0, 1.1, 1.2 or 1.3 context? Since vkGetPhysicalDeviceProperties2KHR does exist only at Vulkan 1.0, since it was promoted to a Core API at Vulkan 1.1, see https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceProperties2.html .

BeRo1985 commented 2 years ago

image

At my NVIDIA RTX3070 Mobile with driver version 512.59 vkGetPhysicalDeviceProperties2KHR does exist, even at >= Vulkan 1.1 contexts.

BeRo1985 commented 2 years ago

As well at my Intel Iris Xe Graphics iGPU (Intel Core i7 11370H)

BeRo1985 commented 2 years ago

image

So ignore it from LoadVulkanGlobalCommands and instead use it from LoadVulkanInstanceCommands . Vulkan is differencely layered here in this context, where not all API functions are already directly usable as global commands, but rather first later as instance commands or even later as device commands.

BeRo1985 commented 2 years ago

This also means fInstance.Commands is from LoadVulkanInstanceCommands and not from LoadVulkanGlobalCommands. So I see no issue here?

johnhutch111 commented 2 years ago

I am using the same NVIDIA driver 512.59. In my original post, the code ..

_if (fInstance.APIVersion and VK_API_VERSION_WITHOUT_PATCH_MASK)=VK_API_VERSION_10 then begin fInstance.Commands.GetPhysicalDeviceFeatures2KHR(Handle,@fFeatures2KHR); end else begin fInstance.Commands.GetPhysicalDeviceFeatures2(Handle,@fFeatures2KHR); end;

comes from pasvulkan.framework and does use fInstance.Commands as suggested. This is where the first fail is.

Shouldn't the code be something like..

if (fInstance.APIVersion and VK_API_VERSION_WITHOUT_PATCH_MASK)=VK_API_VERSION_1_0 AND Assigned(fInstance.Commands.GetPhysicalDeviceFeatures2KHR) then begin fInstance.Commands.GetPhysicalDeviceFeatures2KHR(Handle,@fFeatures2KHR); end else begin fInstance.Commands.GetPhysicalDeviceFeatures2(Handle,@fFeatures2KHR); end;

johnhutch111 commented 2 years ago

I can see why my last post won't work.

You use a lot of fInstance.APIVersion to test the current version for call availability. As this is user selected shouldn't there be another APIVersion which reflects the ACTUAL version of the API and not the user selected version. Or there needs another mechanism to handle the depricated calls.

Perhaps assigning the Procedure entry point for the new version to the old version in this case may work??

if not assigned(vkGetPhysicalDeviceProperties2KHR) then begin @vkGetPhysicalDeviceProperties2KHR:=vkVoidFunctionToPointer(vkGetProcAddress(LibVulkan,'vkGetPhysicalDeviceProperties2KHR')); If not assigned(vkGetPhysicalDeviceProperties2KHR) then @vkGetPhysicalDeviceProperties2KHR:= @vkGetPhysicalDeviceProperties2; @vk.fCommands.GetPhysicalDeviceProperties2KHR:=addr(vkGetPhysicalDeviceProperties2KHR); end;

johnhutch111 commented 2 years ago

In my system (Delphi XE8) fInstance.Commands.GetPhysicalDeviceProperties2KHR is NIL.

johnhutch111 commented 2 years ago

That fixed it. Thanks