Vulkan: Use guardedalloc for driver allocations. #104434

Merged
Jeroen Bakker merged 3 commits from Jeroen-Bakker/blender:vulkan-guardedalloc into main 2023-02-13 08:37:44 +01:00
Member

Vulkan has a pluggable memory allocation feature, which allows internal
driver allocations to be done by the client application provided
allocator. Vulkan uses this for more client application allocations
done inside the driver, but can also do it for more internal oriented
allocations.

VK_ALLOCATION_CALLBACKS initializes allocation callbacks for host allocations.
The macro creates a local static variable with the name vk_allocation_callbacks
that can be passed to vulkan API functions that expect
const VkAllocationCallbacks *pAllocator.

When WITH_VULKAN_GUARDEDALLOC=Off the memory allocation implemented
in the vulkan device driver is used for both internal and application
oriented memory operations.

For now this would help during the development of Vulkan backend to
detect hidden memory leaks that are hidden inside the driver part
of the stack. In a later stage we need to measure the overhead and
if this should become the default behavior.

#104251

Vulkan has a pluggable memory allocation feature, which allows internal driver allocations to be done by the client application provided allocator. Vulkan uses this for more client application allocations done inside the driver, but can also do it for more internal oriented allocations. VK_ALLOCATION_CALLBACKS initializes allocation callbacks for host allocations. The macro creates a local static variable with the name vk_allocation_callbacks that can be passed to vulkan API functions that expect const VkAllocationCallbacks *pAllocator. When WITH_VULKAN_GUARDEDALLOC=Off the memory allocation implemented in the vulkan device driver is used for both internal and application oriented memory operations. For now this would help during the development of Vulkan backend to detect hidden memory leaks that are hidden inside the driver part of the stack. In a later stage we need to measure the overhead and if this should become the default behavior. #104251
Jeroen Bakker added 1 commit 2023-02-07 20:57:10 +01:00
afbc14f0fc Vulkan: Use guardedalloc for driver allocations.
Vulkan has a pluggable memory allocation feature, which allows internal
driver allocations to be done by the client application provided
allocator. Vulkan uses this for more client application allocations
done inside the driver, but can also do it for more internal oriented
allocations.

VK_ALLOCATION_CALLBACKS initializes allocation callbacks for host allocations.
The macro creates a local static variable with the name vk_allocation_callbacks
that can be passed to vulkan API functions that expect
const VkAllocationCallbacks *pAllocator.

When WITH_VULKAN_GUARDEDALLOC=Off the memory allocation implemented
in the vulkan device driver is used for both internal and application
oriented memory operations.

For now this would help during the development of Vulkan backend to
detect hidden memory leaks that are hidden inside the driver part
of the stack. In a later stage we need to measure the overhead and
if this should become the default behavior.
Jeroen Bakker requested review from Clément Foucault 2023-02-07 20:57:28 +01:00
Jeroen Bakker added this to the EEVEE & Viewport project 2023-02-07 20:57:38 +01:00
Author
Member

I have looked how other applications have done this and they seemed to call a function everytime it is needed. This function can still return a nullptr to use the default behavior of the vulkan driver.

Although Macros aren't clear the main benefit of the macro is that it has less overhead to assign the function name to the memory block that is being allocated.

I have looked how other applications have done this and they seemed to call a function everytime it is needed. This function can still return a nullptr to use the default behavior of the vulkan driver. Although Macros aren't clear the main benefit of the macro is that it has less overhead to assign the function name to the memory block that is being allocated.
Jeroen Bakker self-assigned this 2023-02-08 11:04:29 +01:00
Clément Foucault approved these changes 2023-02-11 12:32:44 +01:00
Jeroen Bakker added 1 commit 2023-02-13 08:31:02 +01:00
Jeroen Bakker added 1 commit 2023-02-13 08:36:49 +01:00
Jeroen Bakker merged commit af8941e6a8 into main 2023-02-13 08:37:44 +01:00
Jeroen Bakker deleted branch vulkan-guardedalloc 2023-02-13 08:37:45 +01:00
Jeroen Bakker added this to the 3.5 milestone 2023-02-15 08:24:02 +01:00
Jeroen Bakker added the
Interest
Vulkan
label 2023-03-01 12:57:43 +01:00
Sign in to join this conversation.
No reviewers
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
2 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#104434
No description provided.