Vulkan: More gracefully handle VK_ERROR_OUT_OF_DATE_KHR
This commit is contained in:
parent
369c345a2d
commit
8341499b86
|
@ -20,6 +20,7 @@
|
|||
// Error message (or nullptr if there was no error)
|
||||
typedef const char* DawnSwapChainError;
|
||||
constexpr DawnSwapChainError DAWN_SWAP_CHAIN_NO_ERROR = nullptr;
|
||||
constexpr DawnSwapChainError DAWN_SWAP_CHAIN_ERROR_OUT_OF_DATE = "Out of date";
|
||||
|
||||
typedef struct {
|
||||
/// Backend-specific texture id/name/pointer
|
||||
|
|
|
@ -195,7 +195,12 @@ TextureViewBase* OldSwapChainBase::APIGetCurrentTextureView() {
|
|||
|
||||
// Get the texture but remove the external refcount because it is never passed outside
|
||||
// of dawn_native
|
||||
mCurrentTexture = AcquireRef(GetNextTextureImpl(&descriptor));
|
||||
TextureBase* texture = GetNextTextureImpl(&descriptor);
|
||||
if (texture == nullptr) {
|
||||
// Swapchain out of date
|
||||
return nullptr;
|
||||
}
|
||||
mCurrentTexture = AcquireRef(texture);
|
||||
|
||||
mCurrentTextureView = mCurrentTexture->APICreateView();
|
||||
return mCurrentTextureView.Get();
|
||||
|
|
|
@ -103,10 +103,10 @@ DawnSwapChainError NativeSwapChainImpl::Configure(WGPUTextureFormat format,
|
|||
uint32_t height) {
|
||||
UpdateSurfaceConfig();
|
||||
|
||||
ASSERT(mInfo.capabilities.minImageExtent.width <= width);
|
||||
ASSERT(mInfo.capabilities.maxImageExtent.width >= width);
|
||||
ASSERT(mInfo.capabilities.minImageExtent.height <= height);
|
||||
ASSERT(mInfo.capabilities.maxImageExtent.height >= height);
|
||||
// ASSERT(mInfo.capabilities.minImageExtent.width <= width);
|
||||
// ASSERT(mInfo.capabilities.maxImageExtent.width >= width);
|
||||
// ASSERT(mInfo.capabilities.minImageExtent.height <= height);
|
||||
// ASSERT(mInfo.capabilities.maxImageExtent.height >= height);
|
||||
|
||||
ASSERT(format == static_cast<WGPUTextureFormat>(GetPreferredFormat()));
|
||||
// TODO(crbug.com/dawn/269): need to check usage works too
|
||||
|
@ -177,9 +177,12 @@ DawnSwapChainError NativeSwapChainImpl::GetNextTexture(DawnSwapChainNextTexture*
|
|||
}
|
||||
}
|
||||
|
||||
if (mDevice->fn.AcquireNextImageKHR(mDevice->GetVkDevice(), mSwapChain,
|
||||
std::numeric_limits<uint64_t>::max(), semaphore, VkFence{},
|
||||
&mLastImageIndex) != VK_SUCCESS) {
|
||||
const auto result = mDevice->fn.AcquireNextImageKHR(
|
||||
mDevice->GetVkDevice(), mSwapChain, std::numeric_limits<uint64_t>::max(), semaphore,
|
||||
VkFence{}, &mLastImageIndex);
|
||||
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
|
||||
return DAWN_SWAP_CHAIN_ERROR_OUT_OF_DATE;
|
||||
} else if (result != VK_SUCCESS) {
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
|
@ -211,7 +214,8 @@ DawnSwapChainError NativeSwapChainImpl::Present() {
|
|||
presentInfo.pResults = nullptr;
|
||||
|
||||
VkQueue queue = mDevice->GetQueue();
|
||||
if (mDevice->fn.QueuePresentKHR(queue, &presentInfo) != VK_SUCCESS) {
|
||||
const auto result = mDevice->fn.QueuePresentKHR(queue, &presentInfo);
|
||||
if (result != VK_SUCCESS && result != VK_ERROR_OUT_OF_DATE_KHR) {
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,9 @@ TextureBase* OldSwapChain::GetNextTextureImpl(const TextureDescriptor* descripto
|
|||
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
|
||||
if (error) {
|
||||
GetDevice()->HandleError(InternalErrorType::Internal, error);
|
||||
if (error != DAWN_SWAP_CHAIN_ERROR_OUT_OF_DATE) {
|
||||
GetDevice()->HandleError(InternalErrorType::Internal, error);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue