summaryrefslogtreecommitdiff
path: root/utils/raspberrypi/ctt/ctt_ref.pgm
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-09-09 17:14:51 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-09-11 18:24:51 +0300
commit33a0b14e0ad70b30bf4c57ec085cb9921b2b97f5 (patch)
tree7be63c0686ec965d40656d6c23427a830b1d99cd /utils/raspberrypi/ctt/ctt_ref.pgm
parent2e2aa4079943a330f8e10d22c14ad67da3c4107b (diff)
qcam: viewfinder_gl: Fix binding of vertex buffer and shader program
Starting in Qt 6.7.0, vertex buffers and shader programs are unbound just before calling QOpenGLWidget::paintGL(). This breaks rendering in the GL viewfinder in two ways. First, we bind the vertex buffer only once at initialization time. There is therefore no vertex buffer mapped at rendering time, preventing both the vertex shader from having access to the vertex and texture coordinates. Then, we bind the shader program only when rendering the first frame. There is thus no shader program bound for all subsequent frames, breaking rendering. Fix this by binding the vertex buffer where needed, when setting attribute buffers for the shader program, and binding the shader program for every frame. As we use a single vertex buffer, we could bind it at the beginning of paintGL() and keep it bound indefinitely. That would however fail to clearly indicate in the source code where the vertex buffer is needed, making the code more difficult to understand as it would rely on implicit assumptions. Release the vertex buffer explicitly when we don't need it anymore to avoid this. While at it, fix a coding style violation by adding missing curly brackets. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'utils/raspberrypi/ctt/ctt_ref.pgm')
0 files changed, 0 insertions, 0 deletions
/ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * * cam_helper.cpp - helper information for different sensors */ #include <linux/videodev2.h> #include <assert.h> #include <map> #include <string.h> #include "libcamera/internal/v4l2_videodevice.h" #include "cam_helper.hpp" #include "md_parser.hpp" using namespace RPiController; static std::map<std::string, CamHelperCreateFunc> cam_helpers; CamHelper *CamHelper::Create(std::string const &cam_name) { /* * CamHelpers get registered by static RegisterCamHelper * initialisers. */ for (auto &p : cam_helpers) { if (cam_name.find(p.first) != std::string::npos) return p.second(); } return nullptr; } CamHelper::CamHelper(MdParser *parser, unsigned int frameIntegrationDiff) : parser_(parser), initialized_(false), frameIntegrationDiff_(frameIntegrationDiff) { } CamHelper::~CamHelper() { delete parser_; } uint32_t CamHelper::ExposureLines(double exposure_us) const { assert(initialized_); return exposure_us * 1000.0 / mode_.line_length; } double CamHelper::Exposure(uint32_t exposure_lines) const { assert(initialized_); return exposure_lines * mode_.line_length / 1000.0; } uint32_t CamHelper::GetVBlanking(double &exposure, double minFrameDuration, double maxFrameDuration) const { uint32_t frameLengthMin, frameLengthMax, vblank; uint32_t exposureLines = ExposureLines(exposure); assert(initialized_); /* * minFrameDuration and maxFrameDuration are clamped by the caller * based on the limits for the active sensor mode. */ frameLengthMin = 1e3 * minFrameDuration / mode_.line_length; frameLengthMax = 1e3 * maxFrameDuration / mode_.line_length; /* * Limit the exposure to the maximum frame duration requested, and * re-calculate if it has been clipped. */ exposureLines = std::min(frameLengthMax - frameIntegrationDiff_, exposureLines); exposure = Exposure(exposureLines); /* Limit the vblank to the range allowed by the frame length limits. */ vblank = std::clamp(exposureLines + frameIntegrationDiff_, frameLengthMin, frameLengthMax) - mode_.height; return vblank; } void CamHelper::SetCameraMode(const CameraMode &mode) { mode_ = mode; if (parser_) { parser_->SetBitsPerPixel(mode.bitdepth); parser_->SetLineLengthBytes(0); /* We use SetBufferSize. */ } initialized_ = true; } void CamHelper::GetDelays(int &exposure_delay, int &gain_delay, int &vblank_delay) const { /* * These values are correct for many sensors. Other sensors will * need to over-ride this method. */ exposure_delay = 2; gain_delay = 1; vblank_delay = 2; } bool CamHelper::SensorEmbeddedDataPresent() const { return false; } unsigned int CamHelper::HideFramesStartup() const { /* * The number of frames when a camera first starts that shouldn't be * displayed as they are invalid in some way. */ return 0; } unsigned int CamHelper::HideFramesModeSwitch() const { /* After a mode switch, many sensors return valid frames immediately. */ return 0; } unsigned int CamHelper::MistrustFramesStartup() const { /* Many sensors return a single bad frame on start-up. */ return 1; } unsigned int CamHelper::MistrustFramesModeSwitch() const { /* Many sensors return valid metadata immediately. */ return 0; } RegisterCamHelper::RegisterCamHelper(char const *cam_name, CamHelperCreateFunc create_func) { cam_helpers[std::string(cam_name)] = create_func; }