Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7a682ac

Browse files
author
Jonah Williams
authored
[Impeller] dont create temp vec for discard. (#56759)
This can have at most 3 entries so just use an array to avoid heap allocation.
1 parent 9384df4 commit 7a682ac

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

impeller/renderer/backend/gles/render_pass_gles.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -492,29 +492,30 @@ void RenderPassGLES::ResetGLState(const ProcTableGLES& gl) {
492492
}
493493

494494
if (gl.DiscardFramebufferEXT.IsAvailable()) {
495-
std::vector<GLenum> attachments;
495+
std::array<GLenum, 3> attachments;
496+
size_t attachment_count = 0;
496497

497498
// TODO(130048): discarding stencil or depth on the default fbo causes Angle
498499
// to discard the entire render target. Until we know the reason, default to
499500
// storing.
500501
bool angle_safe = gl.GetCapabilities()->IsANGLE() ? !is_default_fbo : true;
501502

502503
if (pass_data.discard_color_attachment) {
503-
attachments.push_back(is_default_fbo ? GL_COLOR_EXT
504-
: GL_COLOR_ATTACHMENT0);
504+
attachments[attachment_count++] =
505+
(is_default_fbo ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0);
505506
}
506507
if (pass_data.discard_depth_attachment && angle_safe) {
507-
attachments.push_back(is_default_fbo ? GL_DEPTH_EXT
508-
: GL_DEPTH_ATTACHMENT);
508+
attachments[attachment_count++] =
509+
(is_default_fbo ? GL_DEPTH_EXT : GL_DEPTH_ATTACHMENT);
509510
}
510511

511512
if (pass_data.discard_stencil_attachment && angle_safe) {
512-
attachments.push_back(is_default_fbo ? GL_STENCIL_EXT
513-
: GL_STENCIL_ATTACHMENT);
513+
attachments[attachment_count++] =
514+
(is_default_fbo ? GL_STENCIL_EXT : GL_STENCIL_ATTACHMENT);
514515
}
515-
gl.DiscardFramebufferEXT(GL_FRAMEBUFFER, // target
516-
attachments.size(), // attachments to discard
517-
attachments.data() // size
516+
gl.DiscardFramebufferEXT(GL_FRAMEBUFFER, // target
517+
attachment_count, // attachments to discard
518+
attachments.data() // size
518519
);
519520
}
520521

0 commit comments

Comments
 (0)