| Message ID | 20260624085849.873784-10-bryan.odonoghue@linaro.org |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
On 24.06.26 10:58, Bryan O'Donoghue wrote: > Once we get as far a streaming if we have one dmabuf import failure, take > that failure as canonical and do not try further imports. Add a flag to > debayer_egl which gets reset on any configure() to control this logic, flip > the dmabuf bit on the first failure for all subsequent frames. Previous to this commit we already used eGLImage::dmabuf_import_failed_ for that - i.e. we didn't try importing every frame (need commit title/message adoption), but as long as that eGLImage was used, i.e. also only once per session as there was only one of them for input. Now that we're preparing to use one eGLImage per buffer this change perfectly makes sense - however please remove the leftover eGLImage::dmabuf_import_failed_ while on it. Otherwise LGTM! > > Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > --- > src/libcamera/software_isp/debayer_egl.cpp | 13 ++++++------- > src/libcamera/software_isp/debayer_egl.h | 2 ++ > 2 files changed, 8 insertions(+), 7 deletions(-) > > diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp > index f6b7b11e1..0568c413b 100644 > --- a/src/libcamera/software_isp/debayer_egl.cpp > +++ b/src/libcamera/software_isp/debayer_egl.cpp > @@ -316,6 +316,7 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, > inputPixelFormat_ = inputCfg.pixelFormat; > width_ = inputCfg.size.width; > height_ = inputCfg.size.height; > + use_dmabuf_ = true; > > if (outputCfgs.size() != 1) { > LOG(Debayer, Error) > @@ -515,21 +516,19 @@ void DebayerEGL::setShaderVariableValues(eGLImage &eglImageIn, const DebayerPara > > int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms, std::optional<MappedFrameBuffer> *inMapped, std::optional<DmaSyncer> *inDmaSyncer) > { > - bool dmabuf_import_succeeded = false; > - > /* eGL context switch */ > egl_.makeCurrent(); > > /* Try to create texture for input buffer via dmabuf import */ > - if (!eglImageBayerIn_->dmabuf_import_failed_) { > - if (egl_.createInputDMABufTexture2D(*eglImageBayerIn_, input->planes()[0].fd.get()) == 0) > - dmabuf_import_succeeded = true; > - else > + if (use_dmabuf_) { > + if (egl_.createInputDMABufTexture2D(*eglImageBayerIn_, input->planes()[0].fd.get()) != 0) { > + use_dmabuf_ = false; > LOG(Debayer, Info) << "Importing input buffer with DMABuf import failed, falling back to upload"; > + } > } > > /* Otherwise create texture for input buffer via upload from CPU */ > - if (!dmabuf_import_succeeded) { > + if (!use_dmabuf_) { > inDmaSyncer->emplace(input->planes()[0].fd, DmaSyncer::SyncType::Read); > inMapped->emplace(input, MappedFrameBuffer::MapFlag::Read); > if (!inMapped->value().isValid()) { > diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h > index 348d7305b..d8509e9f2 100644 > --- a/src/libcamera/software_isp/debayer_egl.h > +++ b/src/libcamera/software_isp/debayer_egl.h > @@ -68,6 +68,8 @@ private: > void setShaderVariableValues(eGLImage &eGLImageIn, const DebayerParams ¶ms); > int debayerGPU(FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms, std::optional<MappedFrameBuffer> *mappedInputBuffer, std::optional<DmaSyncer> *inputBufferDmaSyncer); > > + bool use_dmabuf_; > + > /* Shader program identifiers */ > GLuint vertexShaderId_ = 0; > GLuint fragmentShaderId_ = 0;
diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index f6b7b11e1..0568c413b 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -316,6 +316,7 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, inputPixelFormat_ = inputCfg.pixelFormat; width_ = inputCfg.size.width; height_ = inputCfg.size.height; + use_dmabuf_ = true; if (outputCfgs.size() != 1) { LOG(Debayer, Error) @@ -515,21 +516,19 @@ void DebayerEGL::setShaderVariableValues(eGLImage &eglImageIn, const DebayerPara int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms, std::optional<MappedFrameBuffer> *inMapped, std::optional<DmaSyncer> *inDmaSyncer) { - bool dmabuf_import_succeeded = false; - /* eGL context switch */ egl_.makeCurrent(); /* Try to create texture for input buffer via dmabuf import */ - if (!eglImageBayerIn_->dmabuf_import_failed_) { - if (egl_.createInputDMABufTexture2D(*eglImageBayerIn_, input->planes()[0].fd.get()) == 0) - dmabuf_import_succeeded = true; - else + if (use_dmabuf_) { + if (egl_.createInputDMABufTexture2D(*eglImageBayerIn_, input->planes()[0].fd.get()) != 0) { + use_dmabuf_ = false; LOG(Debayer, Info) << "Importing input buffer with DMABuf import failed, falling back to upload"; + } } /* Otherwise create texture for input buffer via upload from CPU */ - if (!dmabuf_import_succeeded) { + if (!use_dmabuf_) { inDmaSyncer->emplace(input->planes()[0].fd, DmaSyncer::SyncType::Read); inMapped->emplace(input, MappedFrameBuffer::MapFlag::Read); if (!inMapped->value().isValid()) { diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index 348d7305b..d8509e9f2 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -68,6 +68,8 @@ private: void setShaderVariableValues(eGLImage &eGLImageIn, const DebayerParams ¶ms); int debayerGPU(FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms, std::optional<MappedFrameBuffer> *mappedInputBuffer, std::optional<DmaSyncer> *inputBufferDmaSyncer); + bool use_dmabuf_; + /* Shader program identifiers */ GLuint vertexShaderId_ = 0; GLuint fragmentShaderId_ = 0;
Once we get as far a streaming if we have one dmabuf import failure, take that failure as canonical and do not try further imports. Add a flag to debayer_egl which gets reset on any configure() to control this logic, flip the dmabuf bit on the first failure for all subsequent frames. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> --- src/libcamera/software_isp/debayer_egl.cpp | 13 ++++++------- src/libcamera/software_isp/debayer_egl.h | 2 ++ 2 files changed, 8 insertions(+), 7 deletions(-)