Skip to content

Commit

Permalink
Account for vk.GetPhysicalDeviceSurfaceCapabilitiesKHR returning inva…
Browse files Browse the repository at this point in the history
…lid extents. (flutter#3376)
  • Loading branch information
chinmaygarde authored Jan 31, 2017
1 parent d92d4c1 commit 0c3e6ff
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
29 changes: 26 additions & 3 deletions vulkan/vulkan_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,35 @@ uint32_t VulkanDevice::GetGraphicsQueueIndex() const {
bool VulkanDevice::GetSurfaceCapabilities(
const VulkanSurface& surface,
VkSurfaceCapabilitiesKHR* capabilities) const {
if (!surface.IsValid()) {
if (!surface.IsValid() || capabilities == nullptr) {
return false;
}

return VK_CALL_LOG_ERROR(vk.GetPhysicalDeviceSurfaceCapabilitiesKHR(
physical_device_, surface.Handle(), capabilities)) == VK_SUCCESS;
bool success =
VK_CALL_LOG_ERROR(vk.GetPhysicalDeviceSurfaceCapabilitiesKHR(
physical_device_, surface.Handle(), capabilities)) == VK_SUCCESS;

if (!success) {
return false;
}

// Check if the physical device surface capabilities are valid. If so, there
// is nothing more to do.
if (capabilities->currentExtent.width != 0xFFFFFFFF &&
capabilities->currentExtent.height != 0xFFFFFFFF) {
return true;
}

// Ask the native surface for its size as a fallback.
SkISize size = surface.GetSize();

if (size.width() == 0 || size.height() == 0) {
return false;
}

capabilities->currentExtent.width = size.width();
capabilities->currentExtent.height = size.height();
return true;
}

bool VulkanDevice::GetPhysicalDeviceFeatures(
Expand Down
3 changes: 1 addition & 2 deletions vulkan/vulkan_native_surface_magma.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ bool VulkanNativeSurfaceMagma::IsValid() const {
}

SkISize VulkanNativeSurfaceMagma::GetSize() const {
// See comment in VulkanWindow::AcquireSurface.
return SkISize::Make(0, 0);
return SkISize::Make(2160, 1440);
}

} // namespace vulkan

0 comments on commit 0c3e6ff

Please sign in to comment.