logging on error and return NULL if vkTexture cannot be created

This commit is contained in:
Nick Fisher
2025-04-16 13:36:08 +08:00
parent d3b9ae45cf
commit a1ab4186b4

View File

@@ -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();
}