mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- use I_Error for throwing errors in the Vulkan backend and print the message if one gets thrown during init.
This commit is contained in:
parent
2694b0a167
commit
ab256945aa
7 changed files with 59 additions and 56 deletions
|
@ -121,33 +121,33 @@ static void LoadShaders()
|
|||
FString path = CreateProgramCacheName(false);
|
||||
FileReader fr;
|
||||
if (!fr.OpenFile(path))
|
||||
throw std::runtime_error("Could not open shader file");
|
||||
I_Error("Could not open shader file");
|
||||
|
||||
char magic[4];
|
||||
fr.Read(magic, 4);
|
||||
if (memcmp(magic, ShaderMagic, 4) != 0)
|
||||
throw std::runtime_error("Not a shader cache file");
|
||||
I_Error("Not a shader cache file");
|
||||
|
||||
uint32_t count = fr.ReadUInt32();
|
||||
if (count > 512)
|
||||
throw std::runtime_error("Too many shaders cached");
|
||||
I_Error("Too many shaders cached");
|
||||
|
||||
for (uint32_t i = 0; i < count; i++)
|
||||
{
|
||||
char hexdigest[33];
|
||||
if (fr.Read(hexdigest, 32) != 32)
|
||||
throw std::runtime_error("Read error");
|
||||
I_Error("Read error");
|
||||
hexdigest[32] = 0;
|
||||
|
||||
std::unique_ptr<ProgramBinary> binary(new ProgramBinary());
|
||||
binary->format = fr.ReadUInt32();
|
||||
uint32_t size = fr.ReadUInt32();
|
||||
if (size > 1024 * 1024)
|
||||
throw std::runtime_error("Shader too big, probably file corruption");
|
||||
I_Error("Shader too big, probably file corruption");
|
||||
|
||||
binary->data.Resize(size);
|
||||
if (fr.Read(binary->data.Data(), binary->data.Size()) != binary->data.Size())
|
||||
throw std::runtime_error("Read error");
|
||||
I_Error("Read error");
|
||||
|
||||
ShaderCache[hexdigest] = std::move(binary);
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ std::unique_ptr<VulkanShader> ShaderBuilder::create(VulkanDevice *device)
|
|||
glslang::TIntermediate *intermediate = program.getIntermediate(stage);
|
||||
if (!intermediate)
|
||||
{
|
||||
throw std::runtime_error("Internal shader compiler error");
|
||||
I_Error("Internal shader compiler error");
|
||||
}
|
||||
|
||||
glslang::SpvOptions spvOptions;
|
||||
|
@ -177,7 +177,7 @@ std::unique_ptr<VulkanShader> ShaderBuilder::create(VulkanDevice *device)
|
|||
VkShaderModule shaderModule;
|
||||
VkResult result = vkCreateShaderModule(device->device, &createInfo, nullptr, &shaderModule);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create vulkan shader module");
|
||||
I_Error("Could not create vulkan shader module");
|
||||
|
||||
return std::make_unique<VulkanShader>(device, shaderModule);
|
||||
}
|
||||
|
|
|
@ -408,7 +408,7 @@ inline std::unique_ptr<VulkanImage> ImageBuilder::create(VulkanDevice *device)
|
|||
|
||||
VkResult result = vmaCreateImage(device->allocator, &imageInfo, &allocInfo, &image, &allocation, nullptr);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create vulkan image");
|
||||
I_Error("Could not create vulkan image");
|
||||
|
||||
return std::make_unique<VulkanImage>(device, image, allocation, imageInfo.extent.width, imageInfo.extent.height, imageInfo.mipLevels);
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ inline std::unique_ptr<VulkanImageView> ImageViewBuilder::create(VulkanDevice *d
|
|||
VkImageView view;
|
||||
VkResult result = vkCreateImageView(device->device, &viewInfo, nullptr, &view);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create texture image view");
|
||||
I_Error("Could not create texture image view");
|
||||
|
||||
return std::make_unique<VulkanImageView>(device, view);
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ inline std::unique_ptr<VulkanSampler> SamplerBuilder::create(VulkanDevice *devic
|
|||
VkSampler sampler;
|
||||
VkResult result = vkCreateSampler(device->device, &samplerInfo, nullptr, &sampler);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create texture sampler");
|
||||
I_Error("Could not create texture sampler");
|
||||
return std::make_unique<VulkanSampler>(device, sampler);
|
||||
}
|
||||
|
||||
|
@ -541,7 +541,7 @@ inline std::unique_ptr<VulkanBuffer> BufferBuilder::create(VulkanDevice *device)
|
|||
|
||||
VkResult result = vmaCreateBuffer(device->allocator, &bufferInfo, &allocInfo, &buffer, &allocation, nullptr);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("could not allocate memory for vulkan buffer");
|
||||
I_Error("could not allocate memory for vulkan buffer");
|
||||
|
||||
return std::make_unique<VulkanBuffer>(device, buffer, allocation, bufferInfo.size);
|
||||
}
|
||||
|
@ -601,7 +601,7 @@ inline std::unique_ptr<VulkanDescriptorSetLayout> DescriptorSetLayoutBuilder::cr
|
|||
VkDescriptorSetLayout layout;
|
||||
VkResult result = vkCreateDescriptorSetLayout(device->device, &layoutInfo, nullptr, &layout);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create descriptor set layout");
|
||||
I_Error("Could not create descriptor set layout");
|
||||
return std::make_unique<VulkanDescriptorSetLayout>(device, layout);
|
||||
}
|
||||
|
||||
|
@ -635,7 +635,7 @@ inline std::unique_ptr<VulkanDescriptorPool> DescriptorPoolBuilder::create(Vulka
|
|||
VkDescriptorPool descriptorPool;
|
||||
VkResult result = vkCreateDescriptorPool(device->device, &poolInfo, nullptr, &descriptorPool);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create descriptor pool");
|
||||
I_Error("Could not create descriptor pool");
|
||||
return std::make_unique<VulkanDescriptorPool>(device, descriptorPool);
|
||||
}
|
||||
|
||||
|
@ -679,7 +679,7 @@ inline std::unique_ptr<VulkanFramebuffer> FramebufferBuilder::create(VulkanDevic
|
|||
VkFramebuffer framebuffer = 0;
|
||||
VkResult result = vkCreateFramebuffer(device->device, &framebufferInfo, nullptr, &framebuffer);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Failed to create framebuffer");
|
||||
I_Error("Failed to create framebuffer");
|
||||
return std::make_unique<VulkanFramebuffer>(device, framebuffer);
|
||||
}
|
||||
|
||||
|
@ -972,7 +972,7 @@ inline std::unique_ptr<VulkanPipeline> GraphicsPipelineBuilder::create(VulkanDev
|
|||
VkPipeline pipeline = 0;
|
||||
VkResult result = vkCreateGraphicsPipelines(device->device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &pipeline);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create graphics pipeline");
|
||||
I_Error("Could not create graphics pipeline");
|
||||
return std::make_unique<VulkanPipeline>(device, pipeline);
|
||||
}
|
||||
|
||||
|
@ -1006,7 +1006,7 @@ inline std::unique_ptr<VulkanPipelineLayout> PipelineLayoutBuilder::create(Vulka
|
|||
VkPipelineLayout pipelineLayout;
|
||||
VkResult result = vkCreatePipelineLayout(device->device, &pipelineLayoutInfo, nullptr, &pipelineLayout);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create pipeline layout");
|
||||
I_Error("Could not create pipeline layout");
|
||||
return std::make_unique<VulkanPipelineLayout>(device, pipelineLayout);
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1102,7 @@ inline std::unique_ptr<VulkanRenderPass> RenderPassBuilder::create(VulkanDevice
|
|||
VkRenderPass renderPass = 0;
|
||||
VkResult result = vkCreateRenderPass(device->device, &renderPassInfo, nullptr, &renderPass);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create render pass");
|
||||
I_Error("Could not create render pass");
|
||||
return std::make_unique<VulkanRenderPass>(device, renderPass);
|
||||
}
|
||||
|
||||
|
@ -1235,7 +1235,7 @@ inline void QueueSubmit::execute(VulkanDevice *device, VkQueue queue, VulkanFenc
|
|||
{
|
||||
VkResult result = vkQueueSubmit(device->graphicsQueue, 1, &submitInfo, fence ? fence->fence : VK_NULL_HANDLE);
|
||||
if (result < VK_SUCCESS)
|
||||
throw std::runtime_error("Failed to submit command buffer");
|
||||
I_Error("Failed to submit command buffer");
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -163,7 +163,7 @@ void VulkanDevice::SelectPhysicalDevice()
|
|||
}
|
||||
|
||||
if (SupportedDevices.empty())
|
||||
throw std::runtime_error("No Vulkan device supports the minimum requirements of this application");
|
||||
I_Error("No Vulkan device supports the minimum requirements of this application");
|
||||
|
||||
// The device order returned by Vulkan can be anything. Prefer discrete > integrated > virtual gpu > cpu > other
|
||||
std::stable_sort(SupportedDevices.begin(), SupportedDevices.end(), [&](const auto &a, const auto b) {
|
||||
|
@ -215,7 +215,7 @@ void VulkanDevice::CreateAllocator()
|
|||
allocinfo.device = device;
|
||||
allocinfo.preferredLargeHeapBlockSize = 64 * 1024 * 1024;
|
||||
if (vmaCreateAllocator(&allocinfo, &allocator) != VK_SUCCESS)
|
||||
throw std::runtime_error("Unable to create allocator");
|
||||
I_Error("Unable to create allocator");
|
||||
}
|
||||
|
||||
void VulkanDevice::CreateDevice()
|
||||
|
@ -248,7 +248,7 @@ void VulkanDevice::CreateDevice()
|
|||
|
||||
VkResult result = vkCreateDevice(PhysicalDevice.Device, &deviceCreateInfo, nullptr, &device);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create vulkan device");
|
||||
I_Error("Could not create vulkan device");
|
||||
|
||||
volkLoadDevice(device);
|
||||
|
||||
|
@ -260,7 +260,7 @@ void VulkanDevice::CreateSurface()
|
|||
{
|
||||
if (!I_CreateVulkanSurface(instance, &surface))
|
||||
{
|
||||
throw std::runtime_error("Could not create vulkan surface");
|
||||
I_Error("Could not create vulkan surface");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ void VulkanDevice::CreateInstance()
|
|||
|
||||
VkResult result = vkCreateInstance(&createInfo, nullptr, &instance);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create vulkan instance");
|
||||
I_Error("Could not create vulkan instance");
|
||||
|
||||
volkLoadInstance(instance);
|
||||
|
||||
|
@ -334,7 +334,7 @@ void VulkanDevice::CreateInstance()
|
|||
createInfo.pUserData = this;
|
||||
result = vkCreateDebugUtilsMessengerEXT(instance, &createInfo, nullptr, &debugMessenger);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkCreateDebugUtilsMessengerEXT failed");
|
||||
I_Error("vkCreateDebugUtilsMessengerEXT failed");
|
||||
|
||||
DebugLayerActive = true;
|
||||
}
|
||||
|
@ -427,14 +427,14 @@ std::vector<VulkanPhysicalDevice> VulkanDevice::GetPhysicalDevices(VkInstance in
|
|||
uint32_t deviceCount = 0;
|
||||
VkResult result = vkEnumeratePhysicalDevices(instance, &deviceCount, nullptr);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkEnumeratePhysicalDevices failed");
|
||||
I_Error("vkEnumeratePhysicalDevices failed");
|
||||
if (deviceCount == 0)
|
||||
return {};
|
||||
|
||||
std::vector<VkPhysicalDevice> devices(deviceCount);
|
||||
result = vkEnumeratePhysicalDevices(instance, &deviceCount, devices.data());
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkEnumeratePhysicalDevices failed (2)");
|
||||
I_Error("vkEnumeratePhysicalDevices failed (2)");
|
||||
|
||||
std::vector<VulkanPhysicalDevice> devinfo(deviceCount);
|
||||
for (size_t i = 0; i < devices.size(); i++)
|
||||
|
@ -463,11 +463,11 @@ std::vector<const char *> VulkanDevice::GetPlatformExtensions()
|
|||
{
|
||||
uint32_t extensionCount = 0;
|
||||
if (!I_GetVulkanPlatformExtensions(&extensionCount, nullptr))
|
||||
throw std::runtime_error("Cannot obtain number of Vulkan extensions");
|
||||
I_Error("Cannot obtain number of Vulkan extensions");
|
||||
|
||||
std::vector<const char *> extensions(extensionCount);
|
||||
if (!I_GetVulkanPlatformExtensions(&extensionCount, extensions.data()))
|
||||
throw std::runtime_error("Cannot obtain list of Vulkan extensions");
|
||||
I_Error("Cannot obtain list of Vulkan extensions");
|
||||
return extensions;
|
||||
}
|
||||
|
||||
|
@ -475,12 +475,12 @@ void VulkanDevice::InitVolk()
|
|||
{
|
||||
if (volkInitialize() != VK_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("Unable to find Vulkan");
|
||||
I_Error("Unable to find Vulkan");
|
||||
}
|
||||
auto iver = volkGetInstanceVersion();
|
||||
if (iver == 0)
|
||||
{
|
||||
throw std::runtime_error("Vulkan not supported");
|
||||
I_Error("Vulkan not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,5 +516,6 @@ uint32_t VulkanDevice::FindMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags
|
|||
return i;
|
||||
}
|
||||
|
||||
throw std::runtime_error("failed to find suitable memory type!");
|
||||
I_Error("failed to find suitable memory type!");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "vk_device.h"
|
||||
#include "doomerrors.h"
|
||||
|
||||
class VulkanCommandPool;
|
||||
class VulkanDescriptorPool;
|
||||
|
@ -369,7 +370,7 @@ inline VulkanSemaphore::VulkanSemaphore(VulkanDevice *device) : device(device)
|
|||
semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
||||
VkResult result = vkCreateSemaphore(device->device, &semaphoreInfo, nullptr, &semaphore);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Failed to create semaphore!");
|
||||
I_Error("Failed to create semaphore!");
|
||||
}
|
||||
|
||||
inline VulkanSemaphore::~VulkanSemaphore()
|
||||
|
@ -385,7 +386,7 @@ inline VulkanFence::VulkanFence(VulkanDevice *device) : device(device)
|
|||
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||
VkResult result = vkCreateFence(device->device, &fenceInfo, nullptr, &fence);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Failed to create fence!");
|
||||
I_Error("Failed to create fence!");
|
||||
}
|
||||
|
||||
inline VulkanFence::~VulkanFence()
|
||||
|
@ -427,7 +428,7 @@ inline VulkanCommandPool::VulkanCommandPool(VulkanDevice *device, int queueFamil
|
|||
|
||||
VkResult result = vkCreateCommandPool(device->device, &poolInfo, nullptr, &pool);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create command pool");
|
||||
I_Error("Could not create command pool");
|
||||
}
|
||||
|
||||
inline VulkanCommandPool::~VulkanCommandPool()
|
||||
|
@ -518,7 +519,7 @@ inline VulkanCommandBuffer::VulkanCommandBuffer(VulkanCommandPool *pool) : pool(
|
|||
|
||||
VkResult result = vkAllocateCommandBuffers(pool->device->device, &allocInfo, &buffer);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create command buffer");
|
||||
I_Error("Could not create command buffer");
|
||||
}
|
||||
|
||||
inline VulkanCommandBuffer::~VulkanCommandBuffer()
|
||||
|
@ -535,14 +536,14 @@ inline void VulkanCommandBuffer::begin()
|
|||
|
||||
VkResult result = vkBeginCommandBuffer(buffer, &beginInfo);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Failed to begin recording command buffer!");
|
||||
I_Error("Failed to begin recording command buffer!");
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::end()
|
||||
{
|
||||
VkResult result = vkEndCommandBuffer(buffer);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Failed to record command buffer!");
|
||||
I_Error("Failed to record command buffer!");
|
||||
}
|
||||
|
||||
inline void VulkanCommandBuffer::debugFullPipelineBarrier()
|
||||
|
@ -894,7 +895,7 @@ inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::allocate(Vulka
|
|||
VkDescriptorSet descriptorSet;
|
||||
VkResult result = vkAllocateDescriptorSets(device->device, &allocInfo, &descriptorSet);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not allocate descriptor sets");
|
||||
I_Error("Could not allocate descriptor sets");
|
||||
|
||||
return std::make_unique<VulkanDescriptorSet>(device, this, descriptorSet);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ VulkanSwapChain::VulkanSwapChain(VulkanDevice *device) : vsync(vid_vsync), devic
|
|||
SelectFormat();
|
||||
SelectPresentMode();
|
||||
if (!CreateSwapChain())
|
||||
throw std::runtime_error("Could not create vulkan swapchain");
|
||||
I_Error("Could not create vulkan swapchain");
|
||||
GetImages();
|
||||
CreateViews();
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ uint32_t VulkanSwapChain::AcquireImage(int width, int height, VulkanSemaphore *s
|
|||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Failed to acquire next image!");
|
||||
I_Error("Failed to acquire next image!");
|
||||
}
|
||||
}
|
||||
return imageIndex;
|
||||
|
@ -97,19 +97,19 @@ void VulkanSwapChain::QueuePresent(uint32_t imageIndex, VulkanSemaphore *semapho
|
|||
// The spec says we can recover from this.
|
||||
// However, if we are out of memory it is better to crash now than in some other weird place further away from the source of the problem.
|
||||
|
||||
throw std::runtime_error("vkQueuePresentKHR failed: out of memory");
|
||||
I_Error("vkQueuePresentKHR failed: out of memory");
|
||||
}
|
||||
else if (result == VK_ERROR_DEVICE_LOST)
|
||||
{
|
||||
throw std::runtime_error("vkQueuePresentKHR failed: device lost");
|
||||
I_Error("vkQueuePresentKHR failed: device lost");
|
||||
}
|
||||
else if (result == VK_ERROR_SURFACE_LOST_KHR)
|
||||
{
|
||||
throw std::runtime_error("vkQueuePresentKHR failed: surface lost");
|
||||
I_Error("vkQueuePresentKHR failed: surface lost");
|
||||
}
|
||||
else if (result != VK_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("vkQueuePresentKHR failed");
|
||||
I_Error("vkQueuePresentKHR failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ void VulkanSwapChain::CreateViews()
|
|||
VkImageView view;
|
||||
VkResult result = vkCreateImageView(device->device, &createInfo, nullptr, &view);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("Could not create image view for swapchain image");
|
||||
I_Error("Could not create image view for swapchain image");
|
||||
|
||||
device->SetDebugObjectName("SwapChainImageView", (uint64_t)view, VK_OBJECT_TYPE_IMAGE_VIEW);
|
||||
|
||||
|
@ -225,7 +225,7 @@ void VulkanSwapChain::SelectFormat()
|
|||
{
|
||||
std::vector<VkSurfaceFormatKHR> surfaceFormats = GetSurfaceFormats();
|
||||
if (surfaceFormats.empty())
|
||||
throw std::runtime_error("No surface formats supported");
|
||||
I_Error("No surface formats supported");
|
||||
|
||||
if (surfaceFormats.size() == 1 && surfaceFormats.front().format == VK_FORMAT_UNDEFINED)
|
||||
{
|
||||
|
@ -263,7 +263,7 @@ void VulkanSwapChain::SelectPresentMode()
|
|||
std::vector<VkPresentModeKHR> presentModes = GetPresentModes();
|
||||
|
||||
if (presentModes.empty())
|
||||
throw std::runtime_error("No surface present modes supported");
|
||||
I_Error("No surface present modes supported");
|
||||
|
||||
swapChainPresentMode = VK_PRESENT_MODE_FIFO_KHR;
|
||||
if (vsync)
|
||||
|
@ -315,12 +315,12 @@ void VulkanSwapChain::GetImages()
|
|||
uint32_t imageCount;
|
||||
VkResult result = vkGetSwapchainImagesKHR(device->device, swapChain, &imageCount, nullptr);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkGetSwapchainImagesKHR failed");
|
||||
I_Error("vkGetSwapchainImagesKHR failed");
|
||||
|
||||
swapChainImages.resize(imageCount);
|
||||
result = vkGetSwapchainImagesKHR(device->device, swapChain, &imageCount, swapChainImages.data());
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkGetSwapchainImagesKHR failed (2)");
|
||||
I_Error("vkGetSwapchainImagesKHR failed (2)");
|
||||
}
|
||||
|
||||
void VulkanSwapChain::ReleaseViews()
|
||||
|
@ -344,7 +344,7 @@ VkSurfaceCapabilitiesKHR VulkanSwapChain::GetSurfaceCapabilities()
|
|||
VkSurfaceCapabilitiesKHR surfaceCapabilities;
|
||||
VkResult result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device->PhysicalDevice.Device, device->surface, &surfaceCapabilities);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkGetPhysicalDeviceSurfaceCapabilitiesKHR failed");
|
||||
I_Error("vkGetPhysicalDeviceSurfaceCapabilitiesKHR failed");
|
||||
return surfaceCapabilities;
|
||||
}
|
||||
|
||||
|
@ -353,14 +353,14 @@ std::vector<VkSurfaceFormatKHR> VulkanSwapChain::GetSurfaceFormats()
|
|||
uint32_t surfaceFormatCount = 0;
|
||||
VkResult result = vkGetPhysicalDeviceSurfaceFormatsKHR(device->PhysicalDevice.Device, device->surface, &surfaceFormatCount, nullptr);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkGetPhysicalDeviceSurfaceFormatsKHR failed");
|
||||
I_Error("vkGetPhysicalDeviceSurfaceFormatsKHR failed");
|
||||
else if (surfaceFormatCount == 0)
|
||||
return {};
|
||||
|
||||
std::vector<VkSurfaceFormatKHR> surfaceFormats(surfaceFormatCount);
|
||||
result = vkGetPhysicalDeviceSurfaceFormatsKHR(device->PhysicalDevice.Device, device->surface, &surfaceFormatCount, surfaceFormats.data());
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkGetPhysicalDeviceSurfaceFormatsKHR failed");
|
||||
I_Error("vkGetPhysicalDeviceSurfaceFormatsKHR failed");
|
||||
return surfaceFormats;
|
||||
}
|
||||
|
||||
|
@ -369,13 +369,13 @@ std::vector<VkPresentModeKHR> VulkanSwapChain::GetPresentModes()
|
|||
uint32_t presentModeCount = 0;
|
||||
VkResult result = vkGetPhysicalDeviceSurfacePresentModesKHR(device->PhysicalDevice.Device, device->surface, &presentModeCount, nullptr);
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkGetPhysicalDeviceSurfacePresentModesKHR failed");
|
||||
I_Error("vkGetPhysicalDeviceSurfacePresentModesKHR failed");
|
||||
else if (presentModeCount == 0)
|
||||
return {};
|
||||
|
||||
std::vector<VkPresentModeKHR> presentModes(presentModeCount);
|
||||
vkGetPhysicalDeviceSurfacePresentModesKHR(device->PhysicalDevice.Device, device->surface, &presentModeCount, presentModes.data());
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::runtime_error("vkGetPhysicalDeviceSurfacePresentModesKHR failed");
|
||||
I_Error("vkGetPhysicalDeviceSurfacePresentModesKHR failed");
|
||||
return presentModes;
|
||||
}
|
||||
|
|
|
@ -137,8 +137,9 @@ void I_InitGraphics ()
|
|||
{
|
||||
Video = new Win32VulkanVideo();
|
||||
}
|
||||
catch (CRecoverableError &)
|
||||
catch (CRecoverableError &error)
|
||||
{
|
||||
Printf(TEXTCOLOR_RED "Initialization of Vulkan failed: %s\n", error.what());
|
||||
Video = new Win32GLVideo();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue