ngscopeclient 0.1-dev+51fbda87c
Classes | Typedefs | Enumerations | Functions | Variables
AcceleratorBuffer.h File Reference

Declaration of AcceleratorBuffer. More...

#include "AlignedAllocator.h"
#include "QueueManager.h"
#include <sys/mman.h>
#include <unistd.h>
#include <type_traits>
Include dependency graph for AcceleratorBuffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  AcceleratorBufferIterator< T >
 
class  AcceleratorBuffer< T >
 A buffer of memory which may be used by GPU acceleration. More...
 

Typedefs

typedef bool(* MemoryPressureHandler) (MemoryPressureLevel level, MemoryPressureType type, size_t requestedSize)
 Memory pressure handler type, called when free memory reaches a warning level or a Vulkan allocation fails.
 

Enumerations

enum class  MemoryPressureLevel { Hard , Soft }
 Levels of memory pressure. More...
 
enum class  MemoryPressureType { Host , Device }
 Types of memory pressure. More...
 

Functions

bool OnMemoryPressure (MemoryPressureLevel level, MemoryPressureType type, size_t requestedSize)
 Called when we run low on memory. More...
 
template<class T >
std::ptrdiff_t operator- (const AcceleratorBufferIterator< T > &a, const AcceleratorBufferIterator< T > &b)
 

Variables

uint32_t g_vkPinnedMemoryType
 Vulkan memory type for CPU-based memory that is also GPU-readable.
 
uint32_t g_vkLocalMemoryType
 Vulkan memory type for GPU-based memory (generally not CPU-readable, except on unified memory systems)
 
std::shared_ptr< vk::raii::Deviceg_vkComputeDevice
 The Vulkan device selected for compute operations (may or may not be same device as rendering)
 
std::unique_ptr< vk::raii::CommandBuffer > g_vkTransferCommandBuffer
 Command buffer for AcceleratorBuffer transfers. More...
 
std::shared_ptr< QueueHandleg_vkTransferQueue
 Queue for AcceleratorBuffer transfers. More...
 
std::mutex g_vkTransferMutex
 Mutex for interlocking access to g_vkTransferCommandBuffer and g_vkTransferCommandPool.
 
bool g_hasDebugUtils
 Indicates whether the VK_EXT_debug_utils extension is available.
 
bool g_vulkanDeviceHasUnifiedMemory
 Indicates whether the Vulkan device is unified memory. More...
 
std::set< MemoryPressureHandlerg_memoryPressureHandlers
 List of handlers for low memory registered by various subsystems.
 

Detailed Description

Declaration of AcceleratorBuffer.

Author
Andrew D. Zonenberg

Enumeration Type Documentation

◆ MemoryPressureLevel

enum class MemoryPressureLevel
strong

Levels of memory pressure.

Enumerator
Hard 

A memory allocation has failed and we need to free memory immediately to continue execution.

Soft 

Free memory has reached a warning threshold.

We should trim caches or otherwise try to make space but don't need to be too aggressive about it.

This level is only available if we have VK_EXT_memory_budget; without this extension we do not know about memory pressure until a hard allocation failure occurs.

◆ MemoryPressureType

enum class MemoryPressureType
strong

Types of memory pressure.

Enumerator
Host 

Pinned CPU-side memory.

Device 

GPU-side memory.

Function Documentation

◆ OnMemoryPressure()

bool OnMemoryPressure ( MemoryPressureLevel  level,
MemoryPressureType  type,
size_t  requestedSize 
)

Called when we run low on memory.

Parameters
levelIndicates if this is a soft or hard memory exhaustion condition
typeIndicates if we are low on CPU or GPU memory
requestedSizeFor hard memory exhaustion, the size of the failing allocation. For soft exhaustion, ignored and set to zero
Returns
True if memory was freed, false if no space could be freed