GLES: Invalidate framebuffers bound DONT_CARE.

Let's try to invalidate when it's possible.  We move the invalidate to the
end of the render when detected.
This commit is contained in:
Unknown W. Brackets 2020-05-16 16:56:31 -07:00
parent 6009bf7b74
commit dbbcaa9eca

View File

@ -609,6 +609,44 @@ void GLQueueRunner::RunSteps(const std::vector<GLRStep *> &steps, bool skipGLCal
}
}
auto ignoresContents = [](GLRRenderPassAction act) {
return act == GLRRenderPassAction::CLEAR || act == GLRRenderPassAction::DONT_CARE;
};
int invalidateAllMask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
for (int j = 0; j < (int)steps.size() - 1; ++j) {
GLRStep &primaryStep = *steps[j];
if (primaryStep.stepType == GLRStepType::RENDER) {
const GLRFramebuffer *fb = primaryStep.render.framebuffer;
// Let's see if we can invalidate it...
int invalidateMask = 0;
for (int i = j + 1; i < (int)steps.size(); ++i) {
const GLRStep &secondaryStep = *steps[i];
if (secondaryStep.stepType == GLRStepType::RENDER && secondaryStep.render.framebuffer == fb) {
if (ignoresContents(secondaryStep.render.color))
invalidateMask |= GL_COLOR_BUFFER_BIT;
if (ignoresContents(secondaryStep.render.depth))
invalidateMask |= GL_DEPTH_BUFFER_BIT;
if (ignoresContents(secondaryStep.render.stencil))
invalidateMask |= GL_STENCIL_BUFFER_BIT;
if (invalidateMask == invalidateAllMask)
break;
} else if (secondaryStep.dependencies.contains(fb)) {
// Can't do it, this step may depend on fb's data.
break;
}
}
if (invalidateMask) {
GLRRenderData data{ GLRRenderCommand::INVALIDATE };
data.clear.clearMask = invalidateMask;
primaryStep.commands.push_back(data);
}
}
}
CHECK_GL_ERROR_IF_DEBUG();
size_t renderCount = 0;
for (size_t i = 0; i < steps.size(); i++) {