RobertBeckebans / RBDOOM-3-BFG

Doom 3 BFG Edition source port with updated DX12 / Vulkan renderer and modern game engine features
https://www.moddb.com/mods/rbdoom-3-bfg
GNU General Public License v3.0
1.38k stars 247 forks source link

Linux - Failed to create a Vulkan physical device, error code = VK_ERROR_FEATURE_NOT_PRESENT #804

Open mbugni opened 8 months ago

mbugni commented 8 months ago

After successful compilation of v1.5.1 on Linux (Fedora 38) I'm facing this error on starting the executable (I'm reporting only the relevant part):

----- R_InitOpenGL -----
Initializing Vulkan subsystem
Enabled Vulkan instance extensions:
    VK_EXT_debug_utils
    VK_KHR_xlib_surface
    VK_KHR_surface
    VK_KHR_get_physical_device_properties2
Enabled Vulkan layers:
Enabled Vulkan device extensions:
    VK_KHR_fragment_shading_rate
    VK_KHR_buffer_device_address
    VK_EXT_descriptor_indexing
    VK_KHR_maintenance1
    VK_KHR_synchronization2
    VK_KHR_swapchain
Sys_Error: Failed to create a Vulkan physical device, error code = VK_ERROR_FEATURE_NOT_PRESENT

Honestly, I don't understand what it means, but I think my Intel GPU lacks some feature. I attached my Vulkan info for details.

vulkaninfo.txt

In your Mod DB description about NVRHI you say:

It is not tied to Nvidia GPUs but also works with AMD and Intel drivers.

What Intel models are supported? I'm interested in testing it for Linux, but I need to know if my device is supported.

Calinou commented 8 months ago

Ice Lake IGPs on an up-to-date distribution should be fully Vulkan 1.3 compliant. That said, keep in mind RBDOOM-3-BFG is high-end oriented, so even if it was able to boot, it probably won't run well on your system. This is probably why only compatibility with dedicated GPUs is advertised.

To play on integrated graphics, stick to version 1.4.0 or older which use OpenGL and a more limited renderer.

mbugni commented 8 months ago

Ice Lake IGPs on an up-to-date distribution should be fully Vulkan 1.3 compliant

From my Vulkan info:

Vulkan Instance Version: 1.3.243

To play on integrated graphics, stick to version 1.4.0 or older which use OpenGL and a more limited renderer

Yes, I compiled the v1.4.0 and it works well on my machine, but I think it will not be maintained anymore, isn't it?

Calinou commented 8 months ago

Yes, I compiled the v1.4.0 and it works well on my machine, but I think it will not be maintained anymore, isn't it?

1.4.0 won't be maintained anymore, but it should keep working well enough for the foreseeable future.

mbugni commented 8 months ago

Ice Lake IGPs on an up-to-date distribution should be fully Vulkan 1.3 compliant. That said, keep in mind RBDOOM-3-BFG is high-end oriented, so even if it was able to boot, it probably won't run well on your system.

By using OpenGL, I get it working with both native compilation and flatpak app. Why it should not work using Vulkan? Is Vulkan less efficient or there are new features harder to run?

SRSaunders commented 7 months ago

Just having a look at this now, and thanks for posting your vulkaninfo.txt file. The problem is your Intel GPU and/or driver is missing the shaderStorageImageReadWithoutFormat feature. This was added to eliminate Vulkan validation errors with the new compute shaders (ssao, mipmapgen, histogram, exposure, taa).

This should be relatively easy to fix by testing for the shaderStorageImageReadWithoutFormat feature before enabling it, or possibly enabling the VK_KHR_format_feature_flags2 extension and activating VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT for images and/or buffers used by the shaders in question.

Is this still an issue for you and do you need it fixed? Or have you moved permanently to the legacy OpenGL version?

Note: If you just want to try this out on your system, you can comment out the line containing
.setShaderStorageImageReadWithoutFormat( true ) inside DeviceManager_VK.cpp

mbugni commented 7 months ago

This should be relatively easy to fix by testing for the shaderStorageImageReadWithoutFormat feature before enabling it, or possibly enabling the VK_KHR_format_feature_flags2 extension and activating VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT for images and/or buffers used by the shaders in question.

Is this still an issue for you and do you need it fixed? Or have you moved permanently to the legacy OpenGL version?

My goal was to build a Flatpak release using latest version. But I did it by using the OpenGL version because I couldn't run latest.

Note: If you just want to try this out on your system, you can comment out the line containing .setShaderStorageImageReadWithoutFormat( true ) inside DeviceManager_VK.cpp

Thanks for the suggestion! I'll give a try again to latest version and check if it works.

Anyway, I think the "issue" is to make it working with most GPU as possible.

SRSaunders commented 7 months ago

Thanks for the feedback. First let me know if the workaround solves the problem with your Intel GPU. If so we can proceed from there.

SRSaunders commented 7 months ago

I disabled my AMD discrete GPU and was able to duplicate this issue on my Intel UHD 630 Integrated GPU. Pull request #818 now contains a fix - see the final commit. The performance isn't very good in my case, but at least it runs.

mbugni commented 7 months ago

Hi @SRSaunders, I tried to build your push-constants branch, but I faced this error:

[ 94%] Building CXX object CMakeFiles/RBDoom3BFG.dir/sys/DeviceManager.cpp.o
[ 94%] Building CXX object CMakeFiles/RBDoom3BFG.dir/sys/DeviceManager_VK.cpp.o
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/sys/DeviceManager_VK.cpp:228:25: error: ‘VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME’ was not declared in this scope; did you mean ‘VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME’?
  228 |                         VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                         VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/sys/DeviceManager_VK.cpp:231:9: error: could not convert ‘{"VK_EXT_debug_marker", "VK_EXT_descriptor_indexing", "VK_KHR_buffer_device_address", "VK_NV_mesh_shader", "VK_KHR_fragment_shading_rate", <expression error>, "VK_KHR_synchronization2"}’ from ‘<brace-enclosed initializer list>’ to ‘std::unordered_set<std::__cxx11::basic_string<char> >’
  231 |         };
      |         ^
      |         |
      |         <brace-enclosed initializer list>
make[2]: *** [CMakeFiles/RBDoom3BFG.dir/build.make:7720: CMakeFiles/RBDoom3BFG.dir/sys/DeviceManager_VK.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:260: CMakeFiles/RBDoom3BFG.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

As suggested, I replaced VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME <-> VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME. I don't know if that is the right thing to do, anyway build finished. But when I tried to start the game I got:

...
----- R_InitOpenGL -----
r_vidMode reset from 10 to 0.
Initializing Vulkan subsystem
Enabled Vulkan instance extensions:
    VK_EXT_debug_utils
    VK_KHR_xlib_surface
    VK_KHR_surface
    VK_KHR_get_physical_device_properties2
Enabled Vulkan layers:
Enabled Vulkan device extensions:
    VK_KHR_fragment_shading_rate
    VK_KHR_create_renderpass2
    VK_KHR_buffer_device_address
    VK_EXT_descriptor_indexing
    VK_KHR_maintenance1
    VK_KHR_synchronization2
    VK_KHR_swapchain
Unknown command 'vid_restart'
Sys_Error: Failed to create a Vulkan physical device, error code = VK_ERROR_FEATURE_NOT_PRESENT

So I tried to comment out both lines:

// VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME,
...
//.setShaderStorageImageReadWithoutFormat( actualDeviceFeatures.shaderStorageImageReadWithoutFormat )

But now I'm getting:

----- R_InitOpenGL -----
r_vidMode reset from 10 to 0.
Initializing Vulkan subsystem
Enabled Vulkan instance extensions:
    VK_EXT_debug_utils
    VK_KHR_xlib_surface
    VK_KHR_surface
    VK_KHR_get_physical_device_properties2
Enabled Vulkan layers:
Enabled Vulkan device extensions:
    VK_KHR_fragment_shading_rate
    VK_KHR_buffer_device_address
    VK_EXT_descriptor_indexing
    VK_KHR_maintenance1
    VK_KHR_synchronization2
    VK_KHR_swapchain
Unknown command 'vid_restart'
Sys_Error: Failed to create a Vulkan physical device, error code = VK_ERROR_FEATURE_NOT_PRESENT
SRSaunders commented 7 months ago

First of all, make sure the Khronos Validation Layer is installed. It seems to be missing according to your vulkaninfo.txt

Then add the following line to your autoexec.cfg file in \~/.local/share/rbdoom3bfg/base/

set r_useValidationLayers 2

Run the game using your last working build and report back with the console output. Thanks.

FYI - The only line you need to comment out is: VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME. This was my mistake since I thought it was defined universally for modern Vulkan SDK versions. I will have to add a guard to this extension name to prevent compile failures on Linux. No big deal. The more confusing issue is your device support - your Intel Ice Lake iGPU should be better than my Intel Coffee Lake iGPU. I'm not sure what is different on your machine but the Validation Layer messages should help.

UPDATE: I believe I have finally found the issue by looking deeper into your vulkaninfo.txt: Interestingly your GPU/driver supports VK_KHR_fragment_shading_rate, but does not support the primitiveFragmentShadingRate nor attachmentFragmentShadingRate features requested by the game. As a short term workaround please comment out the line that says vrsSupported = true in the same DeviceManager_VK.cpp file. I am hoping this solves it, but I will have to think about how to address the issue on a permanent basis. Let me know your results.

UPDATE 2: Fix for both issues (VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME guard and individual activation of VK_KHR_fragment_shading_rate features) now pushed to PR #818. No more edits should be required. If you use this PR, for full performance please make sure you also apply the nvrhi patch as linked in the description.

mbugni commented 7 months ago

UPDATE 2: Fix for both issues (VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME guard and individual activation of VK_KHR_fragment_shading_rate features) now pushed to PR #818. No more edits should be required. If you use this PR, for full performance please make sure you also apply the nvrhi patch as linked in the description.

If I build from branch, no patches, it compile and works. Performance are around one-half than OpenGL version. If I apply the suggested patch (I replaced this file, hope it's right), it fails to build:

[ 12%] Building CXX object extern/nvrhi/CMakeFiles/nvrhi.dir/src/validation/validation-device.cpp.o
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/src/validation/validation-device.cpp: In function ‘nvrhi::DeviceHandle nvrhi::validation::createValidationLayer(nvrhi::IDevice*)’:
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/src/validation/validation-device.cpp:34:68: error: invalid new-expression of abstract class type ‘nvrhi::validation::DeviceWrapper’
   34 |         DeviceWrapper* wrapper = new DeviceWrapper(underlyingDevice);
      |                                                                    ^
In file included from /live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/src/validation/validation-device.cpp:23:
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/src/validation/validation-backend.h:221:11: note:   because the following virtual functions are pure within ‘nvrhi::validation::DeviceWrapper’:
  221 |     class DeviceWrapper : public RefCounter<IDevice>
      |           ^~~~~~~~~~~~~
In file included from /live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/include/nvrhi/validation.h:25,
                 from /live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/src/validation/validation-backend.h:25:
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/include/nvrhi/nvrhi.h:2722:43: note:     ‘virtual nvrhi::rt::OpacityMicromapHandle nvrhi::IDevice::createOpacityMicromap(const nvrhi::rt::OpacityMicromapDesc&)’
 2722 |         virtual rt::OpacityMicromapHandle createOpacityMicromap(const rt::OpacityMicromapDesc& desc) = 0;
      |                                           ^~~~~~~~~~~~~~~~~~~~~
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/src/validation/validation-device.cpp: In member function ‘virtual nvrhi::CommandListHandle nvrhi::validation::DeviceWrapper::createCommandList(const nvrhi::CommandListParameters&)’:
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/src/validation/validation-device.cpp:1734:130: error: invalid new-expression of abstract class type ‘nvrhi::validation::CommandListWrapper’
 1734 |         CommandListWrapper* wrapper = new CommandListWrapper(this, commandList, params.enableImmediateExecution, params.queueType);
      |                                                                                                                                  ^
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/src/validation/validation-backend.h:100:11: note:   because the following virtual functions are pure within ‘nvrhi::validation::CommandListWrapper’:
  100 |     class CommandListWrapper : public RefCounter<ICommandList>
      |           ^~~~~~~~~~~~~~~~~~
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/include/nvrhi/nvrhi.h:2573:22: note:     ‘virtual void nvrhi::ICommandList::drawIndexedIndirect(uint32_t, uint32_t)’
 2573 |         virtual void drawIndexedIndirect(uint32_t offsetBytes, uint32_t drawCount = 1) = 0;
      |                      ^~~~~~~~~~~~~~~~~~~
/live/github/flatpak/RBDOOM-3-BFG-vulkan/neo/extern/nvrhi/include/nvrhi/nvrhi.h:2585:22: note:     ‘virtual void nvrhi::ICommandList::buildOpacityMicromap(nvrhi::rt::IOpacityMicromap*, const nvrhi::rt::OpacityMicromapDesc&)’
 2585 |         virtual void buildOpacityMicromap(rt::IOpacityMicromap* omm, const rt::OpacityMicromapDesc& desc) = 0;
      |                      ^~~~~~~~~~~~~~~~~~~~
make[2]: *** [extern/nvrhi/CMakeFiles/nvrhi.dir/build.make:160: extern/nvrhi/CMakeFiles/nvrhi.dir/src/validation/validation-device.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:312: extern/nvrhi/CMakeFiles/nvrhi.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
SRSaunders commented 7 months ago

Good news on the RBDoom3BFG branch fixes. I am not surprised with the lower performance of the new Vulkan version vs. OpenGL on your Intel iGPU. There is a lot more going on lighting-wise with the new stream and iGPUs are not ideal for this. However, I think it's still interesting for you to try with an updated nvrhi installation.

FYI - the way you updated the nvrhi.h file will not work. Note RBDoom3BFG's version of nvrhi is not the repository head, but detached at https://github.com/RobertBeckebans/nvrhi/commit/1cbc9e9d16f997948c429739b1a1886fb4d0c796. The file you used is the head version with my changes applied, which is incorrect and won't work.

You can do either of the following:

  1. Restore the nvrhi.h file using git restore <install_dir>/neo/extern/nvrhi/include/nvrhi/nvrhi.h and then manually apply my changes at https://github.com/RobertBeckebans/nvrhi/pull/6/files (or via patch file at https://patch-diff.githubusercontent.com/raw/RobertBeckebans/nvrhi/pull/6.patch), or
  2. Bring your installed nvrhi directory up to the head version using git checkout main, and then apply the following two patches: https://github.com/RobertBeckebans/nvrhi/pull/4 and https://github.com/RobertBeckebans/nvrhi/pull/6

I think option 1 is easier and less likely to break. Try it out and let me know if performance is any better. I suspect it will be similar since push constants are already limited to 128 bytes for Intel iGPUs/drivers on Linux.

mbugni commented 7 months ago

I think I applyed the patch correctly this time and the build succeded, but performance didn't changed. I tryed to increase/decrease the c_MaxPushConstantSize in #else branch without success. I'll monitor the PR #818, when it will be merged maybe I'll try again.

SRSaunders commented 6 months ago

Changing the c_MaxPushConstantSize above what is in the patch will not do anything. You should revert that change.

I have just pushed my final commit for that branch which helps with performance for more powerful Nvidia and AMD discrete GPUs, but may not help with your Intel Ice Lake iGPU. You can try it but my testing did not show much benefit for my Coffee Lake iGPU.

RBDoom3BFG uses advanced lighting and rendering techniques which benefit from a discrete GPU with dedicated graphics memory, with the exception of the new M-series Apple Silicon GPUs which seem to perform well with this PR. The game will run on an Intel iGPU with shared system memory, just not that well. You can try turning off features in the System Options, or run at a lower resolution.