diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp
index fd8de3942..521316657 100644
--- a/src/libcamera/software_isp/debayer_egl.cpp
+++ b/src/libcamera/software_isp/debayer_egl.cpp
@@ -337,6 +337,7 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg,
 
 	outputPixelFormat_ = outputCfg.pixelFormat;
 	outputSize_ = outputCfg.size;
+	nativeOutputSize_ = outSizeRange.max;
 
 	window_.x = ((inputCfg.size.width - outputCfg.size.width) / 2) &
 		    ~(inputConfig_.patternSize.width - 1);
@@ -408,11 +409,12 @@ void DebayerEGL::setShaderVariableValues(const DebayerParams &params)
 			   1.0f / (height_ - 1) };
 	GLfloat Stride = (GLfloat)width_ / (shaderStridePixels_ / bytesPerPixel_);
 	/*
-	 * Scale input to output size, keeping the aspect ratio and preferring
-	 * cropping over black bars.
+	 * Scale the output size from the native size the algorithm produces for
+	 * the input size. Keep the aspect ratio and prefer cropping over black
+	 * bars.
 	 */
-	GLfloat scale = std::max((GLfloat)window_.width / width_,
-				 (GLfloat)window_.height / height_);
+	GLfloat scale = std::max((GLfloat)outputSize_.width / nativeOutputSize_.width,
+				 (GLfloat)outputSize_.height / nativeOutputSize_.height);
 	GLfloat trans = -(1.0f - scale);
 	GLfloat projMatrix[] = {
 		scale, 0, 0, 0,
diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h
index 943410fdd..fbd5430e4 100644
--- a/src/libcamera/software_isp/debayer_egl.h
+++ b/src/libcamera/software_isp/debayer_egl.h
@@ -102,6 +102,7 @@ private:
 	/* Contrast */
 	GLint contrastExpUniformDataIn_;
 
+	Size nativeOutputSize_;
 	Rectangle window_;
 	std::unique_ptr<SwStatsCpu> stats_;
 	eGL egl_;
