Commit 3ae76941 authored by Sunny Sachanandani's avatar Sunny Sachanandani Committed by Commit Bot

gpu: Assign unique ids to anonymous io surfaces.

crrev.com/804597 accidentally set gmb id for anonymous surfaces to 0 to
use it as a hint for whether to clear surfaces. This causes a memory
regression similar to the one before unique ids were introduced.

Instead, client_id, which is 0 for anonymous images and non-zero
otherwise, can be used for the same purpose.

R=ccameron
BUG=793445

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I76b2fa6cf498b0f2727bef7983ebc063cfb5e9d0
Reviewed-on: https://chromium-review.googlesource.com/820618Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523580}
parent a90bc9d7
...@@ -29,7 +29,7 @@ GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( ...@@ -29,7 +29,7 @@ GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer(
int client_id, int client_id,
SurfaceHandle surface_handle) { SurfaceHandle surface_handle) {
// Don't clear anonymous io surfaces. // Don't clear anonymous io surfaces.
bool should_clear = id.is_valid(); bool should_clear = (client_id != 0);
base::ScopedCFTypeRef<IOSurfaceRef> io_surface( base::ScopedCFTypeRef<IOSurfaceRef> io_surface(
gfx::CreateIOSurface(size, format, should_clear)); gfx::CreateIOSurface(size, format, should_clear));
if (!io_surface) if (!io_surface)
...@@ -99,9 +99,9 @@ GpuMemoryBufferFactoryIOSurface::CreateAnonymousImage(const gfx::Size& size, ...@@ -99,9 +99,9 @@ GpuMemoryBufferFactoryIOSurface::CreateAnonymousImage(const gfx::Size& size,
bool* is_cleared) { bool* is_cleared) {
// Note that the child id doesn't matter since the texture will never be // Note that the child id doesn't matter since the texture will never be
// directly exposed to other processes, only via a mailbox. // directly exposed to other processes, only via a mailbox.
gfx::GpuMemoryBufferHandle handle = gfx::GpuMemoryBufferHandle handle = CreateGpuMemoryBuffer(
CreateGpuMemoryBuffer(gfx::GpuMemoryBufferId(), size, format, usage, gfx::GpuMemoryBufferId(next_anonymous_image_id_++), size, format, usage,
0 /* client_id */, gpu::kNullSurfaceHandle); 0 /* client_id */, gpu::kNullSurfaceHandle);
base::ScopedCFTypeRef<IOSurfaceRef> io_surface; base::ScopedCFTypeRef<IOSurfaceRef> io_surface;
io_surface.reset(IOSurfaceLookupFromMachPort(handle.mach_port.get())); io_surface.reset(IOSurfaceLookupFromMachPort(handle.mach_port.get()));
......
...@@ -71,6 +71,9 @@ class GPU_EXPORT GpuMemoryBufferFactoryIOSurface ...@@ -71,6 +71,9 @@ class GPU_EXPORT GpuMemoryBufferFactoryIOSurface
IOSurfaceMap io_surfaces_; IOSurfaceMap io_surfaces_;
base::Lock io_surfaces_lock_; base::Lock io_surfaces_lock_;
// Assign unique ids to anonymous images to differentiate in memory dumps.
int next_anonymous_image_id_ = 1;
DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactoryIOSurface); DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactoryIOSurface);
}; };
......
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