-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Impeller] Fix GL depth state. #51040
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,12 +214,11 @@ struct RenderPassData { | |
pass_data.clear_color.alpha // alpha | ||
); | ||
if (pass_data.depth_attachment) { | ||
// TODO(bdero): Desktop GL for Apple requires glClearDepth. glClearDepthf | ||
// throws GL_INVALID_OPERATION. | ||
// https://github.com/flutter/flutter/issues/136322 | ||
#if !FML_OS_MACOSX | ||
gl.ClearDepthf(pass_data.clear_depth); | ||
#endif | ||
if (gl.DepthRangef.IsAvailable()) { | ||
gl.ClearDepthf(pass_data.clear_depth); | ||
} else { | ||
gl.ClearDepth(pass_data.clear_depth); | ||
} | ||
} | ||
if (pass_data.stencil_attachment) { | ||
gl.ClearStencil(pass_data.clear_stencil); | ||
|
@@ -242,6 +241,9 @@ struct RenderPassData { | |
gl.Disable(GL_CULL_FACE); | ||
gl.Disable(GL_BLEND); | ||
gl.ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | ||
gl.DepthMask(GL_TRUE); | ||
gl.StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | ||
gl.StencilMaskSeparate(GL_BACK, 0xFFFFFFFF); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When depth buffer clipping + StC is enabled, the depth mask toggles very frequently, so we need to make sure it's on before clearing. We've yet to utilize the stencil mask in the 2D renderer, which is why we haven't noticed this problem up until now. |
||
|
||
gl.Clear(clear_bits); | ||
|
||
|
@@ -315,12 +317,11 @@ struct RenderPassData { | |
viewport.rect.GetHeight() // height | ||
); | ||
if (pass_data.depth_attachment) { | ||
// TODO(bdero): Desktop GL for Apple requires glDepthRange. glDepthRangef | ||
// throws GL_INVALID_OPERATION. | ||
// https://github.com/flutter/flutter/issues/136322 | ||
#if !FML_OS_MACOSX | ||
gl.DepthRangef(viewport.depth_range.z_near, viewport.depth_range.z_far); | ||
#endif | ||
if (gl.DepthRangef.IsAvailable()) { | ||
gl.DepthRangef(viewport.depth_range.z_near, viewport.depth_range.z_far); | ||
} else { | ||
gl.DepthRange(viewport.depth_range.z_near, viewport.depth_range.z_far); | ||
} | ||
} | ||
|
||
//-------------------------------------------------------------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
impeller/renderer/backend/gles/test/proc_table_gles_unittests.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <optional> | ||
|
||
#include "flutter/testing/testing.h" // IWYU pragma: keep | ||
#include "gtest/gtest.h" | ||
#include "impeller/renderer/backend/gles/proc_table_gles.h" | ||
#include "impeller/renderer/backend/gles/test/mock_gles.h" | ||
|
||
namespace impeller { | ||
namespace testing { | ||
|
||
#define EXPECT_AVAILABLE(proc_ivar) \ | ||
EXPECT_TRUE(mock_gles->GetProcTable().proc_ivar.IsAvailable()); | ||
#define EXPECT_UNAVAILABLE(proc_ivar) \ | ||
EXPECT_FALSE(mock_gles->GetProcTable().proc_ivar.IsAvailable()); | ||
|
||
TEST(ProcTableGLES, ResolvesCorrectClearDepthProcOnES) { | ||
auto mock_gles = MockGLES::Init(std::nullopt, "OpenGL ES 3.0"); | ||
EXPECT_TRUE(mock_gles->GetProcTable().GetDescription()->IsES()); | ||
|
||
FOR_EACH_IMPELLER_ES_ONLY_PROC(EXPECT_AVAILABLE); | ||
FOR_EACH_IMPELLER_DESKTOP_ONLY_PROC(EXPECT_UNAVAILABLE); | ||
} | ||
|
||
TEST(ProcTableGLES, ResolvesCorrectClearDepthProcOnDesktopGL) { | ||
auto mock_gles = MockGLES::Init(std::nullopt, "OpenGL 4.0"); | ||
EXPECT_FALSE(mock_gles->GetProcTable().GetDescription()->IsES()); | ||
|
||
FOR_EACH_IMPELLER_DESKTOP_ONLY_PROC(EXPECT_AVAILABLE); | ||
FOR_EACH_IMPELLER_ES_ONLY_PROC(EXPECT_UNAVAILABLE); | ||
} | ||
|
||
} // namespace testing | ||
} // namespace impeller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was one of the issues for OpenGLES playground runs on MacOS. OpenGL defaults the depth clear value to 1. But my new depth clipping scheme relies on clearing to 0.
And so not being able to modify the depth clear value meant nothing could draw in subpasses that had a depth attachment.