autotests/drm: add a test for doing modesets

And fix an issue preventing it from working
remotes/origin/work/zzag/render-backend-graphics-buffer-allocator
Xaver Hugl 3 years ago
parent 9af9e93ef6
commit 8229573e63
  1. 36
      autotests/drm/drmTest.cpp
  2. 4
      src/backends/drm/drm_pipeline.cpp

@ -39,6 +39,8 @@ private Q_SLOTS:
void testModeGeneration_data();
void testModeGeneration();
void testConnectorLifetime();
void testModeset_data();
void testModeset();
};
static void verifyCleanup(MockGpu *mockGpu)
@ -316,5 +318,39 @@ void DrmTest::testConnectorLifetime()
verifyCleanup(mockGpu.get());
}
void DrmTest::testModeset_data()
{
QTest::addColumn<int>("AMS");
// TODO to uncomment this, implement page flip callbacks
// QTest::newRow("disabled") << 0;
QTest::newRow("enabled") << 1;
}
void DrmTest::testModeset()
{
// test if doing a modeset would succeed
QFETCH(int, AMS);
const auto mockGpu = std::make_unique<MockGpu>(1, 5);
mockGpu->deviceCaps[MOCKDRM_DEVICE_CAP_ATOMIC] = AMS;
const auto conn = std::make_shared<MockConnector>(mockGpu.get());
mockGpu->connectors.push_back(conn);
const auto session = Session::create(Session::Type::Noop);
const auto backend = std::make_unique<DrmBackend>(session.get());
const auto renderBackend = backend->createQPainterBackend();
auto gpu = std::make_unique<DrmGpu>(backend.get(), "testModeset", 1, 0);
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().size(), 1);
const auto output = gpu->drmOutputs().front();
output->renderLoop()->beginFrame();
output->renderLoop()->endFrame();
QVERIFY(gpu->drmOutputs().front()->present());
gpu.reset();
verifyCleanup(mockGpu.get());
}
QTEST_GUILESS_MAIN(DrmTest)
#include "drmTest.moc"

@ -190,7 +190,9 @@ bool DrmPipeline::prepareAtomicPresentation(DrmAtomicCommit *commit)
commit->addEnum(m_connector->contentType, m_pending.contentType);
}
commit->addProperty(m_pending.crtc->vrrEnabled, m_pending.syncMode == RenderLoopPrivate::SyncMode::Adaptive || m_pending.syncMode == RenderLoopPrivate::SyncMode::AdaptiveAsync);
if (m_pending.crtc->vrrEnabled.isValid()) {
commit->addProperty(m_pending.crtc->vrrEnabled, m_pending.syncMode == RenderLoopPrivate::SyncMode::Adaptive || m_pending.syncMode == RenderLoopPrivate::SyncMode::AdaptiveAsync);
}
if (m_pending.crtc->gammaLut.isValid()) {
commit->addBlob(m_pending.crtc->gammaLut, m_pending.gamma ? m_pending.gamma->blob() : nullptr);
} else if (m_pending.gamma) {

Loading…
Cancel
Save