[Vulkan] Gracefully fail on copy if a target format is unsupported
This commit is contained in:
parent
abdc0ff05a
commit
399e1fac2a
|
@ -277,7 +277,6 @@ TextureCache::Texture* TextureCache::AllocateTexture(
|
||||||
static_cast<VkFormatFeatureFlagBits>(required_flags &
|
static_cast<VkFormatFeatureFlagBits>(required_flags &
|
||||||
~props.optimalTilingFeatures))
|
~props.optimalTilingFeatures))
|
||||||
.c_str());
|
.c_str());
|
||||||
assert_always();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texture_info.dimension != Dimension::kCube &&
|
if (texture_info.dimension != Dimension::kCube &&
|
||||||
|
@ -331,6 +330,7 @@ TextureCache::Texture* TextureCache::AllocateTexture(
|
||||||
texture->alloc = alloc;
|
texture->alloc = alloc;
|
||||||
texture->alloc_info = vma_info;
|
texture->alloc_info = vma_info;
|
||||||
texture->framebuffer = nullptr;
|
texture->framebuffer = nullptr;
|
||||||
|
texture->usage_flags = image_info.usage;
|
||||||
texture->access_watch_handle = 0;
|
texture->access_watch_handle = 0;
|
||||||
texture->texture_info = texture_info;
|
texture->texture_info = texture_info;
|
||||||
return texture;
|
return texture;
|
||||||
|
@ -410,8 +410,7 @@ TextureCache::Texture* TextureCache::DemandResolveTexture(
|
||||||
// No texture at this location. Make a new one.
|
// No texture at this location. Make a new one.
|
||||||
auto texture = AllocateTexture(texture_info, required_flags);
|
auto texture = AllocateTexture(texture_info, required_flags);
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
// Failed to allocate texture (out of memory?)
|
// Failed to allocate texture (out of memory)
|
||||||
assert_always();
|
|
||||||
XELOGE("Vulkan Texture Cache: Failed to allocate texture!");
|
XELOGE("Vulkan Texture Cache: Failed to allocate texture!");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -463,8 +462,7 @@ TextureCache::Texture* TextureCache::Demand(const TextureInfo& texture_info,
|
||||||
// Create a new texture and cache it.
|
// Create a new texture and cache it.
|
||||||
auto texture = AllocateTexture(texture_info);
|
auto texture = AllocateTexture(texture_info);
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
// Failed to allocate texture (out of memory?)
|
// Failed to allocate texture (out of memory)
|
||||||
assert_always();
|
|
||||||
XELOGE("Vulkan Texture Cache: Failed to allocate texture!");
|
XELOGE("Vulkan Texture Cache: Failed to allocate texture!");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ class TextureCache {
|
||||||
VmaAllocation alloc;
|
VmaAllocation alloc;
|
||||||
VmaAllocationInfo alloc_info;
|
VmaAllocationInfo alloc_info;
|
||||||
VkFramebuffer framebuffer; // Blit target frame buffer.
|
VkFramebuffer framebuffer; // Blit target frame buffer.
|
||||||
|
VkImageUsageFlags usage_flags;
|
||||||
|
|
||||||
uintptr_t access_watch_handle;
|
uintptr_t access_watch_handle;
|
||||||
bool pending_invalidation;
|
bool pending_invalidation;
|
||||||
|
|
|
@ -1024,7 +1024,17 @@ bool VulkanCommandProcessor::IssueCopy() {
|
||||||
std::max(1u, dest_logical_height), &texture_info);
|
std::max(1u, dest_logical_height), &texture_info);
|
||||||
|
|
||||||
auto texture = texture_cache_->DemandResolveTexture(texture_info);
|
auto texture = texture_cache_->DemandResolveTexture(texture_info);
|
||||||
assert_not_null(texture);
|
if (!texture) {
|
||||||
|
// Out of memory.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(texture->usage_flags & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
|
||||||
|
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))) {
|
||||||
|
// Resolve image doesn't support drawing, and we don't support conversion.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
texture->in_flight_fence = current_batch_fence_;
|
texture->in_flight_fence = current_batch_fence_;
|
||||||
|
|
||||||
// For debugging purposes only (trace viewer)
|
// For debugging purposes only (trace viewer)
|
||||||
|
|
Loading…
Reference in New Issue