FidelityFX-SDK icon indicating copy to clipboard operation
FidelityFX-SDK copied to clipboard

amd_fidelityfx_vk null exception while creating context

Open cdozdil opened this issue 1 year ago • 7 comments

Hello,

I was testing Vulkan backend but keep getting access violation error on this line at ffx_vk.cpp. After changing this line on same file as below problem dissapeared for me.

backendContext->vkFunctionTable.vkGetBufferMemoryRequirements2KHR = (PFN_vkGetBufferMemoryRequirements2KHR)vkDeviceContext->vkDeviceProcAddr(backendContext->device, "vkGetBufferMemoryRequirements2");

cdozdil avatar Jul 09 '24 22:07 cdozdil

With pull request #77 I have tried to solve this and one another extension issue I have noticed.

cdozdil avatar Jul 16 '24 08:07 cdozdil

Hello! You might need to load the extension VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME to make it works. But as you have pointed out in your merge request, this function is now in core Vulkan 1.1. Maybe this function should always be used (assuming Vulkan 1.1 is supported)?

lordOznek avatar Aug 29 '24 07:08 lordOznek

vkGetBufferMemoryRequirements2KHR on my RTX3080Ti is NULL vkGetBufferMemoryRequirements2 is defined

->

vkGetBufferMemoryRequirements2KHR = vkGetBufferMemoryRequirements2; // After vulkan initialisation

HerveRV avatar Aug 29 '24 13:08 HerveRV

With the latest driver, your GPU has this extension available. Please refer to https://vulkan.gpuinfo.org/displayreport.php?id=32759#extensions

Have you make sure the extension is loaded during device creation (see VkDeviceCreateInfo::ppEnabledExenstionNames)?

lordOznek avatar Aug 29 '24 13:08 lordOznek

I use Volk for vulkan initialisation, i think it doesn"t fill all the functions. But i override the vkDeviceProcAddr function in ffx::CreateBackendVKDesc BackendVKDesc, and it solved all my FSR problems (but not the framegeneration crash at this time :D)

I give you the information in case off it can help you...

HerveRV avatar Aug 29 '24 13:08 HerveRV

Hi,

Thanks for advice, as far I as remeber FSR3.1 upscaler uses 4 (2 or 3 of them for debugging) Vulkan extensions and last time when I have checked they weren't listed in the docs at all. So it might be better if AMD add this info to FSR docs to prevent confusion.

Hello! You might need to load the extension VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME to make it works. But as you have pointed out in your merge request, this function is now in core Vulkan 1.1. Maybe this function should always be used (assuming Vulkan 1.1 is supported)?

cdozdil avatar Aug 31 '24 20:08 cdozdil

If you want to fix this without modifying FidelityFX source:

PFN_vkVoidFunction VKAPI_PTR CustomVulkanDeviceProcAddr(VkDevice device, const char* pName)
{
    // Brixelizer uses an old version of this function:
    // https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/issues/73
    // So we patch it with the correct one.
    if (strcmp(pName, "vkGetBufferMemoryRequirements2KHR") == 0)
        return reinterpret_cast<PFN_vkVoidFunction>(vkGetBufferMemoryRequirements2);

    // Forward as normal.
    return vkGetDeviceProcAddr(device, pName);
} 

And

VkDeviceContext ffxDeviceContext {};
{
    ffxDeviceContext.vkDevice = ...
    ffxDeviceContext.vkPhysicalDevice  = ...
    ffxDeviceContext.vkDeviceProcAddr = CustomVulkanDeviceProcAddr;
}
auto ffxDevice = ffxGetDeviceVK(&ffxDeviceContext);

IMO the real fix should be provided by volk to auto-resolve all the diverging EXT/KHR/Default vulkan function pointers which is becoming a bit messy.

parsaiej avatar Oct 06 '24 00:10 parsaiej