From a1ab4186b4c30cd809828c9e7a8bcae3b9b78cc6 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Wed, 16 Apr 2025 13:36:08 +0800 Subject: [PATCH] logging on error and return NULL if vkTexture cannot be created --- .../src/windows/vulkan/vulkan_context.cpp | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/thermion_dart/native/src/windows/vulkan/vulkan_context.cpp b/thermion_dart/native/src/windows/vulkan/vulkan_context.cpp index 471999b5..5314a862 100644 --- a/thermion_dart/native/src/windows/vulkan/vulkan_context.cpp +++ b/thermion_dart/native/src/windows/vulkan/vulkan_context.cpp @@ -105,7 +105,7 @@ class ThermionVulkanContext::Impl { } HANDLE CreateRenderingSurface(uint32_t width, uint32_t height, uint32_t left, uint32_t top) { - + Log("Creating Vulkan texture %dx%d", width, height); // creates the D3D texture @@ -113,6 +113,9 @@ class ThermionVulkanContext::Impl { auto d3dTextureHandle = d3dTexture->GetTextureHandle(); auto vkTexture = VulkanTexture::create(device, physicalDevice, width, height, d3dTextureHandle); + if(!vkTexture) { + return NULL; + } // fillImageWithColor(device, commandPool, queue, image, VK_FORMAT_B8G8R8A8_UNORM, VK_IMAGE_LAYOUT_UNDEFINED, // Current image layout // { width, height, 1 }, // Image extent @@ -122,10 +125,6 @@ class ThermionVulkanContext::Impl { _vulkanTextures.push_back(std::move(vkTexture)); return d3dTextureHandle; } - - void ResizeRenderingSurface(uint32_t width, uint32_t height, uint32_t left, uint32_t top) { - - } void DestroyRenderingSurface(HANDLE handle) { std::cerr << "Destroying rendering surface " << handle << std::endl; @@ -159,10 +158,18 @@ class ThermionVulkanContext::Impl { void BlitFromSwapchain() { std::lock_guard lock(_platform->mutex); - if(!_platform->current || _d3dTextures.size() == 0) { + if(!_platform->current) { + ERROR("No platform"); return; } + if(_d3dTextures.size() == 0) { + ERROR("No D3D textures"); + return; + } + + + auto&& vkTexture = _vulkanTextures.back(); auto image = vkTexture->GetImage(); @@ -552,10 +559,6 @@ void ThermionVulkanContext::DestroyRenderingSurface(HANDLE handle) { pImpl->DestroyRenderingSurface(handle); } -void ThermionVulkanContext::ResizeRenderingSurface(uint32_t width, uint32_t height, uint32_t left, uint32_t top) { - pImpl->ResizeRenderingSurface(width, height, left, top); -} - void ThermionVulkanContext::Flush() { pImpl->Flush(); }