From 7f1e35e761ebc23bf877d5431a0b6f24e8b88110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 15 Sep 2020 23:09:58 +0200 Subject: [PATCH] Add missing asserts after some VK resource creation functions --- GPU/Vulkan/DrawEngineVulkan.cpp | 1 + GPU/Vulkan/TextureCacheVulkan.cpp | 3 ++- GPU/Vulkan/VulkanUtil.cpp | 3 ++- ext/native/thin3d/VulkanQueueRunner.cpp | 5 +++-- ext/native/thin3d/VulkanRenderManager.cpp | 9 ++++++--- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index f88ba62877..b89ac08892 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -172,6 +172,7 @@ void DrawEngineVulkan::InitDeviceObjects() { samp.magFilter = VK_FILTER_NEAREST; samp.minFilter = VK_FILTER_NEAREST; res = vkCreateSampler(device, &samp, nullptr, &samplerSecondary_); + _dbg_assert_(VK_SUCCESS == res); res = vkCreateSampler(device, &samp, nullptr, &nullSampler_); _dbg_assert_(VK_SUCCESS == res); diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index c015c498e1..c6d9971770 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -363,7 +363,8 @@ void TextureCacheVulkan::DeviceRestore(VulkanContext *vulkan, Draw::DrawContext samp.magFilter = VK_FILTER_NEAREST; samp.minFilter = VK_FILTER_NEAREST; samp.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; - vkCreateSampler(vulkan_->GetDevice(), &samp, nullptr, &samplerNearest_); + VkResult res = vkCreateSampler(vulkan_->GetDevice(), &samp, nullptr, &samplerNearest_); + _assert_(res == VK_SUCCESS); CompileScalingShader(); diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index 9a617645d1..9a65aa750c 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -549,7 +549,8 @@ VkPipeline VulkanComputeShaderManager::GetPipeline(VkShaderModule cs) { pci.layout = pipelineLayout_; pci.flags = 0; - vkCreateComputePipelines(vulkan_->GetDevice(), pipelineCache_, 1, &pci, nullptr, &pipeline); + VkResult res = vkCreateComputePipelines(vulkan_->GetDevice(), pipelineCache_, 1, &pci, nullptr, &pipeline); + _assert_(res == VK_SUCCESS); pipelines_.Insert(key, pipeline); return pipeline; diff --git a/ext/native/thin3d/VulkanQueueRunner.cpp b/ext/native/thin3d/VulkanQueueRunner.cpp index 87f811eb6c..b97a9a0f4a 100644 --- a/ext/native/thin3d/VulkanQueueRunner.cpp +++ b/ext/native/thin3d/VulkanQueueRunner.cpp @@ -49,7 +49,8 @@ void VulkanQueueRunner::ResizeReadbackBuffer(VkDeviceSize requiredSize) { buf.size = readbackBufferSize_; buf.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; - vkCreateBuffer(device, &buf, nullptr, &readbackBuffer_); + VkResult res = vkCreateBuffer(device, &buf, nullptr, &readbackBuffer_); + _assert_(res == VK_SUCCESS); VkMemoryRequirements reqs{}; vkGetBufferMemoryRequirements(device, readbackBuffer_, &reqs); @@ -75,7 +76,7 @@ void VulkanQueueRunner::ResizeReadbackBuffer(VkDeviceSize requiredSize) { _assert_(successTypeReqs != 0); readbackBufferIsCoherent_ = (successTypeReqs & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0; - VkResult res = vkAllocateMemory(device, &allocInfo, nullptr, &readbackMemory_); + res = vkAllocateMemory(device, &allocInfo, nullptr, &readbackMemory_); if (res != VK_SUCCESS) { readbackMemory_ = VK_NULL_HANDLE; vkDestroyBuffer(device, readbackBuffer_, nullptr); diff --git a/ext/native/thin3d/VulkanRenderManager.cpp b/ext/native/thin3d/VulkanRenderManager.cpp index 6f439134a3..825a437681 100644 --- a/ext/native/thin3d/VulkanRenderManager.cpp +++ b/ext/native/thin3d/VulkanRenderManager.cpp @@ -38,7 +38,9 @@ VKRFramebuffer::VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VkRen fbci.height = height; fbci.layers = 1; - vkCreateFramebuffer(vulkan_->GetDevice(), &fbci, nullptr, &framebuf); + VkResult res = vkCreateFramebuffer(vulkan_->GetDevice(), &fbci, nullptr, &framebuf); + _assert_(res == VK_SUCCESS); + if (tag && vk->Extensions().EXT_debug_utils) { vk->SetDebugName(color.image, VK_OBJECT_TYPE_IMAGE, StringFromFormat("fb_color_%s", tag).c_str()); vk->SetDebugName(depth.image, VK_OBJECT_TYPE_IMAGE, StringFromFormat("fb_depth_%s", tag).c_str()); @@ -86,7 +88,8 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int ici.usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; } - vkCreateImage(vulkan->GetDevice(), &ici, nullptr, &img.image); + VkResult res = vkCreateImage(vulkan->GetDevice(), &ici, nullptr, &img.image); + _dbg_assert_(res == VK_SUCCESS); VkMemoryRequirements memreq; bool dedicatedAllocation = false; @@ -102,7 +105,7 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int vulkan->MemoryTypeFromProperties(memreq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &alloc.memoryTypeIndex); - VkResult res = vkAllocateMemory(vulkan->GetDevice(), &alloc, nullptr, &img.memory); + res = vkAllocateMemory(vulkan->GetDevice(), &alloc, nullptr, &img.memory); _dbg_assert_(res == VK_SUCCESS); res = vkBindImageMemory(vulkan->GetDevice(), img.image, img.memory, 0);