Commit 1ed6908a authored by erikchen's avatar erikchen Committed by Commit bot

Pass responsibility for IOSurface-texture reuse to the gpu process.

The GLRenderer uses the new command buffer function
glScheduleCALayerInUseQueryCHROMIUM to determine whether textures are still in
use by the system compositor. This means that GpuMemoryBufferIds no longer need
to be plumbed through to the browser process.

BUG=608026
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/2061993003
Cr-Commit-Position: refs/heads/master@{#400732}
parent 1e1a7949
...@@ -9,6 +9,7 @@ include_rules = [ ...@@ -9,6 +9,7 @@ include_rules = [
"+gpu/command_buffer/common/mailbox.h", "+gpu/command_buffer/common/mailbox.h",
"+gpu/command_buffer/common/mailbox_holder.h", "+gpu/command_buffer/common/mailbox_holder.h",
"+gpu/command_buffer/common/sync_token.h", "+gpu/command_buffer/common/sync_token.h",
"+gpu/command_buffer/common/texture_in_use_response.h",
"+gpu/vulkan", "+gpu/vulkan",
"+media", "+media",
"+skia/ext", "+skia/ext",
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "cc/raster/task_graph_runner.h" #include "cc/raster/task_graph_runner.h"
#include "cc/resources/resource_provider.h" #include "cc/resources/resource_provider.h"
#include "cc/resources/scoped_resource.h" #include "cc/resources/scoped_resource.h"
#include "gpu/command_buffer/common/texture_in_use_response.h"
#include "ui/gfx/geometry/quad_f.h" #include "ui/gfx/geometry/quad_f.h"
namespace cc { namespace cc {
...@@ -39,6 +40,8 @@ class CC_EXPORT DirectRenderer : public Renderer { ...@@ -39,6 +40,8 @@ class CC_EXPORT DirectRenderer : public Renderer {
const gfx::Rect& device_clip_rect, const gfx::Rect& device_clip_rect,
bool disable_picture_quad_image_filtering) override; bool disable_picture_quad_image_filtering) override;
virtual void SwapBuffersComplete() {} virtual void SwapBuffersComplete() {}
virtual void DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) {}
// If a pass contains a single tile draw quad and can be drawn without // If a pass contains a single tile draw quad and can be drawn without
// a render pass (e.g. applying a filter directly to the tile quad) // a render pass (e.g. applying a filter directly to the tile quad)
......
...@@ -2785,7 +2785,7 @@ void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { ...@@ -2785,7 +2785,7 @@ void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) {
// We always hold onto resources until an extra frame has swapped, to make // We always hold onto resources until an extra frame has swapped, to make
// sure we don't update the buffer while it's being scanned out. // sure we don't update the buffer while it's being scanned out.
if (!settings_->release_overlay_resources_on_swap_complete && if (!settings_->release_overlay_resources_after_gpu_query &&
swapping_overlay_resources_.size() > 2) { swapping_overlay_resources_.size() > 2) {
swapping_overlay_resources_.pop_front(); swapping_overlay_resources_.pop_front();
} }
...@@ -2796,33 +2796,38 @@ void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { ...@@ -2796,33 +2796,38 @@ void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) {
} }
void GLRenderer::SwapBuffersComplete() { void GLRenderer::SwapBuffersComplete() {
// On OS X, the logic in this block moves resources into // Once a resouce has been swap-ACKed, send a query to the GPU process to ask
// |swapped_and_acked_overlay_resources_|, and then erases resources from // if the resource is no longer being consumed by the system compositor. The
// |swapped_and_acked_overlay_resources_| that are no longer in use by the // response will come with the next swap-ACK.
// Window Server. On other platforms, since resources are never in use by the if (settings_->release_overlay_resources_after_gpu_query) {
// Window Server, this is equivalent to just erasing all resources from the
// first element of |swapping_overlay_resources_|.
if (settings_->release_overlay_resources_on_swap_complete) {
// Move resources known to be acked into
// |swapped_and_acked_overlay_resources_|.
if (!swapping_overlay_resources_.empty()) { if (!swapping_overlay_resources_.empty()) {
for (OverlayResourceLock& lock : swapping_overlay_resources_.front()) { for (OverlayResourceLock& lock : swapping_overlay_resources_.front()) {
swapped_and_acked_overlay_resources_[lock->resource_id()] = unsigned texture = lock->texture_id();
std::move(lock); if (swapped_and_acked_overlay_resources_.find(texture) ==
swapped_and_acked_overlay_resources_.end()) {
swapped_and_acked_overlay_resources_[texture] = std::move(lock);
}
} }
swapping_overlay_resources_.pop_front(); swapping_overlay_resources_.pop_front();
} }
// Release resources that are no longer in use by the Window Server. if (!swapped_and_acked_overlay_resources_.empty()) {
auto it = swapped_and_acked_overlay_resources_.begin(); std::vector<unsigned> textures;
while (it != swapped_and_acked_overlay_resources_.end()) { textures.reserve(swapped_and_acked_overlay_resources_.size());
if (it->second->gpu_memory_buffer() && for (auto& pair : swapped_and_acked_overlay_resources_) {
it->second->gpu_memory_buffer()->IsInUseByMacOSWindowServer()) { textures.push_back(pair.first);
++it;
continue;
} }
gl_->ScheduleCALayerInUseQueryCHROMIUM(textures.size(), textures.data());
}
}
}
it = swapped_and_acked_overlay_resources_.erase(it); void GLRenderer::DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) {
DCHECK(settings_->release_overlay_resources_after_gpu_query);
for (const gpu::TextureInUseResponse& response : responses) {
if (!response.in_use) {
swapped_and_acked_overlay_resources_.erase(response.texture);
} }
} }
} }
......
...@@ -66,6 +66,9 @@ class CC_EXPORT GLRenderer : public DirectRenderer { ...@@ -66,6 +66,9 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
void SwapBuffers(const CompositorFrameMetadata& metadata) override; void SwapBuffers(const CompositorFrameMetadata& metadata) override;
void SwapBuffersComplete() override; void SwapBuffersComplete() override;
void DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) override;
virtual bool IsContextLost(); virtual bool IsContextLost();
protected: protected:
...@@ -271,9 +274,9 @@ class CC_EXPORT GLRenderer : public DirectRenderer { ...@@ -271,9 +274,9 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
// Resources that should be shortly swapped by the GPU process. // Resources that should be shortly swapped by the GPU process.
std::deque<OverlayResourceLockList> swapping_overlay_resources_; std::deque<OverlayResourceLockList> swapping_overlay_resources_;
// Resources that the GPU process has finished swapping. // Resources that the GPU process has finished swapping. The key is the
std::map<ResourceId, OverlayResourceLock> // texture id of the resource.
swapped_and_acked_overlay_resources_; std::map<unsigned, OverlayResourceLock> swapped_and_acked_overlay_resources_;
RendererCapabilitiesImpl capabilities_; RendererCapabilitiesImpl capabilities_;
......
...@@ -248,6 +248,11 @@ void OutputSurface::OnSwapBuffersComplete() { ...@@ -248,6 +248,11 @@ void OutputSurface::OnSwapBuffersComplete() {
client_->DidSwapBuffersComplete(); client_->DidSwapBuffersComplete();
} }
void OutputSurface::DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) {
client_->DidReceiveTextureInUseResponses(responses);
}
void OutputSurface::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { void OutputSurface::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy", TRACE_EVENT1("cc", "OutputSurface::SetMemoryPolicy",
"bytes_limit_when_visible", policy.bytes_limit_when_visible); "bytes_limit_when_visible", policy.bytes_limit_when_visible);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "cc/output/overlay_candidate_validator.h" #include "cc/output/overlay_candidate_validator.h"
#include "cc/output/software_output_device.h" #include "cc/output/software_output_device.h"
#include "cc/output/vulkan_context_provider.h" #include "cc/output/vulkan_context_provider.h"
#include "gpu/command_buffer/common/texture_in_use_response.h"
namespace base { class SingleThreadTaskRunner; } namespace base { class SingleThreadTaskRunner; }
...@@ -140,6 +141,12 @@ class CC_EXPORT OutputSurface : public base::trace_event::MemoryDumpProvider { ...@@ -140,6 +141,12 @@ class CC_EXPORT OutputSurface : public base::trace_event::MemoryDumpProvider {
virtual void SwapBuffers(CompositorFrame* frame) = 0; virtual void SwapBuffers(CompositorFrame* frame) = 0;
virtual void OnSwapBuffersComplete(); virtual void OnSwapBuffersComplete();
// Called by subclasses after receiving a response from the gpu process to a
// query about whether a given set of textures is still in use by the OS
// compositor.
void DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses);
bool HasClient() { return !!client_; } bool HasClient() { return !!client_; }
// Get the class capable of informing cc of hardware overlay capability. // Get the class capable of informing cc of hardware overlay capability.
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "cc/base/cc_export.h" #include "cc/base/cc_export.h"
#include "cc/output/context_provider.h" #include "cc/output/context_provider.h"
#include "gpu/command_buffer/common/texture_in_use_response.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
namespace gfx { namespace gfx {
...@@ -35,6 +36,8 @@ class CC_EXPORT OutputSurfaceClient { ...@@ -35,6 +36,8 @@ class CC_EXPORT OutputSurfaceClient {
virtual void SetNeedsRedrawRect(const gfx::Rect& damage_rect) = 0; virtual void SetNeedsRedrawRect(const gfx::Rect& damage_rect) = 0;
virtual void DidSwapBuffers() = 0; virtual void DidSwapBuffers() = 0;
virtual void DidSwapBuffersComplete() = 0; virtual void DidSwapBuffersComplete() = 0;
virtual void DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) = 0;
virtual void ReclaimResources(const CompositorFrameAck* ack) = 0; virtual void ReclaimResources(const CompositorFrameAck* ack) = 0;
virtual void DidLoseOutputSurface() = 0; virtual void DidLoseOutputSurface() = 0;
virtual void SetExternalTilePriorityConstraints( virtual void SetExternalTilePriorityConstraints(
......
...@@ -1226,6 +1226,15 @@ class GLRendererWithOverlaysTest : public testing::Test { ...@@ -1226,6 +1226,15 @@ class GLRendererWithOverlaysTest : public testing::Test {
output_surface_->OnSwapBuffersComplete(); output_surface_->OnSwapBuffersComplete();
renderer_->SwapBuffersComplete(); renderer_->SwapBuffersComplete();
} }
void ReturnResourceInUseQuery(ResourceId id) {
ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), id);
gpu::TextureInUseResponse response;
response.texture = lock.texture_id();
response.in_use = false;
gpu::TextureInUseResponses responses;
responses.push_back(response);
renderer_->DidReceiveTextureInUseResponses(responses);
}
RendererSettings settings_; RendererSettings settings_;
FakeOutputSurfaceClient output_surface_client_; FakeOutputSurfaceClient output_surface_client_;
...@@ -1533,9 +1542,9 @@ TEST_F(GLRendererWithOverlaysTest, ResourcesExportedAndReturnedWithDelay) { ...@@ -1533,9 +1542,9 @@ TEST_F(GLRendererWithOverlaysTest, ResourcesExportedAndReturnedWithDelay) {
Mock::VerifyAndClearExpectations(&scheduler_); Mock::VerifyAndClearExpectations(&scheduler_);
} }
TEST_F(GLRendererWithOverlaysTest, ResourcesExportedAndReturnedAtSwapComplete) { TEST_F(GLRendererWithOverlaysTest, ResourcesExportedAndReturnedAfterGpuQuery) {
bool use_validator = true; bool use_validator = true;
settings_.release_overlay_resources_on_swap_complete = true; settings_.release_overlay_resources_after_gpu_query = true;
Init(use_validator); Init(use_validator);
renderer_->set_expect_overlays(true); renderer_->set_expect_overlays(true);
...@@ -1610,19 +1619,27 @@ TEST_F(GLRendererWithOverlaysTest, ResourcesExportedAndReturnedAtSwapComplete) { ...@@ -1610,19 +1619,27 @@ TEST_F(GLRendererWithOverlaysTest, ResourcesExportedAndReturnedAtSwapComplete) {
// This completion corresponds to the first frame. // This completion corresponds to the first frame.
SwapBuffersComplete(); SwapBuffersComplete();
EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1)); EXPECT_TRUE(resource_provider_->InUseByConsumer(resource1));
EXPECT_TRUE(resource_provider_->InUseByConsumer(resource2)); EXPECT_TRUE(resource_provider_->InUseByConsumer(resource2));
EXPECT_TRUE(resource_provider_->InUseByConsumer(resource3)); EXPECT_TRUE(resource_provider_->InUseByConsumer(resource3));
// This completion corresponds to the second frame. // This completion corresponds to the second frame. The first resource is no
// longer in use.
ReturnResourceInUseQuery(resource1);
SwapBuffersComplete(); SwapBuffersComplete();
EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1)); EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1));
EXPECT_FALSE(resource_provider_->InUseByConsumer(resource2)); EXPECT_TRUE(resource_provider_->InUseByConsumer(resource2));
EXPECT_TRUE(resource_provider_->InUseByConsumer(resource3)); EXPECT_TRUE(resource_provider_->InUseByConsumer(resource3));
// This completion corresponds to the third frame. // This completion corresponds to the third frame.
SwapBuffersComplete(); SwapBuffersComplete();
EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1)); EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1));
EXPECT_TRUE(resource_provider_->InUseByConsumer(resource2));
EXPECT_TRUE(resource_provider_->InUseByConsumer(resource3));
ReturnResourceInUseQuery(resource2);
ReturnResourceInUseQuery(resource3);
EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1));
EXPECT_FALSE(resource_provider_->InUseByConsumer(resource2)); EXPECT_FALSE(resource_provider_->InUseByConsumer(resource2));
EXPECT_FALSE(resource_provider_->InUseByConsumer(resource3)); EXPECT_FALSE(resource_provider_->InUseByConsumer(resource3));
} }
......
...@@ -20,7 +20,7 @@ RendererSettings::RendererSettings() ...@@ -20,7 +20,7 @@ RendererSettings::RendererSettings()
finish_rendering_on_resize(false), finish_rendering_on_resize(false),
should_clear_root_render_pass(true), should_clear_root_render_pass(true),
disable_display_vsync(false), disable_display_vsync(false),
release_overlay_resources_on_swap_complete(false), release_overlay_resources_after_gpu_query(false),
refresh_rate(60.0), refresh_rate(60.0),
highp_threshold_min(0), highp_threshold_min(0),
texture_id_allocation_chunk_size(64), texture_id_allocation_chunk_size(64),
...@@ -40,8 +40,8 @@ void RendererSettings::ToProtobuf(proto::RendererSettings* proto) const { ...@@ -40,8 +40,8 @@ void RendererSettings::ToProtobuf(proto::RendererSettings* proto) const {
proto->set_finish_rendering_on_resize(finish_rendering_on_resize); proto->set_finish_rendering_on_resize(finish_rendering_on_resize);
proto->set_should_clear_root_render_pass(should_clear_root_render_pass); proto->set_should_clear_root_render_pass(should_clear_root_render_pass);
proto->set_disable_display_vsync(disable_display_vsync); proto->set_disable_display_vsync(disable_display_vsync);
proto->set_release_overlay_resources_on_swap_complete( proto->set_release_overlay_resources_after_gpu_query(
release_overlay_resources_on_swap_complete); release_overlay_resources_after_gpu_query);
proto->set_refresh_rate(refresh_rate); proto->set_refresh_rate(refresh_rate);
proto->set_highp_threshold_min(highp_threshold_min); proto->set_highp_threshold_min(highp_threshold_min);
proto->set_texture_id_allocation_chunk_size(texture_id_allocation_chunk_size); proto->set_texture_id_allocation_chunk_size(texture_id_allocation_chunk_size);
...@@ -57,8 +57,8 @@ void RendererSettings::FromProtobuf(const proto::RendererSettings& proto) { ...@@ -57,8 +57,8 @@ void RendererSettings::FromProtobuf(const proto::RendererSettings& proto) {
finish_rendering_on_resize = proto.finish_rendering_on_resize(); finish_rendering_on_resize = proto.finish_rendering_on_resize();
should_clear_root_render_pass = proto.should_clear_root_render_pass(); should_clear_root_render_pass = proto.should_clear_root_render_pass();
disable_display_vsync = proto.disable_display_vsync(); disable_display_vsync = proto.disable_display_vsync();
release_overlay_resources_on_swap_complete = release_overlay_resources_after_gpu_query =
proto.release_overlay_resources_on_swap_complete(); proto.release_overlay_resources_after_gpu_query();
refresh_rate = proto.refresh_rate(); refresh_rate = proto.refresh_rate();
highp_threshold_min = proto.highp_threshold_min(); highp_threshold_min = proto.highp_threshold_min();
texture_id_allocation_chunk_size = proto.texture_id_allocation_chunk_size(); texture_id_allocation_chunk_size = proto.texture_id_allocation_chunk_size();
...@@ -78,8 +78,8 @@ bool RendererSettings::operator==(const RendererSettings& other) const { ...@@ -78,8 +78,8 @@ bool RendererSettings::operator==(const RendererSettings& other) const {
finish_rendering_on_resize == other.finish_rendering_on_resize && finish_rendering_on_resize == other.finish_rendering_on_resize &&
should_clear_root_render_pass == other.should_clear_root_render_pass && should_clear_root_render_pass == other.should_clear_root_render_pass &&
disable_display_vsync == other.disable_display_vsync && disable_display_vsync == other.disable_display_vsync &&
release_overlay_resources_on_swap_complete == release_overlay_resources_after_gpu_query ==
other.release_overlay_resources_on_swap_complete && other.release_overlay_resources_after_gpu_query &&
refresh_rate == other.refresh_rate && refresh_rate == other.refresh_rate &&
highp_threshold_min == other.highp_threshold_min && highp_threshold_min == other.highp_threshold_min &&
texture_id_allocation_chunk_size == texture_id_allocation_chunk_size ==
......
...@@ -29,7 +29,7 @@ class CC_EXPORT RendererSettings { ...@@ -29,7 +29,7 @@ class CC_EXPORT RendererSettings {
bool finish_rendering_on_resize; bool finish_rendering_on_resize;
bool should_clear_root_render_pass; bool should_clear_root_render_pass;
bool disable_display_vsync; bool disable_display_vsync;
bool release_overlay_resources_on_swap_complete; bool release_overlay_resources_after_gpu_query;
double refresh_rate; double refresh_rate;
int highp_threshold_min; int highp_threshold_min;
size_t texture_id_allocation_chunk_size; size_t texture_id_allocation_chunk_size;
......
...@@ -27,7 +27,7 @@ TEST(RendererSettingsTest, AllFieldsFlipped) { ...@@ -27,7 +27,7 @@ TEST(RendererSettingsTest, AllFieldsFlipped) {
settings.finish_rendering_on_resize = true; settings.finish_rendering_on_resize = true;
settings.should_clear_root_render_pass = false; settings.should_clear_root_render_pass = false;
settings.disable_display_vsync = true; settings.disable_display_vsync = true;
settings.release_overlay_resources_on_swap_complete = true; settings.release_overlay_resources_after_gpu_query = true;
settings.refresh_rate = 6.0; settings.refresh_rate = 6.0;
settings.highp_threshold_min = 1; settings.highp_threshold_min = 1;
settings.texture_id_allocation_chunk_size = 46; settings.texture_id_allocation_chunk_size = 46;
...@@ -45,7 +45,7 @@ TEST(RendererSettingsTest, ArbitraryFieldValues) { ...@@ -45,7 +45,7 @@ TEST(RendererSettingsTest, ArbitraryFieldValues) {
settings.finish_rendering_on_resize = false; settings.finish_rendering_on_resize = false;
settings.should_clear_root_render_pass = false; settings.should_clear_root_render_pass = false;
settings.disable_display_vsync = true; settings.disable_display_vsync = true;
settings.release_overlay_resources_on_swap_complete = true; settings.release_overlay_resources_after_gpu_query = true;
settings.refresh_rate = 999.0; settings.refresh_rate = 999.0;
settings.highp_threshold_min = 1; settings.highp_threshold_min = 1;
settings.texture_id_allocation_chunk_size = 12; settings.texture_id_allocation_chunk_size = 12;
......
...@@ -16,7 +16,7 @@ message RendererSettings { ...@@ -16,7 +16,7 @@ message RendererSettings {
optional bool finish_rendering_on_resize = 5; optional bool finish_rendering_on_resize = 5;
optional bool should_clear_root_render_pass = 6; optional bool should_clear_root_render_pass = 6;
optional bool disable_display_vsync = 7; optional bool disable_display_vsync = 7;
optional bool release_overlay_resources_on_swap_complete = 8; optional bool release_overlay_resources_after_gpu_query = 8;
optional double refresh_rate = 9; optional double refresh_rate = 9;
optional uint32 highp_threshold_min = 10; optional uint32 highp_threshold_min = 10;
optional uint32 texture_id_allocation_chunk_size = 11; optional uint32 texture_id_allocation_chunk_size = 11;
......
...@@ -340,6 +340,12 @@ void Display::CommitVSyncParameters(base::TimeTicks timebase, ...@@ -340,6 +340,12 @@ void Display::CommitVSyncParameters(base::TimeTicks timebase,
NOTREACHED(); NOTREACHED();
} }
void Display::DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) {
if (renderer_)
renderer_->DidReceiveTextureInUseResponses(responses);
}
void Display::SetBeginFrameSource(BeginFrameSource* source) { void Display::SetBeginFrameSource(BeginFrameSource* source) {
// The BeginFrameSource is set from the constructor, it doesn't come // The BeginFrameSource is set from the constructor, it doesn't come
// from the OutputSurface for the Display. // from the OutputSurface for the Display.
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "cc/surfaces/surface_id.h" #include "cc/surfaces/surface_id.h"
#include "cc/surfaces/surface_manager.h" #include "cc/surfaces/surface_manager.h"
#include "cc/surfaces/surfaces_export.h" #include "cc/surfaces/surfaces_export.h"
#include "gpu/command_buffer/common/texture_in_use_response.h"
#include "ui/events/latency_info.h" #include "ui/events/latency_info.h"
namespace gpu { namespace gpu {
...@@ -86,6 +87,8 @@ class CC_SURFACES_EXPORT Display : public DisplaySchedulerClient, ...@@ -86,6 +87,8 @@ class CC_SURFACES_EXPORT Display : public DisplaySchedulerClient,
void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override; void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override;
void DidSwapBuffers() override; void DidSwapBuffers() override;
void DidSwapBuffersComplete() override; void DidSwapBuffersComplete() override;
void DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) override;
void ReclaimResources(const CompositorFrameAck* ack) override; void ReclaimResources(const CompositorFrameAck* ack) override;
void DidLoseOutputSurface() override; void DidLoseOutputSurface() override;
void SetExternalTilePriorityConstraints( void SetExternalTilePriorityConstraints(
......
...@@ -25,6 +25,8 @@ class FakeOutputSurfaceClient : public OutputSurfaceClient { ...@@ -25,6 +25,8 @@ class FakeOutputSurfaceClient : public OutputSurfaceClient {
void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override {} void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override {}
void DidSwapBuffers() override; void DidSwapBuffers() override;
void DidSwapBuffersComplete() override {} void DidSwapBuffersComplete() override {}
void DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) override {}
void ReclaimResources(const CompositorFrameAck* ack) override {} void ReclaimResources(const CompositorFrameAck* ack) override {}
void DidLoseOutputSurface() override; void DidLoseOutputSurface() override;
void SetExternalTilePriorityConstraints( void SetExternalTilePriorityConstraints(
......
...@@ -1489,6 +1489,11 @@ void LayerTreeHostImpl::DidSwapBuffersComplete() { ...@@ -1489,6 +1489,11 @@ void LayerTreeHostImpl::DidSwapBuffersComplete() {
client_->DidSwapBuffersCompleteOnImplThread(); client_->DidSwapBuffersCompleteOnImplThread();
} }
void LayerTreeHostImpl::DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) {
NOTREACHED();
}
void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) {
// TODO(piman): We may need to do some validation on this ack before // TODO(piman): We may need to do some validation on this ack before
// processing it. // processing it.
......
...@@ -369,6 +369,8 @@ class CC_EXPORT LayerTreeHostImpl ...@@ -369,6 +369,8 @@ class CC_EXPORT LayerTreeHostImpl
void DidLoseOutputSurface() override; void DidLoseOutputSurface() override;
void DidSwapBuffers() override; void DidSwapBuffers() override;
void DidSwapBuffersComplete() override; void DidSwapBuffersComplete() override;
void DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) override;
void ReclaimResources(const CompositorFrameAck* ack) override; void ReclaimResources(const CompositorFrameAck* ack) override;
void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override; void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override;
void SetTreeActivationCallback(const base::Closure& callback) override; void SetTreeActivationCallback(const base::Closure& callback) override;
......
...@@ -102,6 +102,7 @@ void GpuOutputSurfaceMac::OnGpuSwapBuffersCompleted( ...@@ -102,6 +102,7 @@ void GpuOutputSurfaceMac::OnGpuSwapBuffersCompleted(
} }
} }
} }
DidReceiveTextureInUseResponses(params_mac->responses);
GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(
latency_info, result, params_mac); latency_info, result, params_mac);
} }
......
...@@ -51,6 +51,7 @@ source_set("common_sources") { ...@@ -51,6 +51,7 @@ source_set("common_sources") {
"mailbox_holder.h", "mailbox_holder.h",
"sync_token.cc", "sync_token.cc",
"sync_token.h", "sync_token.h",
"texture_in_use_response.h",
"thread_local.h", "thread_local.h",
"time.h", "time.h",
] ]
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_COMMAND_BUFFER_COMMON_TEXTURE_IN_USE_RESPONSE_H_
#define GPU_COMMAND_BUFFER_COMMON_TEXTURE_IN_USE_RESPONSE_H_
#include <stdint.h>
#include <vector>
#include "gpu/gpu_export.h"
namespace gpu {
// A response from the gpu process about whether a texture is in use by the
// system compositor.
struct GPU_EXPORT TextureInUseResponse {
uint32_t texture = 0;
bool in_use = false;
};
using TextureInUseResponses = std::vector<TextureInUseResponse>;
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_COMMON_TEXTURE_IN_USE_RESPONSE_H_
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
'command_buffer/common/mailbox_holder.h', 'command_buffer/common/mailbox_holder.h',
'command_buffer/common/sync_token.cc', 'command_buffer/common/sync_token.cc',
'command_buffer/common/sync_token.h', 'command_buffer/common/sync_token.h',
'command_buffer/common/texture_in_use_response.h',
'command_buffer/common/thread_local.h', 'command_buffer/common/thread_local.h',
'command_buffer/common/time.h', 'command_buffer/common/time.h',
], ],
......
...@@ -779,6 +779,7 @@ void CommandBufferProxyImpl::OnSwapBuffersCompleted( ...@@ -779,6 +779,7 @@ void CommandBufferProxyImpl::OnSwapBuffersCompleted(
params_mac.io_surface.reset(IOSurfaceLookupFromMachPort(params.io_surface)); params_mac.io_surface.reset(IOSurfaceLookupFromMachPort(params.io_surface));
params_mac.pixel_size = params.pixel_size; params_mac.pixel_size = params.pixel_size;
params_mac.scale_factor = params.scale_factor; params_mac.scale_factor = params.scale_factor;
params_mac.responses = std::move(params.in_use_responses);
gpu::GpuProcessHostedCALayerTreeParamsMac* mac_frame_ptr = &params_mac; gpu::GpuProcessHostedCALayerTreeParamsMac* mac_frame_ptr = &params_mac;
#else #else
gpu::GpuProcessHostedCALayerTreeParamsMac* mac_frame_ptr = nullptr; gpu::GpuProcessHostedCALayerTreeParamsMac* mac_frame_ptr = nullptr;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <IOSurface/IOSurface.h> #include <IOSurface/IOSurface.h>
#include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_cftyperef.h"
#include "gpu/command_buffer/common/texture_in_use_response.h"
#include "gpu/gpu_export.h" #include "gpu/gpu_export.h"
#include "ui/base/cocoa/remote_layer_api.h" #include "ui/base/cocoa/remote_layer_api.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
...@@ -22,6 +23,7 @@ struct GPU_EXPORT GpuProcessHostedCALayerTreeParamsMac { ...@@ -22,6 +23,7 @@ struct GPU_EXPORT GpuProcessHostedCALayerTreeParamsMac {
base::ScopedCFTypeRef<IOSurfaceRef> io_surface; base::ScopedCFTypeRef<IOSurfaceRef> io_surface;
gfx::Size pixel_size; gfx::Size pixel_size;
float scale_factor = 1; float scale_factor = 1;
TextureInUseResponses responses;
}; };
} // namespace gpu } // namespace gpu
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "gpu/command_buffer/common/command_buffer_id.h" #include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/mailbox_holder.h" #include "gpu/command_buffer/common/mailbox_holder.h"
#include "gpu/command_buffer/common/sync_token.h" #include "gpu/command_buffer/common/sync_token.h"
#include "gpu/command_buffer/common/texture_in_use_response.h"
// Generate param traits size methods. // Generate param traits size methods.
#include "ipc/param_traits_size_macros.h" #include "ipc/param_traits_size_macros.h"
...@@ -121,6 +122,38 @@ void ParamTraits<gpu::SyncToken>::Log(const param_type& p, std::string* l) { ...@@ -121,6 +122,38 @@ void ParamTraits<gpu::SyncToken>::Log(const param_type& p, std::string* l) {
p.command_buffer_id().GetUnsafeValue(), p.release_count()); p.command_buffer_id().GetUnsafeValue(), p.release_count());
} }
void ParamTraits<gpu::TextureInUseResponse>::GetSize(base::PickleSizer* s,
const param_type& p) {
GetParamSize(s, p.texture);
GetParamSize(s, p.in_use);
}
void ParamTraits<gpu::TextureInUseResponse>::Write(base::Pickle* m,
const param_type& p) {
WriteParam(m, p.texture);
WriteParam(m, p.in_use);
}
bool ParamTraits<gpu::TextureInUseResponse>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* p) {
uint32_t texture = 0;
bool in_use = false;
if (!ReadParam(m, iter, &texture) || !ReadParam(m, iter, &in_use)) {
return false;
}
p->texture = texture;
p->in_use = in_use;
return true;
}
void ParamTraits<gpu::TextureInUseResponse>::Log(const param_type& p,
std::string* l) {
*l += base::StringPrintf("[%u: %d]", p.texture, static_cast<int>(p.in_use));
}
void ParamTraits<gpu::Mailbox>::GetSize(base::PickleSizer* s, void ParamTraits<gpu::Mailbox>::GetSize(base::PickleSizer* s,
const param_type& p) { const param_type& p) {
s->AddBytes(sizeof(p.name)); s->AddBytes(sizeof(p.name));
......
...@@ -16,6 +16,7 @@ namespace gpu { ...@@ -16,6 +16,7 @@ namespace gpu {
struct Mailbox; struct Mailbox;
struct MailboxHolder; struct MailboxHolder;
struct SyncToken; struct SyncToken;
struct TextureInUseResponse;
} }
namespace IPC { namespace IPC {
...@@ -42,6 +43,17 @@ struct GPU_EXPORT ParamTraits<gpu::SyncToken> { ...@@ -42,6 +43,17 @@ struct GPU_EXPORT ParamTraits<gpu::SyncToken> {
static void Log(const param_type& p, std::string* l); static void Log(const param_type& p, std::string* l);
}; };
template <>
struct GPU_EXPORT ParamTraits<gpu::TextureInUseResponse> {
using param_type = gpu::TextureInUseResponse;
static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* p);
static void Log(const param_type& p, std::string* l);
};
template<> template<>
struct GPU_EXPORT ParamTraits<gpu::Mailbox> { struct GPU_EXPORT ParamTraits<gpu::Mailbox> {
using param_type = gpu::Mailbox; using param_type = gpu::Mailbox;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "gpu/command_buffer/common/gpu_memory_allocation.h" #include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "gpu/command_buffer/common/mailbox.h" #include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/sync_token.h" #include "gpu/command_buffer/common/sync_token.h"
#include "gpu/command_buffer/common/texture_in_use_response.h"
#include "gpu/config/gpu_info.h" #include "gpu/config/gpu_info.h"
#include "gpu/gpu_export.h" #include "gpu/gpu_export.h"
#include "gpu/ipc/common/gpu_command_buffer_traits.h" #include "gpu/ipc/common/gpu_command_buffer_traits.h"
...@@ -86,6 +87,7 @@ IPC_STRUCT_BEGIN(GpuCommandBufferMsg_SwapBuffersCompleted_Params) ...@@ -86,6 +87,7 @@ IPC_STRUCT_BEGIN(GpuCommandBufferMsg_SwapBuffersCompleted_Params)
IPC_STRUCT_MEMBER(gfx::ScopedRefCountedIOSurfaceMachPort, io_surface) IPC_STRUCT_MEMBER(gfx::ScopedRefCountedIOSurfaceMachPort, io_surface)
IPC_STRUCT_MEMBER(gfx::Size, pixel_size) IPC_STRUCT_MEMBER(gfx::Size, pixel_size)
IPC_STRUCT_MEMBER(float, scale_factor) IPC_STRUCT_MEMBER(float, scale_factor)
IPC_STRUCT_MEMBER(gpu::TextureInUseResponses, in_use_responses)
#endif #endif
IPC_STRUCT_MEMBER(std::vector<ui::LatencyInfo>, latency_info) IPC_STRUCT_MEMBER(std::vector<ui::LatencyInfo>, latency_info)
IPC_STRUCT_MEMBER(gfx::SwapResult, result) IPC_STRUCT_MEMBER(gfx::SwapResult, result)
......
...@@ -159,15 +159,13 @@ void ImageTransportSurfaceOverlayMac::SendAcceleratedSurfaceBuffersSwapped( ...@@ -159,15 +159,13 @@ void ImageTransportSurfaceOverlayMac::SendAcceleratedSurfaceBuffersSwapped(
params.latency_info = std::move(latency_info); params.latency_info = std::move(latency_info);
params.result = gfx::SwapResult::SWAP_ACK; params.result = gfx::SwapResult::SWAP_ACK;
// TODO(erikchen): Re-enable this logic alongside the client code that for (auto& query : io_surface_in_use_queries_) {
// consumes this response. https://crbug.com/608026. gpu::TextureInUseResponse response;
// for (auto& query : io_surface_in_use_queries_) { response.texture = query.texture;
// SwapBuffersCompletedIOSurfaceInUseQuery response; response.in_use =
// response.texture = query.texture; query.io_surface.get() && IOSurfaceIsInUse(query.io_surface.get());
// response.in_use = params.in_use_responses.push_back(std::move(response));
// query.io_surface.get() && IOSurfaceIsInUse(query.io_surface.get()); }
// params.in_use_queries.push_back(std::move(response));
// }
io_surface_in_use_queries_.clear(); io_surface_in_use_queries_.clear();
stub_->SendSwapBuffersCompleted(params); stub_->SendSwapBuffersCompleted(params);
......
...@@ -125,7 +125,7 @@ Compositor::Compositor(ui::ContextFactory* context_factory, ...@@ -125,7 +125,7 @@ Compositor::Compositor(ui::ContextFactory* context_factory,
#if defined(OS_WIN) #if defined(OS_WIN)
settings.renderer_settings.finish_rendering_on_resize = true; settings.renderer_settings.finish_rendering_on_resize = true;
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
settings.renderer_settings.release_overlay_resources_on_swap_complete = true; settings.renderer_settings.release_overlay_resources_after_gpu_query = true;
#endif #endif
// These flags should be mirrored by renderer versions in content/renderer/. // These flags should be mirrored by renderer versions in content/renderer/.
......
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