Commit 619ddf10 authored by Mark Yacoub's avatar Mark Yacoub Committed by Chromium LUCI CQ

Reallocate Buffers on SWAP_NAK_RECREATE_BUFFERS

If a scheduling a page flip fails due to SWAP_NAK_RECREATE_BUFFERS,
allocate new images for the subsequent flips.

BUG: 979736
TEST: reallocate buffers after a modeset with RBC modifier enabled
Change-Id: I54ed184ecba36a280f315fa30aa667ac42b32d09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2581693
Commit-Queue: Mark Yacoub <markyacoub@google.com>
Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836146}
parent 78e9fa05
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "gpu/config/gpu_finch_features.h" #include "gpu/config/gpu_finch_features.h"
#include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkSurfaceProps.h" #include "third_party/skia/include/core/SkSurfaceProps.h"
#include "ui/gfx/swap_result.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
namespace viz { namespace viz {
...@@ -434,6 +435,9 @@ void SkiaOutputDeviceBufferQueue::DoFinishSwapBuffers( ...@@ -434,6 +435,9 @@ void SkiaOutputDeviceBufferQueue::DoFinishSwapBuffers(
return true; return true;
}); });
bool should_reallocate =
result.swap_result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS;
DCHECK(!result.gpu_fence); DCHECK(!result.gpu_fence);
const auto& mailbox = const auto& mailbox =
image ? image->skia_representation()->mailbox() : gpu::Mailbox(); image ? image->skia_representation()->mailbox() : gpu::Mailbox();
...@@ -441,6 +445,9 @@ void SkiaOutputDeviceBufferQueue::DoFinishSwapBuffers( ...@@ -441,6 +445,9 @@ void SkiaOutputDeviceBufferQueue::DoFinishSwapBuffers(
/*damage_area=*/base::nullopt, std::move(released_overlays), /*damage_area=*/base::nullopt, std::move(released_overlays),
mailbox); mailbox);
PageFlipComplete(image.get()); PageFlipComplete(image.get());
if (should_reallocate)
RecreateImages();
} }
gfx::Size SkiaOutputDeviceBufferQueue::GetSwapBuffersSize() { gfx::Size SkiaOutputDeviceBufferQueue::GetSwapBuffersSize() {
...@@ -472,7 +479,6 @@ bool SkiaOutputDeviceBufferQueue::Reshape(const gfx::Size& size, ...@@ -472,7 +479,6 @@ bool SkiaOutputDeviceBufferQueue::Reshape(const gfx::Size& size,
color_space_ = color_space; color_space_ = color_space;
image_size_ = size; image_size_ = size;
overlay_transform_ = transform; overlay_transform_ = transform;
FreeAllSurfaces();
if (needs_background_image_ && !background_image_) { if (needs_background_image_ && !background_image_) {
background_image_ = background_image_ =
...@@ -480,16 +486,18 @@ bool SkiaOutputDeviceBufferQueue::Reshape(const gfx::Size& size, ...@@ -480,16 +486,18 @@ bool SkiaOutputDeviceBufferQueue::Reshape(const gfx::Size& size,
background_image_is_scheduled_ = false; background_image_is_scheduled_ = false;
} }
return RecreateImages();
}
bool SkiaOutputDeviceBufferQueue::RecreateImages() {
FreeAllSurfaces();
images_ = presenter_->AllocateImages(color_space_, image_size_, images_ = presenter_->AllocateImages(color_space_, image_size_,
capabilities_.number_of_buffers); capabilities_.number_of_buffers);
if (images_.empty())
return false;
for (auto& image : images_) { for (auto& image : images_) {
available_images_.push_back(image.get()); available_images_.push_back(image.get());
} }
return true; return !images_.empty();
} }
SkSurface* SkiaOutputDeviceBufferQueue::BeginPaint( SkSurface* SkiaOutputDeviceBufferQueue::BeginPaint(
......
...@@ -82,6 +82,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputDeviceBufferQueue : public SkiaOutputDevice { ...@@ -82,6 +82,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputDeviceBufferQueue : public SkiaOutputDevice {
gfx::SwapCompletionResult result); gfx::SwapCompletionResult result);
gfx::Size GetSwapBuffersSize(); gfx::Size GetSwapBuffersSize();
bool RecreateImages();
std::unique_ptr<OutputPresenter> presenter_; std::unique_ptr<OutputPresenter> presenter_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment