Show a patch.

GET /api/1.1/patches/26962/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 26962,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/26962/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26962/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20260618122245.946138-30-bryan.odonoghue@linaro.org>",
    "date": "2026-06-18T12:22:42",
    "name": "[29/30] libcamera: software_isp: gpu: Cache output framebuffers, only recreate when necessary",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "09802b6823c3d3d5e55c7df47523c2fbd1599302",
    "submitter": {
        "id": 175,
        "url": "https://patchwork.libcamera.org/api/1.1/people/175/?format=api",
        "name": "Bryan O'Donoghue",
        "email": "bryan.odonoghue@linaro.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26962/mbox/",
    "series": [
        {
            "id": 6005,
            "url": "https://patchwork.libcamera.org/api/1.1/series/6005/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6005",
            "date": "2026-06-18T12:22:13",
            "name": "RFC/RFT: gpuisp: Multipass with speed optimisations on top",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/6005/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26962/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26962/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CC6BDC3336\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Jun 2026 12:23:41 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 33295656D5;\n\tThu, 18 Jun 2026 14:23:41 +0200 (CEST)",
            "from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com\n\t[IPv6:2a00:1450:4864:20::32f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 565D462C79\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Jun 2026 14:23:20 +0200 (CEST)",
            "by mail-wm1-x32f.google.com with SMTP id\n\t5b1f17b1804b1-490be29c1c5so7266975e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Jun 2026 05:23:20 -0700 (PDT)",
            "from inspiron14p-linux ([109.76.144.236])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-4922fa3a4easm275198015e9.3.2026.06.18.05.23.19\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 18 Jun 2026 05:23:19 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"ulN39u/v\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1781785400; x=1782390200;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=BSSR9mqCpqCL14/lAv+iQMfbEByDwn/6jQSAQFMK9Uk=;\n\tb=ulN39u/vepRrWNuE8EurZwCDWMx+zsS/lvgCxaFMubnBwUcXgfeTjn+qXtXAj5ESWe\n\t5p4/nEP1fnInrdCLwzVDV4Ge1P6ZC+ZpNcopB7nh3BA2ZafQ8R6JOIqxunaRw7ItkyIG\n\tFyC2rtseD6NYNWcfZYfhPb8hBpp53Cc7fhTeZQ+fhvIcp817bdDtyQnIfcXH2pSxbate\n\tkxg35V3GRU1B3lmwXm5bJGthzwqWKJjTxy0HE/BXXywbPfPN+n02f5NwB2l8d51nEmk1\n\thH8+bs0KmSWo9ig8Kr5zoAxGaer9D18E6DalWq95HiaRpyKLg4Fmg370V7PnoVCff5L3\n\tkmQA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1781785400; x=1782390200;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=BSSR9mqCpqCL14/lAv+iQMfbEByDwn/6jQSAQFMK9Uk=;\n\tb=ToUvBDiMYNGghmAuWQtMmBWoE++ii/SQmJ7yFaSVF4sOmZx99ZSaJOpMSBvOh0uYwg\n\tILdpmdODOcZyFVh4lp7i8cReJCM29zTXwS5ZN2jmVmu8Wkqs3AH5r0Ht5M4DYKf73lj9\n\tp2WcONx7mghAIYsAq2bDL6NwBevlH/UyGc8LCFvcIVIF08fHNochknhF91GmHrkirQoQ\n\tbZKYKGSz+pWZKqNBSYBGfhZ6/gGTHbgrGkkOC9CuDpCfR59aZKZdW6KKls2GY1dx8fT5\n\tHOgM1BqEHItEnJhwa6f72dM5rj82zDKjG0mAP130V/niBuCuguYF0PqQC+r0kLhl6aYR\n\tjcLQ==",
        "X-Gm-Message-State": "AOJu0Yyk0exkg041SkaVAgVktF6xmcmBvUR/wRpQvSDI43ou5CEi5CM7\n\tJQKj1ag8Dskmj2efuZOfxTRqLQD6pDB4wj3RoitIdI8K0g7gLXH0t0Gbgni55b+8EcNSJBGwaP7\n\td4b8GBS8=",
        "X-Gm-Gg": "AfdE7cmxL60flH/TpejeMgpr7RHSxIO2vXew8P7VXt3CrjY6thLRYoTQviOtvCutQ7O\n\tsixGCX71TXBIGpgrAMSTq8mefCBqJRcnEQ8zhr3yuB7a89FtpxUPU4q+/qQ39pW4RSqj6i62VOE\n\ttk/mu6hBa+adubzcBLonNTS2gWJB2Y+xqxxeeZYFffpp/Vv+NHY28ayDHPRk61hHmauqhT5+7nb\n\th+F16wGQai4Srmq1kJPoK/qD6oCpjlCIHjSvOHHF/7WdAgO825uPoOOzQksrL8yQNDH8RBHCS3u\n\tVp+e1Gfs+Jjt5i8gjPSC9zoULno9R81SsAjDiCvpUznyxbi5dn3BUaycVRcy6/Y6GgPnibEXtua\n\tyN/1X5s6BxFGbfYShjmVJxHIm3ffHGBQgi8bWRgwfwu4msduhjkHGEriSqEXgkMI2etWkZ6y3U2\n\t4dYNWLPlcQ8VfwgjNh+L9I44Ysk0uL",
        "X-Received": "by 2002:a05:600c:e54a:10b0:490:e104:7943 with SMTP id\n\t5b1f17b1804b1-492333e294dmr102239425e9.18.1781785399781; \n\tThu, 18 Jun 2026 05:23:19 -0700 (PDT)",
        "From": "Bryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "bryan.odonoghue@linaro.org,\n\tpavel@ucw.cz",
        "Subject": "[PATCH 29/30] libcamera: software_isp: gpu: Cache output\n\tframebuffers, only recreate when necessary",
        "Date": "Thu, 18 Jun 2026 13:22:42 +0100",
        "Message-ID": "<20260618122245.946138-30-bryan.odonoghue@linaro.org>",
        "X-Mailer": "git-send-email 2.54.0",
        "In-Reply-To": "<20260618122245.946138-1-bryan.odonoghue@linaro.org>",
        "References": "<20260618122245.946138-1-bryan.odonoghue@linaro.org>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Once a texture has been created using dma-buf handle, we can switch texture\nunits and ids with our glsl program without re-creating textures.\n\nSince we are mapping pages, instead of copying the GPU simply takes the\nmaps it needs and operates on those.\n\nMuch faster.\n\n➜  libcamera git:(0.7.0-multipass-v4) ✗ grep Bench before.log\n[15:07:08.009062165] [1195303]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 729270us, 24309 us/frame\n[15:07:11.686143411] [1195334]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 733995us, 24466 us/frame\n[15:07:14.980640685] [1195363]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 740157us, 24671 us/frame\n[15:07:18.163299379] [1195393]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 720094us, 24003 us/frame\n[15:07:21.366461990] [1195422]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 719166us, 23972 us/frame\n[15:07:24.718877325] [1195451]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 725425us, 24180 us/frame\n[15:07:28.924768220] [1195481]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 753400us, 25113 us/frame\n[15:07:32.336224289] [1195513]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 727160us, 24238 us/frame\n[15:07:35.638928194] [1195542]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 762408us, 25413 us/frame\n[15:07:38.868084716] [1195579]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 728991us, 24299 us/frame\n\n➜  libcamera git:(0.7.0-multipass-v4) ✗ grep Bench after.log\n[16:26:07.109426223] [1202010]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 650120us, 21670 us/frame\n[16:26:18.925748074] [1202048]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 611062us, 20368 us/frame\n[16:26:22.712614967] [1202077]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 609333us, 20311 us/frame\n[16:26:26.551615514] [1202107]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 609791us, 20326 us/frame\n[16:26:30.085663553] [1202136]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 612838us, 20427 us/frame\n[16:26:34.945255617] [1202165]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 681918us, 22730 us/frame\n[16:26:39.031353171] [1202194]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 595551us, 19851 us/frame\n[16:26:42.610503048] [1202227]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 663929us, 22130 us/frame\n[16:26:46.100211690] [1202256]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 580685us, 19356 us/frame\n[16:26:49.394640903] [1202286]  INFO Benchmark benchmark.cpp:89 Debayer processed 30 frames in 595072us, 19835 us/frame\n\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n .../software_isp/software_isp_pipeline_gpu.cpp  | 17 ++++++++++-------\n .../software_isp/software_isp_pipeline_gpu.h    |  2 +-\n 2 files changed, 11 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/src/libcamera/software_isp/software_isp_pipeline_gpu.cpp b/src/libcamera/software_isp/software_isp_pipeline_gpu.cpp\nindex 2e5c0e40e..bc5d59575 100644\n--- a/src/libcamera/software_isp/software_isp_pipeline_gpu.cpp\n+++ b/src/libcamera/software_isp/software_isp_pipeline_gpu.cpp\n@@ -263,8 +263,14 @@ int SoftwareIspPipelineGpu::processGPU(FrameBuffer *input, FrameBuffer *output,\n \t\tegl_.updateInputTexture2D(*eglImageBayerIn_, inMapped->value().planes()[0].data());\n \t}\n \n-\t/* Generate the output render framebuffer as render to texture */\n-\tegl_.createOutputDMABufTexture2D(*eglImageRGBAOut_, output->planes()[0].fd.get());\n+\t/* Find an existing eglImage in the cache */\n+\tauto [output_cache, output_miss] = eglImageRGBAOut_.try_emplace(output);\n+\tif (output_miss) {\n+\t\t/* Generate the output render framebuffer as render to texture */\n+\t\toutput_cache->second = std::make_unique<eGLImage>(GL_RGBA, outputSize_.width, outputSize_.height, outputConfig_.stride, GL_TEXTURE3, 3);\n+\t\tegl_.createOutputDMABufTexture2D(*output_cache->second, output->planes()[0].fd.get());\n+\t}\n+\teGLImage &eglImageRGBAOut = *output_cache->second;\n \n \tpipelineResult = gpuIspShaderPassBlcNormalise_.process(*eglImageBayerIn_, *eglImagePingPong_[0], width_, height_, params);\n \tif (pipelineResult) {\n@@ -272,7 +278,7 @@ int SoftwareIspPipelineGpu::processGPU(FrameBuffer *input, FrameBuffer *output,\n \t\treturn pipelineResult;\n \t}\n \n-\tpipelineResult = gpuIspShaderPassDemosiac_.process(*eglImagePingPong_[0], *eglImageRGBAOut_, width_, height_, params);\n+\tpipelineResult = gpuIspShaderPassDemosiac_.process(*eglImagePingPong_[0], eglImageRGBAOut, width_, height_, params);\n \tif (pipelineResult) {\n \t\tLOG(Debayer, Error) << \"Demosiac fail\";\n \t\treturn pipelineResult;\n@@ -371,9 +377,6 @@ int SoftwareIspPipelineGpu::start()\n \teglImagePingPong_[0] = std::make_unique<eGLImage>(gpuIspShaderPassDemosiac_.glFormat_, width_, height_, outputConfig_.stride, GL_TEXTURE1, 1);\n \teglImagePingPong_[1] = std::make_unique<eGLImage>(gpuIspShaderPassDemosiac_.glFormat_, width_, height_, outputConfig_.stride, GL_TEXTURE2, 2);\n \n-\t/* Texture we will render to */\n-\teglImageRGBAOut_ = std::make_unique<eGLImage>(GL_RGBA, outputSize_.width, outputSize_.height, outputConfig_.stride, GL_TEXTURE3, 3);\n-\n \tegl_.createInputTexture2D(*eglImageBayerIn_, NULL);\n \tegl_.createOutputTexture2D(*eglImagePingPong_[0]);\n \tegl_.createOutputTexture2D(*eglImagePingPong_[1]);\n@@ -383,7 +386,7 @@ int SoftwareIspPipelineGpu::start()\n \n void SoftwareIspPipelineGpu::stop()\n {\n-\teglImageRGBAOut_.reset();\n+\teglImageRGBAOut_.clear();\n \teglImagePingPong_[1].reset();\n \teglImagePingPong_[0].reset();\n \teglImageBayerIn_.reset();\ndiff --git a/src/libcamera/software_isp/software_isp_pipeline_gpu.h b/src/libcamera/software_isp/software_isp_pipeline_gpu.h\nindex b32d4cad3..995e84295 100644\n--- a/src/libcamera/software_isp/software_isp_pipeline_gpu.h\n+++ b/src/libcamera/software_isp/software_isp_pipeline_gpu.h\n@@ -69,7 +69,7 @@ private:\n \t/* Pointer to object representing input texture */\n \tstd::unique_ptr<eGLImage> eglImageBayerIn_;\n \tstd::unique_ptr<eGLImage> eglImagePingPong_[2];\n-\tstd::unique_ptr<eGLImage> eglImageRGBAOut_;\n+\tstd::unordered_map<FrameBuffer *, std::unique_ptr<eGLImage>> eglImageRGBAOut_;\n \n \tstd::unique_ptr<SwStatsCpu> stats_;\n \teGL egl_;\n",
    "prefixes": [
        "29/30"
    ]
}