From 4a17eac8a1fba12e53a8d66424cf90ae9516fbe8 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Fri, 22 Nov 2024 12:26:11 -0800 Subject: [PATCH] [Impeller] dont create temp vec for discard. (flutter/engine#56759) This can have at most 3 entries so just use an array to avoid heap allocation. --- .../renderer/backend/gles/render_pass_gles.cc | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/engine/src/flutter/impeller/renderer/backend/gles/render_pass_gles.cc b/engine/src/flutter/impeller/renderer/backend/gles/render_pass_gles.cc index de30895407..594fcfab07 100644 --- a/engine/src/flutter/impeller/renderer/backend/gles/render_pass_gles.cc +++ b/engine/src/flutter/impeller/renderer/backend/gles/render_pass_gles.cc @@ -492,7 +492,8 @@ void RenderPassGLES::ResetGLState(const ProcTableGLES& gl) { } if (gl.DiscardFramebufferEXT.IsAvailable()) { - std::vector attachments; + std::array attachments; + size_t attachment_count = 0; // TODO(130048): discarding stencil or depth on the default fbo causes Angle // to discard the entire render target. Until we know the reason, default to @@ -500,21 +501,21 @@ void RenderPassGLES::ResetGLState(const ProcTableGLES& gl) { bool angle_safe = gl.GetCapabilities()->IsANGLE() ? !is_default_fbo : true; if (pass_data.discard_color_attachment) { - attachments.push_back(is_default_fbo ? GL_COLOR_EXT - : GL_COLOR_ATTACHMENT0); + attachments[attachment_count++] = + (is_default_fbo ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0); } if (pass_data.discard_depth_attachment && angle_safe) { - attachments.push_back(is_default_fbo ? GL_DEPTH_EXT - : GL_DEPTH_ATTACHMENT); + attachments[attachment_count++] = + (is_default_fbo ? GL_DEPTH_EXT : GL_DEPTH_ATTACHMENT); } if (pass_data.discard_stencil_attachment && angle_safe) { - attachments.push_back(is_default_fbo ? GL_STENCIL_EXT - : GL_STENCIL_ATTACHMENT); + attachments[attachment_count++] = + (is_default_fbo ? GL_STENCIL_EXT : GL_STENCIL_ATTACHMENT); } - gl.DiscardFramebufferEXT(GL_FRAMEBUFFER, // target - attachments.size(), // attachments to discard - attachments.data() // size + gl.DiscardFramebufferEXT(GL_FRAMEBUFFER, // target + attachment_count, // attachments to discard + attachments.data() // size ); }