Commit 26e6b6be authored by Eric Karl's avatar Eric Karl Committed by Commit Bot

Fix clear rect tracking on begin GL access

Previous patch did not update GLTextureRepresentation's clear region
on begin access. This allowed it to get out of sync if other (non-GL)
components modified the clear rect.

This patch updates the cleared rect on each begin access.

Bug: 1039232
Change-Id: Iacc6e65b25d770e1d17e51a5f1c2c632dfad0101
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1990195Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarTommi <tommi@chromium.org>
Commit-Queue: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729950}
parent 5c1564d0
...@@ -104,13 +104,6 @@ IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest, ...@@ -104,13 +104,6 @@ IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest, IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
VerifyCanvasCaptureWebGLFrames) { VerifyCanvasCaptureWebGLFrames) {
#if defined(OS_ANDROID)
// TODO(ericrk): fails on Pixel 2 Skia Renderer Vulkan after shared image
// changes. See https://crbug.com/1039232
if (base::SysInfo::HardwareModelName() == "Pixel 2") {
return;
}
#endif
MakeTypicalCall("testCanvasCapture(drawWebGL);", kCanvasCaptureTestHtmlFile); MakeTypicalCall("testCanvasCapture(drawWebGL);", kCanvasCaptureTestHtmlFile);
} }
......
...@@ -71,10 +71,6 @@ crbug.com/992599 [ android android-webview-instrumentation ] Pixel_OffscreenCanv ...@@ -71,10 +71,6 @@ crbug.com/992599 [ android android-webview-instrumentation ] Pixel_OffscreenCanv
# Produces black images on Nexus 5Xs in Android Webview (qualcomm-adreno-(tm)-418) crbug.com/984352 # Produces black images on Nexus 5Xs in Android Webview (qualcomm-adreno-(tm)-418) crbug.com/984352
# Fails on Pixel 2 (qualcomm-adreno-(tm)-540) crbug.com/966069 # Fails on Pixel 2 (qualcomm-adreno-(tm)-540) crbug.com/966069
crbug.com/805739 [ android ] Pixel_CanvasLowLatency2D [ Skip ] crbug.com/805739 [ android ] Pixel_CanvasLowLatency2D [ Skip ]
crbug.com/1039232 [ android android-chromium qualcomm-adreno-(tm)-540 use-vulkan skia-renderer ] Pixel_CanvasLowLatencyWebGL [ Failure ]
crbug.com/1039232 [ android android-chromium qualcomm-adreno-(tm)-540 use-vulkan skia-renderer ] Pixel_OffscreenCanvasWebGLPaintAfterResize [ Failure ]
crbug.com/1039232 [ android android-chromium qualcomm-adreno-(tm)-540 use-vulkan skia-renderer ] Pixel_OffscreenCanvasWebGLDefaultWorker [ Failure ]
crbug.com/1039232 [ android android-chromium qualcomm-adreno-(tm)-540 use-vulkan skia-renderer ] Pixel_RepeatedWebGLTo2D [ Failure ]
# Skip test that kills GPU process since Android Webview only supports # Skip test that kills GPU process since Android Webview only supports
# in-process GPU. # in-process GPU.
......
...@@ -681,15 +681,10 @@ gles2::Texture* SharedImageBackingAHB::GenGLTexture() { ...@@ -681,15 +681,10 @@ gles2::Texture* SharedImageBackingAHB::GenGLTexture() {
texture->sampler_state_.wrap_t = GL_CLAMP_TO_EDGE; texture->sampler_state_.wrap_t = GL_CLAMP_TO_EDGE;
texture->sampler_state_.wrap_s = GL_CLAMP_TO_EDGE; texture->sampler_state_.wrap_s = GL_CLAMP_TO_EDGE;
// If the backing is already cleared, no need to clear it again.
gfx::Rect cleared_rect;
if (IsCleared())
cleared_rect = gfx::Rect(size());
texture->SetLevelInfo(target, 0, egl_image->GetInternalFormat(), texture->SetLevelInfo(target, 0, egl_image->GetInternalFormat(),
size().width(), size().height(), 1, 0, size().width(), size().height(), 1, 0,
egl_image->GetDataFormat(), egl_image->GetDataType(), egl_image->GetDataFormat(), egl_image->GetDataType(),
cleared_rect); ClearedRect());
texture->SetLevelImage(target, 0, egl_image.get(), gles2::Texture::BOUND); texture->SetLevelImage(target, 0, egl_image.get(), gles2::Texture::BOUND);
texture->SetImmutable(true, false); texture->SetImmutable(true, false);
api->glBindTextureFn(target, old_texture_binding); api->glBindTextureFn(target, old_texture_binding);
...@@ -887,7 +882,6 @@ std::unique_ptr<SharedImageBacking> SharedImageBackingFactoryAHB::MakeBacking( ...@@ -887,7 +882,6 @@ std::unique_ptr<SharedImageBacking> SharedImageBackingFactoryAHB::MakeBacking(
AHardwareBuffer_Desc hwb_info; AHardwareBuffer_Desc hwb_info;
base::AndroidHardwareBufferCompat::GetInstance().Describe(buffer, base::AndroidHardwareBufferCompat::GetInstance().Describe(buffer,
&hwb_info); &hwb_info);
void* address = nullptr; void* address = nullptr;
if (int error = base::AndroidHardwareBufferCompat::GetInstance().Lock( if (int error = base::AndroidHardwareBufferCompat::GetInstance().Lock(
buffer, AHARDWAREBUFFER_USAGE_CPU_WRITE_RARELY, -1, 0, &address)) { buffer, AHARDWAREBUFFER_USAGE_CPU_WRITE_RARELY, -1, 0, &address)) {
......
...@@ -34,6 +34,8 @@ SharedImageRepresentationGLTextureBase::BeginScopedAccess( ...@@ -34,6 +34,8 @@ SharedImageRepresentationGLTextureBase::BeginScopedAccess(
if (!BeginAccess(mode)) if (!BeginAccess(mode))
return nullptr; return nullptr;
UpdateClearedStateOnBeginAccess();
constexpr GLenum kReadAccess = 0x8AF6; constexpr GLenum kReadAccess = 0x8AF6;
if (mode == kReadAccess) if (mode == kReadAccess)
backing()->OnReadSucceeded(); backing()->OnReadSucceeded();
...@@ -61,6 +63,15 @@ void SharedImageRepresentationGLTexture::UpdateClearedStateOnEndAccess() { ...@@ -61,6 +63,15 @@ void SharedImageRepresentationGLTexture::UpdateClearedStateOnEndAccess() {
SetClearedRect(cleared_rect); SetClearedRect(cleared_rect);
} }
void SharedImageRepresentationGLTexture::UpdateClearedStateOnBeginAccess() {
auto* texture = GetTexture();
// Operations outside of the gles2::Texture may have cleared or uncleared it.
// Make sure this state is reflected back in gles2::Texture.
gfx::Rect cleared_rect = ClearedRect();
if (cleared_rect != texture->GetLevelClearedRect(texture->target(), 0))
texture->SetLevelClearedRect(texture->target(), 0, cleared_rect);
}
gpu::TextureBase* gpu::TextureBase*
SharedImageRepresentationGLTexturePassthrough::GetTextureBase() { SharedImageRepresentationGLTexturePassthrough::GetTextureBase() {
return GetTexturePassthrough().get(); return GetTexturePassthrough().get();
......
...@@ -136,7 +136,9 @@ class GPU_GLES2_EXPORT SharedImageRepresentationGLTextureBase ...@@ -136,7 +136,9 @@ class GPU_GLES2_EXPORT SharedImageRepresentationGLTextureBase
protected: protected:
friend class SharedImageRepresentationSkiaGL; friend class SharedImageRepresentationSkiaGL;
// Can be overridden to handle clear state tracking when GL access ends. // Can be overridden to handle clear state tracking when GL access begins or
// ends.
virtual void UpdateClearedStateOnBeginAccess() {}
virtual void UpdateClearedStateOnEndAccess() {} virtual void UpdateClearedStateOnEndAccess() {}
// TODO(ericrk): Make these pure virtual and ensure real implementations // TODO(ericrk): Make these pure virtual and ensure real implementations
...@@ -159,6 +161,7 @@ class GPU_GLES2_EXPORT SharedImageRepresentationGLTexture ...@@ -159,6 +161,7 @@ class GPU_GLES2_EXPORT SharedImageRepresentationGLTexture
gpu::TextureBase* GetTextureBase() override; gpu::TextureBase* GetTextureBase() override;
protected: protected:
void UpdateClearedStateOnBeginAccess() override;
void UpdateClearedStateOnEndAccess() override; void UpdateClearedStateOnEndAccess() override;
}; };
......
...@@ -74,13 +74,26 @@ TEST_F(SharedImageRepresentationTest, GLTextureClearing) { ...@@ -74,13 +74,26 @@ TEST_F(SharedImageRepresentationTest, GLTextureClearing) {
} }
EXPECT_TRUE(representation->IsCleared()); EXPECT_TRUE(representation->IsCleared());
// We can now begin accdess with |allow_uncleared| == false. // We can now begin access with |allow_uncleared| == false.
{ {
auto scoped_access = representation->BeginScopedAccess( auto scoped_access = representation->BeginScopedAccess(
GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM, GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM,
SharedImageRepresentation::AllowUnclearedAccess::kNo); SharedImageRepresentation::AllowUnclearedAccess::kNo);
EXPECT_TRUE(scoped_access); EXPECT_TRUE(scoped_access);
} }
// Reset the representation to uncleared. This should unclear the texture on
// BeginAccess.
representation->SetClearedRect(gfx::Rect());
{
auto scoped_access = representation->BeginScopedAccess(
GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM,
SharedImageRepresentation::AllowUnclearedAccess::kYes);
ASSERT_TRUE(scoped_access);
EXPECT_FALSE(
representation->GetTexture()->IsLevelCleared(GL_TEXTURE_2D, 0));
}
EXPECT_FALSE(representation->IsCleared());
} }
TEST_F(SharedImageRepresentationTest, GLTexturePassthroughClearing) { TEST_F(SharedImageRepresentationTest, GLTexturePassthroughClearing) {
......
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