Blender V4.3
GHOST_ContextVK.cc File Reference
#include "GHOST_ContextVK.hh"
#include <vector>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <mutex>
#include <optional>
#include <sstream>
#include <sys/stat.h>

Go to the source code of this file.

Classes

class  GHOST_DeviceVK
 

Macros

#define SELECT_COMPATIBLE_SURFACES_ONLY   false
 
#define FORMAT_ERROR(X)
 
#define __STR(A)   "" #A
 
#define VK_CHECK(__expression)
 
#define DEBUG_PRINTF(...)
 

Functions

static const char * vulkan_error_as_string (VkResult result)
 
static vector< VkExtensionProperties > getExtensionsAvailable ()
 
static bool checkExtensionSupport (const vector< VkExtensionProperties > &extensions_available, const char *extension_name)
 
static void requireExtension (const vector< VkExtensionProperties > &extensions_available, vector< const char * > &extensions_enabled, const char *extension_name)
 
static GHOST_TSuccess selectPresentMode (VkPhysicalDevice device, VkSurfaceKHR surface, VkPresentModeKHR *r_presentMode)
 
static bool surfaceFormatSupported (const VkSurfaceFormatKHR &surface_format)
 
static bool selectSurfaceFormat (const VkPhysicalDevice physical_device, const VkSurfaceKHR surface, VkSurfaceFormatKHR &r_surfaceFormat)
 

Vulkan Device

static std::optional< GHOST_DeviceVKvulkan_device
 
static GHOST_TSuccess ensure_vulkan_device (VkInstance vk_instance, VkSurfaceKHR vk_surface, const GHOST_GPUDevice &preferred_device, const vector< const char * > &required_extensions)
 

Macro Definition Documentation

◆ __STR

#define __STR ( A)    "" #A

Definition at line 100 of file GHOST_ContextVK.cc.

◆ DEBUG_PRINTF

#define DEBUG_PRINTF ( ...)
Value:
if (m_debug) { \
printf(__VA_ARGS__); \
}

Definition at line 115 of file GHOST_ContextVK.cc.

◆ FORMAT_ERROR

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

Referenced by vulkan_error_as_string().

◆ SELECT_COMPATIBLE_SURFACES_ONLY

#define SELECT_COMPATIBLE_SURFACES_ONLY   false

Definition at line 44 of file GHOST_ContextVK.cc.

◆ VK_CHECK

#define VK_CHECK ( __expression)
Value:
do { \
VkResult r = (__expression); \
if (r != VK_SUCCESS) { \
fprintf(stderr, \
"Vulkan Error : %s:%d : %s failled with %s\n", \
__FILE__, \
__LINE__, \
__STR(__expression), \
return GHOST_kFailure; \
} \
} while (0)
#define __STR(A)
static const char * vulkan_error_as_string(VkResult result)
@ GHOST_kFailure
Definition GHOST_Types.h:87

Definition at line 101 of file GHOST_ContextVK.cc.

Referenced by GHOST_ContextVK::initializeDrawingContext(), and GHOST_ContextVK::swapBuffers().

Function Documentation

◆ checkExtensionSupport()

static bool checkExtensionSupport ( const vector< VkExtensionProperties > & extensions_available,
const char * extension_name )
static

Definition at line 670 of file GHOST_ContextVK.cc.

Referenced by requireExtension().

◆ ensure_vulkan_device()

static GHOST_TSuccess ensure_vulkan_device ( VkInstance vk_instance,
VkSurfaceKHR vk_surface,
const GHOST_GPUDevice & preferred_device,
const vector< const char * > & required_extensions )
static

◆ getExtensionsAvailable()

static vector< VkExtensionProperties > getExtensionsAvailable ( )
static

Definition at line 659 of file GHOST_ContextVK.cc.

Referenced by GHOST_ContextVK::initializeDrawingContext().

◆ requireExtension()

static void requireExtension ( const vector< VkExtensionProperties > & extensions_available,
vector< const char * > & extensions_enabled,
const char * extension_name )
static

Definition at line 681 of file GHOST_ContextVK.cc.

References checkExtensionSupport().

Referenced by GHOST_ContextVK::initializeDrawingContext().

◆ selectPresentMode()

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

Definition at line 693 of file GHOST_ContextVK.cc.

References GHOST_kFailure, and GHOST_kSuccess.

◆ selectSurfaceFormat()

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

Select the surface format that we will use.

We will select any 8bit UNORM surface.

Definition at line 769 of file GHOST_ContextVK.cc.

References surfaceFormatSupported().

◆ surfaceFormatSupported()

static bool surfaceFormatSupported ( const VkSurfaceFormatKHR & surface_format)
static

Definition at line 749 of file GHOST_ContextVK.cc.

Referenced by selectSurfaceFormat().

◆ vulkan_error_as_string()

static const char * vulkan_error_as_string ( VkResult result)
static

Definition at line 50 of file GHOST_ContextVK.cc.

References FORMAT_ERROR.

Referenced by GHOST_ContextVK::swapBuffers().

Variable Documentation

◆ vulkan_device

std::optional<GHOST_DeviceVK> vulkan_device
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 333 of file GHOST_ContextVK.cc.

Referenced by ensure_vulkan_device(), GHOST_ContextVK::getVulkanHandles(), GHOST_ContextVK::initializeDrawingContext(), GHOST_ContextVK::swapBuffers(), and GHOST_ContextVK::~GHOST_ContextVK().