adding headless mode

This commit is contained in:
Kbz-8
2025-09-24 09:54:44 +02:00
parent 26eab93f9f
commit 8c68564be2
2 changed files with 12 additions and 2 deletions

View File

@@ -125,10 +125,12 @@ namespace mlx
vkGetPhysicalDeviceProperties(m_physical_device, &props);
DebugLog("Vulkan: physical device picked '%'", props.deviceName);
const char* device_extensions[] = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
std::vector<const char*> device_extensions;
if(!is_headless)
device_extensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
VkPhysicalDeviceFeatures features{};
vkGetPhysicalDeviceFeatures(m_physical_device, &features);
m_device = kvfCreateDevice(m_physical_device, device_extensions, sizeof(device_extensions) / sizeof(device_extensions[0]), &features);
m_device = kvfCreateDevice(m_physical_device, device_extensions.data(), device_extensions.size(), &features);
DebugLog("Vulkan: logical device created");
loader->LoadDevice(m_device);

View File

@@ -28,6 +28,10 @@ namespace mlx
{
static inline PFN_vkVoidFunction vkGetInstanceProcAddrStub(Handle context, const char* name)
{
bool is_headless = std::getenv("MLX_HEADLESS_MODE") != nullptr;
if(is_headless && std::string_view(name).find("KHR") != std::string_view::npos)
return nullptr;
PFN_vkVoidFunction function = RenderCore::Get().vkGetInstanceProcAddr(static_cast<VkInstance>(context), name);
if(!function)
FatalError("Vulkan Loader: could not load '%'", name);
@@ -37,6 +41,10 @@ namespace mlx
static inline PFN_vkVoidFunction vkGetDeviceProcAddrStub(Handle context, const char* name)
{
bool is_headless = std::getenv("MLX_HEADLESS_MODE") != nullptr;
if(is_headless && std::string_view(name).find("KHR") != std::string_view::npos)
return nullptr;
PFN_vkVoidFunction function = RenderCore::Get().vkGetDeviceProcAddr(static_cast<VkDevice>(context), name);
if(!function)
FatalError("Vulkan Loader: could not load '%'", name);