[12/35] libcamera: software_isp: Start the ISP thread in configure
diff mbox series

Message ID 20250611013245.133785-13-bryan.odonoghue@linaro.org
State New
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue June 11, 2025, 1:32 a.m. UTC
OpenGL is not thread-safe and in fact associates invisible handles with the
threadid of the calling context.

As a result we need to make configure() and process() in SoftISP execute on
the same thread.

Move start thread into configure() as a first step towards this.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 src/libcamera/software_isp/software_isp.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Bryan O'Donoghue June 16, 2025, 7:02 p.m. UTC | #1
On 11/06/2025 02:32, Bryan O'Donoghue wrote:
> OpenGL is not thread-safe and in fact associates invisible handles with the
> threadid of the calling context.
g:/OpenGL/s//Mesa/g

---
bod
Milan Zamazal June 17, 2025, 10:22 a.m. UTC | #2
Hi Bryan,

Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:

> OpenGL is not thread-safe and in fact associates invisible handles with the
> threadid of the calling context.
>
> As a result we need to make configure() and process() in SoftISP execute on
> the same thread.

You mean Debayer::configure+process, right?

> Move start thread into configure() as a first step towards this.
>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  src/libcamera/software_isp/software_isp.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp
> index 28e2a360..7bee8f06 100644
> --- a/src/libcamera/software_isp/software_isp.cpp
> +++ b/src/libcamera/software_isp/software_isp.cpp
> @@ -159,8 +159,6 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
>  					    metadataReady.emit(frame, metadata);
>  				    });
>  	ipa_->setSensorControls.connect(this, &SoftwareIsp::setSensorCtrls);
> -
> -	debayer_->moveToThread(&ispWorkerThread_);

Why is this moved to `configure' too?  To be at the same place as
moveToThread?  And should the thread be started here or in `configure'?

I don't say anything from it is wrong but it would be good to add a bit
more explanation to the commit message to understand what's needed
exactly and why.

>  }
>  
>  SoftwareIsp::~SoftwareIsp()
> @@ -262,6 +260,9 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg,
>  	if (ret < 0)
>  		return ret;
>  
> +	debayer_->moveToThread(&ispWorkerThread_);
> +	ispWorkerThread_.start();
> +
>  	return debayer_->configure(inputCfg, outputCfgs, ccmEnabled_);
>  }
>  
> @@ -343,7 +344,6 @@ int SoftwareIsp::start()
>  	if (ret)
>  		return ret;
>  
> -	ispWorkerThread_.start();
>  	return 0;
>  }

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp
index 28e2a360..7bee8f06 100644
--- a/src/libcamera/software_isp/software_isp.cpp
+++ b/src/libcamera/software_isp/software_isp.cpp
@@ -159,8 +159,6 @@  SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
 					    metadataReady.emit(frame, metadata);
 				    });
 	ipa_->setSensorControls.connect(this, &SoftwareIsp::setSensorCtrls);
-
-	debayer_->moveToThread(&ispWorkerThread_);
 }
 
 SoftwareIsp::~SoftwareIsp()
@@ -262,6 +260,9 @@  int SoftwareIsp::configure(const StreamConfiguration &inputCfg,
 	if (ret < 0)
 		return ret;
 
+	debayer_->moveToThread(&ispWorkerThread_);
+	ispWorkerThread_.start();
+
 	return debayer_->configure(inputCfg, outputCfgs, ccmEnabled_);
 }
 
@@ -343,7 +344,6 @@  int SoftwareIsp::start()
 	if (ret)
 		return ret;
 
-	ispWorkerThread_.start();
 	return 0;
 }