[03/10] libcamera: egl: Extend eGL::createTexture2D to understand floats
diff mbox series

Message ID 20260624085849.873784-4-bryan.odonoghue@linaro.org
State New
Headers show
Series
  • libcamera: software_isp: gpu: Add go faster stripes
Related show

Commit Message

Bryan O'Donoghue June 24, 2026, 8:58 a.m. UTC
We want to have the option to use floats as an intermediary format between
different stages of a multi-pass pipeline. Adding floats means also
plumbing the infrastructure to differentiate on data-type on the input to
texture creation.

Add the floats and the plumbing.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 src/libcamera/egl.cpp | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Comments

Robert Mader June 24, 2026, 11:58 a.m. UTC | #1
On 24.06.26 10:58, Bryan O'Donoghue wrote:
> We want to have the option to use floats as an intermediary format between
> different stages of a multi-pass pipeline. Adding floats means also
> plumbing the infrastructure to differentiate on data-type on the input to
> texture creation.
>
> Add the floats and the plumbing.

I understand that this patch simplified the rebase from the multi-pass 
series, however I would prefer if it was dropped here, given that it's 
otherwise unrelated.

No strong opinion though and the code itself looks good to me, thus I'll 
leave that decision to you / others:

Reviewed-by: Robert Mader <robert.mader@collabora.com>

> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>   src/libcamera/egl.cpp | 18 +++++++++++++++++-
>   1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp
> index e83e24606..8d80a6d1a 100644
> --- a/src/libcamera/egl.cpp
> +++ b/src/libcamera/egl.cpp
> @@ -268,13 +268,29 @@ int eGL::createOutputDMABufTexture2D(eGLImage &eglImage, int fd)
>    */
>   void eGL::createTexture2D(eGLImage &eglImage, void *data)
>   {
> +	GLenum format;
> +	GLenum type = GL_UNSIGNED_BYTE;
> +
>   	ASSERT(tid_ == Thread::currentId());
>   
>   	glActiveTexture(eglImage.texture_unit_);
>   	glBindTexture(GL_TEXTURE_2D, eglImage.texture_);
>   
> +	switch (eglImage.format_) {
> +	case GL_R16F:
> +		format = GL_RED;
> +		type = GL_HALF_FLOAT;
> +		break;
> +	case GL_RG8:
> +		format = GL_RG;
> +		break;
> +	case GL_LUMINANCE:
> +		format = GL_LUMINANCE;
> +		break;
> +	}
> +
>   	// Generate texture, bind, associate image to texture, configure, unbind
> -	glTexImage2D(GL_TEXTURE_2D, 0, eglImage.format_, eglImage.width_, eglImage.height_, 0, eglImage.format_, GL_UNSIGNED_BYTE, data);
> +	glTexImage2D(GL_TEXTURE_2D, 0, eglImage.format_, eglImage.width_, eglImage.height_, 0, format, type, data);
>   
>   	// Nearest filtering
>   	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

Patch
diff mbox series

diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp
index e83e24606..8d80a6d1a 100644
--- a/src/libcamera/egl.cpp
+++ b/src/libcamera/egl.cpp
@@ -268,13 +268,29 @@  int eGL::createOutputDMABufTexture2D(eGLImage &eglImage, int fd)
  */
 void eGL::createTexture2D(eGLImage &eglImage, void *data)
 {
+	GLenum format;
+	GLenum type = GL_UNSIGNED_BYTE;
+
 	ASSERT(tid_ == Thread::currentId());
 
 	glActiveTexture(eglImage.texture_unit_);
 	glBindTexture(GL_TEXTURE_2D, eglImage.texture_);
 
+	switch (eglImage.format_) {
+	case GL_R16F:
+		format = GL_RED;
+		type = GL_HALF_FLOAT;
+		break;
+	case GL_RG8:
+		format = GL_RG;
+		break;
+	case GL_LUMINANCE:
+		format = GL_LUMINANCE;
+		break;
+	}
+
 	// Generate texture, bind, associate image to texture, configure, unbind
-	glTexImage2D(GL_TEXTURE_2D, 0, eglImage.format_, eglImage.width_, eglImage.height_, 0, eglImage.format_, GL_UNSIGNED_BYTE, data);
+	glTexImage2D(GL_TEXTURE_2D, 0, eglImage.format_, eglImage.width_, eglImage.height_, 0, format, type, data);
 
 	// Nearest filtering
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);