From patchwork Wed Nov 18 09:57:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 28978 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D3901BDE17 for ; Wed, 18 Nov 2026 09:58:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 78BAA6A8F1; Wed, 18 Nov 2026 10:58:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YKmAqffr"; dkim-atps=neutral Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 50C916A8DA for ; Wed, 18 Nov 2026 10:58:07 +0100 (CET) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4a210470b49so6710325e9.2 for ; Wed, 18 Nov 2026 01:58:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1794995887; x=1795600687; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=H3yaLXLKrl/tHsPQkdHfE9aVdZPQd0ODo73jt87lwyA=; b=YKmAqffrB75z5aPQWplFeoricPXpA6kJFFyD6VptToOWgiPKqhiD5LfuwERZ49YWZq vvfc+x8mg9vv2P0XcaOKWCUGlCouFqultBuwqurlZPmSUZ1/Yl2mD8EwliGcvLpxs4rc pephqI4ce7tsdw/c3VpIA5QEOrSJhvBOO+ofhqz1CamiV1d3iVjr6P7sIgIAb5tRr2AO AiHcwGp+t0rbbthvGn5n9cPqEI7lEWxkiWlFiI+cb4Z7+cMKBIsKM96xqyrP8F1jd4Qb ecz6mbkLF6ln6nEuXN9ffvITB9ZTqQKbph5ct4sX8rrLd2czon3rRMHeIbOubmFZnSmn tUMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794995887; x=1795600687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=H3yaLXLKrl/tHsPQkdHfE9aVdZPQd0ODo73jt87lwyA=; b=rsqswf2aSq/7rofgk5EtfVjZ+7/dv4UoNPl55ni+SBIAbc3r0rfJVHgjOgNOJT46Dr ZeD9EWPopovrfCtlxVpLRzbq+ssKBluW/cSdGQtLuB/9IYICR+nB8k8e5mwLeFiozutb glIZYLtXsBO5MgdjfxlH0cLAE2b31C/VOt0a1s3rBTmltclJcVW7tObAutl3cTr362oh SNxpeaDf0qY7X6ZIRqwcN9dgXDxbgV00VSb46WdWoPWGuAMDW4IG6uQYe1ZNOnUXjvoB MYG/6F9rKlxo6vvwI65nMsXimBiJmY+Foo3rBqPI5vS4DJccd5elNboI4m97PRle7Qdm 0SBQ== X-Gm-Message-State: APuU4Z/XsxA7J01d/Xb2AAIsAmQAMMjLymUhmoOZO6CBGH9uA4nLmiw1 gfvqSyG3BYdGsR3XfMHdygaNwAl7oqVYU+h+MGNS4SmW458MjdLY5sUY0s/8ExAL//b3b20cNcD ag+OjQEk= X-Gm-Gg: AZFdTZfCfTnwV2NzNnPo8YCHwsuNcSTXxol+EjKVEs3Wzs4AUWRC6Wuvem6bF/JBlRO oBHxH3uFa/eJ1lTmsgGScP2ZTmaNuY5Qh6l6y3ZBZrT6Rnsm+GZRKjvl0+sW+4PE39GOVf2Y4nt L4v+KGTN2kPtFF/HvrBX9eH53T6pajZL8MrlGGyk4jj86SULBXkOL9FOktVZPV6AuC41TXxTgy7 zHYknNDMwbHaKP8rqR1SQK07pBw9RHEDMid32jFW4Pgws/D+Z5ylzeSW4EjQQifDR3hMW8cSPS8 k8JrQwLit8bf6hltx3lBMFL5gVXM3clsxx8Uhoi1BAq118GT850dou7d+f9VJI41tnu1fdMpiEf 0io8/q23Ye3VuAuCMys+9c7VL5JFq903LFzVrA4SporDw0TLnz+iAtoNl6dyRjAdLtV3Tw52RUU sM9fdckd6CJXf/F2elbK/+LI1XN5GJHkOQZCnu8R5Lc0UBllkfOMNfhLwC4QLKJ31C/0RgWTVm2 zHagdxOZW74GV+6vL+2s9IGST+H9iznhuwvrIeNGwDtZDUwYY65XmIJnk2N5d312aPHGknZqDZT cYHuMHWC+V87tZW+3STc5l3f5MSWq7C69oX8hveuAWfuEw== X-Received: by 2002:a05:6000:2509:b0:4a7:e4c7:2775 with SMTP id ffacd0b85a97d-4a7e4c72812mr730046f8f.45.1794995886710; Wed, 18 Nov 2026 01:58:06 -0800 (PST) Received: from inspiron14p-linux ([109.76.187.112]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4a655f9f4a7sm3940871f8f.34.2026.11.18.01.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 01:58:05 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: rstrode@redhat.com, robert.mader@collabora.com, barnabas.pocze@ideasonboard.com, Bryan O'Donoghue Subject: [RFC PATCH v2 17/26] libcamera: software_isp: gpu: Swtich to two pass logic Date: Wed, 18 Nov 2026 10:57:24 +0100 Message-ID: <20261118095735.170587-18-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261118095735.170587-1-bryan.odonoghue@linaro.org> References: <20261118095735.170587-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Signed-off-by: Bryan O'Donoghue --- ...gpu_pipeline_shader_pass_blc_normalise.cpp | 11 ++-- .../gpu_pipeline_shader_pass_demosiac.cpp | 31 ++++------- .../gpu_pipeline_shader_pass_demosiac.h | 3 -- .../software_isp_instance_gpu.cpp | 54 ++++++++++++------- 4 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/libcamera/software_isp/gpu_pipeline_shader_pass_blc_normalise.cpp b/src/libcamera/software_isp/gpu_pipeline_shader_pass_blc_normalise.cpp index 86681061a..c5c19f85d 100644 --- a/src/libcamera/software_isp/gpu_pipeline_shader_pass_blc_normalise.cpp +++ b/src/libcamera/software_isp/gpu_pipeline_shader_pass_blc_normalise.cpp @@ -84,6 +84,8 @@ int GpuIspShaderPassBlcNormalise::selectShaders(struct ShaderConfig &shaderCfg, break; }; + LOG(GpuShaderBlc, Info) << "ShaderPass = " << typeid(this).name() << " selected shader pair "; + return 0; } @@ -95,15 +97,14 @@ int GpuIspShaderPassBlcNormalise::getShaderVariableLocations(void) textureUniformStep_ = glGetUniformLocation(programId_, "tex_step"); textureUniformSize_ = glGetUniformLocation(programId_, "tex_size"); textureUniformStrideFactor_ = glGetUniformLocation(programId_, "stride_factor"); - textureUniformBayerFirstRed_ = glGetUniformLocation(programId_, "tex_bayer_first_red"); textureUniformProjMatrix_ = glGetUniformLocation(programId_, "proj_matrix"); + blackLevelUniformDataIn_ = glGetUniformLocation(programId_, "blacklevel"); LOG(GpuShaderBlc, Debug) << "vertexIn " << attributeVertex_ << " textureIn " << attributeTexture_ << " tex_y " << textureUniformBayerDataIn_ << " tex_step " << textureUniformStep_ << " tex_size " << textureUniformSize_ << " stride_factor " << textureUniformStrideFactor_ - << " tex_bayer_first_red " << textureUniformBayerFirstRed_ << " proj_matrix " << textureUniformProjMatrix_; /* TODO: trap errors */ @@ -169,13 +170,11 @@ void GpuIspShaderPassBlcNormalise::setShaderVariableValues(eGLImage &eglImageIn, /* * These values are: - * firstRed = tex_bayer_first_red - bayer_8.vert * imgSize = tex_size - bayer_8.vert * step = tex_step - bayer_8.vert * Stride = stride_factor identity.vert * textureUniformProjMatri = No scaling */ - glUniform2fv(textureUniformBayerFirstRed_, 1, firstRed); glUniform2fv(textureUniformSize_, 1, imgSize); glUniform2fv(textureUniformStep_, 1, Step); glUniform1f(textureUniformStrideFactor_, Stride); @@ -185,8 +184,7 @@ void GpuIspShaderPassBlcNormalise::setShaderVariableValues(eGLImage &eglImageIn, << " tex_y " << textureUniformBayerDataIn_ << " tex_step " << textureUniformStep_ << " tex_size " << textureUniformSize_ - << " stride_factor " << textureUniformStrideFactor_ - << " tex_bayer_first_red " << textureUniformBayerFirstRed_; + << " stride_factor " << textureUniformStrideFactor_; LOG(GpuShaderBlc, Debug) << "textureUniformY_ = 0 " << " firstRed.x " << firstRed[0] @@ -202,6 +200,7 @@ void GpuIspShaderPassBlcNormalise::setShaderVariableValues(eGLImage &eglImageIn, * 0 = Red, 1 = Green, 2 = Blue */ glUniform3f(blackLevelUniformDataIn_, params.blackLevel[0], params.blackLevel[1], params.blackLevel[2]); + LOG(GpuShaderBlc, Debug) << " blackLevelUniformDataIn_ " << blackLevelUniformDataIn_ << " data " << params.blackLevel; return; diff --git a/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.cpp b/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.cpp index 458d4c02c..47daa1f1f 100644 --- a/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.cpp +++ b/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.cpp @@ -42,18 +42,18 @@ int GpuIspShaderPassDemosiac::selectShaders(struct ShaderConfig &shaderCfg, [[ma egl_.pushEnv(shaderCfg.shaderEnv, "#define APPLY_LSC"); /* Pixel location parameters */ - glFormat_ = GL_LUMINANCE; + glFormat_ = GL_R16F; //todo: not all systems support floating point framebuffers so gl_luminance will be default unless indicated by interrogation bytesPerPixel_ = 1; shaderStridePixels_ = passInputCfg_.stride; - /* Shader selection */ + shaderCfg.fragmentShaderData = bayer_unpacked_frag; + shaderCfg.vertexShaderData = bayer_unpacked_vert; + switch (inputFormat) { case libcamera::formats::SBGGR8: case libcamera::formats::SGBRG8: case libcamera::formats::SGRBG8: case libcamera::formats::SRGGB8: - shaderCfg.fragmentShaderData = bayer_unpacked_frag; - shaderCfg.vertexShaderData = bayer_unpacked_vert; break; case libcamera::formats::SBGGR10_CSI2P: case libcamera::formats::SGBRG10_CSI2P: @@ -61,13 +61,9 @@ int GpuIspShaderPassDemosiac::selectShaders(struct ShaderConfig &shaderCfg, [[ma case libcamera::formats::SRGGB10_CSI2P: egl_.pushEnv(shaderCfg.shaderEnv, "#define RAW10P"); if (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) { - shaderCfg.fragmentShaderData = bayer_unpacked_frag; - shaderCfg.vertexShaderData = bayer_unpacked_vert; glFormat_ = GL_RG; bytesPerPixel_ = 2; } else { - shaderCfg.fragmentShaderData = bayer_1x_packed_frag; - shaderCfg.vertexShaderData = identity_vert; shaderStridePixels_ = passInputCfg_.size.width; } break; @@ -77,13 +73,9 @@ int GpuIspShaderPassDemosiac::selectShaders(struct ShaderConfig &shaderCfg, [[ma case libcamera::formats::SRGGB12_CSI2P: egl_.pushEnv(shaderCfg.shaderEnv, "#define RAW12P"); if (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) { - shaderCfg.fragmentShaderData = bayer_unpacked_frag; - shaderCfg.vertexShaderData = bayer_unpacked_vert; glFormat_ = GL_RG; bytesPerPixel_ = 2; } else { - shaderCfg.fragmentShaderData = bayer_1x_packed_frag; - shaderCfg.vertexShaderData = identity_vert; shaderStridePixels_ = passInputCfg_.size.width; } break; @@ -98,6 +90,8 @@ int GpuIspShaderPassDemosiac::selectShaders(struct ShaderConfig &shaderCfg, [[ma egl_.createTexture2D(*eglImageLscLookup_, nullptr, GL_LINEAR); } + LOG(GpuShaderDemosiac, Info) << "ShaderPass = " << typeid(this).name() << " selected shader pair "; + return 0; } @@ -109,26 +103,23 @@ int GpuIspShaderPassDemosiac::getShaderVariableLocations(void) textureUniformBayerDataIn_ = glGetUniformLocation(programId_, "tex_y"); awbUniformDataIn_ = glGetUniformLocation(programId_, "awb"); ccmUniformDataIn_ = glGetUniformLocation(programId_, "ccm"); - blackLevelUniformDataIn_ = glGetUniformLocation(programId_, "blacklevel"); gammaUniformDataIn_ = glGetUniformLocation(programId_, "gamma"); contrastExpUniformDataIn_ = glGetUniformLocation(programId_, "contrastExp"); textureUniformLsc_ = glGetUniformLocation(programId_, "lsc_tex"); - textureUniformStep_ = glGetUniformLocation(programId_, "tex_step"); - textureUniformSize_ = glGetUniformLocation(programId_, "tex_size"); textureUniformStrideFactor_ = glGetUniformLocation(programId_, "stride_factor"); textureUniformBayerFirstRed_ = glGetUniformLocation(programId_, "tex_bayer_first_red"); textureUniformProjMatrix_ = glGetUniformLocation(programId_, "proj_matrix"); + textureUniformBayerDataIn_ = glGetUniformLocation(programId_, "tex_y"); + textureUniformStep_ = glGetUniformLocation(programId_, "tex_step"); + textureUniformSize_ = glGetUniformLocation(programId_, "tex_size"); LOG(GpuShaderDemosiac, Debug) << "vertexIn " << attributeVertex_ << " textureIn " << attributeTexture_ << " tex_y " << textureUniformBayerDataIn_ << " awb " << awbUniformDataIn_ << " ccm " << ccmUniformDataIn_ - << " blacklevel " << blackLevelUniformDataIn_ << " gamma " << gammaUniformDataIn_ << " contrastExp " << contrastExpUniformDataIn_ - << " tex_step " << textureUniformStep_ - << " tex_size " << textureUniformSize_ << " stride_factor " << textureUniformStrideFactor_ << " tex_bayer_first_red " << textureUniformBayerFirstRed_ << " proj_matrix " << textureUniformProjMatrix_; @@ -210,8 +201,6 @@ void GpuIspShaderPassDemosiac::setShaderVariableValues(eGLImage &eglImageIn, con LOG(GpuShaderDemosiac, Debug) << "vertexIn " << attributeVertex_ << " textureIn " << attributeTexture_ << " tex_y " << textureUniformBayerDataIn_ - << " tex_step " << textureUniformStep_ - << " tex_size " << textureUniformSize_ << " stride_factor " << textureUniformStrideFactor_ << " tex_bayer_first_red " << textureUniformBayerFirstRed_; @@ -240,8 +229,6 @@ void GpuIspShaderPassDemosiac::setShaderVariableValues(eGLImage &eglImageIn, con /* * 0 = Red, 1 = Green, 2 = Blue */ - glUniform3f(blackLevelUniformDataIn_, params.blackLevel[0], params.blackLevel[1], params.blackLevel[2]); - LOG(GpuShaderDemosiac, Debug) << " blackLevelUniformDataIn_ " << blackLevelUniformDataIn_ << " data " << params.blackLevel; glUniform3f(awbUniformDataIn_, params.gains[0], params.gains[1], params.gains[2]); LOG(GpuShaderDemosiac, Debug) << " awbUniformDataIn_ " << awbUniformDataIn_ << " data " << params.gains; diff --git a/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.h b/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.h index 47ac8f7e2..4d91254a2 100644 --- a/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.h +++ b/src/libcamera/software_isp/gpu_pipeline_shader_pass_demosiac.h @@ -53,9 +53,6 @@ private: /* Represent per-frame CCM as a uniform vector of floats 3 x 3 */ GLint ccmUniformDataIn_; - /* Black Level compensation */ - GLint blackLevelUniformDataIn_; - /* Gamma */ GLint gammaUniformDataIn_; diff --git a/src/libcamera/software_isp/software_isp_instance_gpu.cpp b/src/libcamera/software_isp/software_isp_instance_gpu.cpp index ba364516f..13d27ab7a 100644 --- a/src/libcamera/software_isp/software_isp_instance_gpu.cpp +++ b/src/libcamera/software_isp/software_isp_instance_gpu.cpp @@ -29,6 +29,8 @@ namespace libcamera { +LOG_DEFINE_CATEGORY(SoftwareIspInstanceGpu) + /** * \class SoftwareIspInstanceGpu * \brief Class for debayering using an EGL Shader @@ -91,7 +93,7 @@ int SoftwareIspInstanceGpu::getInputConfig(PixelFormat inputFormat, DebayerInput return 0; } - LOG(SoftwareIspInstance, Debug) + LOG(SoftwareIspInstanceGpu, Debug) << "Unsupported input format " << inputFormat; return -EINVAL; @@ -127,7 +129,7 @@ int SoftwareIspInstanceGpu::configure(const StreamConfiguration &inputCfg, const Size &stats_pattern_size = stats_->patternSize(); if (inputConfig_.patternSize.width != stats_pattern_size.width || inputConfig_.patternSize.height != stats_pattern_size.height) { - LOG(SoftwareIspInstance, Error) + LOG(SoftwareIspInstanceGpu, Error) << "mismatching stats and debayer pattern sizes for " << inputCfg.pixelFormat; return -EINVAL; @@ -141,7 +143,7 @@ int SoftwareIspInstanceGpu::configure(const StreamConfiguration &inputCfg, height_ = inputCfg.size.height; if (outputCfgs.size() != 1) { - LOG(SoftwareIspInstance, Error) + LOG(SoftwareIspInstanceGpu, Error) << "Unsupported number of output streams: " << outputCfgs.size(); return -EINVAL; @@ -153,7 +155,7 @@ int SoftwareIspInstanceGpu::configure(const StreamConfiguration &inputCfg, strideAndFrameSize(outputCfg.pixelFormat, outputCfg.size); if (!outSizeRange.contains(outputCfg.size) || outputConfig_.stride != outputCfg.stride) { - LOG(SoftwareIspInstance, Error) + LOG(SoftwareIspInstanceGpu, Error) << "Invalid output size/stride: " << "\n " << outputCfg.size << " (" << outSizeRange << ")" << "\n " << outputCfg.stride << " (" << outputConfig_.stride << ")"; @@ -182,9 +184,12 @@ int SoftwareIspInstanceGpu::configure(const StreamConfiguration &inputCfg, /* Configure for one pass */ PassConfig rawSensorIn = { inputCfg.size, inputConfig_.stride, inputPixelFormat_, window }; + PassConfig pingPongOut = { inputCfg.size, inputCfg.size.width, inputPixelFormat_, Rectangle(inputCfg.size) }; + PassConfig pingPongIn = pingPongOut; PassConfig rgbaOut = { outputCfg.size, outputConfig_.stride, outputPixelFormat_, Rectangle(nativeOutputSize_) }; - gpuIspShaderPassDemosiac_.configure(rawSensorIn, rgbaOut); + gpuIspShaderPassBlcNormalise_.configure(rawSensorIn, pingPongOut); + gpuIspShaderPassDemosiac_.configure(pingPongIn, rgbaOut); return 0; } @@ -240,11 +245,11 @@ eGLImage *SoftwareIspInstanceGpu::getCachedInputFrameBuffer(FrameBuffer *input, if (cache_miss) { if (eglImageInCache_.size() >= inputBufferCount_) { eglImageInCache_.pop_front(); - LOG(SoftwareIspInstance, Debug) << "Input cache " << inputBufferCount_ << " exceeded evicted entry"; + LOG(SoftwareIspInstanceGpu, Debug) << "Input cache " << inputBufferCount_ << " exceeded evicted entry"; } - eglImageInCache_.emplace_back(fd, std::make_unique(gpuIspShaderPassDemosiac_.glFormat_, - inputConfig_.stride / gpuIspShaderPassDemosiac_.getBytesPerPixel(), + eglImageInCache_.emplace_back(fd, std::make_unique(gpuIspShaderPassBlcNormalise_.glFormat_, + inputConfig_.stride / gpuIspShaderPassBlcNormalise_.getBytesPerPixel(), height_, inputConfig_.stride, GL_TEXTURE0, 0)); eglImageIn = eglImageInCache_.back().second.get(); @@ -252,7 +257,7 @@ eGLImage *SoftwareIspInstanceGpu::getCachedInputFrameBuffer(FrameBuffer *input, return eglImageIn; if (eglImageInCache_.size() == 1) - LOG(SoftwareIspInstance, Info) + LOG(SoftwareIspInstanceGpu, Info) << "Importing input DMABuf failed, falling back to upload"; } else if (!eglImageIn->dmabuf_import_failed_) { egl_.activateBindTexture(*eglImageIn); @@ -263,7 +268,7 @@ eGLImage *SoftwareIspInstanceGpu::getCachedInputFrameBuffer(FrameBuffer *input, inDmaSyncer->emplace(input->planes()[0].fd, DmaSyncer::SyncType::Read); inMapped->emplace(input, MappedFrameBuffer::MapFlag::Read); if (!inMapped->value().isValid()) { - LOG(SoftwareIspInstance, Error) << "mmap-ing buffer(s) failed"; + LOG(SoftwareIspInstanceGpu, Error) << "mmap-ing buffer(s) failed"; if (cache_miss) { eglImageInCache_.pop_back(); } @@ -294,7 +299,7 @@ eGLImage *SoftwareIspInstanceGpu::getCachedOutputFrameBuffer(FrameBuffer *output if (cache_miss) { if (eglImageOutCache_.size() >= outputBufferCount_) { eglImageOutCache_.pop_front(); - LOG(SoftwareIspInstance, Debug) << "Output cache " << outputBufferCount_ << " exceeded evicted entry"; + LOG(SoftwareIspInstanceGpu, Debug) << "Output cache " << outputBufferCount_ << " exceeded evicted entry"; } eglImageOutCache_.emplace_back(fd, std::make_unique(GL_RGBA, outputSize_.width, @@ -323,9 +328,19 @@ int SoftwareIspInstanceGpu::processGPU(FrameBuffer *input, FrameBuffer *output, if (!eglImageOut) return -ENOMEM; - pipelineResult = gpuIspShaderPassDemosiac_.process(*eglImageIn, *eglImageOut, width_, height_, params); + pipelineResult = gpuIspShaderPassBlcNormalise_.process(*eglImageIn, *eglImagePingPong_[0], width_, height_, params); + if (pipelineResult) { + LOG(SoftwareIspInstanceGpu, Error) << "BlcNormalise fail"; + return pipelineResult; + } - return pipelineResult; + pipelineResult = gpuIspShaderPassDemosiac_.process(*eglImagePingPong_[0], *eglImageOut, width_, height_, params); + if (pipelineResult) { + LOG(SoftwareIspInstanceGpu, Error) << "Demosiac fail"; + return pipelineResult; + } + + return 0; } void SoftwareIspInstanceGpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) @@ -343,7 +358,7 @@ void SoftwareIspInstanceGpu::process(uint32_t frame, FrameBuffer *input, FrameBu std::optional inDmaSyncer; if (processGPU(input, output, params, &inMapped, &inDmaSyncer)) { - LOG(SoftwareIspInstance, Error) << "debayerGPU failed"; + LOG(SoftwareIspInstanceGpu, Error) << "debayerGPU failed"; goto error; } @@ -390,14 +405,17 @@ int SoftwareIspInstanceGpu::start() glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureImageUnits); - LOG(SoftwareIspInstance, Debug) << "Available fragment shader texture units " << maxTextureImageUnits; + LOG(SoftwareIspInstanceGpu, Debug) << "Available fragment shader texture units " << maxTextureImageUnits; if (initBayerShaders(inputPixelFormat_, outputPixelFormat_)) return -EINVAL; /* Intermediary ping/pong textures */ - eglImagePingPong_[0] = std::make_unique(gpuIspShaderPassDemosiac_.glFormat_, outputSize_.width, outputSize_.height, outputConfig_.stride, GL_TEXTURE1, 1); - eglImagePingPong_[1] = std::make_unique(gpuIspShaderPassDemosiac_.glFormat_, outputSize_.width, outputSize_.height, outputConfig_.stride, GL_TEXTURE2, 2); + eglImagePingPong_[0] = std::make_unique(gpuIspShaderPassDemosiac_.glFormat_, width_, height_, outputConfig_.stride, GL_TEXTURE1, 1); + eglImagePingPong_[1] = std::make_unique(gpuIspShaderPassDemosiac_.glFormat_, width_, height_, outputConfig_.stride, GL_TEXTURE2, 2); + + egl_.createOutputTexture2D(*eglImagePingPong_[0]); + egl_.createOutputTexture2D(*eglImagePingPong_[1]); return 0; } @@ -432,7 +450,7 @@ SizeRange SoftwareIspInstanceGpu::sizes(PixelFormat inputFormat, const Size &inp */ if (inputSize.width < (3 * patternSize.width) || inputSize.height < (2 * borderHeight + patternSize.height)) { - LOG(SoftwareIspInstance, Warning) + LOG(SoftwareIspInstanceGpu, Warning) << "Input format size too small: " << inputSize; return {}; }