Vulkan: Enable as Experimental Option #113057

Merged
Jeroen Bakker merged 7 commits from Jeroen-Bakker/blender:vulkan/enable-as-experimental into main 2023-10-06 15:24:31 +02:00
Member

This PR enables vulkan backend as experimental option.
It will only be available in alpha builds on Linux and Windows.

This option is highly experimental and enabled to get some insight
on supported platforms. Don't expect a fully working Blender
yet. Also don't expect it to have usable performance.

What is known to not work?

  • OCIO textures are not supported on Intel and AMD GPUs. sRGB/Standard is supported
    on those platforms.
  • AMD Polaris based GPUs on Linux will generate a crash when drawing the 3d cursor as it
    doesn't support the needed vertex format. Comment out DRW_draw_cursor in DRW_draw_region_info.
  • The colors in the node editor and sequencer are of as sRGB viewports aren't detected correctly.
  • The image / UV editor isn't working as many texture formats haven't been tested yet. Some
    tweaks are also needed to do correct depth testing.
  • 3D Viewport is known to be flickering. Sometimes workbench doesn't display anything.
  • 3D Viewport wireframe will crash as it uses a framebuffer with gaps between color attachments,
    which isn't supported yet. (#113141)
  • Rotate the view widget is partially drawn due to incompatible depth clipping.
  • GPU Selection isn't working. It is expected to be solved when Overlay-Next will become the
    default engine. For now disable GPU depth picking in the preferences.
  • Cycles/EEVEE are known to not work with Vulkan yet. Cycles requires Vulkan Pixel Buffer.
    Cuda <-> Vulkan interop might require a different approach than OpenGL as Vulkan doesn't allow
    importing memory from a Cuda context. EEVEE uses features that aren't available yet in the backend
  • Workbench is working, except Workbench shadows.
  • EEVEE-Next basics are working. Shadows, lights are known to be not working. Materials/Shading
    works on a single object. Changes are expected in EEVEE-Next that will break Vulkan compatibility
    in the near future.
  • Systems with multiple GPUs is not working.
  • Wayland support is in review and should land before this PR (#113007)
  • OpenXR hasn't been modified and is expected to fail.
  • The backend is very strict when mis-using the GPU module. In debug builds it may crash
    on asserts.
  • Older drivers/GPUs might not have all the features that we require. The workarounds
    for the missing features still need to be implemented.

A word about performance

In the project planning we focus first on stability and platform support. The performance of Vulkan is
around 20% of what we want to achieve. The reason is that each command sent to the
GPU is done one at a time. The implementation even waits until we have feedback that the GPU
is idle again.

Geometry is currently stored in System RAM. The GPU will read and cache the data when
accessing geometry. This slows down when using objects with much geometry.
Some performance features like MDI (Multi-Draw-Indirect) hasn't been implemented and
falls back to Single Draw Indirect.

Why enable it is an experimental option?

  • Ensures that new features are being tested with Vulkan
  • Ensure that building with Vulkan is possible on supported platforms
  • Give feedback from developers if Vulkan can run on their system or that
    there are special cases that we are not aware of. Main development
    environment has been Linux/X11 with occasionally testing using Windows.
  • Validate Add-ons that use the gpu module.
  • Possible to enable GLSL validation on the buildbot. (Needs more work).
  • Does it compile on all machines or does it require more changes to cmake
    config. We expect it to be able to compile without installing the Vulkan SDK.
    The Vulkan SDK is a very powerful tool, but only when actually doing GPU
    development. Otherwise it is an overhead which slows down other
    activities.

How can the backend be enabled?

Currently the Vulkan backend can be enabled per Blender session by starting
with the command line argument --gpu-backend vulkan. In the future, after
the backend is proven to work, we will add a user preference to switch between
OpenGL and Vulkan.

This PR enables vulkan backend as experimental option. It will only be available in alpha builds on Linux and Windows. This option is highly experimental and enabled to get some insight on supported platforms. Don't expect a fully working Blender yet. Also don't expect it to have usable performance. **What is known to not work?** * OCIO textures are not supported on Intel and AMD GPUs. sRGB/Standard is supported on those platforms. * AMD Polaris based GPUs on Linux will generate a crash when drawing the 3d cursor as it doesn't support the needed vertex format. Comment out `DRW_draw_cursor` in `DRW_draw_region_info`. * The colors in the node editor and sequencer are of as sRGB viewports aren't detected correctly. * The image / UV editor isn't working as many texture formats haven't been tested yet. Some tweaks are also needed to do correct depth testing. * 3D Viewport is known to be flickering. Sometimes workbench doesn't display anything. * 3D Viewport wireframe will crash as it uses a framebuffer with gaps between color attachments, which isn't supported yet. (#113141) * Rotate the view widget is partially drawn due to incompatible depth clipping. * GPU Selection isn't working. It is expected to be solved when Overlay-Next will become the default engine. For now disable GPU depth picking in the preferences. * Cycles/EEVEE are known to not work with Vulkan yet. Cycles requires Vulkan Pixel Buffer. Cuda <-> Vulkan interop might require a different approach than OpenGL as Vulkan doesn't allow importing memory from a Cuda context. EEVEE uses features that aren't available yet in the backend * Workbench is working, except Workbench shadows. * EEVEE-Next basics are working. Shadows, lights are known to be not working. Materials/Shading works on a single object. Changes are expected in EEVEE-Next that will break Vulkan compatibility in the near future. * Systems with multiple GPUs is not working. * Wayland support is in review and should land before this PR (#113007) * OpenXR hasn't been modified and is expected to fail. * The backend is very strict when mis-using the GPU module. In debug builds it may crash on asserts. * Older drivers/GPUs might not have all the features that we require. The workarounds for the missing features still need to be implemented. **A word about performance** In the project planning we focus first on stability and platform support. The performance of Vulkan is around 20% of what we want to achieve. The reason is that each command sent to the GPU is done one at a time. The implementation even waits until we have feedback that the GPU is idle again. Geometry is currently stored in System RAM. The GPU will read and cache the data when accessing geometry. This slows down when using objects with much geometry. Some performance features like MDI (Multi-Draw-Indirect) hasn't been implemented and falls back to Single Draw Indirect. **Why enable it is an experimental option?** * Ensures that new features are being tested with Vulkan * Ensure that building with Vulkan is possible on supported platforms * Give feedback from developers if Vulkan can run on their system or that there are special cases that we are not aware of. Main development environment has been Linux/X11 with occasionally testing using Windows. * Validate Add-ons that use the `gpu` module. * Possible to enable GLSL validation on the buildbot. (Needs more work). * Does it compile on all machines or does it require more changes to cmake config. We expect it to be able to compile without installing the Vulkan SDK. The Vulkan SDK is a very powerful tool, but only when actually doing GPU development. Otherwise it is an overhead which slows down other activities. **How can the backend be enabled?** Currently the Vulkan backend can be enabled per Blender session by starting with the command line argument `--gpu-backend vulkan`. In the future, after the backend is proven to work, we will add a user preference to switch between OpenGL and Vulkan.
Jeroen Bakker added this to the 4.1 milestone 2023-09-29 13:41:37 +02:00
Jeroen Bakker added the
Interest
Vulkan
label 2023-09-29 13:41:37 +02:00
Jeroen Bakker self-assigned this 2023-09-29 13:41:38 +02:00
Jeroen Bakker added 1 commit 2023-09-29 13:41:50 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
4e700eb2ea
Vulkan: Enable as Experimental Option
Jeroen Bakker added a new dependency 2023-09-29 14:03:31 +02:00
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR113057) when ready.
Jeroen Bakker requested review from Brecht Van Lommel 2023-09-29 14:35:32 +02:00
Jeroen Bakker requested review from Clément Foucault 2023-09-29 14:35:42 +02:00
Jeroen Bakker requested review from Ray molenkamp 2023-09-29 14:36:02 +02:00
Jeroen Bakker requested review from Campbell Barton 2023-09-29 14:36:44 +02:00
Jeroen Bakker requested review from Bastien Montagne 2023-09-29 14:36:54 +02:00
Author
Member

I added the platform maintainers as reviewer, and Bastien as being the admin associated with the Vulkan Backend.

I added the platform maintainers as reviewer, and Bastien as being the admin associated with the Vulkan Backend.
Author
Member

Seems like the linux build is failing as it is looking for the OS vulkan library (libvulkan.so) on the buildbot worker, who might be head-less. Solution might be to use https://github.com/KhronosGroup/Vulkan-Loader or https://github.com/zeux/volk/

Volk seems like the most easy to integrate with least amount of overhead. Will integrate volk.

Seems like the linux build is failing as it is looking for the OS vulkan library (libvulkan.so) on the buildbot worker, who might be head-less. Solution might be to use https://github.com/KhronosGroup/Vulkan-Loader or https://github.com/zeux/volk/ Volk seems like the most easy to integrate with least amount of overhead. Will integrate volk.
Jeroen Bakker changed title from Vulkan: Enable as Experimental Option to WIP: Vulkan: Enable as Experimental Option 2023-09-29 15:45:26 +02:00

So this would be the equivalent of glew/epoxy? Would it be in extern/ or a new library dependency?

So this would be the equivalent of glew/epoxy? Would it be in extern/ or a new library dependency?
Brecht Van Lommel reviewed 2023-09-29 17:30:01 +02:00
@ -107,3 +105,1 @@
find_package(ShaderC REQUIRED)
find_package(Vulkan REQUIRED)
endif()
set(WITH_VULKAN_BACKEND OFF)

Generally prefer to make the option unavailable rather than silently disabling it like this.

Generally prefer to make the option unavailable rather than silently disabling it like this.
Jeroen-Bakker marked this conversation as resolved

As noted by @LazyDodo on chat, Vulkan Loader is already part of the precompiled libraries, and perhaps the only thing missing is installing the relevant shared libraries?

For Linux this would be done with add_bundled_libraries(vulkan/lib).

As noted by @LazyDodo on chat, Vulkan Loader is already part of the precompiled libraries, and perhaps the only thing missing is installing the relevant shared libraries? For Linux this would be done with `add_bundled_libraries(vulkan/lib)`.
Member

Seems like the linux build is failing as it is looking for the OS vulkan library (libvulkan.so) on the buildbot worker

That's not the OS vulkan library, that's the vulkan loader from our library folder, which we linked, but seemingly didn't copy to our bin folder just yet.

diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 8c8c88326b7..efceb17b452 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -897,6 +897,13 @@ elseif(WIN32)
     ALL
   )

+  if(WITH_VULKAN_BACKEND)
+    windows_install_shared_manifest(
+      FILES ${LIBDIR}/vulkan/bin/vulkan-1.dll
+      ALL
+    )
+  endif()
+
   if(WITH_OPENMP AND MSVC_CLANG)
     windows_install_shared_manifest(
       FILES ${CLANG_OPENMP_DLL}

will fix the issue for the windows bots, linux will need something similar brecht already posted the linux fix

> Seems like the linux build is failing as it is looking for the OS vulkan library (libvulkan.so) on the buildbot worker That's not the OS vulkan library, that's the vulkan loader from our library folder, which we linked, but seemingly didn't copy to our bin folder just yet. ``` diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 8c8c88326b7..efceb17b452 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -897,6 +897,13 @@ elseif(WIN32) ALL ) + if(WITH_VULKAN_BACKEND) + windows_install_shared_manifest( + FILES ${LIBDIR}/vulkan/bin/vulkan-1.dll + ALL + ) + endif() + if(WITH_OPENMP AND MSVC_CLANG) windows_install_shared_manifest( FILES ${CLANG_OPENMP_DLL} ``` will fix the issue for the windows bots, ~~linux will need something similar~~ brecht already posted the linux fix
Jeroen Bakker added 3 commits 2023-10-02 08:09:00 +02:00
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR113057) when ready.
Jeroen Bakker changed title from WIP: Vulkan: Enable as Experimental Option to Vulkan: Enable as Experimental Option 2023-10-02 09:31:28 +02:00
Author
Member

@brecht @LazyDodo yes that seems to work! Thanks.

@brecht @LazyDodo yes that seems to work! Thanks.
Jeroen Bakker added this to the EEVEE & Viewport project 2023-10-02 09:47:44 +02:00
Brecht Van Lommel approved these changes 2023-10-02 11:13:27 +02:00
Author
Member

I downloaded the windows build on a laptop, but it couldn't find a suitable vulkan device. Will look in more depth why it couldn't detect the device.

I downloaded the windows build on a laptop, but it couldn't find a suitable vulkan device. Will look in more depth why it couldn't detect the device.
Member

I downloaded the windows build on a laptop, but it couldn't find a suitable vulkan device. Will look in more depth why it couldn't detect the device.

"Works for me", downloaded the build off the bots and blender started just fine (validated it was using vulkan by switching to wireframe mode to make it crash), whatever it is must be local to your laptop. Then again odds are whatever is happening may be happening on other systems as well, any diagnostics you could add there would help future triagers.

> I downloaded the windows build on a laptop, but it couldn't find a suitable vulkan device. Will look in more depth why it couldn't detect the device. "Works for me", downloaded the build off the bots and blender started just fine (validated it was using vulkan by switching to wireframe mode to make it crash), whatever it is must be local to your laptop. Then again odds are whatever is happening may be happening on other systems as well, any diagnostics you could add there would help future triagers.
Ray molenkamp requested changes 2023-10-02 15:30:57 +02:00
CMakeLists.txt Outdated
@ -805,0 +803,4 @@
WITH_VULKAN_BACKEND
WITH_VULKAN_GUARDEDALLOC
)
else()
Member

not needed, we don't do this for other variables like the wayland stuff either, any non existent variable is equal to false in cmake.

not needed, we don't do this for other variables like the wayland stuff either, any non existent variable is equal to false in cmake.
Jeroen-Bakker marked this conversation as resolved
@ -46,6 +46,9 @@ else()
endif()
endif()
if (NOT WITH_EXPERIMENTAL_FEATURES)
Member

Code is duplicated between the linux and windows platform file, there must be a better place for this

Code is duplicated between the linux and windows platform file, there must be a better place for this
Jeroen-Bakker marked this conversation as resolved
Jeroen Bakker added 1 commit 2023-10-03 07:42:11 +02:00
Author
Member

I found out that the platform I used doesn't support VK_KHR_maintenance4 which was added for performance reasons.
Seems like we need to only enable this when it is available. Can be fixed by updating drivers. Currently around 20% of all platforms
support this extension. Which is fine as it also counts platforms that existed before this extension was introduced :-)

https://vulkan.gpuinfo.org/listdevicescoverage.php?extensionname=VK_KHR_maintenance4&extensionfeature=maintenance4&platform=all

I found out that the platform I used doesn't support `VK_KHR_maintenance4` which was added for performance reasons. Seems like we need to only enable this when it is available. Can be fixed by updating drivers. Currently around 20% of all platforms support this extension. Which is fine as it also counts platforms that existed before this extension was introduced :-) https://vulkan.gpuinfo.org/listdevicescoverage.php?extensionname=VK_KHR_maintenance4&extensionfeature=maintenance4&platform=all
Member

I found out that the platform I used doesn't support VK_KHR_maintenance4 which was added for performance reasons.
Seems like we need to only enable this when it is available. Can be fixed by updating drivers. Currently around 20% of all platforms
support this extension. Which is fine as it also counts platforms that existed before this extension was introduced :-)

https://vulkan.gpuinfo.org/listdevicescoverage.php?extensionname=VK_KHR_maintenance4&extensionfeature=maintenance4&platform=all

I'm a bit confused on the actual solution you are suggesting here, is it

a) update your drivers, we need VK_KHR_maintenance4 otherwise blender won't run, in which case we need to communicate this with the users, ie a popup going "no, sorry" beats a crash.

b) We shouldn't rely on it, unless it's available, we'll fix the code so it's used when available, and if not, no big deal blender will still run (although it's best to update your drivers for optimal performance) ?

> I found out that the platform I used doesn't support `VK_KHR_maintenance4` which was added for performance reasons. > Seems like we need to only enable this when it is available. Can be fixed by updating drivers. Currently around 20% of all platforms > support this extension. Which is fine as it also counts platforms that existed before this extension was introduced :-) > > https://vulkan.gpuinfo.org/listdevicescoverage.php?extensionname=VK_KHR_maintenance4&extensionfeature=maintenance4&platform=all I'm a bit confused on the actual solution you are suggesting here, is it a) update your drivers, we need `VK_KHR_maintenance4` otherwise blender won't run, in which case we need to communicate this with the users, ie a popup going "no, sorry" beats a crash. b) We shouldn't rely on it, unless it's available, we'll fix the code so it's used when available, and if not, no big deal blender will still run (although it's _best_ to update your drivers for optimal performance) ?
Author
Member

b) We shouldn't rely on it, unless it's available, we'll fix the code so it's used when available, and if not, no big deal blender will still run (although it's best to update your drivers for optimal performance) ?

This one. Still need to test on a not supporting device (#113239)

> b) We shouldn't rely on it, unless it's available, we'll fix the code so it's used when available, and if not, no big deal blender will still run (although it's _best_ to update your drivers for optimal performance) ? This one. Still need to test on a not supporting device (#113239)
Jeroen Bakker added 1 commit 2023-10-05 13:41:29 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
2cb3dd62d1
Merge branch 'main' into vulkan/enable-as-experimental
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR113057) when ready.
Author
Member

Running on Intel Iris Plus (Vulkan 1.2)

image

Running on Intel Iris Plus (Vulkan 1.2) ![image](/attachments/35bd8483-8500-4566-9de1-5d25b8c7aa09)
3.1 MiB
Ray molenkamp approved these changes 2023-10-05 17:04:49 +02:00
Clément Foucault approved these changes 2023-10-06 14:50:09 +02:00
Jeroen Bakker added 1 commit 2023-10-06 14:51:34 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
265e19ec4a
Merge branch 'main' into vulkan/enable-as-experimental
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR113057) when ready.
Jeroen Bakker merged commit 1aca58cf16 into main 2023-10-06 15:24:31 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Depends on
Reference: blender/blender#113057
No description provided.