Add desktop GPU compositor readback gate

This commit is contained in:
2026-06-13 18:42:10 +02:00
parent 4534e0ec6d
commit 96b7b6f870
3 changed files with 49 additions and 5 deletions

View File

@@ -213,6 +213,44 @@ void opengl_preview_readback_matches_fixture(pp::tests::Harness& h)
#endif
}
void opengl_compositor_readback_matches_fixture(pp::tests::Harness& h)
{
#if defined(_WIN32)
HiddenWglContext context;
if (!context.ready()) {
std::cout << "[skip] desktop GPU compositor OpenGL readback unavailable: " << context.skip_reason() << "\n";
return;
}
glViewport(0, 0, 1, 1);
glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
glClearColor(0.0F, 0.0F, 1.0F, 1.0F);
glClear(GL_COLOR_BUFFER_BIT);
glFinish();
std::array<std::uint8_t, 4> pixel {};
glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel.data());
constexpr std::array<std::uint8_t, 4> expected {
0,
0,
255,
255,
};
if (pixel != expected) {
std::cout << "compositor readback rgba: "
<< static_cast<int>(pixel[0]) << ", "
<< static_cast<int>(pixel[1]) << ", "
<< static_cast<int>(pixel[2]) << ", "
<< static_cast<int>(pixel[3]) << "\n";
}
PP_EXPECT(h, pixel == expected);
#else
std::cout << "[skip] desktop GPU compositor OpenGL readback unavailable: no platform context helper\n";
#endif
}
}
int main()
@@ -220,5 +258,6 @@ int main()
pp::tests::Harness harness;
harness.run("opengl_clear_readback_matches_fixture", opengl_clear_readback_matches_fixture);
harness.run("opengl_preview_readback_matches_fixture", opengl_preview_readback_matches_fixture);
harness.run("opengl_compositor_readback_matches_fixture", opengl_compositor_readback_matches_fixture);
return harness.finish();
}