Blender V5.3
GHOST_ContextVK.cc File Reference
#include <vulkan/vulkan_core.h>
#include "volk.h"
#include "GHOST_ContextVK.hh"
#include "GHOST_Types.hh"
#include "vulkan/vk_ghost_api.hh"
#include "vk_mem_alloc.h"
#include "CLG_log.h"
#include "BLI_string_ref.hh"
#include "BLI_vector.hh"
#include <algorithm>
#include <array>
#include <cassert>
#include <cinttypes>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <mutex>
#include <optional>
#include <sstream>
#include <vector>
#include <sys/stat.h>

Go to the source code of this file.

Classes

struct  GHOST_ExtensionsVK
class  GHOST_DeviceVK
struct  GHOST_InstanceVK

Macros

#define VOLK_NAMESPACE
#define VOLK_NO_DEVICE_PROTOTYPES
#define VK_NO_PROTOTYPES
#define VMA_EXTERNAL_MEMORY_WIN32   0
#define __STR(A)
#define VK_CHECK(__expression, fail_value)
#define __has_feature(x)

Functions

static const char * to_string_vk_format (VkFormat format)
static const char * to_string_vk_color_space (VkColorSpaceKHR color_space)
static const char * to_string_vk_present_mode (VkPresentModeKHR present_mode)
static GHOST_TSuccess selectPresentMode (const GHOST_TVSyncModes vsync, VkPhysicalDevice device, VkSurfaceKHR surface, VkPresentModeKHR *r_presentMode)
static bool selectSurfaceFormat (const VkPhysicalDevice physical_device, const VkSurfaceKHR surface, bool use_hdr_swapchain, VkSurfaceFormatKHR &r_surfaceFormat)

Variables

static CLG_LogRef LOG = {"ghost.context"}
Vulkan Instance Extensions Query
static std::optional< GHOST_InstanceVK > vulkan_instance

Macro Definition Documentation

◆ __has_feature

#define __has_feature ( x)
Value:
0

◆ __STR

#define __STR ( A)
Value:
"" #A
#define A

Definition at line 67 of file GHOST_ContextVK.cc.

◆ VK_CHECK

#define VK_CHECK ( __expression,
fail_value )
Value:
do { \
VkResult r = (__expression); \
if (r != VK_SUCCESS) { \
CLOG_ERROR(&LOG, \
"Vulkan: %s resulted in code %s.", \
__STR(__expression), \
return fail_value; \
} \
} while (0)
#define __STR(A)
#define LOG(level)
Definition log.h:97
const char * to_string(ShaderStage stage)
Definition mtl_shader.mm:52

Definition at line 68 of file GHOST_ContextVK.cc.

Referenced by GHOST_InstanceVK::create_instance(), GHOST_DeviceVK::init_extensions(), GHOST_InstanceVK::init_extensions(), and GHOST_ContextVK::initializeDrawingContext().

◆ VK_NO_PROTOTYPES

#define VK_NO_PROTOTYPES

Definition at line 13 of file GHOST_ContextVK.cc.

◆ VMA_EXTERNAL_MEMORY_WIN32

#define VMA_EXTERNAL_MEMORY_WIN32   0

Definition at line 39 of file GHOST_ContextVK.cc.

◆ VOLK_NAMESPACE

#define VOLK_NAMESPACE

Definition at line 11 of file GHOST_ContextVK.cc.

◆ VOLK_NO_DEVICE_PROTOTYPES

#define VOLK_NO_DEVICE_PROTOTYPES

Definition at line 12 of file GHOST_ContextVK.cc.

Function Documentation

◆ selectPresentMode()

GHOST_TSuccess selectPresentMode ( const GHOST_TVSyncModes vsync,
VkPhysicalDevice device,
VkSurfaceKHR surface,
VkPresentModeKHR * r_presentMode )
static

◆ selectSurfaceFormat()

bool selectSurfaceFormat ( const VkPhysicalDevice physical_device,
const VkSurfaceKHR surface,
bool use_hdr_swapchain,
VkSurfaceFormatKHR & r_surfaceFormat )
static

Select the surface format that we will use.

We will select any 8bit UNORM surface.

Definition at line 1393 of file GHOST_ContextVK.cc.

References selectSurfaceFormat(), and VK_FORMAT_R8G8B8A8_UNORM.

Referenced by selectSurfaceFormat().

◆ to_string_vk_color_space()

const char * to_string_vk_color_space ( VkColorSpaceKHR color_space)
static

Definition at line 1299 of file GHOST_ContextVK.cc.

References STRINGIFY, STRINGIFY_ARG, and to_string_vk_color_space().

Referenced by to_string_vk_color_space().

◆ to_string_vk_format()

const char * to_string_vk_format ( VkFormat format)
static

◆ to_string_vk_present_mode()

const char * to_string_vk_present_mode ( VkPresentModeKHR present_mode)
static

Definition at line 1327 of file GHOST_ContextVK.cc.

References STRINGIFY, STRINGIFY_ARG, and to_string_vk_present_mode().

Referenced by to_string_vk_present_mode().

Variable Documentation

◆ LOG

◆ vulkan_instance

std::optional<GHOST_InstanceVK> vulkan_instance
static

A shared device between multiple contexts.

The logical device needs to be shared as multiple contexts can be created and the logical vulkan device they share should be the same otherwise memory operations might be done on the incorrect device.

Definition at line 873 of file GHOST_ContextVK.cc.

Referenced by GHOST_ContextVK::getVulkanHandles(), GHOST_ContextVK::initializeDrawingContext(), GHOST_ContextVK::is_device_extension_enabled(), GHOST_ContextVK::is_instance_extension_enabled(), GHOST_ContextVK::swapBufferAcquire(), GHOST_ContextVK::swapBufferRelease(), and GHOST_ContextVK::~GHOST_ContextVK().