| Message ID | 20260624085849.873784-6-bryan.odonoghue@linaro.org |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
On 24.06.26 10:58, Bryan O'Donoghue wrote: > Creates a non-dmabuf texture attached to a frame-buffer-object FBO, which > allows for render-to-texture. > > Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > --- > include/libcamera/internal/egl.h | 1 + > src/libcamera/egl.cpp | 16 ++++++++++++++++ > 2 files changed, 17 insertions(+) > > diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h > index 0709f9019..b992baf25 100644 > --- a/include/libcamera/internal/egl.h > +++ b/include/libcamera/internal/egl.h > @@ -108,6 +108,7 @@ public: > int createInputDMABufTexture2D(eGLImage &eglImage, int fd); > int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); > void createInputTexture2D(eGLImage &eglImage, void *data); > + void createOutputTexture2D(eGLImage &eglImage); > > int attachTextureToFBO(eGLImage &eglImage); > > diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp > index 2825d34d3..123653b58 100644 > --- a/src/libcamera/egl.cpp > +++ b/src/libcamera/egl.cpp > @@ -345,6 +345,22 @@ bool eGL::isAvailable() > return true; > } > > +/** > + * \brief Create a 2D texture attached to an FBO for render-to-texture > + * \param[in,out] eglImage EGL image to associate with the texture > + * \param[in] format OpenGL internal format (e.g., GL_RGB, GL_RGBA) > + * > + * Creates a 2D texture in VRAM. The texture > + * is configured with nearest filtering and clamp-to-edge wrapping. This > + * is useful for uploading static data like lookup tables or uniform color > + * matrices to the GPU. > + */ > +void eGL::createOutputTexture2D(eGLImage &eglImage) > +{ > + createInputTexture2D(eglImage, NULL); As noted in my reply to the previous patch, I'd slightly prefer use a private createTexture2D() instead, which would be in line with createDMABufTexture2D(). I guess it's mainly that mismatch between DMABuf and non-DMABuf functions that I don't like. > + attachTextureToFBO(eglImage); > +} > + > /** > * \brief Initialise the EGL context > *
diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h index 0709f9019..b992baf25 100644 --- a/include/libcamera/internal/egl.h +++ b/include/libcamera/internal/egl.h @@ -108,6 +108,7 @@ public: int createInputDMABufTexture2D(eGLImage &eglImage, int fd); int createOutputDMABufTexture2D(eGLImage &eglImage, int fd); void createInputTexture2D(eGLImage &eglImage, void *data); + void createOutputTexture2D(eGLImage &eglImage); int attachTextureToFBO(eGLImage &eglImage); diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 2825d34d3..123653b58 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -345,6 +345,22 @@ bool eGL::isAvailable() return true; } +/** + * \brief Create a 2D texture attached to an FBO for render-to-texture + * \param[in,out] eglImage EGL image to associate with the texture + * \param[in] format OpenGL internal format (e.g., GL_RGB, GL_RGBA) + * + * Creates a 2D texture in VRAM. The texture + * is configured with nearest filtering and clamp-to-edge wrapping. This + * is useful for uploading static data like lookup tables or uniform color + * matrices to the GPU. + */ +void eGL::createOutputTexture2D(eGLImage &eglImage) +{ + createInputTexture2D(eglImage, NULL); + attachTextureToFBO(eglImage); +} + /** * \brief Initialise the EGL context *
Creates a non-dmabuf texture attached to a frame-buffer-object FBO, which allows for render-to-texture. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> --- include/libcamera/internal/egl.h | 1 + src/libcamera/egl.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)