GHOST Vulkan Backend API. #93031

Closed
opened 2021-11-12 09:20:31 +01:00 by Jeroen Bakker · 8 comments
Member

Supported backends

  • GHOST_SystemSDL
  • GHOST_SystemWayland
  • GHOST_SystemWin32
  • GHOST_SystemX11
  • GHOST_SystemCocoa: using vulkan metal wrapper.

Compile directive

There will be a new compile directive WITH_VULKAN_BACKEND this compile directive will enable adding vulkan context in ghost backend systems.

Creating a vulkan context
Vulkan contexts can be created by passing GHOST_kDrawingContextTypeVulkan when creating window/context.

Device selection
There can be multiple vulkan compatible devices inside a system. User should be able to select a device via the user preferences. When selecting a different device blender should be restarted by the user. When no specific device is selected a best matching device should be selected.

GHOST_VulkanDeviceListHandle* GHOST_GetVulkanAvailableDevices(GHOST_SystemHandle,...): returns a list of all devices that match requirements. When constructing a window/context a specific device should be given.
int64_t GHOST_VulkanDeviceListNumDevices(GHOST_VulkanDeviceListHandle* handle) will return the number of devices found
GHOST_Success GHOST_GetVulkanDeviceListItem(GHOST_VulkanDeviceListHandle* handle, int64_t index, GHOST_VulkanPhysicalDevice * r_device) will fill r_device with available data return the vendor and device id and a number to make the device unique.
GHOST_DestroyVulkanDeviceList should be called to free the GHOST_VulkanDeviceListHandle.

GHOST_VulkanPhysicalDevice is based on VkPhysicalDeviceProperties but has a additional attribute to make the Vendor+Device unique. the combination of those 3 fields will allow to select a unique device.

struct GHOST_VulkanPhysicalDeviceID {
  uint32_t vendor_id;
  uint32_t device_id;
  int32_t index;
};

struct GHOST_VulkanPhysicalDevice {
  GHOST_VulkanPhysicalDeviceID device_id;
  VkPhysicalDeviceProperties device_properties;
};

GHOST_GLSettings will get an GHOST_VulkanPhysicalDeviceID* attribute for device selection.
When NULL is passed for GHOST_VulkanPhysicalDeviceID or the passed device couldn't be found during context creation GHOST will automatically select the best available device based on the device type (discrete before integrated before virtual [before cpu?]).

NOTE: The VkQueryAPI requires an VkInstance. So we can only do this on an initialized GHOST_Context We could use a offscreen context for this.

Command queues
GHOST_GetVulkanBackbuffer(GHOST_WindowHandle will get the handles of the given window.
For offscreen rendering GHOST_GetVulkanHandles will retrieve the device handles and the command queue etc should be constructed by the caller.

Smaller tasks

  • Remove references to OpenGL in the GHOST API that are not OpenGL specific.
    rename GHOST_CreateOpenGLContext to GHOST_CreateDrawingContext. rename GHOST_DisposeOpenGLContext to GHOST_DisposeDrawingContext.
    rename GHOST_ActivateOpenGLContext to GHOST_ActivateDrawingContext. rename GHOST_ReleaseOpenGLContext to GHOST_ReleaseDrawingContext.
    ** Unclear if we need to rename GHOST_GetDefaultOpenGLFramebuffer and GHOST_GetContextDefaultOpenGLFramebuffer or that we will have specific versions for Vulkan.
## Supported backends * GHOST_SystemSDL * GHOST_SystemWayland * GHOST_SystemWin32 * GHOST_SystemX11 * GHOST_SystemCocoa: using vulkan metal wrapper. ## Compile directive There will be a new compile directive `WITH_VULKAN_BACKEND` this compile directive will enable adding vulkan context in ghost backend systems. **Creating a vulkan context** Vulkan contexts can be created by passing `GHOST_kDrawingContextTypeVulkan` when creating window/context. **Device selection** There can be multiple vulkan compatible devices inside a system. User should be able to select a device via the user preferences. When selecting a different device blender should be restarted by the user. When no specific device is selected a best matching device should be selected. `GHOST_VulkanDeviceListHandle* GHOST_GetVulkanAvailableDevices(GHOST_SystemHandle,...)`: returns a list of all devices that match requirements. When constructing a window/context a specific device should be given. `int64_t GHOST_VulkanDeviceListNumDevices(GHOST_VulkanDeviceListHandle* handle)` will return the number of devices found `GHOST_Success GHOST_GetVulkanDeviceListItem(GHOST_VulkanDeviceListHandle* handle, int64_t index, GHOST_VulkanPhysicalDevice * r_device)` will fill r_device with available data return the vendor and device id and a number to make the device unique. `GHOST_DestroyVulkanDeviceList` should be called to free the GHOST_VulkanDeviceListHandle. `GHOST_VulkanPhysicalDevice` is based on `VkPhysicalDeviceProperties` but has a additional attribute to make the Vendor+Device unique. the combination of those 3 fields will allow to select a unique device. ``` struct GHOST_VulkanPhysicalDeviceID { uint32_t vendor_id; uint32_t device_id; int32_t index; }; struct GHOST_VulkanPhysicalDevice { GHOST_VulkanPhysicalDeviceID device_id; VkPhysicalDeviceProperties device_properties; }; ``` `GHOST_GLSettings` will get an `GHOST_VulkanPhysicalDeviceID*` attribute for device selection. When `NULL` is passed for GHOST_VulkanPhysicalDeviceID or the passed device couldn't be found during context creation GHOST will automatically select the best available device based on the device type (discrete before integrated before virtual [before cpu?]). NOTE: The VkQueryAPI requires an VkInstance. So we can only do this on an initialized GHOST_Context We could use a offscreen context for this. **Command queues** `GHOST_GetVulkanBackbuffer(GHOST_WindowHandle` will get the handles of the given window. For offscreen rendering `GHOST_GetVulkanHandles` will retrieve the device handles and the command queue etc should be constructed by the caller. ## Smaller tasks * Remove references to OpenGL in the GHOST API that are not OpenGL specific. **rename `GHOST_CreateOpenGLContext` to `GHOST_CreateDrawingContext`.** rename `GHOST_DisposeOpenGLContext` to `GHOST_DisposeDrawingContext`. **rename `GHOST_ActivateOpenGLContext` to `GHOST_ActivateDrawingContext`.** rename `GHOST_ReleaseOpenGLContext` to `GHOST_ReleaseDrawingContext`. ** Unclear if we need to rename `GHOST_GetDefaultOpenGLFramebuffer` and `GHOST_GetContextDefaultOpenGLFramebuffer` or that we will have specific versions for Vulkan.
Jeroen Bakker self-assigned this 2021-11-12 09:20:31 +01:00
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

Added subscriber: @Jeroen-Bakker

Added subscriber: @Jeroen-Bakker

Added subscriber: @GeorgiaPacific

Added subscriber: @GeorgiaPacific

Added subscriber: @Lain-Iwakura

Added subscriber: @Lain-Iwakura
Jeroen Bakker removed their assignment 2022-02-14 15:34:51 +01:00

Added subscriber: @Emi_Martinez

Added subscriber: @Emi_Martinez
Contributor

Added subscriber: @vnapdv

Added subscriber: @vnapdv

Added subscriber: @fanny

Added subscriber: @fanny

This issue was referenced by 6dac345a64

This issue was referenced by 6dac345a64b1ab6d58ce838e9acd7f09af43a77f
Jeroen Bakker self-assigned this 2022-11-25 10:34:13 +01:00
Philipp Oeser removed the
Interest
EEVEE & Viewport
label 2023-02-09 15:13:05 +01:00
Blender Bot added
Status
Archived
and removed
Status
Confirmed
labels 2023-02-17 22:20:27 +01: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 project
No Assignees
7 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#93031
No description provided.