Blender V5.0
GHOST_ContextVK.cc File Reference
#include "GHOST_ContextVK.hh"
#include "vulkan/vk_ghost_api.hh"
#include "vk_mem_alloc.h"
#include "CLG_log.h"
#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#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 VMA_EXTERNAL_MEMORY_WIN32   0
#define FORMAT_ERROR(X)
#define __STR(A)
#define VK_CHECK(__expression, fail_value)

Functions

static const char * vulkan_error_as_string (VkResult result)
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"}
static std::optional< GHOST_InstanceVKvulkan_instance

Macro Definition Documentation

◆ __STR

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

Definition at line 99 of file GHOST_ContextVK.cc.

◆ FORMAT_ERROR

#define FORMAT_ERROR ( X)
Value:
case X: { \
return "" #X; \
}
#define X

Referenced by vulkan_error_as_string().

◆ 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)
static const char * vulkan_error_as_string(VkResult result)
#define LOG(level)
Definition log.h:97

Definition at line 100 of file GHOST_ContextVK.cc.

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

◆ VMA_EXTERNAL_MEMORY_WIN32

#define VMA_EXTERNAL_MEMORY_WIN32   0

Definition at line 26 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 1084 of file GHOST_ContextVK.cc.

◆ vulkan_error_as_string()

const char * vulkan_error_as_string ( VkResult result)
static

Definition at line 49 of file GHOST_ContextVK.cc.

References FORMAT_ERROR, and result.

Referenced by GHOST_ContextVK::swapBufferRelease().

Variable Documentation

◆ LOG

CLG_LogRef LOG = {"ghost.context"}
static

◆ 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 663 of file GHOST_ContextVK.cc.

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