Mali: Make the placeholder FBO complete for timer queries

Change the bindFramebufferForTimerQueries workaround to ensure
the framebuffer is complete.

Bug: chromium:1356053,b/269068358
Change-Id: Ief3198fdc4800468670a3f4323a1ffd3ca083c6f
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4582606
Auto-Submit: Kramer Ge <fangzhoug@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Kramer Ge 2023-06-02 16:09:24 -04:00 коммит произвёл Angle LUCI CQ
Родитель df787cf049
Коммит 88c6dfcc7d
7 изменённых файлов: 38 добавлений и 11 удалений

Просмотреть файл

@ -604,10 +604,10 @@ struct FeaturesGL : FeatureSetBase
&members,
};
FeatureInfo bindFramebufferForTimerQueries = {
"bindFramebufferForTimerQueries",
FeatureInfo bindCompleteFramebufferForTimerQueries = {
"bindCompleteFramebufferForTimerQueries",
FeatureCategory::OpenGLWorkarounds,
"Some drivers require a non-zero framebuffer when beginQuery for TimeElapsed or"
"Some drivers require a complete framebuffer when beginQuery for TimeElapsed or"
"Timestampis called.",
&members, "https://crbug.com/1356053"
};

Просмотреть файл

@ -652,10 +652,10 @@
]
},
{
"name": "bind_framebuffer_for_timer_queries",
"name": "bind_complete_framebuffer_for_timer_queries",
"category": "Workarounds",
"description": [
"Some drivers require a non-zero framebuffer when beginQuery for TimeElapsed or",
"Some drivers require a complete framebuffer when beginQuery for TimeElapsed or",
"Timestampis called."
],
"issue": "https://crbug.com/1356053"

Просмотреть файл

@ -104,6 +104,7 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions,
mFramebuffers(angle::FramebufferBindingSingletonMax, 0),
mRenderbuffer(0),
mPlaceholderFbo(0),
mPlaceholderRbo(0),
mScissorTestEnabled(false),
mScissor(0, 0, 0, 0),
mViewport(0, 0, 0, 0),
@ -232,6 +233,10 @@ StateManagerGL::~StateManagerGL()
{
deleteFramebuffer(mPlaceholderFbo);
}
if (mPlaceholderRbo != 0)
{
deleteRenderbuffer(mPlaceholderRbo);
}
if (mDefaultVAO != 0)
{
mFunctions->deleteVertexArrays(1, &mDefaultVAO);
@ -775,19 +780,40 @@ void StateManagerGL::beginQuery(gl::QueryType type, QueryGL *queryObject, GLuint
ASSERT(mQueries[type] == nullptr);
ASSERT(queryId != 0);
if (mFeatures.bindFramebufferForTimerQueries.enabled &&
mFramebuffers[angle::FramebufferBindingDraw] == 0 &&
GLuint oldFramebufferBindingDraw = mFramebuffers[angle::FramebufferBindingDraw];
if (mFeatures.bindCompleteFramebufferForTimerQueries.enabled &&
(mFramebuffers[angle::FramebufferBindingDraw] == 0 ||
mFunctions->checkFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) &&
(type == gl::QueryType::TimeElapsed || type == gl::QueryType::Timestamp))
{
if (!mPlaceholderFbo)
{
mFunctions->genFramebuffers(1, &mPlaceholderFbo);
}
bindFramebuffer(GL_FRAMEBUFFER, mPlaceholderFbo);
bindFramebuffer(GL_DRAW_FRAMEBUFFER, mPlaceholderFbo);
if (!mPlaceholderRbo)
{
GLuint oldRenderBufferBinding = mRenderbuffer;
mFunctions->genRenderbuffers(1, &mPlaceholderRbo);
bindRenderbuffer(GL_RENDERBUFFER, mPlaceholderRbo);
mFunctions->renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 2, 2);
mFunctions->framebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_RENDERBUFFER, mPlaceholderRbo);
bindRenderbuffer(GL_RENDERBUFFER, oldRenderBufferBinding);
// This ensures renderbuffer attachment is not lazy.
mFunctions->checkFramebufferStatus(GL_DRAW_FRAMEBUFFER);
}
}
mQueries[type] = queryObject;
mFunctions->beginQuery(ToGLenum(type), queryId);
if (oldFramebufferBindingDraw != mPlaceholderFbo)
{
bindFramebuffer(GL_DRAW_FRAMEBUFFER, oldFramebufferBindingDraw);
}
}
void StateManagerGL::endQuery(gl::QueryType type, QueryGL *queryObject, GLuint queryId)

Просмотреть файл

@ -464,6 +464,7 @@ class StateManagerGL final : angle::NonCopyable
std::vector<GLenum> mFramebuffers;
GLuint mRenderbuffer;
GLuint mPlaceholderFbo;
GLuint mPlaceholderRbo;
bool mScissorTestEnabled;
gl::Rectangle mScissor;

Просмотреть файл

@ -2564,7 +2564,7 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
functions->hasGLESExtension("GL_EXT_shader_pixel_local_storage"));
// https://crbug.com/1356053
ANGLE_FEATURE_CONDITION(features, bindFramebufferForTimerQueries, isMali);
ANGLE_FEATURE_CONDITION(features, bindCompleteFramebufferForTimerQueries, isMali);
// https://crbug.com/1434317
ANGLE_FEATURE_CONDITION(features, disableClipControl, IsMaliG72OrG76(functions));

Просмотреть файл

@ -47,7 +47,7 @@ constexpr PackedEnumMap<Feature, const char *> kFeatureNames = {{
{Feature::AsyncCommandQueue, "asyncCommandQueue"},
{Feature::Avoid1BitAlphaTextureFormats, "avoid1BitAlphaTextureFormats"},
{Feature::AvoidStencilTextureSwizzle, "avoidStencilTextureSwizzle"},
{Feature::BindFramebufferForTimerQueries, "bindFramebufferForTimerQueries"},
{Feature::BindCompleteFramebufferForTimerQueries, "bindCompleteFramebufferForTimerQueries"},
{Feature::BindTransformFeedbackBufferBeforeBindBufferRange, "bindTransformFeedbackBufferBeforeBindBufferRange"},
{Feature::BorderColorSrgb, "borderColorSrgb"},
{Feature::BottomLeftOriginPresentRegionRectangles, "bottomLeftOriginPresentRegionRectangles"},

Просмотреть файл

@ -47,7 +47,7 @@ enum class Feature
AsyncCommandQueue,
Avoid1BitAlphaTextureFormats,
AvoidStencilTextureSwizzle,
BindFramebufferForTimerQueries,
BindCompleteFramebufferForTimerQueries,
BindTransformFeedbackBufferBeforeBindBufferRange,
BorderColorSrgb,
BottomLeftOriginPresentRegionRectangles,