[4/4] libcamera: software_isp: debayer_egl: Only assign static uniforms once
diff mbox series

Message ID 20261026122014.61707-5-remy.alipoursafari@collabora.com
State New
Headers show
Series
  • Support rockchip-cif and optimise softisp
Related show

Commit Message

coolGi Oct. 26, 2026, 12:20 p.m. UTC
This results in an approximately 1.15x performance increase.

Signed-off-by: coolGi <remy.alipoursafari@collabora.com>
---
 src/libcamera/software_isp/debayer_egl.cpp | 21 +++++++++++++--------
 src/libcamera/software_isp/debayer_egl.h   |  1 +
 2 files changed, 14 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index 55fd30cb..10b59f00 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -269,6 +269,8 @@  int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm
 
 	getShaderVariableLocations();
 
+	setShaderUniformValues();
+
 	return 0;
 }
 
@@ -376,7 +378,7 @@  uint32_t DebayerEGL::preferredInputStride(const PixelFormat &inputFormat, const
 	return info.stride(size.width, 0, 256);
 }
 
-void DebayerEGL::setShaderVariableValues(eGLImage &eglImageIn, const DebayerParams &params)
+void DebayerEGL::setShaderUniformValues()
 {
 	/*
 	 * Raw Bayer 8-bit, and packed raw Bayer 10-bit/12-bit formats
@@ -427,13 +429,6 @@  void DebayerEGL::setShaderVariableValues(eGLImage &eglImageIn, const DebayerPara
 	glVertexAttribPointer(attributeTexture_, 2, GL_FLOAT, GL_TRUE,
 			      2 * sizeof(GLfloat), tcoordinates);
 
-	/*
-	 * Set the sampler2D to the respective texture unit for each texutre
-	 * To simultaneously sample multiple textures we need to use multiple
-	 * texture units
-	 */
-	glUniform1i(textureUniformBayerDataIn_, eglImageIn.texture_unit_uniform_id_);
-
 	/*
 	 * These values are:
 	 * firstRed = tex_bayer_first_red - bayer_8.vert
@@ -464,6 +459,16 @@  void DebayerEGL::setShaderVariableValues(eGLImage &eglImageIn, const DebayerPara
 			    << " textureUniformStep_.y " << Step[1]
 			    << " textureUniformStrideFactor_ " << Stride
 			    << " textureUniformProjMatrix_ " << textureUniformProjMatrix_;
+}
+
+void DebayerEGL::setShaderVariableValues(eGLImage &eglImageIn, const DebayerParams &params)
+{
+	/*
+	 * Set the sampler2D to the respective texture unit for each texutre
+	 * To simultaneously sample multiple textures we need to use multiple
+	 * texture units
+	 */
+	glUniform1i(textureUniformBayerDataIn_, eglImageIn.texture_unit_uniform_id_);
 
 	/* Pre-transpose matrix for GLES 2.0. */
 	Matrix<float, 3, 3> ccm = params.combinedMatrix.transpose();
diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h
index 20c8a0b1..73a0690b 100644
--- a/src/libcamera/software_isp/debayer_egl.h
+++ b/src/libcamera/software_isp/debayer_egl.h
@@ -65,6 +65,7 @@  private:
 	static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config);
 	int initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat);
 	void getShaderVariableLocations();
+	void setShaderUniformValues();
 	void setShaderVariableValues(eGLImage &eGLImageIn, const DebayerParams &params);
 	int debayerGPU(FrameBuffer *input, FrameBuffer *output, const DebayerParams &params, std::optional<MappedFrameBuffer> *mappedInputBuffer, std::optional<DmaSyncer> *inputBufferDmaSyncer);